diff options
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/Makefile.inc | 13 | ||||
-rw-r--r-- | lib/libc/gen/ctype_.c | 8 | ||||
-rw-r--r-- | lib/libc/gen/getcap.3 | 2 | ||||
-rw-r--r-- | lib/libc/gen/getcap.c | 29 | ||||
-rw-r--r-- | lib/libc/gen/getfsent.3 | 2 | ||||
-rw-r--r-- | lib/libc/gen/getmntinfo.3 | 2 | ||||
-rw-r--r-- | lib/libc/gen/getpwent.3 | 14 | ||||
-rw-r--r-- | lib/libc/gen/getpwent.c | 93 | ||||
-rw-r--r-- | lib/libc/gen/isctype.c | 142 | ||||
-rw-r--r-- | lib/libc/gen/semconfig.c | 2 | ||||
-rw-r--r-- | lib/libc/gen/setmode.c | 11 | ||||
-rw-r--r-- | lib/libc/gen/setrgid.c | 50 | ||||
-rw-r--r-- | lib/libc/gen/setruid.c | 50 | ||||
-rw-r--r-- | lib/libc/gen/setuid.3 | 99 |
14 files changed, 152 insertions, 365 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 0f0a66405d13..3b54c31a5d12 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -8,10 +8,10 @@ SRCS+= alarm.c assert.c clock.c crypt.c ctermid.c ctime.c ctype_.c \ fnmatch.c frexp.c fstab.c fts.c getcap.c getcwd.c getgrent.c \ getlogin.c getmntinfo.c getpass.c getpwent.c getsubopt.c getttyent.c \ getusershell.c glob.c infinity.c initgroups.c insque.c isatty.c \ - isctype.c isinf.c mktemp.c msgctl.c msgget.c msgsnd.c msgrcv.c \ + isinf.c mktemp.c msgctl.c msgget.c msgsnd.c msgrcv.c \ nice.c nlist.c pause.c popen.c psignal.c raise.c scandir.c \ semconfig.c semctl.c semget.c semop.c \ - setjmperr.c setmode.c setrgid.c setruid.c \ + setjmperr.c setmode.c \ shmat.c shmctl.c shmdt.c shmget.c \ siginterrupt.c siglist.c signal.c sigsetops.c sleep.c syslog.c \ termios.c time.c times.c timezone.c ttyname.c ttyslot.c \ @@ -27,7 +27,9 @@ SRCS+= adddf3.s addsf3.s ashlsi3.s ashrsi3.s cmpdf2.s cmpsf2.s divdf3.s \ umodsi3.s umulsi3.s .elif (${MACHINE} == "i386") SRCS+= _setjmp.S alloca.S fabs.S ldexp.c modf.S setjmp.S sigsetjmp.S +.if defined (GCC1_IN_LIBC) SRCS+= divsi3.S fixdfsi.S fixunsdfsi.S udivsi3.S +.endif .elif (${MACHINE} == "tahoe") CFLAGS+=-I/sys SRCS+= _setjmp.s alloca.s fabs.s ldexp.s modf.s setjmp.s @@ -36,6 +38,9 @@ SRCS+= udiv.s urem.s SRCS+= _setjmp.s alloca.s fabs.s ldexp.s modf.s setjmp.s SRCS+= udiv.s urem.s .endif +.if defined (PW_COMPACT) +CFLAGS+=-DPW_COMPACT +.endif MAN3+= gen/alarm.3 gen/clock.3 gen/crypt.3 gen/ctermid.3 gen/ctime.3 \ gen/ctype.3 gen/directory.3 gen/err.3 gen/exec.3 gen/fnmatch.3 \ @@ -47,7 +52,7 @@ MAN3+= gen/alarm.3 gen/clock.3 gen/crypt.3 gen/ctermid.3 gen/ctime.3 \ gen/islower.3 gen/isprint.3 gen/ispunct.3 gen/isspace.3 \ gen/isupper.3 gen/isxdigit.3 gen/ldexp.3 gen/modf.3 gen/nice.3 \ gen/nlist.3 gen/pause.3 gen/popen.3 gen/psignal.3 gen/raise.3 \ - gen/scandir.3 gen/setjmp.3 gen/setmode.3 gen/setuid.3 \ + gen/scandir.3 gen/setjmp.3 gen/setmode.3 \ gen/siginterrupt.3 gen/signal.3 gen/sigsetops.3 gen/sleep.3 \ gen/syslog.3 gen/tcgetpgrp.3 gen/tcsendbreak.3 gen/tcsetattr.3 \ gen/tcsetpgrp.3 gen/time.3 gen/times.3 gen/timezone.3 gen/tolower.3 \ @@ -86,8 +91,6 @@ MLINKS+=scandir.3 alphasort.3 MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \ setjmp.3 sigsetjmp.3 setjmp.3 siglongjmp.3 setjmp.3 longjmperror.3 MLINKS+=setmode.3 getmode.3 -MLINKS+=setuid.3 setegid.3 setuid.3 seteuid.3 setuid.3 setgid.3 \ - setuid.3 setrgid.3 setuid.3 setruid.3 MLINKS+=sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \ sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \ sigsetops.3 sigismember.3 diff --git a/lib/libc/gen/ctype_.c b/lib/libc/gen/ctype_.c index d361c1617cea..0f06fe2b8123 100644 --- a/lib/libc/gen/ctype_.c +++ b/lib/libc/gen/ctype_.c @@ -5,7 +5,7 @@ * or UNIX System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * - * $Id: ctype_.c,v 1.1.1.1.2.1 1994/05/04 07:39:42 rgrimes Exp $ + * $Id: ctype_.c,v 1.3 1994/05/04 08:17:14 rgrimes Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -41,10 +41,12 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90"; +static char sccsid[] = "From: @(#)ctype_.c 5.6 (Berkeley) 6/1/90"; +static const char rcsid[] = + "$Id: ctype_.c,v 1.3 1994/05/04 08:17:14 rgrimes Exp $"; #endif /* LIBC_SCCS and not lint */ -#include <ctype.h> +#include <octype.h> char _ctype_[1 + 256] = { 0, diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3 index d18b3797bc7e..a2cf2665d0d4 100644 --- a/lib/libc/gen/getcap.3 +++ b/lib/libc/gen/getcap.3 @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)getcap.3 5.4 (Berkeley) 8/11/92 -.\" $Id: getcap.3,v 1.1.2.1 1994/05/01 16:05:00 jkh Exp $ +.\" $Id: getcap.3,v 1.2 1994/04/17 09:16:14 alm Exp $ .\" .Dd "August 11, 1992" .Dt GETCAP 3 diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index 7f70789450fd..647a5bff41a7 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -35,7 +35,8 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getcap.c 5.15 (Berkeley) 3/19/93"; +/*static char *sccsid = "from: @(#)getcap.c 5.15 (Berkeley) 3/19/93";*/ +static char *rcsid = "$Id: getcap.c,v 1.2 1994/04/17 09:16:16 alm Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -194,8 +195,8 @@ getent(cap, len, db_array, fd, name, depth, nfield) DB *capdbp; DBT key, data; register char *r_end, *rp, **db_p; - int myfd, eof, foundit, retval; - char *record; + int myfd, eof, foundit, retval, clen; + char *record, *cbuf; int tc_not_resolved; char pbuf[_POSIX_PATH_MAX]; @@ -250,11 +251,21 @@ getent(cap, len, db_array, fd, name, depth, nfield) != NULL) { free(record); retval = cdbget(capdbp, &record, name); - if (capdbp->close(capdbp) < 0) + if (retval < 0) { + /* no record available */ + (void)capdbp->close(capdbp); + return (retval); + } + /* save the data; close frees it */ + clen = strlen(record); + cbuf = malloc(clen + 1); + memcpy(cbuf, record, clen + 1); + if (capdbp->close(capdbp) < 0) { + free(cbuf); return (-2); - *len = strlen(record); - *cap = malloc(*len + 1); - memmove(*cap, record, *len + 1); + } + *len = clen; + *cap = cbuf; return (retval); } else { fd = open(*db_p, O_RDONLY, 0); @@ -657,7 +668,7 @@ cgetnext(bp, db_array) gottoprec = 1; line = toprec; } else { - line = fgetline(pfp, &len); + line = fgetln(pfp, &len); if (line == NULL && pfp) { (void)fclose(pfp); if (ferror(pfp)) { @@ -716,7 +727,7 @@ cgetnext(bp, db_array) *np = '\0'; break; } else { /* name field extends beyond the line */ - line = fgetline(pfp, &len); + line = fgetln(pfp, &len); if (line == NULL && pfp) { (void)fclose(pfp); if (ferror(pfp)) { diff --git a/lib/libc/gen/getfsent.3 b/lib/libc/gen/getfsent.3 index 16847ed0b5f7..e29ed40724df 100644 --- a/lib/libc/gen/getfsent.3 +++ b/lib/libc/gen/getfsent.3 @@ -43,7 +43,7 @@ .Nd get file system descriptor file entry .Sh SYNOPSIS .Fd #include <fstab.h> -.Ft fstab * +.Ft struct fstab * .Fn getfsent void .Ft struct fstab * .Fn getfsspec "const char *spec" diff --git a/lib/libc/gen/getmntinfo.3 b/lib/libc/gen/getmntinfo.3 index 6119c6a4b2b7..689a28e3ddbf 100644 --- a/lib/libc/gen/getmntinfo.3 +++ b/lib/libc/gen/getmntinfo.3 @@ -41,7 +41,7 @@ .Fd #include <sys/types.h> .Fd #include <sys/mount.h> .Ft int -.Fn getmntinfo "int mntbufp" "int flags" +.Fn getmntinfo "int *mntbufp" "int flags" .Sh DESCRIPTION The .Fn getmntinfo diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3 index 6d0b9194bb0b..7963afab91e6 100644 --- a/lib/libc/gen/getpwent.3 +++ b/lib/libc/gen/getpwent.3 @@ -200,6 +200,20 @@ and .Fn setpwent are fairly useless in a networked environment and should be avoided, if possible. +.Pp +Standard database make routines are slow especially for big passwd +files. Moreover, *pwd.db bases are too big and waste root space. +You can have much faster routines with small *pwd.db, +but loose binary compatibility +with previous versions and with other BSD-like systems. +If you want to setup much faster routines, define +.B PW_COMPACT +envirnoment variable (f.e. 'setenv PW_COMPACT' in csh) and use +.I bootstrappwd +target into /usr/src/Makefile. +If you will want to return this changes back, use the same target +without defining +.BR PW_COMPACT . .Sh COMPATIBILITY The historic function .Xr setpwfile 3 , diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 93a09ee52ff6..96ae370c761c 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -33,7 +33,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)getpwent.c 5.21 (Berkeley) 3/14/91";*/ -static char *rcsid = "$Id: getpwent.c,v 1.4 1994/01/11 19:00:58 nate Exp $"; +static char *rcsid = "$Id: getpwent.c,v 1.9 1994/05/05 18:16:44 ache Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -54,8 +54,14 @@ static char *rcsid = "$Id: getpwent.c,v 1.4 1994/01/11 19:00:58 nate Exp $"; #include <rpcsvc/ypclnt.h> #endif +/* #define PW_COMPACT */ +/* Compact pwd.db/spwd.db structure by Alex G. Bulushev, bag@demos.su */ + static struct passwd _pw_passwd; /* password structure */ static DB *_pw_db; /* password database */ +#ifdef PW_COMPACT +static DB *_spw_db; /* shadow password database */ +#endif static int _pw_keynum; /* key counter */ static int _pw_stayopen; /* keep fd's open */ static int __hashpw(), __initdb(); @@ -260,6 +266,12 @@ getpwnam(name) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return &_pw_passwd; } @@ -268,6 +280,12 @@ getpwnam(name) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return (struct passwd *)NULL; } @@ -283,6 +301,12 @@ getpwnam(name) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return(rval ? &_pw_passwd : (struct passwd *)NULL); } @@ -355,6 +379,12 @@ getpwuid(uid) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return &_pw_passwd; } @@ -363,6 +393,12 @@ getpwuid(uid) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return (struct passwd *)NULL; } @@ -378,6 +414,12 @@ getpwuid(uid) if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } return(rval ? &_pw_passwd : (struct passwd *)NULL); } @@ -410,6 +452,12 @@ endpwent() if (_pw_db) { (void)(_pw_db->close)(_pw_db); _pw_db = (DB *)NULL; +#ifdef PW_COMPACT + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#endif } #ifdef YP __ypmode = 0; @@ -425,12 +473,30 @@ __initdb() static int warned; char *p; +#ifdef PW_COMPACT + if (!geteuid()) { + _spw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL); + if (!_spw_db && !warned) + syslog(LOG_ERR, "%s: %m", _PATH_SMP_DB); + } + _pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL); + if (_pw_db) + return(1); + if (!warned) + syslog(LOG_ERR, "%s: %m", _PATH_MP_DB); + if (_spw_db) { + (void)(_spw_db->close)(_spw_db); + _spw_db = (DB *)NULL; + } +#else p = (geteuid()) ? _PATH_MP_DB : _PATH_SMP_DB; _pw_db = dbopen(p, O_RDONLY, 0, DB_HASH, NULL); if (_pw_db) return(1); if (!warned) syslog(LOG_ERR, "%s: %m", p); +#endif + warned = 1; return(0); } @@ -442,9 +508,26 @@ __hashpw(key) static u_int max; static char *line; DBT data; +#ifdef PW_COMPACT + DBT _key, *__key; + char bf[sizeof(_pw_keynum) + 1]; +#endif if ((_pw_db->get)(_pw_db, key, &data, 0)) return(0); +#ifdef PW_COMPACT + __key = key; + if (((char *)(*__key).data)[0] != _PW_KEYBYNUM) { + if (data.size != sizeof(_pw_keynum)) return(0); + bf[0] = _PW_KEYBYNUM; + bcopy(data.data, bf + 1, sizeof(_pw_keynum)); + _key.data = (u_char *)bf; + _key.size = sizeof(_pw_keynum) + 1; + __key = (DBT *)&_key; + if ((_pw_db->get)(_pw_db, __key, &data, 0)) + return(0); + } +#endif p = (char *)data.data; if (data.size > max && !(line = realloc(line, max += 1024))) return(0); @@ -452,7 +535,9 @@ __hashpw(key) t = line; #define EXPAND(e) e = t; while (*t++ = *p++); EXPAND(_pw_passwd.pw_name); +#ifndef PW_COMPACT EXPAND(_pw_passwd.pw_passwd); +#endif bcopy(p, (char *)&_pw_passwd.pw_uid, sizeof(int)); p += sizeof(int); bcopy(p, (char *)&_pw_passwd.pw_gid, sizeof(int)); @@ -465,5 +550,11 @@ __hashpw(key) EXPAND(_pw_passwd.pw_shell); bcopy(p, (char *)&_pw_passwd.pw_expire, sizeof(time_t)); p += sizeof(time_t); +#ifdef PW_COMPACT + if (_spw_db && !(_spw_db->get)(_spw_db, __key, &data, 0)) + p = (char *)data.data; + else p = "*"; + EXPAND(_pw_passwd.pw_passwd); +#endif return(1); } diff --git a/lib/libc/gen/isctype.c b/lib/libc/gen/isctype.c deleted file mode 100644 index d8dd5bc33e9f..000000000000 --- a/lib/libc/gen/isctype.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) UNIX System Laboratories, Inc. All or some portions - * of this file are derived from material licensed to the - * University of California by American Telephone and Telegraph Co. - * or UNIX System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * $Id: isctype.c,v 1.1.1.1.2.1 1994/05/04 07:39:44 rgrimes Exp $ - */ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)isctype.c 5.2 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#define _ANSI_LIBRARY -#include <ctype.h> - -#undef isalnum -isalnum(c) - int c; -{ - return((_ctype_ + 1)[c] & (_U|_L|_N)); -} - -#undef isalpha -isalpha(c) - int c; -{ - return((_ctype_ + 1)[c] & (_U|_L)); -} - -#undef iscntrl -iscntrl(c) - int c; -{ - return((_ctype_ + 1)[c] & _C); -} - -#undef isdigit -isdigit(c) - int c; -{ - return((_ctype_ + 1)[c] & _N); -} - -#undef isgraph -isgraph(c) - int c; -{ - return((_ctype_ + 1)[c] & (_P|_U|_L|_N)); -} - -#undef islower -islower(c) - int c; -{ - return((_ctype_ + 1)[c] & _L); -} - -#undef isprint -isprint(c) - int c; -{ - return((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B)); -} - -#undef ispunct -ispunct(c) - int c; -{ - return((_ctype_ + 1)[c] & _P); -} - -#undef isspace -isspace(c) - int c; -{ - return((_ctype_ + 1)[c] & _S); -} - -#undef isupper -isupper(c) - int c; -{ - return((_ctype_ + 1)[c] & _U); -} - -#undef isxdigit -isxdigit(c) - int c; -{ - return((_ctype_ + 1)[c] & (_N|_X)); -} - -#undef tolower -tolower(c) - int c; -{ -/* was: return((c) - 'A' + 'a');*/ - return ( isupper(c) ? c - 'A' + 'a' : c); -} - -#undef toupper -toupper(c) - int c; -{ -/* was: return((c) - 'a' + 'A');*/ - return ( islower(c) ? c - 'a' + 'A' : c); -} diff --git a/lib/libc/gen/semconfig.c b/lib/libc/gen/semconfig.c index 66fbb2d93398..cf5399b6dde4 100644 --- a/lib/libc/gen/semconfig.c +++ b/lib/libc/gen/semconfig.c @@ -5,7 +5,7 @@ #if __STDC__ int semconfig(int cmd, int p1, int p2, int p3) #else -int semctl(cmd, p1, p2, p3) +int semconfig(cmd, p1, p2, p3) int cmd, p1, p2, p3; #endif { diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 12f7c1ab1ca7..9858beaa4a06 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -215,6 +215,7 @@ setmode(p) mode_t mask; struct bitcmd *set, *saveset, *endset; int permXbits, setlen; + int equalopdone; static void compress_mode(); /* @@ -285,6 +286,8 @@ setmode(p) free(saveset); return(NULL); } + if(op == '=') + equalopdone = 0; who &= ~S_ISTXT; for (perm = 0, permXbits = 0;; ++p) { @@ -321,10 +324,12 @@ setmode(p) * to flush out any partial mode that we have, * and then do the copying of the mode bits. */ - if (perm || op == '=') { + if (perm) { ADDCMD(op, who, perm, mask); perm = 0; } + if (op == '=') + equalopdone = 1; if (op == '+' && permXbits) { ADDCMD('X', who, permXbits, mask); permXbits = 0; @@ -337,7 +342,9 @@ setmode(p) * Add any permissions that we haven't already * done. */ - if (perm || op == '=') { + if (perm || (op == '=' && !equalopdone)) { + if(op == '=') + equalopdone = 1; ADDCMD(op, who, perm, mask); perm = 0; } diff --git a/lib/libc/gen/setrgid.c b/lib/libc/gen/setrgid.c deleted file mode 100644 index 43492306191e..000000000000 --- a/lib/libc/gen/setrgid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setrgid.c 5.5 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#include <unistd.h> - -int -#ifdef __STDC__ -setrgid(gid_t rgid) -#else -setrgid(rgid) - int rgid; -#endif -{ - - return (setregid(rgid, -1)); -} diff --git a/lib/libc/gen/setruid.c b/lib/libc/gen/setruid.c deleted file mode 100644 index 1c224a33095d..000000000000 --- a/lib/libc/gen/setruid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setruid.c 5.5 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#include <unistd.h> - -int -#ifdef __STDC__ -setruid(uid_t ruid) -#else -setruid(ruid) - int ruid; -#endif -{ - - return (setreuid(ruid, -1)); -} diff --git a/lib/libc/gen/setuid.3 b/lib/libc/gen/setuid.3 deleted file mode 100644 index 4e0e4c3c9ea5..000000000000 --- a/lib/libc/gen/setuid.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1983, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setuid.3 6.4 (Berkeley) 4/19/91 -.\" -.Dd April 19, 1991 -.Dt SETUID 3 -.Os BSD 4.2 -.Sh NAME -.Nm setuid , -.Nm seteuid , -.Nm setruid , -.Nm setgid , -.Nm setegid , -.Nm setrgid -.Nd set user and group ID -.Sh SYNOPSIS -.Fd #include <sys/types.h> -.Ft int -.Fn setuid "uid_t uid" -.Ft int -.Fn seteuid "uid_t euid" -.Ft int -.Fn setruid "uid_t ruid" -.Ft int -.Fn setgid "gid_t gid" -.Ft int -.Fn setegid "gid_t egid" -.Ft int -.Fn setrgid "gid_t rgid" -.Sh DESCRIPTION -The -.Fn setuid -function -.Pq Fn setgid -sets both the real and effective -user ID (group ID) of the current process -as specified. -.Pp -The -.Fn seteuid -function -.Pq Fn setegid -sets the effective user ID (group ID) of the -current process. -.Pp -The -.Fn setruid -function -.Pq Fn setrgid -sets the real user ID (group ID) of the -current process. -.Sh RETURN VALUES -Upon success, these functions return 0; -otherwise \-1 is returned. -.Pp -If the user is not the super user, or the uid -specified is not the real or effective ID, these -functions return \-1. -.Sh SEE ALSO -.Xr setreuid 2 , -.Xr setregid 2 , -.Xr getuid 2 , -.Xr getgid 2 -.Sh HISTORY -A -.Fn setuid -and -.Fn setgid -syscall appeared in -.At v6 . |