diff options
Diffstat (limited to 'src/firecfg')
-rw-r--r-- | src/firecfg/desktop_files.c | 2 | ||||
-rw-r--r-- | src/firecfg/firecfg.h | 2 | ||||
-rw-r--r-- | src/firecfg/main.c | 16 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/firecfg/desktop_files.c b/src/firecfg/desktop_files.c index 963e05ff3..7ac60f70c 100644 --- a/src/firecfg/desktop_files.c +++ b/src/firecfg/desktop_files.c | |||
@@ -108,7 +108,7 @@ static int have_profile(const char *filename, const char *homedir) { | |||
108 | return rv; | 108 | return rv; |
109 | } | 109 | } |
110 | 110 | ||
111 | void fix_desktop_files(char *homedir) { | 111 | void fix_desktop_files(const char *homedir) { |
112 | assert(homedir); | 112 | assert(homedir); |
113 | struct stat sb; | 113 | struct stat sb; |
114 | 114 | ||
diff --git a/src/firecfg/firecfg.h b/src/firecfg/firecfg.h index 825bf8d03..8f74a1198 100644 --- a/src/firecfg/firecfg.h +++ b/src/firecfg/firecfg.h | |||
@@ -49,6 +49,6 @@ int is_link(const char *fname); | |||
49 | void sound(void); | 49 | void sound(void); |
50 | 50 | ||
51 | // desktop_files.c | 51 | // desktop_files.c |
52 | void fix_desktop_files(char *homedir); | 52 | void fix_desktop_files(const char *homedir); |
53 | 53 | ||
54 | #endif | 54 | #endif |
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++) { |