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

Use mkdir -p when creating directories #10556

Merged
merged 31 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
77f5ac6
fix: mount_option_nodev_nonroot_local_partitions/tests: use mkdir -p
maage May 10, 2023
d1b9f19
fix: file_permissions_library_dirs/tests: use mkdir -p
maage May 10, 2023
3f8af08
fix: usbguard_allow_hid_and_hub/tests: use mkdir -p
maage May 10, 2023
65a3914
fix: account_password_selinux_faillock_dir/tests: use mkdir -p
maage May 10, 2023
87b9f54
fix: directory_group_ownership_var_log_audit/tests: use mkdir -p
maage May 10, 2023
fbeca62
fix: rsyslog_remote_tls/tests: use mkdir -p
maage May 10, 2023
772d6d9
fix: dir_perms_world_writable_root_owned/tests: use mkdir -p
maage May 10, 2023
0ef932a
fix: dir_perms_world_writable_sticky_bits/tests: use mkdir -p
maage May 10, 2023
d235771
fix: dir_perms_world_writable_system_owned/tests: use mkdir -p
maage May 10, 2023
e8a89d4
fix: dir_perms_world_writable_system_owned_group/tests: use mkdir -p
maage May 10, 2023
ce21315
fix: sssd_enable_pam_services/bash: use mkdir -p
maage May 10, 2023
8e60a80
fix: dir_system_commands_group_root_owned/tests: use mkdir -p
maage May 10, 2023
d88e53f
fix: rsyslog_encrypt_offload_actionsendstreamdriverauthmode/tests: us…
maage May 10, 2023
d68db58
fix: rsyslog_encrypt_offload_actionsendstreamdrivermode/tests: use mk…
maage May 10, 2023
696628c
fix: rsyslog_encrypt_offload_defaultnetstreamdriver/tests: use mkdir -p
maage May 10, 2023
3859bb2
fix: auditd_data_disk_error_action/tests: use mkdir -p
maage May 10, 2023
1083d5e
fix: auditd_data_disk_full_action/tests: use mkdir -p
maage May 10, 2023
8b294ef
fix: directory_permissions_var_log_audit/tests: use mkdir -p
maage May 10, 2023
2ef7d18
fix: file_group_ownership_var_log_audit/tests: use mkdir -p
maage May 10, 2023
d0b8da8
fix: accounts_umask_interactive_users/tests: use mkdir -p
maage May 10, 2023
89d5ab6
fix: sudo_remove_no_authenticate/tests: use mkdir -p
maage May 10, 2023
f58112c
fix: sudo_remove_nopasswd/tests: use mkdir -p
maage May 10, 2023
70e9b84
fix: sudo_require_authentication/tests: use mkdir -p
maage May 10, 2023
bb67428
fix: file_ownership_library_dirs/tests: use mkdir -p
maage May 10, 2023
c9163f9
fix: accounts_users_home_files_permissions/tests: use mkdir -p
maage May 10, 2023
9ccc8f5
fix: dir_system_commands_root_owned/tests: use mkdir -p
maage May 10, 2023
41290f0
fix: rsyslog_cron_logging/tests: use mkdir -p
maage May 10, 2023
b003ebb
fix: sysctl: use mkdir -p
maage May 13, 2023
42f498c
fix: build_profiler: use mkdir -p
maage May 13, 2023
446d322
fix: accounts_polyinstantiated_tmp: use mkdir -p
maage May 13, 2023
7555229
fix: accounts_polyinstantiated_var_tmp: use mkdir -p
maage May 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SSSD_CONF="/etc/sssd/sssd.conf"
SSSD_CONF_DIR="/etc/sssd/conf.d/*.conf"

if [ ! -f "$SSSD_CONF" ] && [ ! -f "$SSSD_CONF_DIR" ]; then
mkdir /etc/sssd
mkdir -p /etc/sssd
touch "$SSSD_CONF"
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#

mkdir -p /etc/usbguard
rm -f /etc/usbguard/rules.conf
mkdir /etc/usbguard
echo -e " \t \n\t \n" > /etc/usbguard/rules.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#

