From owner-freebsd-bugs Mon Feb 10 00:20:08 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id AAA18078 for bugs-outgoing; Mon, 10 Feb 1997 00:20:08 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id AAA18060; Mon, 10 Feb 1997 00:20:04 -0800 (PST) Resent-Date: Mon, 10 Feb 1997 00:20:04 -0800 (PST) Resent-Message-Id: <199702100820.AAA18060@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, gurney_j@efn.org Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id AAA17939 for ; Mon, 10 Feb 1997 00:18:03 -0800 (PST) Received: from orion.webspan.net (orion.webspan.net [206.154.70.5]) by who.cdrom.com (8.7.5/8.6.11) with ESMTP id XAA27690 for ; Sun, 9 Feb 1997 23:57:07 -0800 (PST) Received: from orion.webspan.net (localhost [127.0.0.1]) by orion.webspan.net (WEBSPN/970116) with ESMTP id CAA15715 for ; Mon, 10 Feb 1997 02:57:05 -0500 (EST) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.18]) by mail.webspan.net (WEBSPAN/970116) with ESMTP id UAA28156 for ; Sat, 8 Feb 1997 20:50:50 -0500 (EST) Received: from hydrogen.nike.efn.org (resnet.uoregon.edu [128.223.170.28]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id RAA14787 for ; Sat, 8 Feb 1997 17:50:23 -0800 (PST) Received: (from jmg@localhost) by hydrogen.nike.efn.org (8.8.4/8.8.4) id RAA13366; Sat, 8 Feb 1997 17:50:22 -0800 (PST) Message-Id: <199702090150.RAA13366@hydrogen.nike.efn.org> Date: Sat, 8 Feb 1997 17:50:22 -0800 (PST) From: John-Mark Gurney Reply-To: gurney_j@efn.org To: FreeBSD-gnats@freefall.FreeBSD.org X-Send-Pr-Version: 3.2 Subject: bin/2703: vipw doesn't allow you to edit master.passwd in another dir Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 2703 >Category: bin >Synopsis: vipw doesn't allow you to edit master.passwd in another dir >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Feb 10 00:20:02 PST 1997 >Last-Modified: >Originator: John-Mark Gurney >Organization: Cu Networking >Release: FreeBSD 2.2-960801-SNAP i386 >Environment: pretty much any FreeBSD box... >Description: if you have a diskless machine and you don't want to stick pwd_mkdb on the machine... you can just manually make the new database files for the machine or you can now use vipw -d /diskless/machine/root/etc hmm... just relized it would be nice to be able to turn off the passwd making.. plus allow you to keep the master.passwd in a different location :) >How-To-Repeat: vipw -d /diskless/machine/root/etc returns the usage info >Fix: apply this patch (patch to do more of above to follow :) ): Index: pw_util.c =================================================================== RCS file: /usr/cvs/src/usr.sbin/vipw/pw_util.c,v retrieving revision 1.5 diff -c -r1.5 pw_util.c *** pw_util.c 1996/07/01 19:38:45 1.5 --- pw_util.c 1997/02/08 09:15:38 *************** *** 62,67 **** --- 62,69 ---- extern char *tempname; static pid_t editpid = -1; static int lockfd; + char *mppath = _PATH_PWD; + char *masterpasswd = _PATH_MASTERPASSWD; void pw_cont(sig) *************** *** 111,119 **** * that users can't get at the encrypted passwords while editing. * Open should allow flock'ing the file; see 4.4BSD. XXX */ ! lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) ! err(1, "%s", _PATH_MASTERPASSWD); if (flock(lockfd, LOCK_EX|LOCK_NB)) errx(1, "the password db file is busy"); return (lockfd); --- 113,121 ---- * that users can't get at the encrypted passwords while editing. * Open should allow flock'ing the file; see 4.4BSD. XXX */ ! lockfd = open(masterpasswd, O_RDONLY, 0); if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) ! err(1, "%s", masterpasswd); if (flock(lockfd, LOCK_EX|LOCK_NB)) errx(1, "the password db file is busy"); return (lockfd); *************** *** 122,131 **** int pw_tmp() { ! static char path[MAXPATHLEN] = _PATH_MASTERPASSWD; int fd; char *p; if (p = strrchr(path, '/')) ++p; else --- 124,136 ---- int pw_tmp() { ! static char path[MAXPATHLEN]; int fd; char *p; + strncpy(path, masterpasswd, MAXPATHLEN-1); + path[MAXPATHLEN - 1] = 0; + if (p = strrchr(path, '/')) ++p; else *************** *** 148,157 **** (void)fflush(stderr); if (!(pid = vfork())) { if(!username) { ! execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); } else { ! execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-u", ! username, tempname, NULL); } pw_error(_PATH_PWD_MKDB, 1, 1); } --- 153,163 ---- (void)fflush(stderr); if (!(pid = vfork())) { if(!username) { ! execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath, ! tempname, NULL); } else { ! execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath, ! "-u", username, tempname, NULL); } pw_error(_PATH_PWD_MKDB, 1, 1); } *************** *** 227,233 **** warnx("NIS information unchanged"); else #endif /* YP */ ! warnx("%s: unchanged", _PATH_MASTERPASSWD); (void)unlink(tempname); exit(eval); } --- 233,239 ---- warnx("NIS information unchanged"); else #endif /* YP */ ! warnx("%s: unchanged", masterpasswd); (void)unlink(tempname); exit(eval); } Index: vipw.8 =================================================================== RCS file: /usr/cvs/src/usr.sbin/vipw/vipw.8,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 vipw.8 *** vipw.8 1994/05/26 05:23:31 1.1.1.1 --- vipw.8 1997/02/08 09:20:56 *************** *** 39,44 **** --- 39,45 ---- .Nd edit the password file .Sh SYNOPSIS .Nm vipw + .Op Fl d Ar directory .Sh DESCRIPTION .Nm Vipw edits the password file after setting the appropriate locks, *************** *** 70,75 **** --- 71,83 ---- at very large sites could take several minutes. Until this update is completed, the password file is unavailable for other updates and the new information is not available to programs. + .Pp + If the + .Fl d Ar directory + option is provided it will user the password files in + .Ar directory + instead of the default of + .Pa /etc . .Sh ENVIRONMENT If the following environment variable exists it will be utilized by .Nm vipw : Index: vipw.c =================================================================== RCS file: /usr/cvs/src/usr.sbin/vipw/vipw.c,v retrieving revision 1.3 diff -c -r1.3 vipw.c *** vipw.c 1996/07/01 19:38:50 1.3 --- vipw.c 1997/02/08 09:11:11 *************** *** 53,58 **** --- 53,61 ---- #include "pw_util.h" + extern char *mppath; + extern char *masterpasswd; + char *tempname; void copyfile __P((int, int)); *************** *** 67,74 **** struct stat begin, end; int ch; ! while ((ch = getopt(argc, argv, "")) != EOF) switch (ch) { case '?': default: usage(); --- 70,91 ---- struct stat begin, end; int ch; ! while ((ch = getopt(argc, argv, "d:")) != EOF) switch (ch) { + case 'd': + masterpasswd = malloc(strlen(optarg) + + strlen(_MASTERPASSWD) + 2); + strcpy(masterpasswd, optarg); + + if(masterpasswd[strlen(masterpasswd) - 1] != '/') + masterpasswd[strlen(masterpasswd)] = '/'; + strcat(masterpasswd, _MASTERPASSWD); + + mppath = strdup(optarg); + if(mppath[strlen(mppath) - 1] == '/') + mppath[strlen(mppath) - 1] = 0; + + break; case '?': default: usage(); *************** *** 122,127 **** usage() { ! (void)fprintf(stderr, "usage: vipw\n"); exit(1); } --- 139,144 ---- usage() { ! (void)fprintf(stderr, "usage: vipw [ -d directory]\n"); exit(1); } >Audit-Trail: >Unformatted: John-Mark Gurney