diff options
Diffstat (limited to 'src/firejail/dhcp.c')
-rw-r--r-- | src/firejail/dhcp.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/firejail/dhcp.c b/src/firejail/dhcp.c index 37547a985..456bba91b 100644 --- a/src/firejail/dhcp.c +++ b/src/firejail/dhcp.c | |||
@@ -130,7 +130,9 @@ static void dhcp_waitll_all() { | |||
130 | dhcp_waitll(cfg.bridge3.devsandbox); | 130 | dhcp_waitll(cfg.bridge3.devsandbox); |
131 | } | 131 | } |
132 | 132 | ||
133 | void dhcp_start(void) { | 133 | // Temporarily copy dhclient executable under /run/firejail/mnt and start it from there |
134 | // in order to recognize it later in firemon and firetools | ||
135 | void dhcp_store_exec(void) { | ||
134 | if (!any_dhcp()) | 136 | if (!any_dhcp()) |
135 | return; | 137 | return; |
136 | 138 | ||
@@ -144,6 +146,26 @@ void dhcp_start(void) { | |||
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
149 | sbox_run(SBOX_ROOT| SBOX_SECCOMP, 4, PATH_FCOPY, "--follow-link", dhclient_path, RUN_MNT_DIR); | ||
150 | } | ||
151 | |||
152 | void dhcp_start(void) { | ||
153 | if (!any_dhcp()) | ||
154 | return; | ||
155 | |||
156 | char *dhclient_path = RUN_MNT_DIR "/dhclient";; | ||
157 | struct stat s; | ||
158 | if (stat(dhclient_path, &s) == -1) { | ||
159 | dhclient_path = "/usr/sbin/dhclient"; | ||
160 | if (stat(dhclient_path, &s) == -1) { | ||
161 | fprintf(stderr, "Error: dhclient was not found.\n"); | ||
162 | exit(1); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | sbox_run(SBOX_ROOT| SBOX_SECCOMP, 4, PATH_FCOPY, "--follow-link", dhclient_path, RUN_MNT_DIR); | ||
167 | dhclient_path = RUN_MNT_DIR "/dhclient"; | ||
168 | |||
147 | EUID_ROOT(); | 169 | EUID_ROOT(); |
148 | if (mkdir(RUN_DHCLIENT_DIR, 0700)) | 170 | if (mkdir(RUN_DHCLIENT_DIR, 0700)) |
149 | errExit("mkdir"); | 171 | errExit("mkdir"); |
@@ -163,4 +185,6 @@ void dhcp_start(void) { | |||
163 | exit(1); | 185 | exit(1); |
164 | } | 186 | } |
165 | } | 187 | } |
188 | |||
189 | unlink(dhclient_path); | ||
166 | } | 190 | } |