Subject: seteuid(2), hk(4) & xp(4), sethostname(2) (#395 1 of 3) Index: sys,lib,man/many 2.11BSD Description: 1) seteuid,setegid(2) do not exist (no 'saved ids'). 2) hk(4) doesn't implement disklabels. 3) xp(4) can put a crash dump on a non-swap partition. 4) gethostname(2) and sethostname(2) dupliate _sysctl(2) functionality. Repeat-By: 1) The saved uid (gid) capability does not exist. This is new in 4.4BSD and has not previously been ported. In 4.2/3BSD 'setreuid' (gid) were used (imperfectly) to allow a setuid (gid) program to switch back and forth between uids. With 4.4BSD setreuid was dropped and 'saved ids' were implemented with seteuid/gid. 2) Observation. Alternatively give "hk(0,0)" to the standalone disklabel program and be rewarded with an error. 3) The check for the partition type when writing the memory image of a crash dump to a 'xp' drive was made before the pointer to the partition information was calculated. This could have allowed a crash dump to be written to a file system by mistake. 4) Note that 'sysctl' has the ability to set and get the hostname. There is no longer any need for separate system calls. A previous update placed the 'gethostid' and 'sethostid' with their sysctl counterparts, now it is time to do the same for set/gethosthame Fix: This is #395 and is part 1 of 3. Make sure you have all 3 parts before proceeding. When all three parts have been collected cut where indicated in each and save to tmp files (the instructions assume /tmp/395, /tmp/396 and /tmp/397 respectively). This description and the instructions will not be repeated in the next two parts. In 4.4BSD the 'setreuid', 'setregid' system calls have been replaced with 'seteuid', 'setegid'. The new system calls allow a setuid/gid (or root) process to change user (group) id's more easily (and completely) than the old system calls. The old 'setrgid', and 'setruid' system calls have been deprecated and while present for now (as 'compatibility' routines) will go away eventually. The RK06/7 ('hk') drivers do not implement disklabels. The changes in this update kit have NOT been tested. There is a good chance that everything will work the first time but if there are problems (does anyone still have RK06/7 drives in working order??) a future update will be posted. The SMD driver (xp(4)) had an error in the check for a valid partition type when performing a crash dump. Only a partition of type 'swap' may be used. The pointer to the partition information was calculated a couple lines too late. This could have resulted in a crash dump image being written over the top of a filesystem. Sysctl(2) is a "super syscall" that has subsumed several other system calls in the past. Since sysctl(2) has the ability to set/get the hostname there is no reason to retain the individual system calls that previously performed that task. A number of system calls (setreuid, usw.) have been placed into 'COMPAT-43' status. This means that the kernel is TEMPORARILY a bit mroe 'bloated' than usual because old binaries which use the old system calls will still continue to work correctly. EVENTUALLY (when a 'make world' is done and the entire system regenerated from sources) all of the compatibility calls will go away. The goal is to within the next 6 months (and before another year goes by) to beging removing compatibility syscalls to reduce the size of the kernel. NOTE: This is a moderately large update. MANY new manpages and source files are added to the system. ALSO, quite a number of OLD files are REMOVED. If you feel a bit nervous about burning down (removing or overwriting) existing files and would like to save existing files these are the commands issued during the REMOVE script: rm -f /usr/man/cat2/getegid.0 rm -f /usr/man/cat2/geteuid.0 rm -f /usr/man/cat2/getgid.0 rm -f /usr/man/cat2/getuid.0 rm -f /usr/man/cat2/setregid.0 rm -f /usr/man/cat2/setreuid.0 rm -f /usr/man/cat3/setegid.0 rm -f /usr/man/cat3/seteuid.0 rm -f /usr/man/cat3/setgid.0 rm -f /usr/man/cat3/setrgid.0 rm -f /usr/man/cat3/setruid.0 rm -f /usr/man/cat3/setuid.0 rm -f /usr/src/lib/libc/gen/setegid.c rm -f /usr/src/lib/libc/gen/seteuid.c rm -f /usr/src/lib/libc/gen/setgid.c rm -f /usr/src/lib/libc/gen/setrgid.c rm -f /usr/src/lib/libc/gen/setruid.c rm -f /usr/src/lib/libc/gen/setuid.c rm -f /usr/src/man/man2/getgid.2 rm -f /usr/src/man/man2/getuid.2 rm -f /usr/src/man/man2/setregid.2 rm -f /usr/src/man/man2/setreuid.2 rm -f /usr/src/man/man3/setuid.3 The following files are PATCHED by this update kit: /usr/include/syscall.h /usr/src/bin/adb/opset.c /usr/src/bin/ps.c /usr/src/lib/libc/compat-43/Makefile /usr/src/lib/libc/gen/Makefile /usr/src/lib/libc/pdp/sys/Makefile /usr/src/man/man2/Makefile /usr/src/man/man3/Makefile /usr/src/new/crash/crash.c /usr/src/share/adb/u /usr/src/sys/GENERIC/Make.sys /usr/src/sys/GENERIC/Makefile /usr/src/sys/conf/Make.nsunix /usr/src/sys/conf/Make.sunix /usr/src/sys/conf/Make.sys /usr/src/sys/conf/Make.unix /usr/src/sys/h/acct.h /usr/src/sys/h/user.h /usr/src/sys/pdp/conf.c /usr/src/sys/pdpstand/conf.c /usr/src/sys/pdpstand/hk.c /usr/src/sys/pdpstand/rl.c /usr/src/sys/pdpuba/hk.c /usr/src/sys/pdpuba/xp.c /usr/src/sys/sys/init_sysent.c /usr/src/sys/sys/kern_exec.c /usr/src/sys/sys/kern_fork.c /usr/src/sys/sys/kern_prot.c /usr/src/sys/sys/kern_sig.c /usr/src/sys/sys/syscalls.c /usr/src/sys/sys/ufs_fio.c /usr/src/sys/sys/ufs_syscalls.c /usr/src/ucb/Mail/fio.c /usr/src/usr.sbin/pstat/pstat.c /VERSION These are the NEW files added to the system: /usr/src/lib/libc/compat-43/setregid.c /usr/src/lib/libc/compat-43/setreuid.c /usr/src/lib/libc/compat-43/setrgid.c /usr/src/lib/libc/compat-43/setruid.c /usr/src/lib/libc/gen/gethostname.c /usr/src/lib/libc/gen/sethostname.c /usr/src/man/man2/getgid.2 /usr/src/man/man2/getuid.2 /usr/src/man/man2/setregid.2 /usr/src/man/man2/setreuid.2 /usr/src/man/man2/setuid.2 /usr/src/man/man3/setruid.3 /usr/src/sys/sys/kern_prot2.c As you can see there is a new file (kern_prot2.c) added to the kernel during the update. This is a bit of a PAIN because existing kernel build directories need to be updated for each kernel (except GENERIC which is done for you during the patch processing) on the system ALSO, the 'u' area (user process context area used by the kernel) changes (to make room for the saved uid/gid information). This means that applications that deal with the 'u' area need to be recompiled (the debugger 'adb', 'ps', and a couple others). Installing The Update ===================== Make sure you have all three parts (395, 396, 397) and have cut where indicated in and saved the results to /tmp/395 /tmp/396 and /tmp/397. The '395.rm' script MUST be run first otherwise the 'shar' archive unpacking will fail when trying to create some of the files. Then cd /tmp sh 395 chmod +x 395.rm ./395.rm sh 395.shar patch -p0 < 396 patch -p0 < 397 Now the kernel(s) are updated. You do NOT have to do anything with GENERIC (but it can be used as a guide) but all other kernels which have been configured on the system need to be updated. The file 'Makefile' and 'Make.sys' need to be updated. cd /sys foreach file (YOUR_KERNEL_1 YOUR_KERNEL_2 ...) cp conf/Make.sys $file/Make.sys EDIT $file/Makefile end The line with "EDIT" means to add 'kern_prot2.o' to the the kernel. Any place (an overlay _or_ the base segment) that has 496 bytes of room is suitable. The chances that kern_prot2.o will fit in the same list of files as kern_prot.o is good so check that location first. NOTE: adding the compatibility system calls caused the kernel to grow a little bit. It may be necessary to adjust the overlay layout. A new kernel is now compiled, installed and the system rebooted. The following assumes a 'networking' kernel is being built. If this is not the case omit references to 'netnix': cd /sys/YOUR_KERNEL make clean make cp -p /unix /ounix cp -p /netnix /onetnix install -m 744 unix netnix / reboot If you keep an emergency GENERIC kernel around (as /genunix perhaps) then now is a good time to rebuild and install it: cd /sys/GENERIC make clean make mv unix /genunix The C library and manpages are the next items to be rebuilt and installed. Not all of the manpages changed but it is easier (if a bit more time consuming) to let the makefile do the creation of all the links between the manpages: cd /usr/src/lib/libc make clean make make install cd /usr/src/man/man2 make clean make make install make clean cd /usr/src/man/man3 make clean make make install make clean Several applications that are aware of the 'u' structure now need to be built: cd /usr/src/bin make ps install -s -m 2755 -g kmem ps /bin/ps cd /usr/src/bin/adb make clean make make install cd /usr/src/usr.sbin/pstat make clean make make install cd /usr/src/libexec/identd make clean make make install cd /usr/src/usr.bin/fstat make clean make make install cd /usr/src/ucb make w gcore install -s -m 2755 -g kmem w /usr/ucb/w rm /usr/ucb/uptime ln /usr/ucb/w /usr/ucb/uptime install -s -m 2755 -g kmem gcore /usr/ucb/gcore Lastly the 'boot' program: cd /sys/pdpstand make clean make install -c -s -m 700 boot /boot If you keep a copy of the 'standalone disklabel' program handy in / then: install -c -s -m 700 disklabel /disklabel This would be a good time to create a boot tape containing the standalone utilities and a dump of the root filesystem. You never know when it will come in handy when recovering from a disaster OR if you need to install 2.11BSD on another system: (place a tape in the drive, assumed to be /dev/nrmt0) ./maketape /dev/nrmt0 maketape.data dump 0f /dev/rmt0 / The 'ps' database needs rebuilding: ps -U Lastly the manpage database (used by 'whatis') is rebuilt: /usr/sbin/makewhatis That's all. You're done. Enjoy. As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. ============================cut here======================== #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1997-12-27 13:52 PST by . # Source directory was `/users/sms/KIT'. # # Existing files will *not* be overwritten unless `-c' is specified. # This format requires very little intelligence at unshar time. # "if test", "echo", "mkdir", and "sed" may be needed. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 767 -rwxr-xr-x 395.rm # 43458 -rw-r--r-- 395.shar # echo=echo if mkdir _sh22977; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= 395.rm ============== if test -f '395.rm' && test "$first_param" != -c; then $echo 'x -' SKIPPING '395.rm' '(file already exists)' else $echo 'x -' extracting '395.rm' '(text)' sed 's/^X//' << 'SHAR_EOF' > '395.rm' && X#!/bin/sh -x X Xrm -f /usr/man/cat2/getegid.0 Xrm -f /usr/man/cat2/geteuid.0 Xrm -f /usr/man/cat2/getgid.0 Xrm -f /usr/man/cat2/getuid.0 Xrm -f /usr/man/cat2/setregid.0 Xrm -f /usr/man/cat2/setreuid.0 Xrm -f /usr/man/cat3/setegid.0 Xrm -f /usr/man/cat3/seteuid.0 Xrm -f /usr/man/cat3/setgid.0 Xrm -f /usr/man/cat3/setrgid.0 Xrm -f /usr/man/cat3/setruid.0 Xrm -f /usr/man/cat3/setuid.0 Xrm -f /usr/src/lib/libc/gen/setegid.c Xrm -f /usr/src/lib/libc/gen/seteuid.c Xrm -f /usr/src/lib/libc/gen/setgid.c Xrm -f /usr/src/lib/libc/gen/setrgid.c Xrm -f /usr/src/lib/libc/gen/setruid.c Xrm -f /usr/src/lib/libc/gen/setuid.c Xrm -f /usr/src/man/man2/getgid.2 Xrm -f /usr/src/man/man2/getuid.2 Xrm -f /usr/src/man/man2/setregid.2 Xrm -f /usr/src/man/man2/setreuid.2 Xrm -f /usr/src/man/man3/setuid.3 SHAR_EOF : || $echo 'restore of' '395.rm' 'failed' fi # ============= 395.shar ============== if test -f '395.shar' && test "$first_param" != -c; then $echo 'x -' SKIPPING '395.shar' '(file already exists)' else $echo 'x -' extracting '395.shar' '(text)' sed 's/^X//' << 'SHAR_EOF' > '395.shar' && X#! /bin/sh X# This is a shell archive, meaning: X# 1. Remove everything above the #! /bin/sh line. X# 2. Save the resulting text in a file. X# 3. Execute the file with /bin/sh (not csh) to create: X# /usr/src/lib/libc/compat-43/setregid.c X# /usr/src/lib/libc/compat-43/setreuid.c X# /usr/src/lib/libc/compat-43/setrgid.c X# /usr/src/lib/libc/compat-43/setruid.c X# /usr/src/lib/libc/gen/gethostname.c X# /usr/src/lib/libc/gen/sethostname.c X# /usr/src/man/man2/getgid.2 X# /usr/src/man/man2/getuid.2 X# /usr/src/man/man2/setregid.2 X# /usr/src/man/man2/setreuid.2 X# /usr/src/man/man2/setuid.2 X# /usr/src/man/man3/setruid.3 X# /usr/src/sys/sys/kern_prot2.c X# This archive created: Tue Dec 16 20:59:36 1997 Xexport PATH; PATH=/bin:/usr/bin:$PATH Xif test -f '/usr/src/lib/libc/compat-43/setregid.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/compat-43/setregid.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/compat-43/setregid.c' XZ/* XZ * Copyright (c) 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)setregid.c 8.1.1 (2.11BSD) 1997/11/26"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ#include XZ XZint XZsetregid(rgid, egid) XZ register gid_t rgid, egid; XZ{ XZ static gid_t savedgid = -1; XZ XZ if (savedgid == -1) XZ savedgid = getegid(); XZ /* XZ * we assume that the intent here is to be able to XZ * get back rgid priviledge. So we make sure that XZ * we will be able to do so, but do not actually XZ * set the rgid. XZ */ XZ if (rgid != -1 && rgid != getgid() && rgid != savedgid) { XZ errno = EPERM; XZ return (-1); XZ } XZ if (egid != -1 && setegid(egid) < 0) XZ return (-1); XZ return (0); XZ} XSHAR_EOF Xchmod 644 '/usr/src/lib/libc/compat-43/setregid.c' Xfi Xif test -f '/usr/src/lib/libc/compat-43/setreuid.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/compat-43/setreuid.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/compat-43/setreuid.c' XZ/* XZ * Copyright (c) 1992, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)setreuid.c 8.1.1 (2.11BSD) 1997/11/26"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ#include XZ XZint XZsetreuid(ruid, euid) XZ register uid_t ruid, euid; XZ{ XZ static uid_t saveduid = -1; XZ XZ if (saveduid == -1) XZ saveduid = geteuid(); XZ /* XZ * we assume that the intent here is to be able to XZ * get back ruid priviledge. So we make sure that XZ * we will be able to do so, but do not actually XZ * set the ruid. XZ */ XZ if (ruid != -1 && ruid != getuid() && ruid != saveduid) { XZ errno = EPERM; XZ return (-1); XZ } XZ if (euid != -1 && seteuid(euid) < 0) XZ return (-1); XZ return (0); XZ} XSHAR_EOF Xchmod 644 '/usr/src/lib/libc/compat-43/setreuid.c' Xfi Xif test -f '/usr/src/lib/libc/compat-43/setrgid.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/compat-43/setrgid.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/compat-43/setrgid.c' XZ/* XZ * Copyright (c) 1983, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)setrgid.c 8.1.1 (2.11BSD) 1997/11/26"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ XZint XZsetrgid(rgid) XZ int rgid; XZ{ XZ XZ return (setregid(rgid, -1)); XZ} XSHAR_EOF Xchmod 644 '/usr/src/lib/libc/compat-43/setrgid.c' Xfi Xif test -f '/usr/src/lib/libc/compat-43/setruid.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/compat-43/setruid.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/compat-43/setruid.c' XZ/* XZ * Copyright (c) 1983, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)setruid.c 8.1.1 (2.11BSD) 1997/11/26"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ XZint XZsetruid(ruid) XZ int ruid; XZ{ XZ XZ return (setreuid(ruid, -1)); XZ} XSHAR_EOF Xchmod 644 '/usr/src/lib/libc/compat-43/setruid.c' Xfi Xif test -f '/usr/src/lib/libc/gen/gethostname.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/gethostname.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/gen/gethostname.c' XZ/* XZ * Copyright (c) 1989, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)gethostname.c 8.1.1 (2.11BSD) 1997/11/30"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ#include XZ XZgethostname(name, namelen) XZ char *name; XZ int namelen; XZ{ XZ int mib[2]; XZ size_t size; XZ XZ mib[0] = CTL_KERN; XZ mib[1] = KERN_HOSTNAME; XZ size = namelen; XZ if (sysctl(mib, 2, name, &size, NULL, 0) == -1) XZ return (-1); XZ return (0); XZ} XSHAR_EOF Xchmod 444 '/usr/src/lib/libc/gen/gethostname.c' Xfi Xif test -f '/usr/src/lib/libc/gen/sethostname.c' Xthen X echo shar: "will not over-write existing file '/usr/src/lib/libc/gen/sethostname.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/lib/libc/gen/sethostname.c' XZ/* XZ * Copyright (c) 1989, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ */ XZ XZ#if defined(LIBC_SCCS) && !defined(lint) XZstatic char sccsid[] = "@(#)sethostname.c 8.1.1 (2.11BSD) 1997/11/30"; XZ#endif /* LIBC_SCCS and not lint */ XZ XZ#include XZ#include XZ XZsethostname(name, namelen) XZ char *name; XZ int namelen; XZ{ XZ int mib[2]; XZ XZ mib[0] = CTL_KERN; XZ mib[1] = KERN_HOSTNAME; XZ if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) XZ return (-1); XZ return (0); XZ} XSHAR_EOF Xchmod 444 '/usr/src/lib/libc/gen/sethostname.c' Xfi Xif test -f '/usr/src/man/man2/getgid.2' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man2/getgid.2'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man2/getgid.2' XZ.\" Copyright (c) 1983, 1991, 1993 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)getgid.2 8.1.1 (2.11BSD) 1997/12/2 XZ.\" XZ.TH GETGID 2 "December 2, 1997" XZ.UC 5 XZ.SH NAME XZ\fBgetgid\fP, \fBgetegid\fP \- get group process identification XZ.SH SYNOPSIS XZ.B #include XZ.sp XZ.nf XZ\fIgid_t\fP XZ\fBgetgid\fP() XZ.sp XZ\fIgid_t\fP XZ\fBgetegid\fP() XZ.fi XZ.SH DESCRIPTION XZThe XZ.B getgid XZfunction returns the real group ID of the calling process, XZ.B getegid XZreturns the effective group ID of the calling process. XZ.PP XZThe real group ID is specified at login time. XZ.PP XZThe real group ID is the group of the user who invoked the program. XZAs the effective group ID gives the process additional permissions XZduring the execution of XZ``\fIset-group-ID\fP'' XZmode processes, XZ.B getgid XZis used to determine the real-user-id of the calling process. XZ.SH ERRORS XZThe XZ.B getgid XZand XZ.B getegid XZfunctions are always successful, and no return value is reserved to XZindicate an error. XZ.SH SEE ALSO XZgetuid(2), setregid(2), setgid(3) XZ.SH STANDARDS XZ.B Getgid XZand XZ.B getegid XZconform to IEEE Std 1003.1-1988 (``POSIX''). XSHAR_EOF Xchmod 644 '/usr/src/man/man2/getgid.2' Xfi Xif test -f '/usr/src/man/man2/getuid.2' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man2/getuid.2'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man2/getuid.2' XZ.\" Copyright (c) 1980, 1991, 1993 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)getuid.2 8.1.1 (2.11BSD) 1997/12/2 XZ.\" XZ.TH GETUID 2 "December 2, 1997" XZ.UC 5 XZ.SH NAME XZ\fBgetuid\fP, \fBgeteuid\fP \- get user identification XZ.SH SYNOPSIS XZ.nf XZ.B #include XZ.B #include XZ.sp XZ\fIuid_t\fP XZ\fBgetuid\fP() XZ.sp XZ\fIuid_t\fP XZ\fBgeteuid\fP() XZ.fi XZ.SH DESCRIPTION XZThe XZ.B getuid XZfunction returns the real user ID of the calling process. XZThe XZ.B geteuid XZfunction XZreturns the effective user ID of the calling process. XZ.PP XZThe real user ID is that of the user who has invoked the program. XZAs the effective user ID XZgives the process additional permissions during XZexecution of ``\fIset-user-ID\fP'' XZmode processes, XZ.B getuid XZis used to determine the real-user-id of the calling process. XZ.SH ERRORS XZThe XZ.B getuid XZand XZ.B geteuid XZfunctions are always successful, and no return value is reserved to XZindicate an error. XZ.SH SEE ALSO XZgetgid(2), setreuid(2) XZ.SH STANDARDS XZ.B Geteuid XZand XZ.B getuid XZconform to IEEE Std 1003.1-1988 (``POSIX''). XSHAR_EOF Xchmod 644 '/usr/src/man/man2/getuid.2' Xfi Xif test -f '/usr/src/man/man2/setregid.2' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man2/setregid.2'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man2/setregid.2' XZ.\" Copyright (c) 1980, 1991, 1993, 1994 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)setregid.2 8.2.1 (2.11BSD) 1997/12/2 XZ.\" XZ.TH SETREGID 2 "December 2, 1997" XZ.UC 5 XZ.SH NAME XZ\fBsetregid\fP \- set real and effective group ID XZ.SH SYNOPSIS XZ.B #include XZ.sp XZ.nf XZ\fIint\fP XZ\fBsetregid(rgid, egid)\fP XZ\ \ \ \ \ gid_t rgid, egid XZ.fi XZ.SH DESCRIPTION XZThe real and effective group ID's of the current process XZare set to the arguments. XZUnprivileged users may change the real group XZID to the effective group ID and vice-versa; only the super-user may XZmake other changes. XZ.PP XZSupplying a value of -1 for either the real or effective XZgroup ID forces the system to substitute the current XZID in place of the -1 parameter. XZ.PP XZThe XZ.B setregid XZfunction was intended to allow swapping XZthe real and effective group IDs XZin set-group-ID programs to temporarily relinquish the set-group-ID value. XZThis function did not work correctly, XZand its purpose is now better served by the use of the XZ.B setegid XZfunction (see setuid(2)). XZ.PP XZWhen setting the real and effective group IDs to the same value, XZthe standard XZ.B setgid XZfunction is preferred. XZ.SH RETURN VALUES XZUpon successful completion, a value of 0 is returned. Otherwise, XZa value of -1 is returned and XZ.I errno XZis set to indicate the error. XZ.SH ERRORS XZ.TP 10 XZEPERM XZThe current process is not the super-user and a change XZother than changing the effective group-id to the real group-id XZwas specified. XZ.SH SEE ALSO XZgetgid(2), setegid(2), setgid(2), setuid(2) XZ.SH HISTORY XZThe XZ.B setregid XZfunction call appeared in 4.2BSD XZand was dropped in 4.4BSD. XSHAR_EOF Xchmod 644 '/usr/src/man/man2/setregid.2' Xfi Xif test -f '/usr/src/man/man2/setreuid.2' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man2/setreuid.2'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man2/setreuid.2' XZ.\" Copyright (c) 1980, 1991, 1993, 1994 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)setreuid.2 8.2.1 (2.11BSD) 1997/12/3 XZ.\" XZ.TH SETREUID 2 "December 3, 1997" XZ.UC 4 XZ.SH NAME XZ\fBsetreuid\fP \- set real and effective user ID's XZ.SH SYNOPSIS XZ.B #include XZ.nf XZ.sp XZ\fIint\fP XZ\fBsetreuid\fP(ruid, euid) XZ\ \ \ \ uid_t ruid, euid XZ.fi XZ.SH DESCRIPTION XZThe real and effective user IDs of the XZcurrent process are set according to the arguments. XZIf XZ.I ruid XZor XZ.I euid XZis -1, the current uid is filled in by the system. XZUnprivileged users may change the real user XZID to the effective user ID and vice-versa; only the super-user may XZmake other changes. XZ.PP XZThe XZ.B setreuid XZfunction has been used to swap the real and effective user IDs XZin set-user-ID programs to temporarily relinquish the set-user-ID value. XZThis purpose is now better served by the use of the XZ.B seteuid XZfunction (see setuid(2)). XZ.PP XZWhen setting the real and effective user IDs to the same value, XZthe standard XZ.B setuid XZfunction is preferred. XZ.SH RETURN VALUES XZUpon successful completion, a value of 0 is returned. Otherwise, XZa value of -1 is returned and XZ.I errno XZis set to indicate the error. XZ.SH ERRORS XZ.TP 10 XZEPERM XZThe current process is not the super-user and a change XZother than changing the effective user-id to the real user-id XZwas specified. XZ.SH SEE ALSO XZgetuid(2), seteuid(2), setuid(2) XZ.SH HISTORY XZThe XZ.B setreuid XZfunction call appeared in 4.2BSD XZand was dropped in XZ4.4BSD. XSHAR_EOF Xchmod 644 '/usr/src/man/man2/setreuid.2' Xfi Xif test -f '/usr/src/man/man2/setuid.2' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man2/setuid.2'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man2/setuid.2' XZ.\" Copyright (c) 1983, 1991, 1993 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)setuid.2 8.1.1 (2.11BSD) 1997/12/3 XZ.\" XZ.TH SETUID 2 "December 3, 1997" XZ.UC 5 XZ.SH NAME XZ\fBsetuid\fP, \fBseteuid\fP,\fBsetgid\fP,\fBsetegid\fP \- set user and group ID XZ.SH SYNOPSIS XZ.nf XZ.B #include XZ.B #include XZ.sp XZ\fIint\fP XZ\fBsetuid\fP(uid) XZ\ \ \ \ uid_t uid XZ.sp XZ\fIint\fP XZ\fBseteuid\fP(euid) XZ\ \ \ \ uid_t euid XZ.sp XZ\fIint\fP XZ\fBsetgid\fP(gid) XZ\ \ \ \ gid_t gid XZ.sp XZ\fIint\fP XZ\fBsetegid\fP(egid) XZ\ \ \ \ gid_t egid XZ.fi XZ.SH DESCRIPTION XZThe XZ.B setuid XZfunction XZsets the real and effective XZuser IDs and the saved set-user-ID of the current process XZto the specified value. XZThe XZ.B setuid XZfunction is permitted if the specified ID is equal to the real user ID XZof the process, or if the effective user ID is that of the super user. XZ.PP XZThe XZ.B setgid XZfunction XZsets the real and effective XZgroup IDs and the saved set-group-ID of the current process XZto the specified value. XZThe XZ.B setgid XZfunction is permitted if the specified ID is equal to the real group ID XZof the process, or if the effective user ID is that of the super user. XZ.PP XZThe XZ.B seteuid XZfunction XZ(\fBsetegid\fP) XZsets the effective user ID (group ID) of the XZcurrent process. XZThe effective user ID may be set to the value XZof the real user ID or the saved set-user-ID (see XZintro(2) XZand XZexecve(2); XZin this way, the effective user ID of a set-user-ID executable XZmay be toggled by switching to the real user ID, then re-enabled XZby reverting to the set-user-ID value. XZSimilarly, the effective group ID may be set to the value XZof the real group ID or the saved set-user-ID. XZ.PP XZ.SH RETURN VALUES XZUpon success, these functions return 0; XZotherwise \-1 is returned. XZ.PP XZIf the user is not the super user, or the uid XZspecified is not the real, effective ID, or saved ID, XZthese functions return \-1. XZ.SH SEE ALSO XZgetuid(2), getgid(2) XZ.SH STANDARDS XZThe XZ.B setuid XZand XZ.B setgid XZfunctions are compliant with the XZIEEE Std 1003.1-1988 (``POSIX'') XZspecification with XZ_POSIX_SAVED_IDS XZnot defined. XZThe XZ.B seteuid XZand XZ.B setegid XZfunctions are extensions based on the XZPOSIX XZconcept of XZ_POSIX_SAVED_IDS , XZand have been proposed for a future revision of the standard. XSHAR_EOF Xchmod 644 '/usr/src/man/man2/setuid.2' Xfi Xif test -f '/usr/src/man/man3/setruid.3' Xthen X echo shar: "will not over-write existing file '/usr/src/man/man3/setruid.3'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/man/man3/setruid.3' XZ.\" Copyright (c) 1983, 1991, 1993 XZ.\" The Regents of the University of California. All rights reserved. XZ.\" XZ.\" Redistribution and use in source and binary forms, with or without XZ.\" modification, are permitted provided that the following conditions XZ.\" are met: XZ.\" 1. Redistributions of source code must retain the above copyright XZ.\" notice, this list of conditions and the following disclaimer. XZ.\" 2. Redistributions in binary form must reproduce the above copyright XZ.\" notice, this list of conditions and the following disclaimer in the XZ.\" documentation and/or other materials provided with the distribution. XZ.\" 3. All advertising materials mentioning features or use of this software XZ.\" must display the following acknowledgement: XZ.\" This product includes software developed by the University of XZ.\" California, Berkeley and its contributors. XZ.\" 4. Neither the name of the University nor the names of its contributors XZ.\" may be used to endorse or promote products derived from this software XZ.\" without specific prior written permission. XZ.\" XZ.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ.\" SUCH DAMAGE. XZ.\" XZ.\" @(#)setruid.3 8.1.1 (2.11BSD) 1997/12/3 XZ.\" XZ.TH SETRUID 3 "December 3, 1997" XZ.UC 4 XZ.SH NAME XZ\fBsetruid\fP, \fBsetrgid\fP \- set user and group ID XZ.SH SYNOPSIS XZ.B #include XZ.nf XZ\fIint\fP XZ\fBsetruid\fP(ruid) XZ\ \ \ \ uid_t ruid XZ.sp XZ\fIint\fP XZ\fBsetrgid\fP(rgid) XZ\ \ \ \ gid_t rgid XZ.fi XZ.SH DESCRIPTION XZThe XZ.B setruid XZfunction XZ(\fBsetrgid\fP) XZsets the real user ID (group ID) of the XZcurrent process. XZ.SH RETURN VALUES XZUpon success, these functions return 0; XZotherwise \-1 is returned. XZ.PP XZIf the user is not the super user, or the uid XZspecified is not the real or effective ID, these XZfunctions return \-1. XZ.PP XZThe use of these calls is not portable. XZTheir use is discouraged; they will be removed in the future. XZ.SH SEE ALSO XZsetuid(2), setgid(2), seteuid(2), setegid(2), getuid(2), getgid(2) XZ.SH HISTORY XZThe XZ.B setruid XZand XZ.B setrgid XZsyscalls appeared in 4.2BSD XZand were dropped in XZ4.4BSD. XSHAR_EOF Xchmod 644 '/usr/src/man/man3/setruid.3' Xfi Xif test -f '/usr/src/sys/sys/kern_prot2.c' Xthen X echo shar: "will not over-write existing file '/usr/src/sys/sys/kern_prot2.c'" Xelse Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/sys/sys/kern_prot2.c' XZ/* XZ * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 XZ * The Regents of the University of California. All rights reserved. XZ * (c) UNIX System Laboratories, Inc. XZ * All or some portions of this file are derived from material licensed XZ * to the University of California by American Telephone and Telegraph XZ * Co. or Unix System Laboratories, Inc. and are reproduced herein with XZ * the permission of UNIX System Laboratories, Inc. XZ * XZ * Redistribution and use in source and binary forms, with or without XZ * modification, are permitted provided that the following conditions XZ * are met: XZ * 1. Redistributions of source code must retain the above copyright XZ * notice, this list of conditions and the following disclaimer. XZ * 2. Redistributions in binary form must reproduce the above copyright XZ * notice, this list of conditions and the following disclaimer in the XZ * documentation and/or other materials provided with the distribution. XZ * 3. All advertising materials mentioning features or use of this software XZ * must display the following acknowledgement: XZ * This product includes software developed by the University of XZ * California, Berkeley and its contributors. XZ * 4. Neither the name of the University nor the names of its contributors XZ * may be used to endorse or promote products derived from this software XZ * without specific prior written permission. XZ * XZ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND XZ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE XZ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE XZ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE XZ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL XZ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS XZ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) XZ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT XZ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY XZ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF XZ * SUCH DAMAGE. XZ * XZ * @(#)kern_prot.c 8.9.1 (2.11BSD) 1997/11/28 XZ */ XZ XZ#include "param.h" XZ#include "user.h" XZ#include "acct.h" XZ#include "proc.h" XZ#include "systm.h" XZ#ifdef QUOTA XZ#include "quota.h" XZ#endif XZ XZint XZsetuid() XZ{ XZ struct a { XZ uid_t uid; XZ } *uap = (struct a *)u.u_ap; XZ XZ return(_setuid(uap->uid)); XZ } XZ XZ/* XZ * This is a helper function used by setuid() above and the 4.3BSD XZ * compatibility code. When the latter goes away this can be joined XZ * back into the above code and save a function call. XZ*/ XZint XZ_setuid(uid) XZ register uid_t uid; XZ { XZ XZ if (uid != u.u_ruid && !suser()) XZ return(u.u_error); XZ /* XZ * Everything's okay, do it. XZ * Since the real user id is changing the quota references need XZ * to be updated. XZ */ XZ#ifdef QUOTA XZ QUOTAMAP(); XZ if (u.u_quota->q_uid != uid) { XZ qclean(); XZ qstart(getquota((uid_t)uid, 0, 0)); XZ } XZ QUOTAUNMAP(); XZ#endif XZ XZ u.u_procp->p_uid = uid; XZ u.u_uid = uid; XZ u.u_ruid = uid; XZ u.u_svuid = uid; XZ u.u_acflag |= ASUGID; XZ return (u.u_error = 0); XZ } XZ XZint XZseteuid() XZ{ XZ struct a { XZ uid_t euid; XZ } *uap = (struct a *)u.u_ap; XZ XZ return(_seteuid(uap->euid)); XZ } XZ XZint XZ_seteuid(euid) XZ register uid_t euid; XZ { XZ XZ if (euid != u.u_ruid && euid != u.u_svuid && !suser()) XZ return (u.u_error); XZ /* XZ * Everything's okay, do it. XZ */ XZ u.u_uid = euid; XZ u.u_acflag |= ASUGID; XZ return (u.u_error = 0); XZ } XZ XZint XZsetgid() XZ { XZ struct a { XZ gid_t gid; XZ } *uap = (struct a *)u.u_ap; XZ XZ return(_setgid(uap->gid)); XZ } XZ XZint XZ_setgid(gid) XZ register gid_t gid; XZ { XZ XZ if (gid != u.u_rgid && !suser()) XZ return (u.u_error); /* XXX */ XZ u.u_groups[0] = gid; /* effective gid is u_groups[0] */ XZ u.u_rgid = gid; XZ u.u_svgid = gid; XZ u.u_acflag |= ASUGID; XZ return (u.u_error = 0); XZ } XZ XZint XZsetegid() XZ { XZ struct a { XZ gid_t egid; XZ } *uap = (struct a *)u.u_ap; XZ XZ return(_setegid(uap->egid)); XZ } XZ XZint XZ_setegid(egid) XZ register gid_t egid; XZ { XZ XZ if (egid != u.u_rgid && egid != u.u_svgid && !suser()) XZ return (u.u_error); XZ u.u_groups[0] = egid; XZ u.u_acflag |= ASUGID; XZ return (u.u_error = 0); XZ } XZ XZ/* 4.3 compatibility */ XZ XZint XZsetreuid() XZ{ XZ register struct a { XZ int ruid; XZ int euid; XZ } *uap = (struct a *)u.u_ap; XZ XZ /* XZ * If ruid == euid then setreuid is being used to emulate setuid, XZ * just do it. XZ */ XZ if (uap->ruid != -1 && uap->ruid == uap->euid) XZ return (_setuid(uap->ruid)); XZ /* XZ * Otherwise we assume that the intent of setting ruid is to be XZ * able to get back ruid priviledge (i.e. swapping ruid and euid). XZ * So we make sure that we will be able to do so, but do not XZ * actually set the ruid. XZ */ XZ if (uap->ruid != (uid_t)-1 && uap->ruid != u.u_ruid && XZ uap->ruid != u.u_svuid) XZ return (u.u_error = EPERM); XZ if (uap->euid == (uid_t)-1) XZ return (u.u_error = 0); XZ return (_seteuid(uap->euid)); XZ} XZ XZ/* 4.3 compatibility */ XZ XZint XZsetregid() XZ{ XZ register struct a { XZ int rgid; XZ int egid; XZ } *uap = (struct a *)u.u_ap; XZ XZ /* XZ * If rgid == egid then setreuid is being used to emulate setgid, XZ * just do it. XZ */ XZ if (uap->rgid != -1 && uap->rgid == uap->egid) XZ return (_setgid(uap->rgid)); XZ /* XZ * Otherwise we assume that the intent of setting rgid is to be XZ * able to get back rgid priviledge (i.e. swapping rgid and egid). XZ * So we make sure that we will be able to do so, but do not XZ * actually set the rgid. XZ */ XZ if (uap->rgid != (gid_t)-1 && uap->rgid != u.u_rgid && XZ uap->rgid != u.u_svgid) XZ return (u.u_error = EPERM); XZ if (uap->egid == (gid_t)-1) XZ return (u.u_error = 0); XZ return (_setegid(uap->egid)); XZ} XSHAR_EOF Xchmod 644 '/usr/src/sys/sys/kern_prot2.c' Xfi Xexit 0 X# End of shell archive SHAR_EOF : || $echo 'restore of' '395.shar' 'failed' fi rm -fr _sh22977 exit 0