From 4098cb437d822f802cc44e217a1f72f73960b797 Mon Sep 17 00:00:00 2001 From: smitsohu Date: Mon, 7 Jun 2021 22:59:41 +0200 Subject: misc --- src/firejail/dhcp.c | 9 +++------ src/firejail/main.c | 10 ++++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/firejail/dhcp.c b/src/firejail/dhcp.c index 5bcdcad37..47dd39ac0 100644 --- a/src/firejail/dhcp.c +++ b/src/firejail/dhcp.c @@ -153,14 +153,11 @@ void dhcp_start(void) { if (!any_dhcp()) return; - char *dhclient_path = RUN_MNT_DIR "/dhclient";; + char *dhclient_path = RUN_MNT_DIR "/dhclient"; struct stat s; if (stat(dhclient_path, &s) == -1) { - dhclient_path = "/usr/sbin/dhclient"; - if (stat(dhclient_path, &s) == -1) { - fprintf(stderr, "Error: dhclient was not found.\n"); - exit(1); - } + fprintf(stderr, "Error: %s was not found.\n", dhclient_path); + exit(1); } sbox_run(SBOX_ROOT| SBOX_SECCOMP, 4, PATH_FCOPY, "--follow-link", dhclient_path, RUN_MNT_DIR); diff --git a/src/firejail/main.c b/src/firejail/main.c index 7ec2d6114..12ac01de7 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -862,12 +862,11 @@ static void run_cmd_and_exit(int i, int argc, char **argv) { char *guess_shell(void) { const char *shell; char *retval; - struct stat s; shell = env_get("SHELL"); if (shell) { invalid_filename(shell, 0); // no globbing - if (!is_dir(shell) && strstr(shell, "..") == NULL && stat(shell, &s) == 0 && access(shell, X_OK) == 0 && + if (access(shell, X_OK) == 0 && !is_dir(shell) && strstr(shell, "..") == NULL && strcmp(shell, PATH_FIREJAIL) != 0) goto found; } @@ -878,12 +877,15 @@ char *guess_shell(void) { int i = 0; while (shells[i] != NULL) { // access call checks as real UID/GID, not as effective UID/GID - if (stat(shells[i], &s) == 0 && access(shells[i], X_OK) == 0) { + if (access(shells[i], X_OK) == 0) { shell = shells[i]; - break; + goto found; } i++; } + + return NULL; + found: retval = strdup(shell); if (!retval) -- cgit v1.2.3-54-g00ecf