-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Verify access permissions for shadow & gshadow
Merge with the existing passwd & group check and also check backup files. See: coreos/rpm-ostree#4911
- Loading branch information
Showing
2 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
## kola: | ||
## exclusive: false | ||
## description: Verify that /etc/(passwd|group|shadow|gshadow) have correct permissions. | ||
|
||
set -xeuo pipefail | ||
|
||
# shellcheck disable=SC1091 | ||
. "$KOLA_EXT_DATA/commonlib.sh" | ||
|
||
incorrect="" | ||
for f in '/etc/passwd' '/etc/group'; do | ||
if [[ $(stat --format="%a %u %g" "${f}") != "644 0 0" ]]; then | ||
incorrect+=" ${f}" | ||
fi | ||
done | ||
for f in '/etc/passwd-' '/etc/group-'; do | ||
if [[ -f "${f}" ]]; then | ||
if [[ $(stat --format="%a %u %g" "${f}") != "644 0 0" ]]; then | ||
incorrect+=" ${f}" | ||
fi | ||
fi | ||
done | ||
for f in '/etc/shadow' '/etc/gshadow'; do | ||
if [[ $(stat --format="%a %u %g" "${f}") != "0 0 0" ]]; then | ||
incorrect+=" ${f}" | ||
fi | ||
done | ||
for f in '/etc/shadow-' '/etc/gshadow-'; do | ||
if [[ -f "${f}" ]]; then | ||
if [[ $(stat --format="%a %u %g" "${f}") != "0 0 0" ]]; then | ||
incorrect+=" ${f}" | ||
fi | ||
fi | ||
done | ||
|
||
if [[ -n "${incorrect}" ]]; then | ||
# We explicitely want to split on whitespace here | ||
# shellcheck disable=SC2086 | ||
ls -al ${incorrect} | ||
fatal "found incorrect permissions for: ${incorrect}" | ||
fi | ||
|
||
ok "correct ownership and mode on /etc/passwd, /etc/group, /etc/shadow and /etc/gshadow" |