diff --git a/Makefile b/Makefile index 4f06b3b..2498611 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,21 @@ all: - $(CC) -Wall -o ./chkpw ./chkpw.c -lpam - gzip -fk ./chkpw.1 + $(CC) -Wall -o ./chkpwd ./chkpwd.c -lpam + gzip -fk ./chkpwd.1 clean: - rm -f ./chkpw - rm -f ./chkpw.1.gz + rm -f ./chkpwd + rm -f ./chkpwd.1.gz rm -f ./test install: - install -g 0 -o 0 -m 0655 ./chkpw /usr/bin/ - install -g 0 -o 0 -m 0644 ./chkpw.h /usr/include/ - install -g 0 -o 0 -m 0644 ./chkpw.1.gz /usr/share/man/man1/ + install -g 0 -o 0 -m 0655 ./chkpwd /usr/bin/ + install -g 0 -o 0 -m 0644 ./chkpwd.h /usr/include/ + install -g 0 -o 0 -m 0644 ./chkpwd.1.gz /usr/share/man/man1/ uninstall: - rm -f /usr/bin/chkpw - rm -f /usr/include/chkpw.h - rm -f /usr/share/man/man1/chkpw.1.gz + rm -f /usr/bin/chkpwd + rm -f /usr/include/chkpwd.h + rm -f /usr/share/man/man1/chkpwd.1.gz test: $(CC) -Wall -DPAM_DEBUG -o test test.c diff --git a/README.md b/README.md index e6ac795..f59d457 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# chkpw +# chkpwd -chkpw is a program that checks the validity of a users password on a UNIX/[PAM](https://en.wikipedia.org/wiki/Pluggable_Authentication_Module)-based system. +chkpwd is a program that checks the validity of a users password on a UNIX/[PAM](https://en.wikipedia.org/wiki/Pluggable_Authentication_Module)-based system. -Currently chkpw is only tested on Linux, but it should work on a [AIX](https://en.wikipedia.org/wiki/IBM_AIX), [DragonFly BSD](https://www.dragonflybsd.org/), [FreeBSD](https://www.freebsd.org/), [HP-UX](https://en.wikipedia.org/wiki/HP-UX), [Linux](https://kernel.org/), [macOS](https://en.wikipedia.org/wiki/MacOS), [NetBSD](https://netbsd.org/) and [Solaris](https://en.wikipedia.org/wiki/Oracle_Solaris) operating system too. +Currently chkpwd is only tested on Linux, but it should work on a [AIX](https://en.wikipedia.org/wiki/IBM_AIX), [DragonFly BSD](https://www.dragonflybsd.org/), [FreeBSD](https://www.freebsd.org/), [HP-UX](https://en.wikipedia.org/wiki/HP-UX), [Linux](https://kernel.org/), [macOS](https://en.wikipedia.org/wiki/MacOS), [NetBSD](https://netbsd.org/) and [Solaris](https://en.wikipedia.org/wiki/Oracle_Solaris) operating system too. ## The idea @@ -12,35 +12,35 @@ I needed a program to verify passwords of users on Linux/UNIX systems using PAM You need the PAM development package installed. On Alpine it is named linux-pam-dev, on Debian based systems it is libpam0g-dev. -## Building chkpw +## Building chkpwd ``` -git clone https://git.xw3.org/hanez/chkpw.git -cd chkpw +git clone https://git.xw3.org/hanez/chkpwd.git +cd chkpwd make ``` -The code only supports verifying passwords for user id 1000 by default. Look at the file chkpw.h for some compile time options! +The code only supports verifying passwords for user id 1000 by default. Look at the file chkpwd.h for some compile time options! ### Custom build example Set MAX_UID and MIN_UID at compile time: ``` -gcc -Wall -DMAX_UID=1000 -DMIN_UID=1000 -o chkpw chkpw.c -lpam -lpam_misc +gcc -Wall -DMAX_UID=1000 -DMIN_UID=1000 -o chkpwd chkpwd.c -lpam -lpam_misc ``` ## Installation -**WARNING:** Install this software with care. chkpw could easily be used for bruteforcing passwords from local users! +**WARNING:** Install this software with care. chkpwd could easily be used for bruteforcing passwords from local users! ``` sudo make install ``` -chkpw is installed to /usr/bin/. +chkpwd is installed to /usr/bin/. -chkpw.h is installed to /usr/include/ for use in other applications. +chkpwd.h is installed to /usr/include/ for use in other applications. ## Uninstall @@ -51,8 +51,8 @@ sudo make uninstall ## Usage ``` -chkpw -h -Usage: chkpw [-u ] [-p ] [-v] [-V] [-h] +chkpwd -h +Usage: chkpwd [-u ] [-p ] [-v] [-V] [-h] Options: -u Set username. @@ -62,15 +62,15 @@ Options: -h Show this help. ``` -You can also use chkpw even without installing by just running the following command: +You can also use chkpwd even without installing by just running the following command: ``` -./chkpw +./chkpwd ``` ### Return codes -chkpw returns 0 on success, 1 otherwise. +chkpwd returns 0 on success, 1 otherwise. ### Examples @@ -78,19 +78,19 @@ chkpw returns 0 on success, 1 otherwise. #### Interactive mode asking for a username and a password ``` -chkpw +chkpwd ``` #### Interactive mode only asking for a password ``` -chkpw -u hanez +chkpwd -u hanez ``` -#### None interactive mode with username and password provided as arguments to chkpw +#### None interactive mode with username and password provided as arguments to chkpwd ``` -chkpw -u hanez -p password +chkpwd -u hanez -p password ``` #### Request the result from the above commands @@ -101,14 +101,14 @@ echo $? ## License -chkpw is licensed under the Apache License, Version 2.0. +chkpwd is licensed under the Apache License, Version 2.0. See LICENSE for details. ## Links - - [https://git.xw3.org/hanez/chkpw](https://git.xw3.org/hanez/chkpw) - - [https://linux.die.net/man/8/unix_chkpwd](https://linux.die.net/man/8/unix_chkpwd) + - [https://git.xw3.org/hanez/chkpwd](https://git.xw3.org/hanez/chkpwd) + - [https://linux.die.net/man/8/unix_chkpwdd](https://linux.die.net/man/8/unix_chkpwd) - [https://cr.yp.to/checkpwd.html](https://cr.yp.to/checkpwd.html) - [https://pamtester.sourceforge.net/](https://pamtester.sourceforge.net/) diff --git a/chkpw.1 b/chkpw.1 deleted file mode 100644 index ebfc480..0000000 --- a/chkpw.1 +++ /dev/null @@ -1,24 +0,0 @@ -.TH man 1 "01 Jun 2025" "chkpw 1.2.0" "chkpw man page" -.SH NAME -chkpw \- checks the validity of a users password on a UNIX/PAM-based system. -.SH SYNOPSIS -chkpw [OPTION]... -.SH DESCRIPTION -chkpw is a program that checks the validity of a users password on a UNIX/PAM-based system. -.SH OPTIONS -The options which apply to the chkpw command are: - - -u Set username. - -p Set password. - -v Enable verbose mode. - -V Print program version. - -h Show this help. - -chkpw runs in an interactive mode when no username and/or password are set. A missing username and/or password will then be asked for program execution. - -.SH SEE ALSO -pam(3), pam_authenticate(3), PAM(8) -.SH BUGS -No known bugs. -.SH AUTHOR -Johannes Findeisen (you@hanez.org) diff --git a/chkpwd.1 b/chkpwd.1 new file mode 100644 index 0000000..cc83125 --- /dev/null +++ b/chkpwd.1 @@ -0,0 +1,24 @@ +.TH man 1 "01 Jun 2025" "chkpwd 1.3.0" "chkpwd man page" +.SH NAME +chkpwd \- checks the validity of a users password on a UNIX/PAM-based system. +.SH SYNOPSIS +chkpwd [OPTION]... +.SH DESCRIPTION +chkpwd is a program that checks the validity of a users password on a UNIX/PAM-based system. +.SH OPTIONS +The options which apply to the chkpwd command are: + + -u Set username. + -p Set password. + -v Enable verbose mode. + -V Print program version. + -h Show this help. + +chkpwd runs in an interactive mode when no username and/or password are set. A missing username and/or password will then be asked for program execution. + +.SH SEE ALSO +pam(3), pam_authenticate(3), PAM(8) +.SH BUGS +No known bugs. +.SH AUTHOR +Johannes Findeisen (you@hanez.org) diff --git a/chkpw.c b/chkpwd.c similarity index 98% rename from chkpw.c rename to chkpwd.c index 47b589d..7339620 100644 --- a/chkpw.c +++ b/chkpwd.c @@ -1,12 +1,12 @@ /** - * chkpw is a program that checks the validity of a users password on a + * chkpwd is a program that checks the validity of a users password on a * UNIX/PAM-based system. * * Author: Johannes Findeisen - 2024 * License: Apache-2.0 (see LICENSE) */ -#include "chkpw.h" +#include "chkpwd.h" #include #include diff --git a/chkpw.h b/chkpwd.h similarity index 96% rename from chkpw.h rename to chkpwd.h index 95b8b21..ef1e97b 100644 --- a/chkpw.h +++ b/chkpwd.h @@ -1,5 +1,5 @@ /** - * chkpw.h is part of chkpw, a program that checks the validity of a users + * chkpwd.h is part of chkpwd, a program that checks the validity of a users * password on a UNIX/PAM-based system. * * Author: Johannes Findeisen - 2025 @@ -11,7 +11,7 @@ #include #include -#define VERSION "1.2.0" +#define VERSION "1.3.0" bool checkpw_authenticate(const char *username, const char *password, bool verbose);