-
Notifications
You must be signed in to change notification settings - Fork 381
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
oscap-ssh: simplify to allow limited sudo rule #1881
Open
maage
wants to merge
8
commits into
OpenSCAP:maint-1.3
Choose a base branch
from
maage:oscap-ssh-1
base: maint-1.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handle options conversions up to 2nd last arg as last is input and is handled next. (( ..., 1 )) ensures return value is ok. arr[-1] is last element From shellcheck: In utils/oscap-ssh line 217: for i in $(seq 0 `expr $# - 1`); do ^-----------^ SC2046: Quote this to prevent word splitting. ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: for i in $(seq 0 $(expr $# - 1)); do In utils/oscap-ssh line 218: let j=i+1 ^-------^ SC2219: Instead of 'let expr', prefer (( expr )) . In utils/oscap-ssh line 267: LOCAL_CONTENT_PATH="${oscap_args[`expr $# - 1`]}" ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: LOCAL_CONTENT_PATH="${oscap_args[$(expr $# - 1)]}" In utils/oscap-ssh line 268: oscap_args[`expr $# - 1`]="$REMOTE_TEMP_DIR/input.xml" ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: oscap_args[$(expr $# - 1)]="$REMOTE_TEMP_DIR/input.xml"
- use printf %q instead of home made implementation - use $@ - there is no point using fancy array arrayref and eval in this simple use case - printf just iterates parameters and "$@" works just fine - changes usage: from: command_array_to_string arref to: command_array_to_string "${array[@]}"
Change OSCAP_SUDO as array and after this there is no need to test it.
Fail if can not cd into a directory. Shellcheck would warn about this.
This ensures whole command is quoted.
This is needed sometimes when debugging.
Two test enva failed at |
Hey, @maage. Can you please rebase the PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this patch set I can use very limited sudo rule when running
oscap xccdf eval
.Also address some shellcheck warnings.
Without this to try to limit how sudo needs to be configured, sudoers rule needs to have
/usr/bin/sh
permission, exec permission (sh -c
), and runchown
without known path. This is too broad.chown
is not needed asumask 022
+rm -rf dir
is enough to remove files as directory is user owned.My example rule:
xccdf eval
under sudo, example user is namedoscap-eval-user
.eval
are accepted, tune for your solutionoscap
asunconfined_t
. This is default, but rule just ensures it works even if SELinux user (staff_u
) are used.requiretty
only for this user, so there is no issues, but not expose other users.