diff options
author | 2023-07-16 11:24:12 -0400 | |
---|---|---|
committer | 2023-07-16 11:24:12 -0400 | |
commit | cb39a0eafd030829c0081e698cb934fd4f09692f (patch) | |
tree | 755ee6a74cd9fee380c4fd1c6a5cb2a4361c4b66 /src/firecfg/main.c | |
parent | fnettrace cleanup (diff) | |
parent | Merge pull request #5900 from kmk3/firecfg-support-doas (diff) | |
download | firejail-cb39a0eafd030829c0081e698cb934fd4f09692f.tar.gz firejail-cb39a0eafd030829c0081e698cb934fd4f09692f.tar.zst firejail-cb39a0eafd030829c0081e698cb934fd4f09692f.zip |
Merge branch 'master' of ssh://github.com/netblue30/firejail
Diffstat (limited to 'src/firecfg/main.c')
-rw-r--r-- | src/firecfg/main.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/firecfg/main.c b/src/firecfg/main.c index da962c35d..4ec81c5b3 100644 --- a/src/firecfg/main.c +++ b/src/firecfg/main.c | |||
@@ -288,8 +288,11 @@ static void set_links_homedir(const char *homedir) { | |||
288 | free(firejail_exec); | 288 | free(firejail_exec); |
289 | } | 289 | } |
290 | 290 | ||
291 | static char *get_user(void) { | 291 | static const char *get_sudo_user(void) { |
292 | char *user = getenv("SUDO_USER"); | 292 | const char *doas_user = getenv("DOAS_USER"); |
293 | const char *sudo_user = getenv("SUDO_USER"); | ||
294 | const char *user = doas_user ? doas_user : sudo_user; | ||
295 | |||
293 | if (!user) { | 296 | if (!user) { |
294 | user = getpwuid(getuid())->pw_name; | 297 | user = getpwuid(getuid())->pw_name; |
295 | if (!user) { | 298 | if (!user) { |
@@ -301,13 +304,13 @@ static char *get_user(void) { | |||
301 | return user; | 304 | return user; |
302 | } | 305 | } |
303 | 306 | ||
304 | static char *get_homedir(const char *user, uid_t *uid, gid_t *gid) { | 307 | static const char *get_homedir(const char *user, uid_t *uid, gid_t *gid) { |
305 | // find home directory | 308 | // find home directory |
306 | struct passwd *pw = getpwnam(user); | 309 | struct passwd *pw = getpwnam(user); |
307 | if (!pw) | 310 | if (!pw) |
308 | goto errexit; | 311 | goto errexit; |
309 | 312 | ||
310 | char *home = pw->pw_dir; | 313 | const char *home = pw->pw_dir; |
311 | if (!home) | 314 | if (!home) |
312 | goto errexit; | 315 | goto errexit; |
313 | 316 | ||
@@ -326,12 +329,11 @@ int main(int argc, char **argv) { | |||
326 | int bindir_set = 0; | 329 | int bindir_set = 0; |
327 | 330 | ||
328 | // user setup | 331 | // user setup |
329 | char *user = get_user(); | 332 | const char *user = get_sudo_user(); |
330 | assert(user); | 333 | assert(user); |
331 | uid_t uid; | 334 | uid_t uid; |
332 | gid_t gid; | 335 | gid_t gid; |
333 | char *home = get_homedir(user, &uid, &gid); | 336 | const char *home = get_homedir(user, &uid, &gid); |
334 | |||
335 | 337 | ||
336 | // check for --bindir | 338 | // check for --bindir |
337 | for (i = 1; i < argc; i++) { | 339 | for (i = 1; i < argc; i++) { |