diff --git a/README.md b/README.md index 49d5edf..b0cbede 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# checkpw - 1.0! +# checkpw - 1.0.1! checkpw is a program that checks the validity of a users password on a Linux/PAM-based system. diff --git a/checkpw.c b/checkpw.c index 793d989..29b0206 100644 --- a/checkpw.c +++ b/checkpw.c @@ -29,6 +29,10 @@ #define MAX_USERNAME_LEN 32 #define MAX_PASSWORD_LEN 256 +#ifndef MAX_UID +#define MAX_UID 1000 +#endif + #ifndef MIN_UID #define MIN_UID 1000 #endif @@ -238,9 +242,9 @@ int main(int argc, char *argv[]) { exit(1); } - // Check if the user's UID is below the minimum allowed UID - if (pwd->pw_uid < MIN_UID) { - fprintf(stderr, "Error: User '%s' has a UID less than %d and is not allowed to authenticate.\n", username, MIN_UID); + // Check if the user's UID is below the minimum allowed UID and not higher than maximum allowed UID + if (pwd->pw_uid < MIN_UID || pwd->pw_uid > MAX_UID) { + fprintf(stderr, "Error: User '%s' has a UID less than %d or higher than %d and is not allowed to authenticate.\n", username, MIN_UID, MAX_UID); exit(1); }