* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)mkpasswd.c 5.1 (Berkeley) %G%";
struct passwd
*fgetpwent();
register struct passwd
*pwd
;
int verbose
= 0, entries
= 0, maxlen
= 0;
if (argc
> 1 && strcmp(argv
[1], "-v") == 0) {
fprintf(stderr
, "usage: mkpasswd [ -v ] file\n");
if (access(argv
[1], R_OK
) < 0) {
fprintf(stderr
, "mkpasswd: ");
dp
= dbm_open(argv
[1], O_WRONLY
|O_CREAT
|O_EXCL
, 0644);
fprintf(stderr
, "mkpasswd: ");
while (pwd
= getpwent()) {
#define COMPACT(e) tp = pwd->pw_/**/e; while (*cp++ = *tp++);
bcopy((char *)&pwd
->pw_uid
, cp
, sizeof (int));
bcopy((char *)&pwd
->pw_gid
, cp
, sizeof (int));
bcopy((char *)&pwd
->pw_quota
, cp
, sizeof (int));
content
.dsize
= cp
- buf
;
printf("store %s, uid %d\n", pwd
->pw_name
, pwd
->pw_uid
);
key
.dsize
= strlen(pwd
->pw_name
);
if (dbm_store(dp
, key
, content
, DBM_INSERT
) < 0) {
fprintf(stderr
, "mkpasswd: ");
perror("dbm_store failed");
key
.dptr
= (char *)&pwd
->pw_uid
;
key
.dsize
= sizeof (int);
if (dbm_store(dp
, key
, content
, DBM_INSERT
) < 0) {
fprintf(stderr
, "mkpasswd: ");
perror("dbm_store failed");
printf("%d password entries, maximum length %d\n", entries
, maxlen
);