SCCS-vsn: usr.sbin/pwd_mkdb/pwd_mkdb.c 8.2
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)pwd_mkdb.c 8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)pwd_mkdb.c 8.2 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <db.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <db.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#define INSECURE 1
#define SECURE 2
#define PERM_INSECURE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
#define INSECURE 1
#define SECURE 2
#define PERM_INSECURE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
-char *progname = "pwd_mkdb";
-
static enum state { FILE_INSECURE, FILE_SECURE, FILE_ORIG } clean;
static struct passwd pwd; /* password structure */
static char *pname; /* password file name */
static enum state { FILE_INSECURE, FILE_SECURE, FILE_ORIG } clean;
static struct passwd pwd; /* password structure */
static char *pname; /* password file name */
int argc;
char *argv[];
{
int argc;
char *argv[];
{
- extern int optind;
- register int len, makeold;
- register char *p, *t;
DB *dp, *edp;
DBT data, key;
FILE *fp, *oldfp;
sigset_t set;
DB *dp, *edp;
DBT data, key;
FILE *fp, *oldfp;
sigset_t set;
+ int ch, cnt, len, makeold, tfd;
+ char *p, *t;
char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024];
makeold = 0;
char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024];
makeold = 0;
char *p;
if (!fgets(line, sizeof(line), fp))
char *p;
if (!fgets(line, sizeof(line), fp))
++lcnt;
/*
* ``... if I swallow anything evil, put your fingers down my
++lcnt;
/*
* ``... if I swallow anything evil, put your fingers down my
* -- The Who
*/
if (!(p = strchr(line, '\n'))) {
* -- The Who
*/
if (!(p = strchr(line, '\n'))) {
- (void)fprintf(stderr, "pwd_mkdb: line too long\n");
+ warnx("line too long");
goto fmt;
}
*p = '\0';
if (!pw_scan(line, pw)) {
goto fmt;
}
*p = '\0';
if (!pw_scan(line, pw)) {
- (void)fprintf(stderr, "pwd_mkdb: at line #%d.\n", lcnt);
-fmt: errno = EFTYPE;
+ warnx("at line #%d", lcnt);
+fmt: errno = EFTYPE; /* XXX */
}
void
mv(from, to)
char *from, *to;
{
}
void
mv(from, to)
char *from, *to;
{
char buf[MAXPATHLEN];
if (rename(from, to)) {
char buf[MAXPATHLEN];
if (rename(from, to)) {
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
errno = sverrno;
error(buf);
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
errno = sverrno;
error(buf);
error(name)
char *name;
{
error(name)
char *name;
{
- (void)fprintf(stderr, "pwd_mkdb: %s: %s\n", name, strerror(errno));
(void)fprintf(stderr, "usage: pwd_mkdb [-p] file\n");
exit(1);
}
(void)fprintf(stderr, "usage: pwd_mkdb [-p] file\n");
exit(1);
}