diff options
author | 2023-07-16 11:57:08 +0000 | |
---|---|---|
committer | 2023-07-16 11:57:08 +0000 | |
commit | 2ebb09e346544785d1b4e27d7b779a2a7476ca3e (patch) | |
tree | 9871d689a1aa76836e8cb99ad69f845ed92a8680 /src/firecfg/main.c | |
parent | bleachbit.profile: allow erasing Trash contents (diff) | |
parent | feature: add doas support in firecfg and jailcheck (diff) | |
download | firejail-2ebb09e346544785d1b4e27d7b779a2a7476ca3e.tar.gz firejail-2ebb09e346544785d1b4e27d7b779a2a7476ca3e.tar.zst firejail-2ebb09e346544785d1b4e27d7b779a2a7476ca3e.zip |
Merge pull request #5900 from kmk3/firecfg-support-doas
feature: add doas support in firecfg and jailcheck
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++) { |