1 /* kern_prot.c 5.2 82/07/22 */ 2 3 /* 4 * System calls related to protection 5 */ 6 7 #include "../h/param.h" 8 #include "../h/systm.h" 9 #include "../h/dir.h" 10 #include "../h/user.h" 11 #include "../h/reg.h" 12 #include "../h/inode.h" 13 #include "../h/proc.h" 14 #include "../h/clock.h" 15 #include "../h/mtpr.h" 16 #include "../h/timeb.h" 17 #include "../h/times.h" 18 #include "../h/reboot.h" 19 #include "../h/fs.h" 20 #include "../h/conf.h" 21 #include "../h/buf.h" 22 #include "../h/mount.h" 23 #include "../h/quota.h" 24 25 getuid() 26 { 27 28 u.u_r.r_val1 = u.u_ruid; 29 u.u_r.r_val2 = u.u_uid; 30 } 31 32 setuid() 33 { 34 register uid; 35 register struct a { 36 int uid; 37 } *uap; 38 39 uap = (struct a *)u.u_ap; 40 uid = uap->uid; 41 if (u.u_ruid == uid || u.u_uid == uid || suser()) { 42 #ifdef QUOTA 43 if (u.u_quota->q_uid != uid) { 44 qclean(); 45 qstart(getquota(uid, 0, 0)); 46 } 47 #endif 48 u.u_uid = uid; 49 u.u_procp->p_uid = uid; 50 u.u_ruid = uid; 51 } 52 } 53 54 getgid() 55 { 56 57 u.u_r.r_val1 = u.u_rgid; 58 u.u_r.r_val2 = u.u_gid; 59 } 60 61 setgid() 62 { 63 register gid; 64 register struct a { 65 int gid; 66 } *uap; 67 68 uap = (struct a *)u.u_ap; 69 gid = uap->gid; 70 if (u.u_rgid == gid || u.u_gid == gid || suser()) { 71 u.u_gid = gid; 72 u.u_rgid = gid; 73 } 74 } 75