1
0
Fork 0
forked from soccera/rdo

Merge pull request 'Small fixes' (#3) from remoof/rdo:patch2 into main

Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/3
This commit is contained in:
sw1tchbl4d3 2021-07-15 15:51:13 +02:00
commit 225e6b0d6b

15
rdo.c
View file

@ -50,22 +50,23 @@ int main(int argc, char** argv) {
if (argc < 2) if (argc < 2)
errx(1, "Please specify a program to run"); errx(1, "Please specify a program to run");
int ruid = getuid();
if (ruid == 0) {
runprog(argc, argv);
return 0;
}
FILE* fp = fopen("/etc/rdo.conf", "r"); FILE* fp = fopen("/etc/rdo.conf", "r");
if (!fp) if (!fp)
err(1, "Could not open /etc/rdo.conf"); err(1, "Could not open /etc/rdo.conf");
int ruid = getuid();
if (ruid == 0) {
fclose(fp);
runprog(argc, argv);
return 0;
}
getconf(fp, "username", username, sizeof(username)); getconf(fp, "username", username, sizeof(username));
getconf(fp, "wrong_pw_sleep", wrong_pw_sleep, sizeof(wrong_pw_sleep)); getconf(fp, "wrong_pw_sleep", wrong_pw_sleep, sizeof(wrong_pw_sleep));
sleep_ms = atoi(wrong_pw_sleep) * 1000; sleep_ms = atoi(wrong_pw_sleep) * 1000;
fclose(fp);
struct passwd* p = getpwnam(username); struct passwd* p = getpwnam(username);
if (!p) if (!p)
err(1, "Could not get user info"); err(1, "Could not get user info");