Added MAX_UID.
This commit is contained in:
parent
2b24250a68
commit
10d8447d30
2 changed files with 8 additions and 4 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
10
checkpw.c
10
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue