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