diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-08-08 06:36:49 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-08-08 06:36:49 +0000 |
commit | 8bbdba13ee2292814ea3886e24276e7fba0d6501 (patch) | |
tree | 05af789b1bf99150a6c012b007a2bcef86425864 /sys/kern/vfs_subr.c | |
parent | 4d772254ed458ba0aa2aaf4046cb7c94035303bb (diff) |
Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 4cbf0a43afa..888163257e4 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -77,6 +77,7 @@ int vttoif_tab[9] = { int doforce = 1; /* 1 => permit forcible unmounting */ int prtactive = 0; /* 1 => print out reclaim of active vnodes */ +int suid_clear = 1; /* 1 => clear SUID / SGID on owner change */ /* * Insq/Remq for the vnode usage lists. @@ -1610,3 +1611,56 @@ vfs_shutdown() else printf("done\n"); } + +/* + * posix file system related system variables. + */ +int +fs_posix_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + /* all sysctl names at this level are terminal */ + if (namelen != 1) + return (ENOTDIR); + + switch (name[0]) { + case FS_POSIX_SETUID: + if (newp && securelevel > 0) + return (EPERM); + return(sysctl_int(oldp, oldlenp, newp, newlen, &suid_clear)); + default: + return (EOPNOTSUPP); + } + /* NOTREACHED */ +} + +/* + * file system related system variables. + */ +int +fs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + sysctlfn *fn; + + switch (name[0]) { + case FS_POSIX: + fn = fs_posix_sysctl; + break; + default: + return (EOPNOTSUPP); + } + return (*fn)(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, p); +} |