mkdir -p /etc/usbguard
rm -f /etc/usbguard/rules.conf
mkdir /etc/usbguard
touch /etc/usbguard/rules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
truncate -s 0 /etc/security/faillock.conf
echo "dir=/var/log/faillock" > /etc/security/faillock.conf

mkdir /var/log/faillock
mkdir -p /var/log/faillock
semanage fcontext -a -t faillog_t "/var/log/faillock(/.*)?"
restorecon -R -v "/var/log/faillock"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ truncate -s 0 /etc/security/faillock.conf
echo "dir=/var/log/faillock" > /etc/security/faillock.conf
echo "auth required pam_faillock.so dir=/var/log/faillock_admins" >> /etc/pam.d/system-auth

mkdir /var/log/faillock /var/log/faillock_admins
mkdir -p /var/log/faillock /var/log/faillock_admins
semanage fcontext -a -t faillog_t "/var/log/faillock(/.*)?"
semanage fcontext -a -t faillog_t "/var/log/faillock_admins(/.*)?"
restorecon -R -v "/var/log/faillock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
truncate -s 0 /etc/security/faillock.conf
echo "dir=/var/log/faillock" > /etc/security/faillock.conf

mkdir /var/log/faillock
mkdir -p /var/log/faillock
semanage fcontext -a -t tmp_t "/var/log/faillock(/.*)?"
restorecon -R -v "/var/log/faillock"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ truncate -s 0 /etc/security/faillock.conf
echo "dir=/var/log/faillock" > /etc/security/faillock.conf
echo "auth required pam_faillock.so dir=/var/log/faillock_admins" >> /etc/pam.d/system-auth

mkdir /var/log/faillock /var/log/faillock_admins
mkdir -p /var/log/faillock /var/log/faillock_admins
semanage fcontext -a -t tmp_t "/var/log/faillock(/.*)?"
semanage fcontext -a -t faillog_t "/var/log/faillock_admins(/.*)?"
restorecon -R -v "/var/log/faillock"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
# platform = multi_platform_all
if ! [ -d /tmp/tmp-inst ] ; then
mkdir --mode 000 /tmp/tmp-inst
fi

# shellcheck disable=SC2174
mkdir -p --mode 000 /tmp/tmp-inst
chmod 000 /tmp/tmp-inst
chcon --reference=/tmp /tmp/tmp-inst

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /tmp/tmp-inst
mkdir --mode 000 /tmp/tmp-inst
mkdir -p --mode 000 /tmp/tmp-inst
chmod 000 /tmp/tmp-inst
echo "/tmp /tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

rm -rf /tmp/tmp-inst
echo "/tmp /tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /tmp/tmp-inst
mkdir --mode 000 /tmp/tmp-inst
mkdir -p --mode 000 /tmp/tmp-inst
chmod 000 /tmp/tmp-inst
sed -i "/^\s*\/tmp\s*/d" /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /tmp/tmp-inst
mkdir --mode 600 /tmp/tmp-inst
mkdir -p --mode 600 /tmp/tmp-inst
chmod 600 /tmp/tmp-inst
echo "/tmp /tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
# platform = multi_platform_all
if ! [ -d /tmp-inst ] ; then
mkdir --mode 000 /var/tmp/tmp-inst
fi

# shellcheck disable=SC2174
mkdir -p --mode 000 /var/tmp/tmp-inst
chmod 000 /var/tmp/tmp-inst
chcon --reference=/var/tmp/ /var/tmp/tmp-inst
chcon --reference=/var/tmp /var/tmp/tmp-inst

if ! grep -Eq '^\s*/var/tmp\s+/var/tmp/tmp-inst/\s+level\s+root,adm$' /etc/security/namespace.conf ; then
if grep -Eq '^\s*/var/tmp\s+' /etc/security/namespace.conf ; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /var/tmp/tmp-inst
mkdir --mode 000 /var/tmp/tmp-inst
mkdir -p --mode 000 /var/tmp/tmp-inst
chmod 000 /var/tmp/tmp-inst
echo "/var/tmp /var/tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

