Document passwd(1).

This commit is contained in:
Daniel Roskams 2016-10-02 21:39:29 +08:00
parent 07b89e600d
commit 28fec736dc
3 changed files with 37 additions and 25 deletions

View File

@ -76,6 +76,7 @@ xinstall
MANPAGES=\
chkblayout.1 \
kernelinfo.1 \
passwd.1 \
readlink.1 \
all: $(BINARIES)

33
utils/passwd.1 Normal file
View File

@ -0,0 +1,33 @@
.Dd October 02, 2016
.Dt PASSWD 1
.Os
.Sh NAME
.Nm passwd
.Nd change user password
.Sh SYNOPSIS
.Nm
.Op Fl c Ar cipher
.Op Ar user
.Sh DESCRIPTION
.Nm
changes the password for the specified
.Ar user ,
or the current user if none is specified.
.Pp
The options are as follows:
.Bl -tag -width "12345678"
.It Fl c Ar cipher
Hash the password using the specified
.Ar cipher .
.El
.Sh FILES
.Bl -tag -width "/etc/passwd" -compact
.It Pa /etc/passwd
Password information for all users.
.El
.Sh EXIT STATUS
.Nm
will exit 0 on success and non-zero otherwise.
.Sh SEE ALSO
.Xr crypt_newpass 3 ,
.Xr passwd 5

View File

@ -68,16 +68,6 @@ static void compact_arguments(int* argc, char*** argv)
}
}
static void version(FILE* fp, const char* argv0)
{
fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR);
}
static void help(FILE* fp, const char* argv0)
{
fprintf(fp, "Usage: %s [OPTION]... [LOGIN]\n", argv0);
}
int main(int argc, char* argv[])
{
const char* cipher = "blowfish,a";
@ -100,31 +90,19 @@ int main(int argc, char* argv[])
if ( !*(cipher = arg + 1) )
{
if ( i + 1 == argc )
{
warnx("option requires an argument -- 'c'");
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
exit(125);
}
errx(125, "option requires an argument -- 'c'");
cipher = argv[i+1];
argv[++i] = NULL;
}
arg = "c";
break;
default:
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
help(stderr, argv0);
exit(1);
errx(1, "%s: unknown option -- '%c'", argv0, c);
}
}
else if ( !strcmp(arg, "--version") )
version(stdout, argv0), exit(0);
else if ( !strcmp(arg, "--help") )
help(stdout, argv0), exit(0);
else
{
fprintf(stderr, "%s: unrecognized option: %s\n", argv0, arg);
help(stderr, argv0);
exit(1);
errx(1, "%s: unrecognized option: %s", argv0, arg);
}
}