Browse Source

passwd.conf has been deprecated since login.conf was imported.

Today it finally dies.  Based on a diff from Gabriel Kihlman.
OPENBSD_3_6
millert 20 years ago
parent
commit
20709cb14a
5 changed files with 7 additions and 240 deletions
  1. +1
    -2
      src/include/pwd.h
  2. +3
    -4
      src/lib/libutil/Makefile
  3. +2
    -145
      src/lib/libutil/passwd.c
  4. +0
    -87
      src/lib/libutil/pw_getconf.3
  5. +1
    -2
      src/lib/libutil/util.h

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

@ -1,4 +1,4 @@
/* $OpenBSD: pwd.h,v 1.16 2004/04/06 10:59:18 djm Exp $ */
/* $OpenBSD: pwd.h,v 1.17 2004/07/13 21:09:47 millert Exp $ */
/* $NetBSD: pwd.h,v 1.9 1996/05/15 21:36:45 jtc Exp $ */
/*-
@ -45,7 +45,6 @@
#ifndef _POSIX_SOURCE
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_PASSWDCONF "/etc/passwd.conf"
#define _PATH_MASTERPASSWD "/etc/master.passwd"
#define _PATH_MASTERPASSWD_LOCK "/etc/ptmp"


+ 3
- 4
src/lib/libutil/Makefile View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.27 2003/07/23 23:10:25 deraadt Exp $
# $OpenBSD: Makefile,v 1.28 2004/07/13 21:09:48 millert Exp $
# $NetBSD: Makefile,v 1.8 1996/05/16 07:03:28 thorpej Exp $
LIB= util
@ -11,9 +11,8 @@ SRCS= check_expire.c getmaxpartitions.c getrawpartition.c login.c \
fmt_scaled.c
MAN= check_expire.3 getmaxpartitions.3 getrawpartition.3 login.3 opendev.3 \
openpty.3 pw_init.3 pw_lock.3 readlabelfs.3 pw_getconf.3 \
uucplock.3 fparseln.3 opendisk.3 login_fbtab.3 pidfile.3 \
fmt_scaled.3
openpty.3 pw_init.3 pw_lock.3 readlabelfs.3 uucplock.3 \
fparseln.3 opendisk.3 login_fbtab.3 pidfile.3 fmt_scaled.3
MLINKS+=login.3 logout.3
MLINKS+=login.3 logwtmp.3


+ 2
- 145
src/lib/libutil/passwd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: passwd.c,v 1.43 2004/04/20 23:20:07 millert Exp $ */
/* $OpenBSD: passwd.c,v 1.44 2004/07/13 21:09:48 millert Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -30,7 +30,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$OpenBSD: passwd.c,v 1.43 2004/04/20 23:20:07 millert Exp $";
static const char rcsid[] = "$OpenBSD: passwd.c,v 1.44 2004/07/13 21:09:48 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -54,78 +54,10 @@ static const char rcsid[] = "$OpenBSD: passwd.c,v 1.43 2004/04/20 23:20:07 mille
#include "util.h"
#define NUM_OPTIONS 2 /* Number of hardcoded defaults */
static void pw_cont(int sig);
static const char options[NUM_OPTIONS][2][80] = {
{"localcipher", "blowfish,4"},
{"ypcipher", "old"}
};
static char pw_defdir[] = "/etc";
static char *pw_dir = pw_defdir;
static char *pw_lck;
static void trim_whitespace(char *);
static int read_line(FILE *, char *, int);
static const char *pw_default(const char *);
/* Removes head and/or tail spaces. */
static void
trim_whitespace(char *line)
{
char *p;
/* Remove leading spaces */
p = line;
while (isspace(*p))
p++;
(void) memmove(line, p, strlen(p) + 1);
/* Remove trailing spaces */
p = line + strlen(line) - 1;
while (isspace(*p))
p--;
*(p + 1) = '\0';
}
/* Get one line, remove spaces from front and tail */
static int
read_line(FILE *fp, char *line, int max)
{
char *p;
/* Read one line of config */
if (fgets(line, max, fp) == 0)
return 0;
if (!(p = strchr(line, '\n'))) {
warnx("line too long");
return 0;
}
*p = '\0';
/* Remove comments */
if ((p = strchr(line, '#')))
*p = '\0';
trim_whitespace(line);
return 1;
}
static const char *
pw_default(const char *option)
{
int i;
for (i = 0; i < NUM_OPTIONS; i++)
if (!strcmp(options[i][0], option))
return options[i][1];
return NULL;
}
char *
pw_file(const char *nm)
{
@ -142,81 +74,6 @@ pw_file(const char *nm)
return new_nm;
}
/*
* Retrieve password information from the /etc/passwd.conf file,
* at the moment this is only for choosing the cipher to use.
* It could easily be used for other authentication methods as
* well.
*/
void
pw_getconf(char *data, size_t max, const char *key, const char *option)
{
FILE *fp;
char line[LINE_MAX];
static char result[LINE_MAX];
char *p;
int got = 0;
int found = 0;
result[0] = '\0';
p = pw_file(_PATH_PASSWDCONF);
if (!p || (fp = fopen(p, "r")) == NULL) {
if (p)
free(p);
if ((p = (char *)pw_default(option))) {
strncpy(data, p, max - 1);
data[max - 1] = '\0';
} else
data[0] = '\0';
return;
}
free(p);
while (!found && (got || read_line(fp, line, LINE_MAX))) {
got = 0;
if (strncmp(key, line, strlen(key)) ||
line[strlen(key)] != ':')
continue;
/* Now we found our specified key */
while (read_line(fp, line, LINE_MAX)) {
char *p2;
/* Leaving key field */
if (strchr(line, ':')) {
got = 1;
break;
}
p2 = line;
if (!(p = strsep(&p2, "=")) || p2 == NULL)
continue;
trim_whitespace(p);
if (!strncmp(p, option, strlen(option))) {
trim_whitespace(p2);
strlcpy(result, p2, sizeof result);
found = 1;
break;
}
}
}
fclose(fp);
/*
* If we got no result and were looking for a default
* value, try hard coded defaults.
*/
if (!strlen(result) && !strcmp(key,"default") &&
(p = (char *)pw_default(option)))
strncpy(data, p, max - 1);
else
strncpy(data, result, max - 1);
data[max - 1] = '\0';
}
void
pw_setdir(const char *dir)
{


+ 0
- 87
src/lib/libutil/pw_getconf.3 View File

@ -1,87 +0,0 @@
.\" $OpenBSD: pw_getconf.3,v 1.9 2002/11/24 20:46:40 millert Exp $
.\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" 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 Niels Provos.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
.\"
.Dd June 18, 2001
.Dt PW_GETCONF 3
.Os
.Sh NAME
.Nm pw_getconf
.Nd passwd configuration access function
.Sh SYNOPSIS
.Fd #include <util.h>
.Ft void
.Fn pw_getconf "char *data" "size_t len" "const char *key" "const char *option"
.Sh DESCRIPTION
.Bf -symbolic
This interface is made obsolete by
.Xr login_cap 3 .
The
.Fn pw_getconf
function will be removed in a future release of
.Ox .
.Ef
.Pp
The
.Fn pw_getconf
function reads
.Pa /etc/passwd.conf
and retrieves the value of the option specified
by
.Pa option
from the section given by
.Pa key .
If no suitable entry is found
for the
.Pa key
an empty string will be returned in data.
.Pp
For default values the key
.Pa default
can be used.
This might be useful when no entry was found
for a specific key or option.
.Pp
An empty string is also returned for other errors.
.Sh FILES
.Bl -tag -width /etc/passwd.conf -compact
.It Pa /etc/passwd.conf
.El
.Sh SEE ALSO
.Xr login_cap 3 ,
.Xr login.conf 5 ,
.Xr passwd 5 ,
.Xr passwd.conf 5
.Sh HISTORY
The
.Fn pw_getconf
function appeared in
.Ox 2.1
and was deprecated in
.Ox 3.0 .

+ 1
- 2
src/lib/libutil/util.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.h,v 1.25 2004/04/20 23:20:07 millert Exp $ */
/* $OpenBSD: util.h,v 1.26 2004/07/13 21:09:48 millert Exp $ */
/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */
/*-
@ -98,7 +98,6 @@ void pw_init(void);
void pw_edit(int, const char *);
void pw_prompt(void);
void pw_copy(int, int, const struct passwd *, const struct passwd *);
void pw_getconf(char *, size_t, const char *, const char *);
int pw_scan(char *, struct passwd *, int *);
void pw_error(const char *, int, int);
int openpty(int *, int *, char *, struct termios *, struct winsize *);


Loading…
Cancel
Save