Removed interactive mode (is default now), moved some code to checkpw.h and many fixes.

This commit is contained in:
Johannes Findeisen 2025-01-01 06:23:03 +01:00
commit 82aced57b6
5 changed files with 204 additions and 176 deletions

View file

@ -4,84 +4,96 @@ checkpw is a program that checks the validity of a users password on a UNIX/PAM-
Currently only tested on Linux, but it should work on the [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 behind:
## The idea
I needed a program to verify passwords of users on Linux based systems using PAM.
I needed a program to verify passwords of users on Linux/UNIX systems using PAM that just return 0 on success and 1 on error.
Exactly a program like this... not more!
## Installation:
**WARNING:** Install this software with care. checkpw could easily be used for bruteforcing passwords from local users!
## Building checkpw
```
git clone https://git.xw3.org/xw3/checkpw.git
cd checkpw
make
sudo make install
```
The code only supports verifying passwords for user id 1000 by default. Look a the code for some compile time options!
The code only supports verifying passwords for user id 1000 by default. Look at the file checkpw.h for some compile time options!
### Manual installation:
### Custom build example
Set MAX_UID and MIN_UID in the code or you can compile checkpw without editing the code using the following command and install it manually:
Set MAX_UID and MIN_UID at compile time:
```
gcc -Wall -DMAX_UID=1000 -DMIN_UID=1000 -o checkpw checkpw.c -lpam -lpam_misc
sudo cp ./checkpw /usr/bin/
```
## Uninstall:
## Installation
**WARNING:** Install this software with care. checkpw could easily be used for bruteforcing passwords from local users!
```
sudo make install
```
checkpw is installed to /usr/bin/.
checkpw.h is installed to /usr/include/ for use in other applications.
## Uninstall
```
sudo make uninstall
```
## Usage:
## Usage
```
checkpw -h
Usage: checkpw [-u <username>] [-p <password>] [-i] [-v] [-h]
Usage: checkpw [-u <username>] [-p <password>] [-v] [-V] [-h]
Options:
-u <username> Specify username.
-p <password> Specify password.
-i Enable interactive mode to prompt for missing username/password.
-v Enable verbose mode.
-V Show program version.
-V Print program version.
-h Show this help.
```
Returns 0 on success, 1 otherwise.
### Examples:
#### Interactive mode:
You can also use checkpw even without installing by just running the following command:
```
checkpw -i
./checkpk
```
#### Interactive mode only asking for a password:
checkpw returns 0 on success, 1 otherwise.
### Examples
#### Interactive mode asking for a username and a password
```
checkpw -u hanez -i
checkpw
```
#### None interactive mode with username and password provided as arguments to checkpw:
#### Interactive mode only asking for a password
```
checkpw -u hanez
```
#### None interactive mode with username and password provided as arguments to checkpw
```
checkpw -u hanez -p password
```
#### Request the result from the above commands:
#### Request the result from the above commands
```
echo $?
```
## Links:
## Links
- [https://cr.yp.to/checkpwd.html](https://cr.yp.to/checkpwd.html)
- [https://pamtester.sourceforge.net/](https://pamtester.sourceforge.net/)