From b9fe3cca6a0921d35d919f234e3f9faf7910ce3f Mon Sep 17 00:00:00 2001 From: smitsohu Date: Mon, 22 Jul 2019 14:29:27 +0200 Subject: fix verbosity for non-authorized user users not in firejail.users should only see the error, not the symlink warning. Also exposes less code to non- authorized users. --- src/firejail/main.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/firejail/main.c b/src/firejail/main.c index d1c41c58a..f5785ff50 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -302,29 +302,29 @@ static void init_cfg(int argc, char **argv) { if (!cfg.username) errExit("strdup"); - // build home directory name - if (pw->pw_dir == NULL) { - fprintf(stderr, "Error: user %s doesn't have a user directory assigned\n", cfg.username); + // check user database + if (!firejail_user_check(cfg.username)) { + fprintf(stderr, "Error: the user is not allowed to use Firejail.\n" + "Please add the user in %s/firejail.users file,\n" + "either by running \"sudo firecfg\", or by editing the file directly.\n" + "See \"man firejail-users\" for more details.\n\n", SYSCONFDIR); + + // attempt to run the program as is + run_symlink(argc, argv, 1); exit(1); } - build_cfg_homedir(pw->pw_dir); - assert(cfg.homedir); cfg.cwd = getcwd(NULL, 0); if (!cfg.cwd && errno != ENOENT) errExit("getcwd"); - // check user database - if (!firejail_user_check(cfg.username)) { - fprintf(stderr, "Error: the user is not allowed to use Firejail. " - "Please add the user in %s/firejail.users file, " - "either by running \"sudo firecfg\", or by editing the file directly.\n" - "See \"man firejail-users\" for more details.\n", SYSCONFDIR); - - // attempt to run the program as is - run_symlink(argc, argv, 1); + // build home directory name + if (pw->pw_dir == NULL) { + fprintf(stderr, "Error: user %s doesn't have a user directory assigned\n", cfg.username); exit(1); } + build_cfg_homedir(pw->pw_dir); + assert(cfg.homedir); // initialize random number generator sandbox_pid = getpid(); -- cgit v1.2.3-70-g09d2