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

remove "cant find escaltion tool if user is already root #816

Open
solomoncyj opened this issue Oct 13, 2024 · 13 comments · May be fixed by #821
Open

remove "cant find escaltion tool if user is already root #816

solomoncyj opened this issue Oct 13, 2024 · 13 comments · May be fixed by #821
Labels
bug Something isn't working

Comments

@solomoncyj
Copy link

Describe the bug

log in as root user without a escation tool, eg docker

To Reproduce

Steps to reproduce the behavior:
run the script
select an opetion which requires elevation

Expected behavior

the script to run normal

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Checklist

  • [*] I checked for duplicate issues.
  • [*] I checked already existing discussions.
  • [*] This issue is not included in the roadmap.
  • [*] This issue is present on both stable and development branches.
@solomoncyj solomoncyj added the bug Something isn't working label Oct 13, 2024
@solomoncyj
Copy link
Author

image

@jeevithakannan2
Copy link
Contributor

Linutil should not be ran as root. Will add restriction to prevent running as root.

@solomoncyj
Copy link
Author

Linutil should not be ran as root. Will add restriction to prevent running as root.

how should i make my docker container not log me in as root?

@jeevithakannan2
Copy link
Contributor

jeevithakannan2 commented Oct 13, 2024

You can specify a new user in the docker file and run it with docker run --user myuser myimage. If you're using an image from the docker hub most of them have a non-root user by default run them with --user.

@jeevithakannan2 jeevithakannan2 linked a pull request Oct 13, 2024 that will close this issue
12 tasks
@cartercanedy
Copy link
Contributor

I mean, we could make this work with a superuser check and setting ESCALATION_TOOL="" in common_script.sh if run with a root session, right?

@cartercanedy
Copy link
Contributor

cartercanedy commented Oct 13, 2024

There might be some other issues if relative dirs (besides those referencing the common utility scripts)* are used in any of the scripts, but that's generally discouraged anyways

@lj3954
Copy link
Contributor

lj3954 commented Oct 13, 2024

I mean, we could make this work with a superuser check and setting ESCALATION_TOOL="" in common_script.sh if run with a root session, right?

All scripts would also need to be updated to not quote the escalation tool variable in that case, since otherwise they'd be attempting launch a binary with an empty name in your PATH, which obviously cannot exist.

@cartercanedy
Copy link
Contributor

That could get quickly solved by redirecting to a custom escalation function that can implement the branching logic to check for the root user case. Would be as simple as implementing the fn in common-script.sh and a sed replace for "$ESCALATION_TOOL". I'd do it myself, but I'm not at home, atm

@jeevithakannan2
Copy link
Contributor

elevated_execution() {
    if [ -z "$ESCALATION_TOOL" ]; then
        "$@"
    else
        "$ESCALATION_TOOL" "$@"
    fi
}

Need to replace every ESCALATION_TOOL in scripts with elevated_execution function

Is this simple function good in common-script.sh ??

@cartercanedy
Copy link
Contributor

cartercanedy commented Oct 14, 2024

Nice! Yeah, that's exactly what I'm thinking. I'd probably use a find ./ ! -name 'common-script.sh' -type f -name '*.sh' to iterate over all of the scripts and run sed -i'' 's/"$ESCALATION_TOOL"/elevated_execution/g'

@jeevithakannan2
Copy link
Contributor

Yeah was thinking of same idea

@lj3954
Copy link
Contributor

lj3954 commented Oct 14, 2024

elevated_execution() {
    if [ -z "$ESCALATION_TOOL" ]; then
        "$@"
    else
        "$ESCALATION_TOOL" "$@"
    fi
}

Need to replace every ESCALATION_TOOL in scripts with elevated_execution function

Is this simple function good in common-script.sh ??

You'll need to remove the quotes from $@, quoting it will cause the shell to treat the entire list of arguments as one command.

@cartercanedy
Copy link
Contributor

You'll need to remove the quotes from $@, quoting it will cause the shell to treat the entire list of arguments as one command.

Quoting $@ should still work. I'm fairly certain that word expansion of quoted $@ is posix, same with the non-expansion of quoted$*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants