Skip to content

add sudo permissions check to sysinfo.#13

Merged
Shalankwa merged 9 commits into
mainfrom
add-sudo-perm-checker
Mar 12, 2025
Merged

add sudo permissions check to sysinfo.#13
Shalankwa merged 9 commits into
mainfrom
add-sudo-perm-checker

Conversation

@lrojash

@lrojash lrojash commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

Add permission checker, if the user is not running as sudo during agent actions, warn the user and don't proceed with installation.

@lrojash lrojash marked this pull request as ready for review March 11, 2025 23:26
@lrojash lrojash requested a review from Shalankwa March 11, 2025 23:26
Comment thread sysinfo/sysinfo_test.go Outdated
Comment on lines +130 to +144
func TestSudoPerm(t *testing.T) {
defer func() { osGeteUid = originalOsGeteUid }()
osGeteUid = 0 // sudo permissions
expected := true

require.Equal(t, expected, checkSudoPerm())
}

func TestNoSudoPerm(t *testing.T) {
defer func() { osGeteUid = originalOsGeteUid }()
osGeteUid = 1000 // no sudo permissions
expected := false

require.Equal(t, expected, checkSudoPerm())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't really necessary to test.

@Shalankwa Shalankwa merged commit 71ff13b into main Mar 12, 2025
@lrojash lrojash deleted the add-sudo-perm-checker branch March 12, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants