diff options
-rw-r--r-- | chpass/Makefile | 7 | ||||
-rw-r--r-- | libc/gen/pw_scan.c | 25 | ||||
-rw-r--r-- | libutil/flopen.c | 13 |
3 files changed, 27 insertions, 18 deletions
diff --git a/chpass/Makefile b/chpass/Makefile index 2bbdc08..e958956 100644 --- a/chpass/Makefile +++ b/chpass/Makefile @@ -39,11 +39,12 @@ MLINKS+= chpass.1 ypchpass.1 chpass.1 ypchfn.1 chpass.1 ypchsh.1 beforeinstall: .for i in chpass chfn chsh ypchpass ypchfn ypchsh - [ ! -e ${DESTDIR}${BINDIR}/$i ] || \ - chflags noschg ${DESTDIR}${BINDIR}/$i || true + -chflags noschg ${DESTDIR}${BINDIR}/$i .endfor +.if !defined(NO_FSCHG) afterinstall: - -chflags schg ${DESTDIR}${BINDIR}/chpass + chflags schg ${DESTDIR}${BINDIR}/chpass +.endif .include <bsd.prog.mk> diff --git a/libc/gen/pw_scan.c b/libc/gen/pw_scan.c index 9242dd0..24e8225 100644 --- a/libc/gen/pw_scan.c +++ b/libc/gen/pw_scan.c @@ -58,8 +58,14 @@ __FBSDID("$FreeBSD$"); * * If pw_big_ids_warning is -1 on entry to pw_scan(), it will be set based * on the existence of PW_SCAN_BIG_IDS in the environment. + * + * It is believed all baseline system software that can not handle the + * normal ID sizes is now gone so pw_big_ids_warning is disabled for now. + * But the code has been left in place in case end-users want to re-enable + * it and/or for the next time the ID sizes get bigger but pieces of the + * system lag behind. */ -static int pw_big_ids_warning = -1; +static int pw_big_ids_warning = 0; int __pw_scan(char *bp, struct passwd *pw, int flags) @@ -67,6 +73,7 @@ __pw_scan(char *bp, struct passwd *pw, int flags) uid_t id; int root; char *ep, *p, *sh; + unsigned long temp; if (pw_big_ids_warning == -1) pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0; @@ -94,12 +101,14 @@ __pw_scan(char *bp, struct passwd *pw, int flags) return (0); } } - id = strtoul(p, &ep, 10); - if (errno == ERANGE) { + errno = 0; + temp = strtoul(p, &ep, 10); + if ((temp == ULONG_MAX && errno == ERANGE) || temp > UID_MAX) { if (flags & _PWSCAN_WARN) - warnx("%s > max uid value (%lu)", p, ULONG_MAX); + warnx("%s > max uid value (%u)", p, UID_MAX); return (0); } + id = temp; if (*ep != '\0') { if (flags & _PWSCAN_WARN) warnx("%s uid is incorrect", p); @@ -127,12 +136,14 @@ __pw_scan(char *bp, struct passwd *pw, int flags) return (0); } } - id = strtoul(p, &ep, 10); - if (errno == ERANGE) { + errno = 0; + temp = strtoul(p, &ep, 10); + if ((temp == ULONG_MAX && errno == ERANGE) || temp > GID_MAX) { if (flags & _PWSCAN_WARN) - warnx("%s > max gid value (%lu)", p, ULONG_MAX); + warnx("%s > max gid value (%u)", p, GID_MAX); return (0); } + id = temp; if (*ep != '\0') { if (flags & _PWSCAN_WARN) warnx("%s gid is incorrect", p); diff --git a/libutil/flopen.c b/libutil/flopen.c index ae98daf..754c9c0 100644 --- a/libutil/flopen.c +++ b/libutil/flopen.c @@ -28,12 +28,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/file.h> #include <sys/stat.h> #include <errno.h> -#include <fcntl.h> #include <stdarg.h> -#include <string.h> #include <unistd.h> #include <libutil.h> @@ -42,7 +41,6 @@ int flopen(const char *path, int flags, ...) { int fd, operation, serrno, trunc; - struct flock lock; struct stat sb, fsb; mode_t mode; @@ -59,10 +57,9 @@ flopen(const char *path, int flags, ...) va_end(ap); } - memset(&lock, 0, sizeof lock); - lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK; - lock.l_whence = SEEK_SET; - operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW; + operation = LOCK_EX; + if (flags & O_NONBLOCK) + operation |= LOCK_NB; trunc = (flags & O_TRUNC); flags &= ~O_TRUNC; @@ -71,7 +68,7 @@ flopen(const char *path, int flags, ...) if ((fd = open(path, flags, mode)) == -1) /* non-existent or no access */ return (-1); - if (fcntl(fd, operation, &lock) == -1) { + if (flock(fd, operation) == -1) { /* unsupported or interrupted */ serrno = errno; (void)close(fd); |