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

fix: do not hard depend on sudo being installed #671

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

plurpio
Copy link
Contributor

@plurpio plurpio commented Sep 25, 2024

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Hotfix
  • Security patch
  • UI/UX improvement

Description

the checkCommandRequirements function under checkEnv function in common-script.sh hard-depended on sudo, although doas could be picked as an $ESCALATION_TOOL.

Testing

I activated acouple of the scripts from with the UI, there was no error for not having sudo on my sudo-less system anymore.

Impact

Allows doas to properly be used as an escalation tool now.

Issues / other PRs related

Additional Information

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

similar to #193
the checkCommandRequirements function under checkEnv hard-depended on
sudo, although doas can be picked as an $ESCALATION_TOOL.
@@ -125,11 +125,11 @@ checkDistro() {
}

checkEnv() {
checkCommandRequirements 'curl groups sudo'
checkEscalationTool

This comment was marked as outdated.

checkPackageManager 'nala apt-get dnf pacman zypper'
checkCurrentDirectoryWritable
checkSuperUser
checkDistro
checkEscalationTool

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not removed, just reordered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not removed, just reordered.

oops, was really tired when i typed that lol

@@ -125,11 +125,11 @@ checkDistro() {
}

checkEnv() {
checkCommandRequirements 'curl groups sudo'
checkEscalationTool
checkCommandRequirements "curl groups $ESCALATION_TOOL"

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Contributor

@cartercanedy cartercanedy Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're starting to broach the topic of advanced privilege escalation tools, you should also look at refactoring this:

checkSuperUser() {
## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do
if groups | grep -q "${sug}"; then
SUGROUP=${sug}
printf "%b\n" "${CYAN}Super user group ${SUGROUP}${RC}"
break
fi
done
## Check if member of the sudo group.
if ! groups | grep -q "${SUGROUP}"; then
printf "%b\n" "${RED}You need to be a member of the sudo group to run me!${RC}"
exit 1
fi
}

doas might be configured to use wheel group over sudo group for privilege checks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both doas and sudo have commands for checking the current user's permission to run commands as root.

  • sudo --validate
  • doas -C /etc/doas.conf echo # requires a command and configuration file to be passed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw both of these need to be interactive so they aren't really an option.

@ChrisTitusTech ChrisTitusTech merged commit 97b7d28 into ChrisTitusTech:main Sep 28, 2024
2 checks passed
@ChrisTitusTech ChrisTitusTech added the bug Something isn't working label Sep 28, 2024
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 this pull request may close these issues.

5 participants