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>
This commit is contained in:
parent
f7335c8761
commit
61a67856ed
30
sus.c
30
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user