diff --git a/sus.c b/sus.c index 2c958d2..e87c42c 100644 --- a/sus.c +++ b/sus.c @@ -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);