diff options
author | se <se@FreeBSD.org> | 2018-01-17 02:43:27 +0800 |
---|---|---|
committer | se <se@FreeBSD.org> | 2018-01-17 02:43:27 +0800 |
commit | 7668ec9380b25532fe71f3e37c52c33fd7af3b1c (patch) | |
tree | 7b565f205c411f3f74d5eeb41b172474e1e36f1c /ports-mgmt | |
parent | 9b867bfd9c6f2e9dc44e11cdd7b017474d74f47c (diff) | |
download | freebsd-ports-gnome-7668ec9380b25532fe71f3e37c52c33fd7af3b1c.tar.gz freebsd-ports-gnome-7668ec9380b25532fe71f3e37c52c33fd7af3b1c.tar.zst freebsd-ports-gnome-7668ec9380b25532fe71f3e37c52c33fd7af3b1c.zip |
Test privileges early and complain if privileges are insufficient.
The patch is based on ideas presented in the PR, but implemented
differently. Re-open the PR, if this solution has unexpected side-effects
or proves insufficient.
PR: 174729
Reported by: ngie
Approved by: antoine (implicit)
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/portmaster/files/patch-portmaster | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ports-mgmt/portmaster/files/patch-portmaster b/ports-mgmt/portmaster/files/patch-portmaster new file mode 100644 index 000000000000..beaf29429359 --- /dev/null +++ b/ports-mgmt/portmaster/files/patch-portmaster @@ -0,0 +1,21 @@ +--- portmaster.orig 2018-01-14 21:53:23 UTC ++++ portmaster +@@ -45,7 +45,7 @@ if [ -z "$PM_PARENT_PID" ]; then + my_environment=`set` + + # If we are already root, unset this to avoid potential conflict +- [ `ps -o uid= $$` -eq 0 ] && unset PM_SU_CMD PM_SU_VERBOSE ++ [ `id -u` -eq 0 ] && unset PM_SU_CMD PM_SU_VERBOSE + fi + + #=============== Begin functions we always want to have =============== +@@ -3233,6 +3233,9 @@ if [ -n "$PM_FIRST_PASS" -a -z "$FETCH_ONLY" ]; then + elif [ -n "$FETCH_ONLY" -a -n "$PM_PACKAGES" ]; then + update_pm_nu $portdir + fi ++ ++# Test for necessary privileges to actually install ports ++[ "$($PM_SU_CMD id -u)" = 0 ] || fail "Insufficient privileges to install ports (run as root or set PM_SU_CMD)" + + # Do these things first time through + if [ -z "$PM_INDEX_ONLY" -a -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ]; then |