diff options
author | Slendi <slendi@socopon.com> | 2023-05-25 23:38:49 +0300 |
---|---|---|
committer | Slendi <slendi@socopon.com> | 2023-05-25 23:38:49 +0300 |
commit | 61a67856ed5191e40a501952c4f8135eb721b9ab (patch) | |
tree | b490964c732374dca8f920f4e769061648883646 | |
parent | f7335c87614b1a444b950c0f8e4247b1c6bdb236 (diff) |
Add a way to make it so that you don't need to input a password.
In /etc/sus, if you suffix the group ID with a "n", then it will not
ask for any password for users in that group.
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r-- | sus.c | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -13,18 +13,37 @@ #define MAX_IDS 100 long long ids[MAX_IDS] = { 0 }; +char nopass[MAX_IDS] = { 0 }; size_t ids_len = 0; read_ids() { FILE *f = fopen("/etc/sus", "r"); if (!f) return 0; - while (!feof(f) && ids_len < 99) + while (!feof(f) && ids_len < 99) { + char ch; fscanf(f, "%lld", &ids[ids_len++]); + if (!feof(f)) { + if ((ch = fgetc(f)) == 'n') + nopass[ids_len] = 1; + else + ungetc(ch, f); + } + } if (ids_len == 0) return 0; return 1; } +uid_nopass(uid) +{ + int i; + for (i = 0; i < ids_len; i++) { + if (ids[i] == uid && nopass[i]) + return 1; + } + return 0; +} + check_password(pass_buf) char *pass_buf; { @@ -178,10 +197,11 @@ uid_t uid; return -1; } - if (ask_password() != 1) { - fputs("Too many attempts.\n", stderr); - return -1; - } + if (!uid_nopass(uid)) + if (ask_password() != 1) { + fputs("Too many attempts.\n", stderr); + return -1; + } sigaction(SIGALRM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); |