Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEFAULT_PATH to match de-facto Linux standards #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ usage: configure [options]

--uid-max=NUM set UID_MAX (default 65535)
--gid-max=NUM set GID_MAX (default 65535)

--default-path=PATH set default PATH for executed environment

--help, -h display this help and exit
EOF
Expand All @@ -40,6 +42,7 @@ EOF
WITHOUT_TIMESTAMP=yes
UID_MAX=65535
GID_MAX=65535
DEFAULT_PATH="/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin"

for x; do
opt=${x%%=*}
Expand All @@ -64,6 +67,7 @@ for x; do
--without-timestamp) WITHOUT_TIMESTAMP=yes ;;
--uid-max) UID_MAX=$var ;;
--gid-max) UID_MAX=$var ;;
--default-path) DEFAULT_PATH=$var ;;
--help|-h) usage ;;
*) die "Error: unknown option $opt" ;;
esac
Expand Down Expand Up @@ -104,6 +108,9 @@ fi

OS_CFLAGS="-D__${OS}__"

printf 'Setting DEFAULT_PATH\t\t\t%s.\n' "$DEFAULT_PATH" >&2
printf '#define DEFAULT_PATH "%s"\n' "$DEFAULT_PATH" >>$CONFIG_H

case "$OS" in
linux)
printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
Expand Down
4 changes: 2 additions & 2 deletions doas.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ main(int argc, char **argv)
err(1, "initgroups");
if (setresuid(target, target, target) != 0)
err(1, "setresuid");
if (setenv("PATH", safepath, 1) == -1)
err(1, "failed to set PATH '%s'", safepath);
if (setenv("PATH", DEFAULT_PATH, 1) == -1)
err(1, "failed to set PATH '%s'", DEFAULT_PATH);
#endif

if (getcwd(cwdpath, sizeof(cwdpath)) == NULL)
Expand Down