Hardcoding Prog to known value

See #959. We now set Prog (program name) based on hardcoded value instead
of argv[0]. This is to help prevent escape sequence injection.
This commit is contained in:
Skyler Ferrante
2024-03-03 00:54:05 -05:00
committed by Alejandro Colomar
parent d13844408c
commit e6c2e43937
37 changed files with 85 additions and 171 deletions
+3 -7
View File
@@ -72,7 +72,7 @@
/*
* Global variables
*/
const char *Prog;
static const char Prog[] = "userdel";
static char *user_name;
static uid_t user_id;
@@ -959,10 +959,6 @@ int main (int argc, char **argv)
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
/*
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
log_set_progname(Prog);
log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
@@ -972,7 +968,7 @@ int main (int argc, char **argv)
process_root_flag ("-R", argc, argv);
prefix = process_prefix_flag ("-P", argc, argv);
OPENLOG ("userdel");
OPENLOG (Prog);
#ifdef WITH_AUDIT
audit_help_open ();
#endif /* WITH_AUDIT */
@@ -1056,7 +1052,7 @@ int main (int argc, char **argv)
exit (E_PW_UPDATE);
}
retval = pam_start ("userdel", pampw->pw_name, &conv, &pamh);
retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
}
if (PAM_SUCCESS == retval) {