diff --git a/utils/Makefile b/utils/Makefile index dc091981..45c078c9 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -76,6 +76,7 @@ xinstall MANPAGES=\ chkblayout.1 \ kernelinfo.1 \ +passwd.1 \ readlink.1 \ all: $(BINARIES) diff --git a/utils/passwd.1 b/utils/passwd.1 new file mode 100644 index 00000000..cf34cc35 --- /dev/null +++ b/utils/passwd.1 @@ -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 diff --git a/utils/passwd.c b/utils/passwd.c index 31a0620b..9339553f 100644 --- a/utils/passwd.c +++ b/utils/passwd.c @@ -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); } }