|
|
1.1.1.2 ! root 1: /* ! 2: * linux/kernel/sys.c ! 3: * ! 4: * (C) 1991 Linus Torvalds ! 5: */ ! 6: 1.1 root 7: #include <errno.h> 8: 9: #include <linux/sched.h> 10: #include <linux/tty.h> 11: #include <linux/kernel.h> 12: #include <asm/segment.h> 13: #include <sys/times.h> 14: #include <sys/utsname.h> 15: 16: int sys_ftime() 17: { 18: return -ENOSYS; 19: } 20: 21: int sys_break() 22: { 23: return -ENOSYS; 24: } 25: 26: int sys_ptrace() 27: { 28: return -ENOSYS; 29: } 30: 31: int sys_stty() 32: { 33: return -ENOSYS; 34: } 35: 36: int sys_gtty() 37: { 38: return -ENOSYS; 39: } 40: 41: int sys_rename() 42: { 43: return -ENOSYS; 44: } 45: 46: int sys_prof() 47: { 48: return -ENOSYS; 49: } 50: 1.1.1.2 ! root 51: int sys_setregid(int rgid, int egid) 1.1 root 52: { 1.1.1.2 ! root 53: if (rgid>0) { ! 54: if ((current->gid == rgid) || ! 55: suser()) ! 56: current->gid = rgid; ! 57: else ! 58: return(-EPERM); ! 59: } ! 60: if (egid>0) { ! 61: if ((current->gid == egid) || ! 62: (current->egid == egid) || ! 63: (current->sgid == egid) || ! 64: suser()) ! 65: current->egid = egid; 1.1 root 66: else 1.1.1.2 ! root 67: return(-EPERM); ! 68: } 1.1 root 69: return 0; 70: } 71: 1.1.1.2 ! root 72: int sys_setgid(int gid) ! 73: { ! 74: return(sys_setregid(gid, gid)); ! 75: } ! 76: 1.1 root 77: int sys_acct() 78: { 79: return -ENOSYS; 80: } 81: 82: int sys_phys() 83: { 84: return -ENOSYS; 85: } 86: 87: int sys_lock() 88: { 89: return -ENOSYS; 90: } 91: 92: int sys_mpx() 93: { 94: return -ENOSYS; 95: } 96: 97: int sys_ulimit() 98: { 99: return -ENOSYS; 100: } 101: 102: int sys_time(long * tloc) 103: { 104: int i; 105: 106: i = CURRENT_TIME; 107: if (tloc) { 108: verify_area(tloc,4); 109: put_fs_long(i,(unsigned long *)tloc); 110: } 111: return i; 112: } 113: 1.1.1.2 ! root 114: /* ! 115: * Unprivileged users may change the real user id to the effective uid ! 116: * or vice versa. ! 117: */ ! 118: int sys_setreuid(int ruid, int euid) 1.1 root 119: { 1.1.1.2 ! root 120: int old_ruid = current->uid; ! 121: ! 122: if (ruid>0) { ! 123: if ((current->euid==ruid) || ! 124: (old_ruid == ruid) || ! 125: suser()) ! 126: current->uid = ruid; 1.1 root 127: else 1.1.1.2 ! root 128: return(-EPERM); ! 129: } ! 130: if (euid>0) { ! 131: if ((old_ruid == euid) || ! 132: (current->euid == euid) || ! 133: suser()) ! 134: current->euid = euid; ! 135: else { ! 136: current->uid = old_ruid; ! 137: return(-EPERM); ! 138: } ! 139: } 1.1 root 140: return 0; 141: } 142: 1.1.1.2 ! root 143: int sys_setuid(int uid) ! 144: { ! 145: return(sys_setreuid(uid, uid)); ! 146: } ! 147: 1.1 root 148: int sys_stime(long * tptr) 149: { 1.1.1.2 ! root 150: if (!suser()) ! 151: return -EPERM; 1.1 root 152: startup_time = get_fs_long((unsigned long *)tptr) - jiffies/HZ; 153: return 0; 154: } 155: 156: int sys_times(struct tms * tbuf) 157: { 1.1.1.2 ! root 158: if (tbuf) { ! 159: verify_area(tbuf,sizeof *tbuf); ! 160: put_fs_long(current->utime,(unsigned long *)&tbuf->tms_utime); ! 161: put_fs_long(current->stime,(unsigned long *)&tbuf->tms_stime); ! 162: put_fs_long(current->cutime,(unsigned long *)&tbuf->tms_cutime); ! 163: put_fs_long(current->cstime,(unsigned long *)&tbuf->tms_cstime); ! 164: } 1.1 root 165: return jiffies; 166: } 167: 168: int sys_brk(unsigned long end_data_seg) 169: { 170: if (end_data_seg >= current->end_code && 171: end_data_seg < current->start_stack - 16384) 172: current->brk = end_data_seg; 173: return current->brk; 174: } 175: 176: /* 177: * This needs some heave checking ... 178: * I just haven't get the stomach for it. I also don't fully 179: * understand sessions/pgrp etc. Let somebody who does explain it. 180: */ 181: int sys_setpgid(int pid, int pgid) 182: { 183: int i; 184: 185: if (!pid) 186: pid = current->pid; 187: if (!pgid) 1.1.1.2 ! root 188: pgid = current->pid; 1.1 root 189: for (i=0 ; i<NR_TASKS ; i++) 190: if (task[i] && task[i]->pid==pid) { 191: if (task[i]->leader) 192: return -EPERM; 193: if (task[i]->session != current->session) 194: return -EPERM; 195: task[i]->pgrp = pgid; 196: return 0; 197: } 198: return -ESRCH; 199: } 200: 201: int sys_getpgrp(void) 202: { 203: return current->pgrp; 204: } 205: 206: int sys_setsid(void) 207: { 1.1.1.2 ! root 208: if (current->leader && !suser()) 1.1 root 209: return -EPERM; 210: current->leader = 1; 211: current->session = current->pgrp = current->pid; 212: current->tty = -1; 213: return current->pgrp; 214: } 215: 216: int sys_uname(struct utsname * name) 217: { 218: static struct utsname thisname = { 219: "linux .0","nodename","release ","version ","machine " 220: }; 221: int i; 222: 1.1.1.2 ! root 223: if (!name) return -ERROR; 1.1 root 224: verify_area(name,sizeof *name); 225: for(i=0;i<sizeof *name;i++) 226: put_fs_byte(((char *) &thisname)[i],i+(char *) name); 1.1.1.2 ! root 227: return 0; 1.1 root 228: } 229: 230: int sys_umask(int mask) 231: { 232: int old = current->umask; 233: 234: current->umask = mask & 0777; 235: return (old); 236: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.