Skip to content

Commit ead1092

Browse files
committed
avoid using sudo if already using account root
1 parent d5608ec commit ead1092

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

usr/bin/upgrade-nonroot

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@ set -e
88
# shellcheck source=../../../helper-scripts/usr/libexec/helper-scripts/package_installed_check.bsh
99
source /usr/libexec/helper-scripts/package_installed_check.bsh
1010

11+
if [ "$(id -un)" = 'root' ]; then
12+
## Avoid using 'sudo' if already using account 'root'. Reasons:
13+
## - Using 'sudo' is unnecessary in this case.
14+
## - Would work in case of a user-sysmaint-split or sudo bug.
15+
exec /usr/bin/apt-get-update-plus dist-upgrade
16+
fi
17+
18+
## This is never reached if using 'exec' above.
19+
1120
if pkg_installed user-sysmaint-split; then
1221
## Example use cases for using account 'root' with user-sysmaint-split installed:
1322
## - root login
1423
## - Qubes root console.
15-
if [ "$(id -un)" != 'sysmaint' ] && [ "$(id -un)" != 'root' ]; then
24+
if [ "$(id -un)" != 'sysmaint' ]; then
1625
1>&2 echo "ERROR: upgrade-nonroot cannot be used by accounts other than"
1726
1>&2 echo "'sysmaint' (or 'root') on this system. For more information, see"
1827
1>&2 echo "https://www.kicksecure.com/wiki/Sysmaint"
1928
exit 1
2029
fi
2130
fi
2231

23-
sudo /usr/bin/apt-get-update-plus dist-upgrade
32+
exec sudo /usr/bin/apt-get-update-plus dist-upgrade

0 commit comments

Comments
 (0)