aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/ucred.h
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2001-05-25 16:59:11 +0000
committerRobert Watson <rwatson@FreeBSD.org>2001-05-25 16:59:11 +0000
commitb1fc0ec1a7a49dede256c4d357878fa2ba19cf93 (patch)
tree75f6fb93b72acac3ddfbfb0c1cbfcefff13848a5 /sys/sys/ucred.h
parent7edce08ac4f77962b15b2fca8a8e15ac67357f91 (diff)
downloadsrc-b1fc0ec1a7a49dede256c4d357878fa2ba19cf93.tar.gz
src-b1fc0ec1a7a49dede256c4d357878fa2ba19cf93.zip
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the pcred->pc_uidinfo, which was associated with the real uid, only rename it to cr_ruidinfo so as not to conflict with cr_uidinfo, which corresponds to the effective uid. o Remove p_cred from struct proc; add p_ucred to struct proc, replacing original macro that pointed. p->p_ucred to p->p_cred->pc_ucred. o Universally update code so that it makes use of ucred instead of pcred, p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo, cr_{r,sv}{u,g}id instead of p_*, etc. o Remove pcred0 and its initialization from init_main.c; initialize cr_ruidinfo there. o Restruction many credential modification chunks to always crdup while we figure out locking and optimizations; generally speaking, this means moving to a structure like this: newcred = crdup(oldcred); ... p->p_ucred = newcred; crfree(oldcred); It's not race-free, but better than nothing. There are also races in sys_process.c, all inter-process authorization, fork, exec, and exit. o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid; remove comments indicating that the old arrangement was a problem. o Restructure exec1() a little to use newcred/oldcred arrangement, and use improved uid management primitives. o Clean up exit1() so as to do less work in credential cleanup due to pcred removal. o Clean up fork1() so as to do less work in credential cleanup and allocation. o Clean up ktrcanset() to take into account changes, and move to using suser_xxx() instead of performing a direct uid==0 comparision. o Improve commenting in various kern_prot.c credential modification calls to better document current behavior. In a couple of places, current behavior is a little questionable and we need to check POSIX.1 to make sure it's "right". More commenting work still remains to be done. o Update credential management calls, such as crfree(), to take into account new ruidinfo reference. o Modify or add the following uid and gid helper routines: change_euid() change_egid() change_ruid() change_rgid() change_svuid() change_svgid() In each case, the call now acts on a credential not a process, and as such no longer requires more complicated process locking/etc. They now assume the caller will do any necessary allocation of an exclusive credential reference. Each is commented to document its reference requirements. o CANSIGIO() is simplified to require only credentials, not processes and pcreds. o Remove lots of (p_pcred==NULL) checks. o Add an XXX to authorization code in nfs_lock.c, since it's questionable, and needs to be considered carefully. o Simplify posix4 authorization code to require only credentials, not processes and pcreds. Note that this authorization, as well as CANSIGIO(), needs to be updated to use the p_cansignal() and p_cansched() centralized authorization routines, as they currently do not take into account some desirable restrictions that are handled by the centralized routines, as well as being inconsistent with other similar authorization instances. o Update libkvm to take these changes into account. Obtained from: TrustedBSD Project Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
Notes
Notes: svn path=/head/; revision=77183
Diffstat (limited to 'sys/sys/ucred.h')
-rw-r--r--sys/sys/ucred.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h
index c48df00cc37e..356cca284946 100644
--- a/sys/sys/ucred.h
+++ b/sys/sys/ucred.h
@@ -50,9 +50,14 @@
struct ucred {
u_int cr_ref; /* reference count */
uid_t cr_uid; /* effective user id */
+ uid_t cr_ruid; /* real user id */
+ uid_t cr_svuid; /* saved user id */
short cr_ngroups; /* number of groups */
gid_t cr_groups[NGROUPS]; /* groups */
- struct uidinfo *cr_uidinfo; /* per uid resource consumption */
+ gid_t cr_rgid; /* real group id */
+ gid_t cr_svgid; /* saved user id */
+ struct uidinfo *cr_uidinfo; /* per euid resource consumption */
+ struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
struct prison *cr_prison; /* jail(4) */
struct mtx cr_mtx; /* protect refcount */
};
@@ -77,8 +82,12 @@ struct xucred {
struct proc;
-void change_euid __P((struct proc *p, uid_t euid));
-void change_ruid __P((struct proc *p, uid_t ruid));
+void change_egid __P((struct ucred *newcred, gid_t egid));
+void change_euid __P((struct ucred *newcred, uid_t euid));
+void change_rgid __P((struct ucred *newcred, gid_t rgid));
+void change_ruid __P((struct ucred *newcred, uid_t ruid));
+void change_svgid __P((struct ucred *newcred, gid_t svgid));
+void change_svuid __P((struct ucred *newcred, uid_t svuid));
struct ucred *crcopy __P((struct ucred *cr));
struct ucred *crdup __P((struct ucred *cr));
void crfree __P((struct ucred *cr));