Skip to content

Commit 6134e21

Browse files
committed
build
1 parent a5f1631 commit 6134e21

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ ${underline}Non-Root Check:${nounderline} Running as root detected.
231231

232232
## Wrapper that supports su, sudo, doas
233233
root_cmd(){
234+
local cmdarr
235+
234236
test -z "${1:-}" && die 1 "${underline}root_cmd function:${nounderline} Failed to pass arguments to root_cmd."
235237
if test -z "${sucmd:-}"; then
236238
get_su_cmd
@@ -245,7 +247,15 @@ root_cmd(){
245247
log_run "$root_cmd_loglevel" su root -s "${cmd}" -- "${@}"
246248
;;
247249
sudo)
248-
log_run "$root_cmd_loglevel" sudo -- "${@}"
250+
cmdarr=( 'log_run' "$root_cmd_loglevel" 'sudo' )
251+
if [ -n "$ROOT_CMD_TARGET_USER" ]; then
252+
cmdarr+=( '--user' "$ROOT_CMD_TARGET_USER" );
253+
fi
254+
if [ -n "$ROOT_CMD_TARGET_DIR" ]; then
255+
cmdarr+=( '--chdir' "$ROOT_CMD_TARGET_DIR" );
256+
fi
257+
cmdarr+=( '--' "${@}" )
258+
"${cmdarr[@]}"
249259
;;
250260
doas)
251261
log_run "$root_cmd_loglevel" doas -u root -- "${@}"
@@ -258,6 +268,8 @@ root_cmd(){
258268

259269

260270
get_su_cmd(){
271+
export ROOT_CMD_TARGET_USER=''
272+
export ROOT_CMD_TARGET_DIR=''
261273
while true; do
262274
has sudo && sucmd=sudo && break
263275
has doas && sucmd=doas && break

0 commit comments

Comments
 (0)