rm -rf /var/tmp/tmp-inst
echo "/var/tmp /var/tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /var/tmp/tmp-inst
mkdir --mode 000 /var/tmp/tmp-inst
mkdir -p --mode 000 /var/tmp/tmp-inst
chmod 000 /var/tmp/tmp-inst
sed -i "/^\s*\/var\/tmp\s*/d" /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

rm -rf /var/tmp/tmp-inst
mkdir --mode 600 /var/tmp/tmp-inst
mkdir -p --mode 600 /var/tmp/tmp-inst
chmod 600 /var/tmp/tmp-inst
echo "/var/tmp /var/tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

USER="cac_user"
useradd -m $USER
mkdir /home/$USER/folder
chmod -Rf 700 /home/$USER/.*
chmod -f o+r /home/$USER/folder
useradd -m "${USER}"
mkdir -p /home/"${USER}"/folder
chmod -Rf 700 /home/"${USER}"/.*
chmod -f o+r /home/"${USER}"/folder
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

USER="cac_user"
useradd -m $USER
mkdir /home/$USER/.hiddenfolder
mkdir -p /home/"${USER}"/.hiddenfolder
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash
# packages = audit


sed -i "/\s*log_group.*/d" /etc/audit/auditd.conf
sed -i "/\s*log_file.*/d" /etc/audit/auditd.conf
echo "log_group = root" >> /etc/audit/auditd.conf
echo "log_file = /var/log/audit2/audit.log" >> /etc/audit/auditd.conf

mkdir /var/log/audit2
mkdir -p /var/log/audit2
groupadd group_test

chgrp root /var/log/audit2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sed -i "/\s*log_file.*/d" /etc/audit/auditd.conf
echo "log_group = root" >> /etc/audit/auditd.conf
echo "log_file = /var/log/audit2/audit.log" >> /etc/audit/auditd.conf

mkdir /var/log/audit2
mkdir -p /var/log/audit2
groupadd group_test

chgrp root /var/log/audit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sed -i "/^\s*log_file.*/d" /etc/audit/auditd.conf
DIR1=/var/log/audit/
DIR2=/var/log/audit2/

mkdir ${DIR2}
mkdir -p "${DIR2}"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sed -i "/^\s*log_group.*/d" /etc/audit/auditd.conf

groupadd group_test
rm -f /var/log/audit/*
mkdir /var/log/audit2/
mkdir -p /var/log/audit2

FILE1=/var/log/audit/audit.log
FILE2=/var/log/audit2/audit.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

mkdir -p /etc/audit
truncate -s 0 /etc/audit/auditd.conf
mkdir /etc/audit/
touch /etc/audit/auditd.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

mkdir -p /etc/audit
truncate -s 0 /etc/audit/auditd.conf
mkdir /etc/audit/
touch /etc/audit/auditd.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash
# platform = Oracle Linux 7,Oracle Linux 8

. set_cron_logging.sh

RSYSLOG_CONF='/etc/rsyslog.conf'
RSYSLOG_D_FOLDER='/etc/rsyslog.d'
RSYSLOG_D_FILES='/etc/rsyslog.d/*'
RSYSLOG_D_FILES=("${RSYSLOG_D_FOLDER}"/*)

mkdir $RSYSLOG_D_FOLDER
rm $RSYSLOG_D_FILES
truncate -s 0 $RSYSLOG_CONF
mkdir -p "${RSYSLOG_D_FOLDER}"
rm -rf "${RSYSLOG_D_FILES[@]}"
truncate -s 0 "${RSYSLOG_CONF}"

echo '*.* /var/log/messages' >> $RSYSLOG_CONF
echo '*.* /var/log/messages' >> "${RSYSLOG_CONF}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

# Use this script to ensure the rsyslog directory structure and rsyslog conf file
# exist in the test env.
config_file=/etc/rsyslog.conf

# Ensure directory structure exists (useful for container based testing)
test -f $config_file || touch $config_file

test -d /etc/rsyslog.d/ || mkdir /etc/rsyslog.d/
mkdir -p /etc/rsyslog.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

# Use this script to ensure the rsyslog directory structure and rsyslog conf file
# exist in the test env.
config_file=/etc/rsyslog.conf

# Ensure directory structure exists (useful for container based testing)
test -f $config_file || touch $config_file

test -d /etc/rsyslog.d/ || mkdir /etc/rsyslog.d/
mkdir -p /etc/rsyslog.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

# Use this script to ensure the rsyslog directory structure and rsyslog conf file
# exist in the test env.
config_file=/etc/rsyslog.conf

# Ensure directory structure exists (useful for container based testing)
test -f $config_file || touch $config_file

test -d /etc/rsyslog.d/ || mkdir /etc/rsyslog.d/
mkdir -p /etc/rsyslog.d
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash

if [ ! -d /etc/rsyslog.d/ ]; then
mkdir /etc/rsyslog.d
fi
mkdir -p /etc/rsyslog.d

cat >> /etc/rsyslog.d/test.conf <<EOF
action(type="omfwd" protocol="tcp" Target="remote.system.com" port="6514" StreamDriver="gtls" StreamDriverMode="1" StreamDriverAuthMode="x509/name" streamdriver.CheckExtendedKeyPurpose="on")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash

if [ ! -d /etc/rsyslog.d/ ]; then
mkdir /etc/rsyslog.d
fi
mkdir -p /etc/rsyslog.d

cat >> /etc/rsyslog.d/test.conf <<EOF
action(type="omfwd"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
# packages = nfs-utils

mkdir -p /tmp/testdir/testdir2
mkdir /tmp/testmount
mkdir -p /tmp/testdir/testdir2 /tmp/testmount
chown 2 /tmp/testdir/testdir2
chmod 777 /tmp/testdir/testdir2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash


mkdir /test
mkdir -p /test
chown 2 /test
chmod 777 /test
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ df --local -P | awk '{if (NR!=1) print $6}' \
-exec chmod a+t {} +

# Create a new dir that has sticky bit but is not word-writable
mkdir /test_dir_1
mkdir -p /test_dir_1
chmod 1770 /test_dir_1

# Create a new dir that is word-writable but doesn't have sticky bit
mkdir /test_dir_2
mkdir -p /test_dir_2
chmod 0774 /test_dir_2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

useradd testUser

mkdir testDir
mkdir -p testDir

chown testUser testDir/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

groupadd testGrp

mkdir testDir
mkdir -p testDir

chgrp testGrp testDir/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

for TESTDIR in /bin/test_me /sbin/test_me /usr/bin/test_me /usr/sbin/test_me /usr/local/bin/test_me /usr/local/sbin/test_me
do
if [[ ! -d $TESTDIR ]]
then
mkdir $TESTDIR
fi
chown nobody.nobody $TESTDIR
mkdir -p "${TESTDIR}"
chown nobody.nobody "${TESTDIR}"
done
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

for TESTDIR in /bin/test_1 /sbin/test_1 /usr/bin/test_1 /usr/sbin/test_1 /usr/local/bin/test_1 /usr/local/sbin/test_1
do
if [[ ! -d $TESTDIR ]]
then
mkdir $TESTDIR
fi
chown nobody.nobody $TESTDIR
done

TESTDIRS=(
/bin/test_1
/sbin/test_1
/usr/bin/test_1
/usr/sbin/test_1
/usr/local/bin/test_1
/usr/local/sbin/test_1
)
mkdir -p "${TESTDIRS[@]}"
chown nobody.nobody "${TESTDIRS[@]}"
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ useradd user_test

TESTDIR="/usr/lib/dir/"

mkdir $TESTDIR
touch $TESTDIR/test_me
chown user_test $TESTDIR/test_me
mkdir -p "${TESTDIR}"
touch "${TESTDIR}"/test_me
chown user_test "${TESTDIR}"/test_me
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ chmod -R u-s,g-ws,o-wt /lib /lib64 /usr/lib /usr/lib64
# Let's setup a symlink to a directory,whose permissions are incompliant

# Directory with incorrect perms
mkdir /home/user_test/directory
mkdir -p /home/user_test/directory
chmod 0766 /home/user_test/directory

# File with correct perms
Expand Down
Loading