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

Added sudo skipping when UID is zero #106

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

victormlg
Copy link
Contributor

I couldn't test on a minimal centos 9 container, because I don't how to spawn them.

@craigcomstock
Copy link
Contributor

@victormlg maybe this incoming documentation would help!? https://github.com/cfengine/documentation/pull/3355/files

@victormlg victormlg force-pushed the CFE-4464-check-sudo branch from e22f73f to a254766 Compare January 2, 2025 10:08
@victormlg
Copy link
Contributor Author

@victormlg maybe this incoming documentation would help!? https://github.com/cfengine/documentation/pull/3355/files

Thanks!
I tested now and for me it works

cf_remote/ssh.py Outdated
@@ -18,6 +18,7 @@ class LocalConnection:

def __init__(self):
self.ssh_user = pwd.getpwuid(os.getuid()).pw_name
self.has_sudo = self.run("echo $UID", hide=True).stdout.strip() != '0'
Copy link
Member

@olehermanse olehermanse Jan 2, 2025

Choose a reason for hiding this comment

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

The name, has_sudo, is not good. It sounds like it means that you have the sudo program. I would choose something else, like needs_sudo, is_not_uid_zero or is_non_root;

Suggested change
self.has_sudo = self.run("echo $UID", hide=True).stdout.strip() != '0'
self.needs_sudo = self.run("echo $UID", hide=True).stdout.strip() != '0'

Ticket: CFE-4464
Signed-off-by: Victor Moene <[email protected]>
@victormlg victormlg force-pushed the CFE-4464-check-sudo branch from 53c9b9b to 49432f4 Compare January 3, 2025 09:00
@victormlg victormlg requested a review from olehermanse January 3, 2025 09:01
@olehermanse olehermanse merged commit f86e5a4 into cfengine:master Jan 8, 2025
6 checks passed
@victormlg victormlg deleted the CFE-4464-check-sudo branch January 8, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants