Browse Source

Change the second arg to pw_mkdb() from a boolean flag to a set of

bit flags ORed together.  Currently the only flags defined are
_PASSWORD_SECUREONLY and _PASSWORD_OMITV7 but this is enough to
cause pw_mkdb() to run pwd_mkdb with the options we want.
With this change we no longer generate the old V7 passwd file when
only the extra fields in master.passwd (or the encrypted password)
have changed.  There are other programs that could probably use
the _PASSWORD_OMITV7 flag; they will be converted at a future date.
OPENBSD_3_0
millert 23 years ago
parent
commit
dc64978377
3 changed files with 31 additions and 17 deletions
  1. +5
    -1
      src/include/pwd.h
  2. +6
    -6
      src/lib/libutil/passwd.c
  3. +20
    -10
      src/lib/libutil/pw_lock.3

+ 5
- 1
src/include/pwd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: pwd.h,v 1.11 2001/02/13 14:48:40 pjanzen Exp $ */
/* $OpenBSD: pwd.h,v 1.12 2001/08/26 03:28:30 millert Exp $ */
/* $NetBSD: pwd.h,v 1.9 1996/05/15 21:36:45 jtc Exp $ */
/*-
@ -75,6 +75,10 @@
#define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */
#define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */
/* Flags for pw_mkdb(3) */
#define _PASSWORD_SECUREONLY 0x01 /* only generate spwd.db file */
#define _PASSWORD_OMITV7 0x02 /* don't generate v7 passwd file */
#endif
struct passwd {


+ 6
- 6
src/lib/libutil/passwd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: passwd.c,v 1.27 2001/08/16 18:24:32 millert Exp $ */
/* $OpenBSD: passwd.c,v 1.28 2001/08/26 03:28:30 millert Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -34,7 +34,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$OpenBSD: passwd.c,v 1.27 2001/08/16 18:24:32 millert Exp $";
static char rcsid[] = "$OpenBSD: passwd.c,v 1.28 2001/08/26 03:28:30 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -273,9 +273,9 @@ pw_lock(retries)
}
int
pw_mkdb(username, secureonly)
pw_mkdb(username, flags)
char *username;
int secureonly;
int flags;
{
int pstat, ac;
pid_t pid;
@ -295,9 +295,9 @@ pw_mkdb(username, secureonly)
av[ac++] = "pwd_mkdb";
av[ac++] = "-d";
av[ac++] = pw_dir;
if (secureonly)
if (flags & _PASSWORD_SECUREONLY)
av[ac++] = "-s";
else
else if (!(flags & _PASSWORD_OMITV7))
av[ac++] = "-p";
if (username) {
av[ac++] = "-u";


+ 20
- 10
src/lib/libutil/pw_lock.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: pw_lock.3,v 1.7 2001/08/16 18:24:32 millert Exp $
.\" $OpenBSD: pw_lock.3,v 1.8 2001/08/26 03:28:30 millert Exp $
.\"
.\" Copyright (c) 1995
.\" The Regents of the University of California. All rights reserved.
@ -35,7 +35,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd December 15, 1995
.Dd August 20, 2001
.Dt PW_LOCK 3
.Os
.Sh NAME
@ -48,7 +48,7 @@
.Ft int
.Fn pw_lock "int retries"
.Ft int
.Fn pw_mkdb "char *username" "int secureonly"
.Fn pw_mkdb "char *username" "int pwflags"
.Ft void
.Fn pw_abort
.Sh DESCRIPTION
@ -84,13 +84,23 @@ via
If a
.Fa username
is specified, only the record for the specified user will be updated.
If the
.Fa secureonly
argument is non-zero, only the secure database file,
.Pa /etc/spwd.db ,
will be updated.
This is useful for cases when the password field is the only part of the
entry that has been modified.
The
.Fa pwflags
are specified by
.Tn OR Ns 'ing
the following values:
.Pp
.Bl -tag -width _PASSWORD_SECUREONLY -offset "xxxx" -compact
.It Dv _PASSWORD_SECUREONLY
only update the secure database file
.Po Pa /etc/spwd.db Pc .
.It Dv _PASSWORD_OMITV7
do not update the Version 7 format password file
.Po Pa /etc/passwd Pc .
.El
.Pp
By default the secure, insecure and Version 7 format password databases
are updated.
You should finish writing to and close the file descriptor returned by
.Fn pw_lock
before calling


Loading…
Cancel
Save