summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>1999-03-02 00:53:33 +0000
committerDavid Nugent <davidn@FreeBSD.org>1999-03-02 00:53:33 +0000
commit3ac6f2f73aa5de1c99b76016bedf656a78c400a4 (patch)
tree16e5cf7951c421e4943e4b743ffc1f50dc9a1e47 /pw
parentd103cd21c4fb6c24b725050e7dfa6ca3b603fb6f (diff)
downloadpw-darwin-3ac6f2f73aa5de1c99b76016bedf656a78c400a4.tar.gz
pw-darwin-3ac6f2f73aa5de1c99b76016bedf656a78c400a4.tar.zst
pw-darwin-3ac6f2f73aa5de1c99b76016bedf656a78c400a4.zip
Add the ability to print user records in unix version 7 (old) format.
Diffstat (limited to 'pw')
-rw-r--r--pw/pw.c7
-rw-r--r--pw/pw_user.c23
2 files changed, 19 insertions, 11 deletions
diff --git a/pw/pw.c b/pw/pw.c
index 6fbcfb5..f71cdf7 100644
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pw.c,v 1.13 1999/02/23 10:35:47 davidn Exp $";
+ "$Id: pw.c,v 1.14 1999/02/23 11:01:50 davidn Exp $";
#endif /* not lint */
#include <err.h>
@@ -101,7 +101,7 @@ main(int argc, char *argv[])
"V:C:qn:u:c:d:e:p:g:G:mk:s:oL:i:w:h:Db:NPy:Y",
"V:C:qn:u:rY",
"V:C:qn:u:c:d:e:p:g:G:ml:k:s:w:L:h:FNPY",
- "V:C:qn:u:FPa",
+ "V:C:qn:u:FPa7",
"V:C:q"
},
{ /* grp */
@@ -351,7 +351,8 @@ cmdhelp(int mode, int which)
"\t-u uid user id\n"
"\t-F force print\n"
"\t-P prettier format\n"
- "\t-a print all users\n",
+ "\t-a print all users\n"
+ "\t-7 print in v7 format\n",
"usage: pw usernext [switches]\n"
"\t-V etcdir alternate /etc location\n"
"\t-C config configuration file\n"
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 635b530..0eb9802 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -27,7 +27,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pw_user.c,v 1.26 1999/02/08 21:26:44 des Exp $";
+ "$Id: pw_user.c,v 1.27 1999/02/23 07:15:10 davidn Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -56,7 +56,7 @@ static const char rcsid[] =
static randinit;
-static int print_user(struct passwd * pwd, int pretty);
+static int print_user(struct passwd * pwd, int pretty, int v7);
static uid_t pw_uidpolicy(struct userconf * cnf, struct cargs * args);
static uid_t pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer);
static time_t pw_pwdpolicy(struct userconf * cnf, struct cargs * args);
@@ -271,10 +271,11 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
if (mode == M_PRINT && getarg(args, 'a')) {
int pretty = getarg(args, 'P') != NULL;
+ int v7 = getarg(args, '7') != NULL;
SETPWENT();
while ((pwd = GETPWENT()) != NULL)
- print_user(pwd, pretty);
+ print_user(pwd, pretty, v7);
ENDPWENT();
return EXIT_SUCCESS;
}
@@ -309,7 +310,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_PRINT && getarg(args, 'F')) {
fakeuser.pw_name = a_name ? a_name->val : "nouser";
fakeuser.pw_uid = a_uid ? (uid_t) atol(a_uid->val) : -1;
- return print_user(&fakeuser, getarg(args, 'P') != NULL);
+ return print_user(&fakeuser,
+ getarg(args, 'P') != NULL,
+ getarg(args, '7') != NULL);
}
if (a_name == NULL)
errx(EX_NOUSER, "no such uid `%s'", a_uid->val);
@@ -389,7 +392,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
return EXIT_SUCCESS;
} else if (mode == M_PRINT)
- return print_user(pwd, getarg(args, 'P') != NULL);
+ return print_user(pwd,
+ getarg(args, 'P') != NULL,
+ getarg(args, '7') != NULL);
/*
* The rest is edit code
@@ -525,7 +530,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* Special case: -N only displays & exits
*/
if (getarg(args, 'N') != NULL)
- return print_user(pwd, getarg(args, 'P') != NULL);
+ return print_user(pwd,
+ getarg(args, 'P') != NULL,
+ getarg(args, '7') != NULL);
r = r1 = 1;
if (mode == M_ADD) {
@@ -964,12 +971,12 @@ pw_password(struct userconf * cnf, struct cargs * args, char const * user)
static int
-print_user(struct passwd * pwd, int pretty)
+print_user(struct passwd * pwd, int pretty, int v7)
{
if (!pretty) {
char buf[_UC_MAXLINE];
- fmtpwent(buf, pwd);
+ fmtpwentry(buf, pwd, v7 ? PWF_PASSWD : PWF_STANDARD);
fputs(buf, stdout);
} else {
int j;