Skip to content

Commit

Permalink
fix firecfg --guide
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Apr 22, 2022
1 parent c8c69ca commit d4106f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/firecfg/firejail-welcome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
# Copyright (C) 2020-2022 Firejail Authors
# License GPL v2
#
# Usage: firejail-welcome PROGRAM SYSCONFDIR
# Usage: firejail-welcome PROGRAM SYSCONFDIR USER_NAME
# where PROGRAM is detected and driven by firecfg.
# SYSCONFDIR is most of the time /etc/firejail.
#
# The plan is to go with zenity by default. If zenity is not installed
# we will provide a console-only replacement in /usr/lib/firejail/fzenity
#

PROGRAM=$1
SYSCONFDIR=$2

if ! command -v "$PROGRAM" >/dev/null; then
echo "Please install $PROGRAM."
if ! command -v "$1" >/dev/null; then
echo "Please install $1."
exit 1
fi

PROGRAM="sudo -u $3 $1"
SYSCONFDIR=$2
export LANG=en_US.UTF8

TITLE="Firejail Configuration Guide"
Expand Down Expand Up @@ -165,7 +164,7 @@ Now, I will apply the changes. This is what I will do:
EOM

MSG_RUN+="\n\n"
if [[ "$run_firecfg" == "true" ]]; then
MSG_RUN+=" * enable Firejail for all recognized programs\n"
fi
Expand Down
6 changes: 5 additions & 1 deletion src/firecfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,15 @@ int main(int argc, char **argv) {
}

if (arg_guide) {
int status = system("sudo "LIBDIR "/firejail/firejail-welcome.sh zenity " SYSCONFDIR);
char *cmd;
if (asprintf(&cmd, "sudo %s/firejail/firejail-welcome.sh /usr/bin/zenity %s %s", LIBDIR, SYSCONFDIR, user) == -1)
errExit("asprintf");
int status = system(cmd);
if (status == -1) {
fprintf(stderr, "Error: cannot run firejail-welcome.sh\n");
exit(1);
}
free(cmd);

// the last 8 bits of the status is the return value of the command executed by system()
// firejail-welcome.sh returns 55 if setting sysmlinks is required
Expand Down

0 comments on commit d4106f7

Please sign in to comment.