|
|
1.1 ! root 1: /* interfaces to "secure unix" system calls, designed to ! 2: "work" on systems with or without these calls */ ! 3: ! 4: #include <errno.h> ! 5: #include "label.h" /* SHOULD BE <sys/label.h> */ ! 6: ! 7: extern int errno; ! 8: #ifndef ENOSYS ! 9: #define ENOSYS 39 ! 10: #endif ! 11: ! 12: static struct label lbot = {0, L_BITS }; ! 13: static struct label lfloor = { 0, L_BITS }; ! 14: static int labels = 1; ! 15: ! 16: static iflabeled() ! 17: { ! 18: if(errno==100 || errno==ENOSYS) ! 19: return labels = errno = 0; ! 20: else ! 21: return -1; ! 22: } ! 23: getflab(name, lp) ! 24: char *name; ! 25: struct label *lp; ! 26: { ! 27: register r; ! 28: ! 29: r = labels? syscall(64+30, name, lp): 0; ! 30: if(r == -1) ! 31: r = iflabeled(); ! 32: if(!labels) ! 33: *lp = lbot; ! 34: return(r); ! 35: } ! 36: fgetflab(fd, lp) ! 37: struct label *lp; ! 38: { ! 39: register r; ! 40: ! 41: r = labels? syscall(64+31, fd, lp): 0; ! 42: if(r == -1) ! 43: r = iflabeled(); ! 44: if(!labels) ! 45: *lp = lbot; ! 46: return(r); ! 47: } ! 48: setflab(name, lp) ! 49: char *name; ! 50: struct label *lp; ! 51: { ! 52: register r; ! 53: ! 54: r = labels? syscall(64+32, name, lp): 0; ! 55: if(r == -1) ! 56: r = iflabeled(); ! 57: return(r); ! 58: } ! 59: fsetflab(fd, lp) ! 60: struct label *lp; ! 61: { ! 62: register r; ! 63: ! 64: r = labels? syscall(64+33, fd, lp): 0; ! 65: if(r == -1) ! 66: r = iflabeled(); ! 67: return(r); ! 68: } ! 69: flabclr(fd) ! 70: { ! 71: if(getflab("/etc/floor", &lfloor) == -1) ! 72: iflabeled(); ! 73: lfloor.lb_priv = lbot.lb_priv; ! 74: fsetflab(fd, &lfloor); ! 75: } ! 76: getplab(lp, cp) ! 77: struct label *lp, *cp; ! 78: { ! 79: register r; ! 80: ! 81: r = labels? syscall(64+34, lp, cp): 0; ! 82: if(r == -1) ! 83: r = iflabeled(); ! 84: if(!labels) { ! 85: *lp = lbot; ! 86: *cp = lbot; ! 87: } ! 88: return(r); ! 89: } ! 90: setplab(lp, cp) ! 91: struct label *lp, *cp; ! 92: { ! 93: register r; ! 94: ! 95: r = labels? syscall(64+35, lp, cp): 0; ! 96: if(r == -1) ! 97: r = iflabeled(); ! 98: return(r); ! 99: } ! 100: nochk(fd, flag) ! 101: { ! 102: register r; ! 103: ! 104: r = labels? syscall(64+29, fd, flag): 0; ! 105: if(r == -1) ! 106: r = iflabeled(); ! 107: return(r); ! 108: } ! 109: #include <sys/types.h> ! 110: #include <sys/filio.h> ! 111: ! 112: #ifndef FIOGSRC ! 113: # define FIOGSRC (('f'<<8)|106) ! 114: # define FIOSSRC (('f'<<8)|107) ! 115: #endif ! 116: ! 117: static char buf[100]; /* <sys/stream.h>: sizeof( (struct stdata *)->source) */ ! 118: ! 119: setstsrc(fd, name) ! 120: char *name; ! 121: { ! 122: strncpy(buf, name?name:"", sizeof(buf)); ! 123: return ioctl(fd, FIOSSRC, buf); ! 124: } ! 125: ! 126: set2stsrc(fd, s1, s2) ! 127: char *s1; ! 128: char *s2; ! 129: { ! 130: strncpy(buf, s1?s1:"", sizeof(buf)-1); ! 131: strncat(buf, s2?s2:"", sizeof(buf)-strlen(buf)); ! 132: return ioctl(fd, FIOSSRC, buf); ! 133: } ! 134: ! 135: char * ! 136: getstsrc(fd) ! 137: { ! 138: if(ioctl(fd, FIOGSRC, buf) == -1) ! 139: return 0; ! 140: else ! 141: return buf; ! 142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.