forked from soccera/rdo
Move type declerations to start of main
This commit is contained in:
parent
225e6b0d6b
commit
2f4ff0812a
1 changed files with 10 additions and 14 deletions
24
rdo.c
24
rdo.c
|
|
@ -29,7 +29,7 @@ void getconf(FILE* fp, const char* entry, char* result, size_t len_result) {
|
|||
errx(1, "Could not get '%s' entry in config", entry);
|
||||
}
|
||||
|
||||
void runprog(int argc, char** argv) {
|
||||
int runprog(int argc, char** argv) {
|
||||
for(int i=0; i<argc; i++)
|
||||
argv[i] = argv[i + 1];
|
||||
|
||||
|
|
@ -40,21 +40,20 @@ void runprog(int argc, char** argv) {
|
|||
|
||||
if (execvp(argv[0], argv) != 0)
|
||||
perror(argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char username[64];
|
||||
char wrong_pw_sleep[64];
|
||||
unsigned int sleep_ms;
|
||||
char username[64], wrong_pw_sleep[64], password[128];
|
||||
unsigned int sleep_ms, tries;
|
||||
|
||||
if (argc < 2)
|
||||
errx(1, "Please specify a program to run");
|
||||
|
||||
int ruid = getuid();
|
||||
if (ruid == 0) {
|
||||
runprog(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
if (ruid == 0)
|
||||
return runprog(argc, argv);
|
||||
|
||||
FILE* fp = fopen("/etc/rdo.conf", "r");
|
||||
|
||||
|
|
@ -80,16 +79,13 @@ int main(int argc, char** argv) {
|
|||
if (!shadowEntry)
|
||||
err(1, "Could not get shadow entry");
|
||||
|
||||
int tries = 0;
|
||||
char password[128];
|
||||
tries = 0;
|
||||
while (tries < 3) {
|
||||
if (!readpassphrase("(rdo) Password: ", password, sizeof(password), RPP_REQUIRE_TTY))
|
||||
err(1, "Could not get passphrase");
|
||||
|
||||
if (strcmp(shadowEntry->sp_pwdp, crypt(password, shadowEntry->sp_pwdp)) == 0) {
|
||||
runprog(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(shadowEntry->sp_pwdp, crypt(password, shadowEntry->sp_pwdp)) == 0)
|
||||
return runprog(argc, argv);
|
||||
|
||||
usleep(sleep_ms);
|
||||
fprintf(stderr, "Wrong password.\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue