diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/bash/shared.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/bash/shared.sh index d233bc61dc9..b5e66f019b2 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/bash/shared.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/bash/shared.sh @@ -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 diff --git a/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_contains_only_whitespaces.fail.sh b/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_contains_only_whitespaces.fail.sh index b7ac29dd9c0..14e9084e172 100644 --- a/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_contains_only_whitespaces.fail.sh +++ b/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_contains_only_whitespaces.fail.sh @@ -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 diff --git a/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_empty.fail.sh b/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_empty.fail.sh index b610ad99a38..4e0e11f8377 100644 --- a/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_empty.fail.sh +++ b/linux_os/guide/services/usbguard/usbguard_allow_hid_and_hub/tests/file_empty.fail.sh @@ -1,6 +1,6 @@ #!/bin/bash # +mkdir -p /etc/usbguard rm -f /etc/usbguard/rules.conf -mkdir /etc/usbguard touch /etc/usbguard/rules.conf diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value.pass.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value.pass.sh index 152670b0e9f..80e51347df1 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value.pass.sh +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value.pass.sh @@ -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" diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value_multiple_dirs.pass.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value_multiple_dirs.pass.sh index 1c2e4ae38ea..a619bfb92d9 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value_multiple_dirs.pass.sh +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/correct_value_multiple_dirs.pass.sh @@ -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" diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value.fail.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value.fail.sh index e55dbed93eb..9addafe49bc 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value.fail.sh +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value.fail.sh @@ -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" diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value_multiple_dirs.fail.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value_multiple_dirs.fail.sh index 55b81ef2bae..06424b48693 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value_multiple_dirs.fail.sh +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/account_password_selinux_faillock_dir/tests/wrong_value_multiple_dirs.fail.sh @@ -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" diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/bash/shared.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/bash/shared.sh index 062dda3b8a7..a2875535c6b 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/bash/shared.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/bash/shared.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/correct.pass.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/correct.pass.sh index 68fbfb986ce..10e8f89cf4d 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/correct.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/correct.pass.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/directory_doesnt_exist.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/directory_doesnt_exist.fail.sh index c71728801fc..2cc1738ed61 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/directory_doesnt_exist.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/directory_doesnt_exist.fail.sh @@ -1,3 +1,4 @@ #!/bin/bash + rm -rf /tmp/tmp-inst echo "/tmp /tmp/tmp-inst/ level root,adm" >> /etc/security/namespace.conf diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/line_not_there.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/line_not_there.fail.sh index a79b8279aea..9f4291ce758 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/line_not_there.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/line_not_there.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/wrong_mode.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/wrong_mode.fail.sh index f825a701590..29afd460b4f 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/wrong_mode.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_tmp/tests/wrong_mode.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/bash/shared.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/bash/shared.sh index 9313059baf7..28f69bec5e5 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/bash/shared.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/bash/shared.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/correct.pass.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/correct.pass.sh index 84ece4be09e..95bc197d95d 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/correct.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/correct.pass.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/directory_doesnt_exist.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/directory_doesnt_exist.fail.sh index bd4dc539b30..c7ae9215af5 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/directory_doesnt_exist.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/directory_doesnt_exist.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/line_not_there.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/line_not_there.fail.sh index 02cca90b16b..32c3747c2ca 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/line_not_there.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/line_not_there.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/wrong_mode.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/wrong_mode.fail.sh index 4a77322eb45..8c2cf389e60 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/wrong_mode.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_polyinstantiated_var_tmp/tests/wrong_mode.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/lenient_permissions_directory.fail.sh b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/lenient_permissions_directory.fail.sh index 0e6e494b08c..d62aae1a375 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/lenient_permissions_directory.fail.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/lenient_permissions_directory.fail.sh @@ -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 diff --git a/linux_os/guide/system/accounts/accounts-session/user_umask/accounts_umask_interactive_users/tests/hidden_folder_ignored.pass.sh b/linux_os/guide/system/accounts/accounts-session/user_umask/accounts_umask_interactive_users/tests/hidden_folder_ignored.pass.sh index b9e1b7519ef..ccb7727a873 100644 --- a/linux_os/guide/system/accounts/accounts-session/user_umask/accounts_umask_interactive_users/tests/hidden_folder_ignored.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/user_umask/accounts_umask_interactive_users/tests/hidden_folder_ignored.pass.sh @@ -2,4 +2,4 @@ USER="cac_user" useradd -m $USER -mkdir /home/$USER/.hiddenfolder +mkdir -p /home/"${USER}"/.hiddenfolder diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/correct_value_log_file.pass.sh b/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/correct_value_log_file.pass.sh index b90e4df055d..3acf2098166 100644 --- a/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/correct_value_log_file.pass.sh +++ b/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/correct_value_log_file.pass.sh @@ -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 diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/wrong_value_log_file.fail.sh b/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/wrong_value_log_file.fail.sh index 0c9720de92e..6f12a3da849 100644 --- a/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/wrong_value_log_file.fail.sh +++ b/linux_os/guide/system/auditing/auditd_configure_rules/directory_group_ownership_var_log_audit/tests/wrong_value_log_file.fail.sh @@ -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 diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/directory_permissions_var_log_audit/tests/common_0700.sh b/linux_os/guide/system/auditing/auditd_configure_rules/directory_permissions_var_log_audit/tests/common_0700.sh index a9d5e0acbd6..0b23eca31cb 100644 --- a/linux_os/guide/system/auditing/auditd_configure_rules/directory_permissions_var_log_audit/tests/common_0700.sh +++ b/linux_os/guide/system/auditing/auditd_configure_rules/directory_permissions_var_log_audit/tests/common_0700.sh @@ -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}" diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/file_group_ownership_var_log_audit/tests/common.sh b/linux_os/guide/system/auditing/auditd_configure_rules/file_group_ownership_var_log_audit/tests/common.sh index dd6994e34fe..7b4e54aa251 100644 --- a/linux_os/guide/system/auditing/auditd_configure_rules/file_group_ownership_var_log_audit/tests/common.sh +++ b/linux_os/guide/system/auditing/auditd_configure_rules/file_group_ownership_var_log_audit/tests/common.sh @@ -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 diff --git a/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_error_action/tests/common.sh b/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_error_action/tests/common.sh index 7c8f80eac21..660d5343bd0 100644 --- a/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_error_action/tests/common.sh +++ b/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_error_action/tests/common.sh @@ -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 diff --git a/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_full_action/tests/common.sh b/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_full_action/tests/common.sh index 7c8f80eac21..660d5343bd0 100644 --- a/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_full_action/tests/common.sh +++ b/linux_os/guide/system/auditing/configure_auditd_data_retention/auditd_data_disk_full_action/tests/common.sh @@ -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 diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/tests/all_facilities_set_rsyslog_conf.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/tests/all_facilities_set_rsyslog_conf.pass.sh index 8e3187030b6..69383499749 100644 --- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/tests/all_facilities_set_rsyslog_conf.pass.sh +++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/tests/all_facilities_set_rsyslog_conf.pass.sh @@ -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}" diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/tests/setup.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/tests/setup.sh index 9686f16bcc9..6faecccfac4 100644 --- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/tests/setup.sh +++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/tests/setup.sh @@ -1,4 +1,5 @@ #!/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 @@ -6,4 +7,4 @@ 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 diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdrivermode/tests/setup.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdrivermode/tests/setup.sh index 9686f16bcc9..6faecccfac4 100644 --- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdrivermode/tests/setup.sh +++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdrivermode/tests/setup.sh @@ -1,4 +1,5 @@ #!/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 @@ -6,4 +7,4 @@ 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 diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/tests/setup.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/tests/setup.sh index 9686f16bcc9..6faecccfac4 100644 --- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/tests/setup.sh +++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/tests/setup.sh @@ -1,4 +1,5 @@ #!/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 @@ -6,4 +7,4 @@ 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 diff --git a/linux_os/guide/system/logging/rsyslog_sending_messages/rsyslog_remote_tls/tests/correct_singleline_include_file.pass.sh b/linux_os/guide/system/logging/rsyslog_sending_messages/rsyslog_remote_tls/tests/correct_singleline_include_file.pass.sh index 0a61610b448..10ce9ebfa22 100644 --- a/linux_os/guide/system/logging/rsyslog_sending_messages/rsyslog_remote_tls/tests/correct_singleline_include_file.pass.sh +++ b/linux_os/guide/system/logging/rsyslog_sending_messages/rsyslog_remote_tls/tests/correct_singleline_include_file.pass.sh @@ -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 <> /etc/rsyslog.d/test.conf <> /etc/sudoers chmod 440 /etc/sudoers -mkdir /etc/sudoers.d/ +mkdir -p /etc/sudoers.d echo "Defaults !authenticate" >> /etc/sudoers.d/sudoers chmod 440 /etc/sudoers.d/sudoers diff --git a/linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/wrong_value.fail.sh b/linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/wrong_value.fail.sh index 19537f9c1d3..fa821e9dc3c 100644 --- a/linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/wrong_value.fail.sh +++ b/linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/wrong_value.fail.sh @@ -3,6 +3,6 @@ echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers chmod 440 /etc/sudoers -mkdir /etc/sudoers.d/ +mkdir -p /etc/sudoers.d echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudoers chmod 440 /etc/sudoers.d/sudoers diff --git a/linux_os/guide/system/software/sudo/sudo_require_authentication/tests/wrong_value.fail.sh b/linux_os/guide/system/software/sudo/sudo_require_authentication/tests/wrong_value.fail.sh index 50d651667ab..1c2d98e824a 100644 --- a/linux_os/guide/system/software/sudo/sudo_require_authentication/tests/wrong_value.fail.sh +++ b/linux_os/guide/system/software/sudo/sudo_require_authentication/tests/wrong_value.fail.sh @@ -4,7 +4,7 @@ echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers echo "Defaults !authenticate" >> /etc/sudoers chmod 440 /etc/sudoers -mkdir /etc/sudoers.d/ +mkdir -p /etc/sudoers.d echo "%wheel ALL=(ALL) !authenticate ALL" >> /etc/sudoers.d/sudoers echo "Defaults !authenticate" >> /etc/sudoers.d/sudoers chmod 440 /etc/sudoers.d/sudoers diff --git a/shared/templates/sysctl/tests/correct_value_usr_local_lib.pass.sh b/shared/templates/sysctl/tests/correct_value_usr_local_lib.pass.sh index 19769ebae7e..e8810e1682d 100644 --- a/shared/templates/sysctl/tests/correct_value_usr_local_lib.pass.sh +++ b/shared/templates/sysctl/tests/correct_value_usr_local_lib.pass.sh @@ -8,7 +8,7 @@ rm -rf /usr/lib/sysctl.d/* /usr/local/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/* sed -i "/{{{ SYSCTLVAR }}}/d" /etc/sysctl.conf -mkdir /usr/local/lib/sysctl.d/ +mkdir -p /usr/local/lib/sysctl.d echo "{{{ SYSCTLVAR }}} = {{{ SYSCTL_CORRECT_VALUE }}}" >> /usr/local/lib/sysctl.d/correct.conf # set correct runtime value to check if the filesystem configuration is evaluated properly diff --git a/shared/templates/sysctl/tests/wrong_value_usr_local_lib.fail.sh b/shared/templates/sysctl/tests/wrong_value_usr_local_lib.fail.sh index 5b03e6c3969..2f5c5a35645 100644 --- a/shared/templates/sysctl/tests/wrong_value_usr_local_lib.fail.sh +++ b/shared/templates/sysctl/tests/wrong_value_usr_local_lib.fail.sh @@ -8,7 +8,7 @@ rm -rf /usr/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/* sed -i "/{{{ SYSCTLVAR }}}/d" /etc/sysctl.conf -mkdir /usr/local/lib/sysctl.d/ +mkdir -p /usr/local/lib/sysctl.d echo "{{{ SYSCTLVAR }}} = {{{ SYSCTL_WRONG_VALUE }}}" >> /usr/local/lib/sysctl.d/wrong.conf # Setting correct runtime value diff --git a/utils/build_profiler.sh b/utils/build_profiler.sh index 9a567cf16ec..b3aae2f631b 100755 --- a/utils/build_profiler.sh +++ b/utils/build_profiler.sh @@ -13,14 +13,12 @@ fi product_string="$1" # Create and change to .build_profiling dir -[ ! -d ".build_profiling" ] && (mkdir .build_profiling || die \ -"Creating the .build_profiling directory failed") +mkdir -p .build_profiling || die "Creating the .build_profiling directory failed" cd .build_profiling || die "Changing to the .build_profiling directory failed" # Create and change to product_string dir -[ ! -d "$product_string" ] && (mkdir "$product_string" || die \ -"Creating the $product_string directory failed") +mkdir -p "$product_string" || die "Creating the $product_string directory failed" cd "$product_string" || die "Changing to the $product_string directory failed"