xref: /csrg-svn/sys/kern/kern_prot.c (revision 7420)
1 /*	kern_prot.c	5.1	82/07/15	*/
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 
24 getuid()
25 {
26 
27 	u.u_r.r_val1 = u.u_ruid;
28 	u.u_r.r_val2 = u.u_uid;
29 }
30 
31 setuid()
32 {
33 	register uid;
34 	register struct a {
35 		int	uid;
36 	} *uap;
37 
38 	uap = (struct a *)u.u_ap;
39 	uid = uap->uid;
40 	if (u.u_ruid == uid || u.u_uid == uid || suser()) {
41 		u.u_uid = uid;
42 		u.u_procp->p_uid = uid;
43 		u.u_ruid = uid;
44 	}
45 }
46 
47 getgid()
48 {
49 
50 	u.u_r.r_val1 = u.u_rgid;
51 	u.u_r.r_val2 = u.u_gid;
52 }
53 
54 setgid()
55 {
56 	register gid;
57 	register struct a {
58 		int	gid;
59 	} *uap;
60 
61 	uap = (struct a *)u.u_ap;
62 	gid = uap->gid;
63 	if (u.u_rgid == gid || u.u_gid == gid || suser()) {
64 		u.u_gid = gid;
65 		u.u_rgid = gid;
66 	}
67 }
68