1*7489Skre /* kern_prot.c 5.2 82/07/22 */ 27420Sroot 37420Sroot /* 47420Sroot * System calls related to protection 57420Sroot */ 67420Sroot 77420Sroot #include "../h/param.h" 87420Sroot #include "../h/systm.h" 97420Sroot #include "../h/dir.h" 107420Sroot #include "../h/user.h" 117420Sroot #include "../h/reg.h" 127420Sroot #include "../h/inode.h" 137420Sroot #include "../h/proc.h" 147420Sroot #include "../h/clock.h" 157420Sroot #include "../h/mtpr.h" 167420Sroot #include "../h/timeb.h" 177420Sroot #include "../h/times.h" 187420Sroot #include "../h/reboot.h" 197420Sroot #include "../h/fs.h" 207420Sroot #include "../h/conf.h" 217420Sroot #include "../h/buf.h" 227420Sroot #include "../h/mount.h" 23*7489Skre #include "../h/quota.h" 247420Sroot 257420Sroot getuid() 267420Sroot { 277420Sroot 287420Sroot u.u_r.r_val1 = u.u_ruid; 297420Sroot u.u_r.r_val2 = u.u_uid; 307420Sroot } 317420Sroot 327420Sroot setuid() 337420Sroot { 347420Sroot register uid; 357420Sroot register struct a { 367420Sroot int uid; 377420Sroot } *uap; 387420Sroot 397420Sroot uap = (struct a *)u.u_ap; 407420Sroot uid = uap->uid; 417420Sroot if (u.u_ruid == uid || u.u_uid == uid || suser()) { 42*7489Skre #ifdef QUOTA 43*7489Skre if (u.u_quota->q_uid != uid) { 44*7489Skre qclean(); 45*7489Skre qstart(getquota(uid, 0, 0)); 46*7489Skre } 47*7489Skre #endif 487420Sroot u.u_uid = uid; 497420Sroot u.u_procp->p_uid = uid; 507420Sroot u.u_ruid = uid; 517420Sroot } 527420Sroot } 537420Sroot 547420Sroot getgid() 557420Sroot { 567420Sroot 577420Sroot u.u_r.r_val1 = u.u_rgid; 587420Sroot u.u_r.r_val2 = u.u_gid; 597420Sroot } 607420Sroot 617420Sroot setgid() 627420Sroot { 637420Sroot register gid; 647420Sroot register struct a { 657420Sroot int gid; 667420Sroot } *uap; 677420Sroot 687420Sroot uap = (struct a *)u.u_ap; 697420Sroot gid = uap->gid; 707420Sroot if (u.u_rgid == gid || u.u_gid == gid || suser()) { 717420Sroot u.u_gid = gid; 727420Sroot u.u_rgid = gid; 737420Sroot } 747420Sroot } 75