Skip to content

added SELinux enforcement validation and toggle tests#403

Open
Rohan-in-Qualcomm wants to merge 1 commit intoqualcomm-linux:mainfrom
Rohan-in-Qualcomm:linux-security
Open

added SELinux enforcement validation and toggle tests#403
Rohan-in-Qualcomm wants to merge 1 commit intoqualcomm-linux:mainfrom
Rohan-in-Qualcomm:linux-security

Conversation

@Rohan-in-Qualcomm
Copy link
Copy Markdown

  • Run-GetEnforce: Verifies SELinux is running in Permissive mode.
  • Toggle-SetEnforce: Validates runtime switching between Enforcing and Permissive states.

- Run-GetEnforce: Verifies SELinux is running in Permissive mode.
- Toggle-SetEnforce: Validates runtime switching between Enforcing and Permissive states.

Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
run:
steps:
- REPO_PATH=$PWD || true
- cd Runner/suites/Kernel/DEBUG/Run-GetEnforce || true
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.

The testcase is being launched from the wrong path, and wrapper masking hides orchestration issues.

run:
steps:
- REPO_PATH=$PWD || true
- cd Runner/suites/Kernel/DEBUG/Toggle-SetEnforce || true
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.

The testcase is being launched from the wrong path, and wrapper masking hides orchestration issues.


if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env" >&2
exit 1
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.

Write SKIP or FAIL to Run-GetEnforce.res first, then exit 0.

exit 1
fi

if [ -z "$__INIT_ENV_LOADED" ]; then
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.

Current code expands "$__INIT_ENV_LOADED" directly and is less robust.

cd "$test_path" || exit 1
res_file="./$TESTNAME.res"
log_info "------------------------$TESTNAME Starting------------------------"

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.

use check_dependencies "getenforce"

if getenforce is missing, SKIP

if getenforce returns Disabled, SKIP

only assert Permissive on SELinux-enabled builds

Also, use > instead of >> when writing the .res file so reruns do not append stale results.


state1=$(getenforce)
log_info "Current state: $state1"

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.

use check_dependencies "getenforce setenforce"

if getenforce returns Disabled, SKIP

if initial state is not one of Permissive or Enforcing, SKIP

after setenforce 1, explicitly check state2 = Enforcing

after setenforce 0, explicitly check state3 = Permissive

fail if either transition did not occur

## Script Location

```
Runner/suites/Kernel/DEBUG/Run-GetEnforce/run.sh
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.

Update it to the actual path under Kernel Security.

## Script Location

```
Runner/suites/Kernel/DEBUG/Toggle-SetEnforce/run.sh
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.

Update it to the actual path under Kernel Security.

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