diff --git a/README.md b/README.md index d65563e..f943e2f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ hardening [INFO] Treating /opt/cis-hardening/bin/hardening/13.15_check_duplicate ```console $ git clone https://github.com/ovh/debian-cis.git && cd debian-cis $ cp debian/default /etc/default/cis-hardening +$ sed -i "s#CIS_ROOT_DIR=.*#CIS_ROOT_DIR='$(pwd)'#" /etc/default/cis-hardening $ bin/hardening/1.1_install_updates.sh --audit-all 1.1_install_updates [INFO] Working on 1.1_install_updates 1.1_install_updates [INFO] Checking Configuration diff --git a/bin/hardening/1.1_install_updates.sh b/bin/hardening/1.1_install_updates.sh index 9405078..7d1d787 100755 --- a/bin/hardening/1.1_install_updates.sh +++ b/bin/hardening/1.1_install_updates.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.1.1_set_password_exp_days.sh b/bin/hardening/10.1.1_set_password_exp_days.sh index 107637b..2342724 100755 --- a/bin/hardening/10.1.1_set_password_exp_days.sh +++ b/bin/hardening/10.1.1_set_password_exp_days.sh @@ -76,11 +76,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.1.2_set_password_min_days_change.sh b/bin/hardening/10.1.2_set_password_min_days_change.sh index 3465301..f725e39 100755 --- a/bin/hardening/10.1.2_set_password_min_days_change.sh +++ b/bin/hardening/10.1.2_set_password_min_days_change.sh @@ -76,11 +76,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.1.3_set_password_exp_warning_days.sh b/bin/hardening/10.1.3_set_password_exp_warning_days.sh index b81a2c9..f6fea94 100755 --- a/bin/hardening/10.1.3_set_password_exp_warning_days.sh +++ b/bin/hardening/10.1.3_set_password_exp_warning_days.sh @@ -76,11 +76,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.2_disable_system_accounts.sh b/bin/hardening/10.2_disable_system_accounts.sh index 472ef58..d32b2d2 100755 --- a/bin/hardening/10.2_disable_system_accounts.sh +++ b/bin/hardening/10.2_disable_system_accounts.sh @@ -81,11 +81,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.3_default_root_group.sh b/bin/hardening/10.3_default_root_group.sh index e6aa07f..22da017 100755 --- a/bin/hardening/10.3_default_root_group.sh +++ b/bin/hardening/10.3_default_root_group.sh @@ -44,11 +44,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.4_default_umask.sh b/bin/hardening/10.4_default_umask.sh index 20e4078..ecef1e6 100755 --- a/bin/hardening/10.4_default_umask.sh +++ b/bin/hardening/10.4_default_umask.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/10.5_lock_inactive_user_account.sh b/bin/hardening/10.5_lock_inactive_user_account.sh index cd2b7d5..68fded9 100755 --- a/bin/hardening/10.5_lock_inactive_user_account.sh +++ b/bin/hardening/10.5_lock_inactive_user_account.sh @@ -36,11 +36,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/11.1_warning_banners.sh b/bin/hardening/11.1_warning_banners.sh index eae7e8b..8a8d208 100755 --- a/bin/hardening/11.1_warning_banners.sh +++ b/bin/hardening/11.1_warning_banners.sh @@ -70,11 +70,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/11.2_remove_os_info_warning_banners.sh b/bin/hardening/11.2_remove_os_info_warning_banners.sh index 19cfb3b..7da9b99 100755 --- a/bin/hardening/11.2_remove_os_info_warning_banners.sh +++ b/bin/hardening/11.2_remove_os_info_warning_banners.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/11.3_graphical_warning_banners.sh b/bin/hardening/11.3_graphical_warning_banners.sh index b1be64e..82d46ee 100755 --- a/bin/hardening/11.3_graphical_warning_banners.sh +++ b/bin/hardening/11.3_graphical_warning_banners.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.10_find_suid_files.sh b/bin/hardening/12.10_find_suid_files.sh index 0d73f83..d10bf7e 100755 --- a/bin/hardening/12.10_find_suid_files.sh +++ b/bin/hardening/12.10_find_suid_files.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.11_find_sgid_files.sh b/bin/hardening/12.11_find_sgid_files.sh index 15a63d1..56509e2 100755 --- a/bin/hardening/12.11_find_sgid_files.sh +++ b/bin/hardening/12.11_find_sgid_files.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.1_etc_passwd_permissions.sh b/bin/hardening/12.1_etc_passwd_permissions.sh index 6de6c9a..c18a86c 100755 --- a/bin/hardening/12.1_etc_passwd_permissions.sh +++ b/bin/hardening/12.1_etc_passwd_permissions.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.2_etc_shadow_permissions.sh b/bin/hardening/12.2_etc_shadow_permissions.sh index a290691..696a30c 100755 --- a/bin/hardening/12.2_etc_shadow_permissions.sh +++ b/bin/hardening/12.2_etc_shadow_permissions.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.3_etc_group_permissions.sh b/bin/hardening/12.3_etc_group_permissions.sh index baafaa4..2cc64e1 100755 --- a/bin/hardening/12.3_etc_group_permissions.sh +++ b/bin/hardening/12.3_etc_group_permissions.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.4_etc_passwd_ownership.sh b/bin/hardening/12.4_etc_passwd_ownership.sh index b33b7d0..0f2cf56 100755 --- a/bin/hardening/12.4_etc_passwd_ownership.sh +++ b/bin/hardening/12.4_etc_passwd_ownership.sh @@ -61,11 +61,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.5_etc_shadow_ownership.sh b/bin/hardening/12.5_etc_shadow_ownership.sh index 40c5d75..005b1d1 100755 --- a/bin/hardening/12.5_etc_shadow_ownership.sh +++ b/bin/hardening/12.5_etc_shadow_ownership.sh @@ -61,11 +61,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.6_etc_group_ownership.sh b/bin/hardening/12.6_etc_group_ownership.sh index bc7a883..50595a5 100755 --- a/bin/hardening/12.6_etc_group_ownership.sh +++ b/bin/hardening/12.6_etc_group_ownership.sh @@ -61,11 +61,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.7_find_world_writable_file.sh b/bin/hardening/12.7_find_world_writable_file.sh index c63f0c3..33fd01c 100755 --- a/bin/hardening/12.7_find_world_writable_file.sh +++ b/bin/hardening/12.7_find_world_writable_file.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.8_find_unowned_files.sh b/bin/hardening/12.8_find_unowned_files.sh index 616ec77..d81289b 100755 --- a/bin/hardening/12.8_find_unowned_files.sh +++ b/bin/hardening/12.8_find_unowned_files.sh @@ -49,11 +49,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/12.9_find_ungrouped_files.sh b/bin/hardening/12.9_find_ungrouped_files.sh index 1e79e33..7a6cf14 100755 --- a/bin/hardening/12.9_find_ungrouped_files.sh +++ b/bin/hardening/12.9_find_ungrouped_files.sh @@ -49,11 +49,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.10_find_user_rhosts_files.sh b/bin/hardening/13.10_find_user_rhosts_files.sh index 6e16d71..0445ece 100755 --- a/bin/hardening/13.10_find_user_rhosts_files.sh +++ b/bin/hardening/13.10_find_user_rhosts_files.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.11_find_passwd_group_inconsistencies.sh b/bin/hardening/13.11_find_passwd_group_inconsistencies.sh index 6acdffb..218f244 100755 --- a/bin/hardening/13.11_find_passwd_group_inconsistencies.sh +++ b/bin/hardening/13.11_find_passwd_group_inconsistencies.sh @@ -45,11 +45,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.12_users_valid_homedir.sh b/bin/hardening/13.12_users_valid_homedir.sh index 7ecf4dd..4bf627c 100755 --- a/bin/hardening/13.12_users_valid_homedir.sh +++ b/bin/hardening/13.12_users_valid_homedir.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.13_check_user_homedir_ownership.sh b/bin/hardening/13.13_check_user_homedir_ownership.sh index e87f605..10bb7cd 100755 --- a/bin/hardening/13.13_check_user_homedir_ownership.sh +++ b/bin/hardening/13.13_check_user_homedir_ownership.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.14_check_duplicate_uid.sh b/bin/hardening/13.14_check_duplicate_uid.sh index 2fdeaad..e67b35f 100755 --- a/bin/hardening/13.14_check_duplicate_uid.sh +++ b/bin/hardening/13.14_check_duplicate_uid.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.15_check_duplicate_gid.sh b/bin/hardening/13.15_check_duplicate_gid.sh index 0c1b3fa..24a72b4 100755 --- a/bin/hardening/13.15_check_duplicate_gid.sh +++ b/bin/hardening/13.15_check_duplicate_gid.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.16_check_duplicate_username.sh b/bin/hardening/13.16_check_duplicate_username.sh index e29d516..c0a336e 100755 --- a/bin/hardening/13.16_check_duplicate_username.sh +++ b/bin/hardening/13.16_check_duplicate_username.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.17_check_duplicate_groupname.sh b/bin/hardening/13.17_check_duplicate_groupname.sh index fecb922..9228b47 100755 --- a/bin/hardening/13.17_check_duplicate_groupname.sh +++ b/bin/hardening/13.17_check_duplicate_groupname.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.18_find_user_netrc_files.sh b/bin/hardening/13.18_find_user_netrc_files.sh index cf9c63a..9a2063a 100755 --- a/bin/hardening/13.18_find_user_netrc_files.sh +++ b/bin/hardening/13.18_find_user_netrc_files.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.19_find_user_forward_files.sh b/bin/hardening/13.19_find_user_forward_files.sh index c3f262d..02324e1 100755 --- a/bin/hardening/13.19_find_user_forward_files.sh +++ b/bin/hardening/13.19_find_user_forward_files.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.1_remove_empty_password_field.sh b/bin/hardening/13.1_remove_empty_password_field.sh index bcf614b..d953a81 100755 --- a/bin/hardening/13.1_remove_empty_password_field.sh +++ b/bin/hardening/13.1_remove_empty_password_field.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.20_shadow_group_empty.sh b/bin/hardening/13.20_shadow_group_empty.sh index 19573b5..6935b33 100755 --- a/bin/hardening/13.20_shadow_group_empty.sh +++ b/bin/hardening/13.20_shadow_group_empty.sh @@ -57,11 +57,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.2_remove_legacy_passwd_entries.sh b/bin/hardening/13.2_remove_legacy_passwd_entries.sh index 4924934..29b878a 100755 --- a/bin/hardening/13.2_remove_legacy_passwd_entries.sh +++ b/bin/hardening/13.2_remove_legacy_passwd_entries.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.3_remove_legacy_shadow_entries.sh b/bin/hardening/13.3_remove_legacy_shadow_entries.sh index 2e88888..1c962b0 100755 --- a/bin/hardening/13.3_remove_legacy_shadow_entries.sh +++ b/bin/hardening/13.3_remove_legacy_shadow_entries.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.4_remove_legacy_group_entries.sh b/bin/hardening/13.4_remove_legacy_group_entries.sh index 13323ce..bea35d4 100755 --- a/bin/hardening/13.4_remove_legacy_group_entries.sh +++ b/bin/hardening/13.4_remove_legacy_group_entries.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.5_find_0_uid_non_root_account.sh b/bin/hardening/13.5_find_0_uid_non_root_account.sh index 2e3aee6..b5c7d34 100755 --- a/bin/hardening/13.5_find_0_uid_non_root_account.sh +++ b/bin/hardening/13.5_find_0_uid_non_root_account.sh @@ -55,11 +55,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.6_sanitize_root_path.sh b/bin/hardening/13.6_sanitize_root_path.sh index d2da9fa..3d0e6b3 100755 --- a/bin/hardening/13.6_sanitize_root_path.sh +++ b/bin/hardening/13.6_sanitize_root_path.sh @@ -74,11 +74,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.7_check_user_dir_perm.sh b/bin/hardening/13.7_check_user_dir_perm.sh index 1132a65..5a6502f 100755 --- a/bin/hardening/13.7_check_user_dir_perm.sh +++ b/bin/hardening/13.7_check_user_dir_perm.sh @@ -99,11 +99,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.8_check_user_dot_file_perm.sh b/bin/hardening/13.8_check_user_dot_file_perm.sh index 92eadc9..6d99d38 100755 --- a/bin/hardening/13.8_check_user_dot_file_perm.sh +++ b/bin/hardening/13.8_check_user_dot_file_perm.sh @@ -67,11 +67,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/13.9_set_perm_on_user_netrc.sh b/bin/hardening/13.9_set_perm_on_user_netrc.sh index 8c05416..bf8fdf2 100755 --- a/bin/hardening/13.9_set_perm_on_user_netrc.sh +++ b/bin/hardening/13.9_set_perm_on_user_netrc.sh @@ -66,11 +66,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.10_home_nodev.sh b/bin/hardening/2.10_home_nodev.sh index 5459d3f..b790f9b 100755 --- a/bin/hardening/2.10_home_nodev.sh +++ b/bin/hardening/2.10_home_nodev.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.11_removable_device_nodev.sh b/bin/hardening/2.11_removable_device_nodev.sh index 0057d89..39c657a 100755 --- a/bin/hardening/2.11_removable_device_nodev.sh +++ b/bin/hardening/2.11_removable_device_nodev.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.12_removable_device_noexec.sh b/bin/hardening/2.12_removable_device_noexec.sh index 91a69d5..223d0ea 100755 --- a/bin/hardening/2.12_removable_device_noexec.sh +++ b/bin/hardening/2.12_removable_device_noexec.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.13_removable_device_nosuid.sh b/bin/hardening/2.13_removable_device_nosuid.sh index 541904b..6ba8cb0 100755 --- a/bin/hardening/2.13_removable_device_nosuid.sh +++ b/bin/hardening/2.13_removable_device_nosuid.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.14_run_shm_nodev.sh b/bin/hardening/2.14_run_shm_nodev.sh index 7d1ad62..9146ec6 100755 --- a/bin/hardening/2.14_run_shm_nodev.sh +++ b/bin/hardening/2.14_run_shm_nodev.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.15_run_shm_nosuid.sh b/bin/hardening/2.15_run_shm_nosuid.sh index 5d91ae7..c836f60 100755 --- a/bin/hardening/2.15_run_shm_nosuid.sh +++ b/bin/hardening/2.15_run_shm_nosuid.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.16_run_shm_noexec.sh b/bin/hardening/2.16_run_shm_noexec.sh index 2e2b3cb..91eac39 100755 --- a/bin/hardening/2.16_run_shm_noexec.sh +++ b/bin/hardening/2.16_run_shm_noexec.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.17_sticky_bit_world_writable_folder.sh b/bin/hardening/2.17_sticky_bit_world_writable_folder.sh index 2785ae5..f722705 100755 --- a/bin/hardening/2.17_sticky_bit_world_writable_folder.sh +++ b/bin/hardening/2.17_sticky_bit_world_writable_folder.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.18_disable_cramfs.sh b/bin/hardening/2.18_disable_cramfs.sh index a18f109..652f7ad 100755 --- a/bin/hardening/2.18_disable_cramfs.sh +++ b/bin/hardening/2.18_disable_cramfs.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.19_disable_freevxfs.sh b/bin/hardening/2.19_disable_freevxfs.sh index a3d222a..a4834c0 100755 --- a/bin/hardening/2.19_disable_freevxfs.sh +++ b/bin/hardening/2.19_disable_freevxfs.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.1_tmp_partition.sh b/bin/hardening/2.1_tmp_partition.sh index cc7e475..903d9f3 100755 --- a/bin/hardening/2.1_tmp_partition.sh +++ b/bin/hardening/2.1_tmp_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.20_disable_jffs2.sh b/bin/hardening/2.20_disable_jffs2.sh index 98fb2d5..fa0eb38 100755 --- a/bin/hardening/2.20_disable_jffs2.sh +++ b/bin/hardening/2.20_disable_jffs2.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.21_disable_hfs.sh b/bin/hardening/2.21_disable_hfs.sh index abedc00..7211d75 100755 --- a/bin/hardening/2.21_disable_hfs.sh +++ b/bin/hardening/2.21_disable_hfs.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.22_disable_hfsplus.sh b/bin/hardening/2.22_disable_hfsplus.sh index 9d04eb5..11d3ba4 100755 --- a/bin/hardening/2.22_disable_hfsplus.sh +++ b/bin/hardening/2.22_disable_hfsplus.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.23_disable_squashfs.sh b/bin/hardening/2.23_disable_squashfs.sh index f6444f4..1543a96 100755 --- a/bin/hardening/2.23_disable_squashfs.sh +++ b/bin/hardening/2.23_disable_squashfs.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.24_disable_udf.sh b/bin/hardening/2.24_disable_udf.sh index 605430b..c4ea480 100755 --- a/bin/hardening/2.24_disable_udf.sh +++ b/bin/hardening/2.24_disable_udf.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.25_disable_automounting.sh b/bin/hardening/2.25_disable_automounting.sh index 2b2f42b..8414662 100755 --- a/bin/hardening/2.25_disable_automounting.sh +++ b/bin/hardening/2.25_disable_automounting.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.2_tmp_nodev.sh b/bin/hardening/2.2_tmp_nodev.sh index 7a7fc90..2609eae 100755 --- a/bin/hardening/2.2_tmp_nodev.sh +++ b/bin/hardening/2.2_tmp_nodev.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.3_tmp_nosuid.sh b/bin/hardening/2.3_tmp_nosuid.sh index 4e5bc4e..7f7b024 100755 --- a/bin/hardening/2.3_tmp_nosuid.sh +++ b/bin/hardening/2.3_tmp_nosuid.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.4_tmp_noexec.sh b/bin/hardening/2.4_tmp_noexec.sh index 7b2cc65..5920b08 100755 --- a/bin/hardening/2.4_tmp_noexec.sh +++ b/bin/hardening/2.4_tmp_noexec.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.5_var_partition.sh b/bin/hardening/2.5_var_partition.sh index 7f565f4..a462a4e 100755 --- a/bin/hardening/2.5_var_partition.sh +++ b/bin/hardening/2.5_var_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.6.1_var_tmp_partition.sh b/bin/hardening/2.6.1_var_tmp_partition.sh index 422b35a..a4c15c7 100755 --- a/bin/hardening/2.6.1_var_tmp_partition.sh +++ b/bin/hardening/2.6.1_var_tmp_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.6.2_var_tmp_nodev.sh b/bin/hardening/2.6.2_var_tmp_nodev.sh index 41d0aca..5e36bf9 100755 --- a/bin/hardening/2.6.2_var_tmp_nodev.sh +++ b/bin/hardening/2.6.2_var_tmp_nodev.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.6.3_var_tmp_nosuid.sh b/bin/hardening/2.6.3_var_tmp_nosuid.sh index e9a8132..ef60002 100755 --- a/bin/hardening/2.6.3_var_tmp_nosuid.sh +++ b/bin/hardening/2.6.3_var_tmp_nosuid.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.6.4_var_tmp_noexec.sh b/bin/hardening/2.6.4_var_tmp_noexec.sh index 6cde5aa..f3e0d61 100755 --- a/bin/hardening/2.6.4_var_tmp_noexec.sh +++ b/bin/hardening/2.6.4_var_tmp_noexec.sh @@ -71,11 +71,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.7_var_log_partition.sh b/bin/hardening/2.7_var_log_partition.sh index 2951000..c6a7e37 100755 --- a/bin/hardening/2.7_var_log_partition.sh +++ b/bin/hardening/2.7_var_log_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.8_var_log_audit_partition.sh b/bin/hardening/2.8_var_log_audit_partition.sh index 7a79c5b..8e20d06 100755 --- a/bin/hardening/2.8_var_log_audit_partition.sh +++ b/bin/hardening/2.8_var_log_audit_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/2.9_home_partition.sh b/bin/hardening/2.9_home_partition.sh index a3b5930..ed0dedf 100755 --- a/bin/hardening/2.9_home_partition.sh +++ b/bin/hardening/2.9_home_partition.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/3.1_bootloader_ownership.sh b/bin/hardening/3.1_bootloader_ownership.sh index 8ad6485..d8d71b6 100755 --- a/bin/hardening/3.1_bootloader_ownership.sh +++ b/bin/hardening/3.1_bootloader_ownership.sh @@ -69,11 +69,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/3.2_bootloader_permissions.sh b/bin/hardening/3.2_bootloader_permissions.sh index 6504242..b3db481 100755 --- a/bin/hardening/3.2_bootloader_permissions.sh +++ b/bin/hardening/3.2_bootloader_permissions.sh @@ -56,11 +56,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/3.3_bootloader_password.sh b/bin/hardening/3.3_bootloader_password.sh index 63c4983..6dd9ff6 100755 --- a/bin/hardening/3.3_bootloader_password.sh +++ b/bin/hardening/3.3_bootloader_password.sh @@ -67,11 +67,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/3.4_root_password.sh b/bin/hardening/3.4_root_password.sh index 498818b..38ea68e 100755 --- a/bin/hardening/3.4_root_password.sh +++ b/bin/hardening/3.4_root_password.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/4.1_restrict_core_dumps.sh b/bin/hardening/4.1_restrict_core_dumps.sh index 5975f54..f08100d 100755 --- a/bin/hardening/4.1_restrict_core_dumps.sh +++ b/bin/hardening/4.1_restrict_core_dumps.sh @@ -66,11 +66,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/4.2_enable_nx_support.sh b/bin/hardening/4.2_enable_nx_support.sh index 30b484a..356899c 100755 --- a/bin/hardening/4.2_enable_nx_support.sh +++ b/bin/hardening/4.2_enable_nx_support.sh @@ -44,11 +44,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/4.3_enable_randomized_vm_placement.sh b/bin/hardening/4.3_enable_randomized_vm_placement.sh index 4a373c9..e69c09a 100755 --- a/bin/hardening/4.3_enable_randomized_vm_placement.sh +++ b/bin/hardening/4.3_enable_randomized_vm_placement.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/4.4_disable_prelink.sh b/bin/hardening/4.4_disable_prelink.sh index c8eb21a..75b44b0 100755 --- a/bin/hardening/4.4_disable_prelink.sh +++ b/bin/hardening/4.4_disable_prelink.sh @@ -49,11 +49,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/4.5_enable_apparmor.sh b/bin/hardening/4.5_enable_apparmor.sh index f735392..c1f6f8c 100755 --- a/bin/hardening/4.5_enable_apparmor.sh +++ b/bin/hardening/4.5_enable_apparmor.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.1_disable_nis.sh b/bin/hardening/5.1.1_disable_nis.sh index bddf22d..0b23e81 100755 --- a/bin/hardening/5.1.1_disable_nis.sh +++ b/bin/hardening/5.1.1_disable_nis.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.2_disable_rsh.sh b/bin/hardening/5.1.2_disable_rsh.sh index bd7a380..0462494 100755 --- a/bin/hardening/5.1.2_disable_rsh.sh +++ b/bin/hardening/5.1.2_disable_rsh.sh @@ -79,11 +79,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.3_disable_rsh_client.sh b/bin/hardening/5.1.3_disable_rsh_client.sh index 3a83a31..43421ac 100755 --- a/bin/hardening/5.1.3_disable_rsh_client.sh +++ b/bin/hardening/5.1.3_disable_rsh_client.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.4_disable_talk.sh b/bin/hardening/5.1.4_disable_talk.sh index 3a91b67..d15fc0a 100755 --- a/bin/hardening/5.1.4_disable_talk.sh +++ b/bin/hardening/5.1.4_disable_talk.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.5_disable_talk_client.sh b/bin/hardening/5.1.5_disable_talk_client.sh index db637b8..ec40852 100755 --- a/bin/hardening/5.1.5_disable_talk_client.sh +++ b/bin/hardening/5.1.5_disable_talk_client.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.6_disable_telnet_server.sh b/bin/hardening/5.1.6_disable_telnet_server.sh index 9289a98..1b7554e 100755 --- a/bin/hardening/5.1.6_disable_telnet_server.sh +++ b/bin/hardening/5.1.6_disable_telnet_server.sh @@ -79,11 +79,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.7_disable_tftp_server.sh b/bin/hardening/5.1.7_disable_tftp_server.sh index 26932eb..ee8b791 100755 --- a/bin/hardening/5.1.7_disable_tftp_server.sh +++ b/bin/hardening/5.1.7_disable_tftp_server.sh @@ -79,11 +79,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.1.8_disable_inetd.sh b/bin/hardening/5.1.8_disable_inetd.sh index 95b2f96..76c9c59 100755 --- a/bin/hardening/5.1.8_disable_inetd.sh +++ b/bin/hardening/5.1.8_disable_inetd.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.2_disable_chargen.sh b/bin/hardening/5.2_disable_chargen.sh index 7408d6c..91299ed 100755 --- a/bin/hardening/5.2_disable_chargen.sh +++ b/bin/hardening/5.2_disable_chargen.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.3_disable_daytime.sh b/bin/hardening/5.3_disable_daytime.sh index 77821ee..4c9e0d0 100755 --- a/bin/hardening/5.3_disable_daytime.sh +++ b/bin/hardening/5.3_disable_daytime.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.4_disable_echo.sh b/bin/hardening/5.4_disable_echo.sh index e38b4cf..22cdd01 100755 --- a/bin/hardening/5.4_disable_echo.sh +++ b/bin/hardening/5.4_disable_echo.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.5_disable_discard.sh b/bin/hardening/5.5_disable_discard.sh index 8807aba..0b56853 100755 --- a/bin/hardening/5.5_disable_discard.sh +++ b/bin/hardening/5.5_disable_discard.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/5.6_disable_time.sh b/bin/hardening/5.6_disable_time.sh index aa7be28..539229d 100755 --- a/bin/hardening/5.6_disable_time.sh +++ b/bin/hardening/5.6_disable_time.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.10_disable_http_server.sh b/bin/hardening/6.10_disable_http_server.sh index c9f1cc9..6338041 100755 --- a/bin/hardening/6.10_disable_http_server.sh +++ b/bin/hardening/6.10_disable_http_server.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.11_disable_imap_pop.sh b/bin/hardening/6.11_disable_imap_pop.sh index 414283a..32aeb15 100755 --- a/bin/hardening/6.11_disable_imap_pop.sh +++ b/bin/hardening/6.11_disable_imap_pop.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.12_disable_samba.sh b/bin/hardening/6.12_disable_samba.sh index c89793b..8242ead 100755 --- a/bin/hardening/6.12_disable_samba.sh +++ b/bin/hardening/6.12_disable_samba.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.13_disable_http_proxy.sh b/bin/hardening/6.13_disable_http_proxy.sh index b7c00cc..ccce332 100755 --- a/bin/hardening/6.13_disable_http_proxy.sh +++ b/bin/hardening/6.13_disable_http_proxy.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.14_disable_snmp_server.sh b/bin/hardening/6.14_disable_snmp_server.sh index fa6a144..8ff8ae1 100755 --- a/bin/hardening/6.14_disable_snmp_server.sh +++ b/bin/hardening/6.14_disable_snmp_server.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.15_mta_localhost.sh b/bin/hardening/6.15_mta_localhost.sh index 9404650..033c6e1 100755 --- a/bin/hardening/6.15_mta_localhost.sh +++ b/bin/hardening/6.15_mta_localhost.sh @@ -57,11 +57,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.16_disable_rsync.sh b/bin/hardening/6.16_disable_rsync.sh index 95ad6d5..d5a4725 100755 --- a/bin/hardening/6.16_disable_rsync.sh +++ b/bin/hardening/6.16_disable_rsync.sh @@ -61,11 +61,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.1_disable_xwindow_system.sh b/bin/hardening/6.1_disable_xwindow_system.sh index 3bec993..ef67426 100755 --- a/bin/hardening/6.1_disable_xwindow_system.sh +++ b/bin/hardening/6.1_disable_xwindow_system.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.2_disable_avahi_server.sh b/bin/hardening/6.2_disable_avahi_server.sh index 232a0f1..53aa108 100755 --- a/bin/hardening/6.2_disable_avahi_server.sh +++ b/bin/hardening/6.2_disable_avahi_server.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.3_disable_print_server.sh b/bin/hardening/6.3_disable_print_server.sh index 0d55e7f..b261710 100755 --- a/bin/hardening/6.3_disable_print_server.sh +++ b/bin/hardening/6.3_disable_print_server.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.4_disable_dhcp.sh b/bin/hardening/6.4_disable_dhcp.sh index 848df33..ed62bf8 100755 --- a/bin/hardening/6.4_disable_dhcp.sh +++ b/bin/hardening/6.4_disable_dhcp.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.5_configure_ntp.sh b/bin/hardening/6.5_configure_ntp.sh index 67bed3d..cd60359 100755 --- a/bin/hardening/6.5_configure_ntp.sh +++ b/bin/hardening/6.5_configure_ntp.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.6_disable_ldap.sh b/bin/hardening/6.6_disable_ldap.sh index c2a337d..2977204 100755 --- a/bin/hardening/6.6_disable_ldap.sh +++ b/bin/hardening/6.6_disable_ldap.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.7_disable_nfs_rpc.sh b/bin/hardening/6.7_disable_nfs_rpc.sh index a318aa8..f4c4d71 100755 --- a/bin/hardening/6.7_disable_nfs_rpc.sh +++ b/bin/hardening/6.7_disable_nfs_rpc.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.8_disable_dns_server.sh b/bin/hardening/6.8_disable_dns_server.sh index 2acdbd9..d35a2a4 100755 --- a/bin/hardening/6.8_disable_dns_server.sh +++ b/bin/hardening/6.8_disable_dns_server.sh @@ -50,11 +50,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/6.9_disable_ftp.sh b/bin/hardening/6.9_disable_ftp.sh index c9ea292..38bd717 100755 --- a/bin/hardening/6.9_disable_ftp.sh +++ b/bin/hardening/6.9_disable_ftp.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.1.1_disable_ip_forwarding.sh b/bin/hardening/7.1.1_disable_ip_forwarding.sh index 48611f9..c848399 100755 --- a/bin/hardening/7.1.1_disable_ip_forwarding.sh +++ b/bin/hardening/7.1.1_disable_ip_forwarding.sh @@ -51,11 +51,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.1.2_disable_send_packet_redirects.sh b/bin/hardening/7.1.2_disable_send_packet_redirects.sh index 54364a1..3de64d0 100755 --- a/bin/hardening/7.1.2_disable_send_packet_redirects.sh +++ b/bin/hardening/7.1.2_disable_send_packet_redirects.sh @@ -61,11 +61,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.1_disable_source_routed_packets.sh b/bin/hardening/7.2.1_disable_source_routed_packets.sh index b057a2c..f11790a 100755 --- a/bin/hardening/7.2.1_disable_source_routed_packets.sh +++ b/bin/hardening/7.2.1_disable_source_routed_packets.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.2_disable_icmp_redirect.sh b/bin/hardening/7.2.2_disable_icmp_redirect.sh index 1a8a193..c3468f1 100755 --- a/bin/hardening/7.2.2_disable_icmp_redirect.sh +++ b/bin/hardening/7.2.2_disable_icmp_redirect.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.3_disable_secure_icmp_redirect.sh b/bin/hardening/7.2.3_disable_secure_icmp_redirect.sh index 5ce550f..2b0f8b0 100755 --- a/bin/hardening/7.2.3_disable_secure_icmp_redirect.sh +++ b/bin/hardening/7.2.3_disable_secure_icmp_redirect.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.4_log_martian_packets.sh b/bin/hardening/7.2.4_log_martian_packets.sh index 4f56bb8..d779685 100755 --- a/bin/hardening/7.2.4_log_martian_packets.sh +++ b/bin/hardening/7.2.4_log_martian_packets.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.5_ignore_broadcast_requests.sh b/bin/hardening/7.2.5_ignore_broadcast_requests.sh index 2dbf1dd..84e1317 100755 --- a/bin/hardening/7.2.5_ignore_broadcast_requests.sh +++ b/bin/hardening/7.2.5_ignore_broadcast_requests.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.6_enable_bad_error_message_protection.sh b/bin/hardening/7.2.6_enable_bad_error_message_protection.sh index f03bec1..6864d86 100755 --- a/bin/hardening/7.2.6_enable_bad_error_message_protection.sh +++ b/bin/hardening/7.2.6_enable_bad_error_message_protection.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.7_enable_source_route_validation.sh b/bin/hardening/7.2.7_enable_source_route_validation.sh index 5c80650..62703b7 100755 --- a/bin/hardening/7.2.7_enable_source_route_validation.sh +++ b/bin/hardening/7.2.7_enable_source_route_validation.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.2.8_enable_tcp_syn_cookies.sh b/bin/hardening/7.2.8_enable_tcp_syn_cookies.sh index 1e3c13b..d755cdd 100755 --- a/bin/hardening/7.2.8_enable_tcp_syn_cookies.sh +++ b/bin/hardening/7.2.8_enable_tcp_syn_cookies.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.3.1_disable_ipv6_router_advertisement.sh b/bin/hardening/7.3.1_disable_ipv6_router_advertisement.sh index 63e5a04..85a5354 100755 --- a/bin/hardening/7.3.1_disable_ipv6_router_advertisement.sh +++ b/bin/hardening/7.3.1_disable_ipv6_router_advertisement.sh @@ -70,11 +70,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.3.2_disable_ipv6_redirect.sh b/bin/hardening/7.3.2_disable_ipv6_redirect.sh index 16cc84b..05d9962 100755 --- a/bin/hardening/7.3.2_disable_ipv6_redirect.sh +++ b/bin/hardening/7.3.2_disable_ipv6_redirect.sh @@ -70,11 +70,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.3.3_disable_ipv6.sh b/bin/hardening/7.3.3_disable_ipv6.sh index 86c823b..c9af25e 100755 --- a/bin/hardening/7.3.3_disable_ipv6.sh +++ b/bin/hardening/7.3.3_disable_ipv6.sh @@ -70,11 +70,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.4.1_install_tcp_wrapper.sh b/bin/hardening/7.4.1_install_tcp_wrapper.sh index adabcf6..be67662 100755 --- a/bin/hardening/7.4.1_install_tcp_wrapper.sh +++ b/bin/hardening/7.4.1_install_tcp_wrapper.sh @@ -45,11 +45,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.4.2_hosts_allow.sh b/bin/hardening/7.4.2_hosts_allow.sh index c6a13ae..8e944ba 100755 --- a/bin/hardening/7.4.2_hosts_allow.sh +++ b/bin/hardening/7.4.2_hosts_allow.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.4.3_hosts_allow_permissions.sh b/bin/hardening/7.4.3_hosts_allow_permissions.sh index 381f5a7..dedc7fb 100755 --- a/bin/hardening/7.4.3_hosts_allow_permissions.sh +++ b/bin/hardening/7.4.3_hosts_allow_permissions.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.4.4_hosts_deny.sh b/bin/hardening/7.4.4_hosts_deny.sh index f2649bb..f7a7a07 100755 --- a/bin/hardening/7.4.4_hosts_deny.sh +++ b/bin/hardening/7.4.4_hosts_deny.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.4.5_hosts_deny_permissions.sh b/bin/hardening/7.4.5_hosts_deny_permissions.sh index 9930f56..faf2d93 100755 --- a/bin/hardening/7.4.5_hosts_deny_permissions.sh +++ b/bin/hardening/7.4.5_hosts_deny_permissions.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.5.1_disable_dccp.sh b/bin/hardening/7.5.1_disable_dccp.sh index e997418..deb690b 100755 --- a/bin/hardening/7.5.1_disable_dccp.sh +++ b/bin/hardening/7.5.1_disable_dccp.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.5.2_disable_sctp.sh b/bin/hardening/7.5.2_disable_sctp.sh index 490d430..817f726 100755 --- a/bin/hardening/7.5.2_disable_sctp.sh +++ b/bin/hardening/7.5.2_disable_sctp.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.5.3_disable_rds.sh b/bin/hardening/7.5.3_disable_rds.sh index a8901ee..4e6ebe2 100755 --- a/bin/hardening/7.5.3_disable_rds.sh +++ b/bin/hardening/7.5.3_disable_rds.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.5.4_disable_tipc.sh b/bin/hardening/7.5.4_disable_tipc.sh index f55b540..963f040 100755 --- a/bin/hardening/7.5.4_disable_tipc.sh +++ b/bin/hardening/7.5.4_disable_tipc.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.6_disable_wireless.sh b/bin/hardening/7.6_disable_wireless.sh index a88dc83..def2d34 100755 --- a/bin/hardening/7.6_disable_wireless.sh +++ b/bin/hardening/7.6_disable_wireless.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/7.7_enable_firewall.sh b/bin/hardening/7.7_enable_firewall.sh index 28c0033..7517ff9 100755 --- a/bin/hardening/7.7_enable_firewall.sh +++ b/bin/hardening/7.7_enable_firewall.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.0_enable_auditd_kernel.sh b/bin/hardening/8.0_enable_auditd_kernel.sh index 8f9c443..79e7767 100755 --- a/bin/hardening/8.0_enable_auditd_kernel.sh +++ b/bin/hardening/8.0_enable_auditd_kernel.sh @@ -49,11 +49,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.1.1_audit_log_storage.sh b/bin/hardening/8.1.1.1_audit_log_storage.sh index 0211d8e..cda0d96 100755 --- a/bin/hardening/8.1.1.1_audit_log_storage.sh +++ b/bin/hardening/8.1.1.1_audit_log_storage.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.1.2_halt_when_audit_log_full.sh b/bin/hardening/8.1.1.2_halt_when_audit_log_full.sh index 915dec0..1ae0a70 100755 --- a/bin/hardening/8.1.1.2_halt_when_audit_log_full.sh +++ b/bin/hardening/8.1.1.2_halt_when_audit_log_full.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.1.3_keep_all_audit_logs.sh b/bin/hardening/8.1.1.3_keep_all_audit_logs.sh index 18d7d3d..475b549 100755 --- a/bin/hardening/8.1.1.3_keep_all_audit_logs.sh +++ b/bin/hardening/8.1.1.3_keep_all_audit_logs.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.10_record_dac_edit.sh b/bin/hardening/8.1.10_record_dac_edit.sh index f28b9b4..ffa8b2e 100755 --- a/bin/hardening/8.1.10_record_dac_edit.sh +++ b/bin/hardening/8.1.10_record_dac_edit.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.11_record_failed_access_file.sh b/bin/hardening/8.1.11_record_failed_access_file.sh index 1bd9d8b..1e81ec5 100755 --- a/bin/hardening/8.1.11_record_failed_access_file.sh +++ b/bin/hardening/8.1.11_record_failed_access_file.sh @@ -58,11 +58,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.12_record_privileged_commands.sh b/bin/hardening/8.1.12_record_privileged_commands.sh index 6788870..3888f9b 100755 --- a/bin/hardening/8.1.12_record_privileged_commands.sh +++ b/bin/hardening/8.1.12_record_privileged_commands.sh @@ -58,11 +58,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.13_record_successful_mount.sh b/bin/hardening/8.1.13_record_successful_mount.sh index 37a19fa..9efa734 100755 --- a/bin/hardening/8.1.13_record_successful_mount.sh +++ b/bin/hardening/8.1.13_record_successful_mount.sh @@ -56,11 +56,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.14_record_file_deletions.sh b/bin/hardening/8.1.14_record_file_deletions.sh index c6c00ee..31fb0ef 100755 --- a/bin/hardening/8.1.14_record_file_deletions.sh +++ b/bin/hardening/8.1.14_record_file_deletions.sh @@ -56,11 +56,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.15_record_sudoers_edit.sh b/bin/hardening/8.1.15_record_sudoers_edit.sh index 24a42fb..6498a66 100755 --- a/bin/hardening/8.1.15_record_sudoers_edit.sh +++ b/bin/hardening/8.1.15_record_sudoers_edit.sh @@ -56,11 +56,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.16_record_sudo_usage.sh b/bin/hardening/8.1.16_record_sudo_usage.sh index 7a71f2f..c42b74b 100755 --- a/bin/hardening/8.1.16_record_sudo_usage.sh +++ b/bin/hardening/8.1.16_record_sudo_usage.sh @@ -55,11 +55,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.17_record_kernel_modules.sh b/bin/hardening/8.1.17_record_kernel_modules.sh index 5ebf25e..ee524fb 100755 --- a/bin/hardening/8.1.17_record_kernel_modules.sh +++ b/bin/hardening/8.1.17_record_kernel_modules.sh @@ -58,11 +58,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.18_freeze_auditd_conf.sh b/bin/hardening/8.1.18_freeze_auditd_conf.sh index 956885f..2c29902 100755 --- a/bin/hardening/8.1.18_freeze_auditd_conf.sh +++ b/bin/hardening/8.1.18_freeze_auditd_conf.sh @@ -55,11 +55,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.2_enable_auditd.sh b/bin/hardening/8.1.2_enable_auditd.sh index 66ed321..8d63c7f 100755 --- a/bin/hardening/8.1.2_enable_auditd.sh +++ b/bin/hardening/8.1.2_enable_auditd.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.3_audit_bootloader.sh b/bin/hardening/8.1.3_audit_bootloader.sh index a47fec4..fa21932 100755 --- a/bin/hardening/8.1.3_audit_bootloader.sh +++ b/bin/hardening/8.1.3_audit_bootloader.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.4_record_date_time_edit.sh b/bin/hardening/8.1.4_record_date_time_edit.sh index 4483911..af4625d 100755 --- a/bin/hardening/8.1.4_record_date_time_edit.sh +++ b/bin/hardening/8.1.4_record_date_time_edit.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.5_record_user_group_edit.sh b/bin/hardening/8.1.5_record_user_group_edit.sh index 57c2d02..46b0698 100755 --- a/bin/hardening/8.1.5_record_user_group_edit.sh +++ b/bin/hardening/8.1.5_record_user_group_edit.sh @@ -59,11 +59,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.6_record_network_edit.sh b/bin/hardening/8.1.6_record_network_edit.sh index fefed01..6589d33 100755 --- a/bin/hardening/8.1.6_record_network_edit.sh +++ b/bin/hardening/8.1.6_record_network_edit.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.7_record_mac_edit.sh b/bin/hardening/8.1.7_record_mac_edit.sh index 7a271fa..71a6a1b 100755 --- a/bin/hardening/8.1.7_record_mac_edit.sh +++ b/bin/hardening/8.1.7_record_mac_edit.sh @@ -55,11 +55,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.8_record_login_logout.sh b/bin/hardening/8.1.8_record_login_logout.sh index 75fe87a..e64e425 100755 --- a/bin/hardening/8.1.8_record_login_logout.sh +++ b/bin/hardening/8.1.8_record_login_logout.sh @@ -57,11 +57,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.1.9_record_session_init.sh b/bin/hardening/8.1.9_record_session_init.sh index 45016c2..81281e8 100755 --- a/bin/hardening/8.1.9_record_session_init.sh +++ b/bin/hardening/8.1.9_record_session_init.sh @@ -57,11 +57,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.1_install_syslog-ng.sh b/bin/hardening/8.2.1_install_syslog-ng.sh index 61c9c0a..26e270e 100755 --- a/bin/hardening/8.2.1_install_syslog-ng.sh +++ b/bin/hardening/8.2.1_install_syslog-ng.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.2_enable_syslog-ng.sh b/bin/hardening/8.2.2_enable_syslog-ng.sh index 499a4c4..9c59f7e 100755 --- a/bin/hardening/8.2.2_enable_syslog-ng.sh +++ b/bin/hardening/8.2.2_enable_syslog-ng.sh @@ -48,11 +48,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.3_configure_syslog-ng.sh b/bin/hardening/8.2.3_configure_syslog-ng.sh index fa36f53..15745a0 100755 --- a/bin/hardening/8.2.3_configure_syslog-ng.sh +++ b/bin/hardening/8.2.3_configure_syslog-ng.sh @@ -36,11 +36,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.4_set_logfile_perm.sh b/bin/hardening/8.2.4_set_logfile_perm.sh index ddf9523..a3f52aa 100755 --- a/bin/hardening/8.2.4_set_logfile_perm.sh +++ b/bin/hardening/8.2.4_set_logfile_perm.sh @@ -84,11 +84,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.5_syslog-ng_remote_host.sh b/bin/hardening/8.2.5_syslog-ng_remote_host.sh index cb5916f..5950abe 100755 --- a/bin/hardening/8.2.5_syslog-ng_remote_host.sh +++ b/bin/hardening/8.2.5_syslog-ng_remote_host.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.2.6_remote_syslog-ng_acl.sh b/bin/hardening/8.2.6_remote_syslog-ng_acl.sh index 4ccd8d8..aaf01de 100755 --- a/bin/hardening/8.2.6_remote_syslog-ng_acl.sh +++ b/bin/hardening/8.2.6_remote_syslog-ng_acl.sh @@ -32,11 +32,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.3.1_install_tripwire.sh b/bin/hardening/8.3.1_install_tripwire.sh index 591ab2a..dcfe112 100755 --- a/bin/hardening/8.3.1_install_tripwire.sh +++ b/bin/hardening/8.3.1_install_tripwire.sh @@ -47,11 +47,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.3.2_tripwire_cron.sh b/bin/hardening/8.3.2_tripwire_cron.sh index 873ab51..36aef43 100755 --- a/bin/hardening/8.3.2_tripwire_cron.sh +++ b/bin/hardening/8.3.2_tripwire_cron.sh @@ -46,11 +46,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/8.4_configure_logrotate.sh b/bin/hardening/8.4_configure_logrotate.sh index 3a7415c..ea3a2cf 100755 --- a/bin/hardening/8.4_configure_logrotate.sh +++ b/bin/hardening/8.4_configure_logrotate.sh @@ -36,11 +36,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.1_enable_cron.sh b/bin/hardening/9.1.1_enable_cron.sh index 49fb1ae..11cdd85 100755 --- a/bin/hardening/9.1.1_enable_cron.sh +++ b/bin/hardening/9.1.1_enable_cron.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.2_crontab_perm_ownership.sh b/bin/hardening/9.1.2_crontab_perm_ownership.sh index 1e8f140..290913b 100755 --- a/bin/hardening/9.1.2_crontab_perm_ownership.sh +++ b/bin/hardening/9.1.2_crontab_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.3_cron_hourly_perm_ownership.sh b/bin/hardening/9.1.3_cron_hourly_perm_ownership.sh index e2ef13e..1aca1c6 100755 --- a/bin/hardening/9.1.3_cron_hourly_perm_ownership.sh +++ b/bin/hardening/9.1.3_cron_hourly_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.4_cron_daily_perm_ownership.sh b/bin/hardening/9.1.4_cron_daily_perm_ownership.sh index ffcde0b..896c729 100755 --- a/bin/hardening/9.1.4_cron_daily_perm_ownership.sh +++ b/bin/hardening/9.1.4_cron_daily_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.5_cron_weekly_perm_ownership.sh b/bin/hardening/9.1.5_cron_weekly_perm_ownership.sh index fbb81e4..48beddc 100755 --- a/bin/hardening/9.1.5_cron_weekly_perm_ownership.sh +++ b/bin/hardening/9.1.5_cron_weekly_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.6_cron_monthly_perm_ownership.sh b/bin/hardening/9.1.6_cron_monthly_perm_ownership.sh index 40b9aee..1d02b46 100755 --- a/bin/hardening/9.1.6_cron_monthly_perm_ownership.sh +++ b/bin/hardening/9.1.6_cron_monthly_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.7_cron_d_perm_ownership.sh b/bin/hardening/9.1.7_cron_d_perm_ownership.sh index 046e9ac..3da40fb 100755 --- a/bin/hardening/9.1.7_cron_d_perm_ownership.sh +++ b/bin/hardening/9.1.7_cron_d_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.1.8_cron_users.sh b/bin/hardening/9.1.8_cron_users.sh index b89ad3d..4e69d71 100755 --- a/bin/hardening/9.1.8_cron_users.sh +++ b/bin/hardening/9.1.8_cron_users.sh @@ -13,7 +13,7 @@ set -u # One variable unset, it's over FILES_ABSENT='/etc/cron.deny /etc/at.deny' FILES_PRESENT='/etc/cron.allow /etc/at.allow' -PERMISSIONS='600' +PERMISSIONS='644' USER='root' GROUP='root' @@ -102,11 +102,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.2.1_enable_cracklib.sh b/bin/hardening/9.2.1_enable_cracklib.sh index ce7ef3e..6495ce0 100755 --- a/bin/hardening/9.2.1_enable_cracklib.sh +++ b/bin/hardening/9.2.1_enable_cracklib.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.2.2_enable_lockout_failed_password.sh b/bin/hardening/9.2.2_enable_lockout_failed_password.sh index d72e4c8..59c70fd 100755 --- a/bin/hardening/9.2.2_enable_lockout_failed_password.sh +++ b/bin/hardening/9.2.2_enable_lockout_failed_password.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.2.3_limit_password_reuse.sh b/bin/hardening/9.2.3_limit_password_reuse.sh index 4146a18..c01f19b 100755 --- a/bin/hardening/9.2.3_limit_password_reuse.sh +++ b/bin/hardening/9.2.3_limit_password_reuse.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.10_disable_sshd_setenv.sh b/bin/hardening/9.3.10_disable_sshd_setenv.sh index fad68cf..218d058 100755 --- a/bin/hardening/9.3.10_disable_sshd_setenv.sh +++ b/bin/hardening/9.3.10_disable_sshd_setenv.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.11_sshd_ciphers.sh b/bin/hardening/9.3.11_sshd_ciphers.sh index 7d6540e..93fe5c7 100755 --- a/bin/hardening/9.3.11_sshd_ciphers.sh +++ b/bin/hardening/9.3.11_sshd_ciphers.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.12_sshd_idle_timeout.sh b/bin/hardening/9.3.12_sshd_idle_timeout.sh index b7b891d..617664b 100755 --- a/bin/hardening/9.3.12_sshd_idle_timeout.sh +++ b/bin/hardening/9.3.12_sshd_idle_timeout.sh @@ -80,11 +80,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.13_sshd_limit_access.sh b/bin/hardening/9.3.13_sshd_limit_access.sh index 28531be..39aec5f 100755 --- a/bin/hardening/9.3.13_sshd_limit_access.sh +++ b/bin/hardening/9.3.13_sshd_limit_access.sh @@ -94,11 +94,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.14_ssh_banner.sh b/bin/hardening/9.3.14_ssh_banner.sh index 0ac086a..2b6b65c 100755 --- a/bin/hardening/9.3.14_ssh_banner.sh +++ b/bin/hardening/9.3.14_ssh_banner.sh @@ -78,11 +78,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.1_sshd_protocol.sh b/bin/hardening/9.3.1_sshd_protocol.sh index df6de4f..da575b0 100755 --- a/bin/hardening/9.3.1_sshd_protocol.sh +++ b/bin/hardening/9.3.1_sshd_protocol.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.2_sshd_loglevel.sh b/bin/hardening/9.3.2_sshd_loglevel.sh index b60ccd2..773f7af 100755 --- a/bin/hardening/9.3.2_sshd_loglevel.sh +++ b/bin/hardening/9.3.2_sshd_loglevel.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.3_sshd_conf_perm_ownership.sh b/bin/hardening/9.3.3_sshd_conf_perm_ownership.sh index e715afc..4da35ff 100755 --- a/bin/hardening/9.3.3_sshd_conf_perm_ownership.sh +++ b/bin/hardening/9.3.3_sshd_conf_perm_ownership.sh @@ -75,11 +75,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.4_disable_x11_forwarding.sh b/bin/hardening/9.3.4_disable_x11_forwarding.sh index cee73a2..cc6e5b0 100755 --- a/bin/hardening/9.3.4_disable_x11_forwarding.sh +++ b/bin/hardening/9.3.4_disable_x11_forwarding.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.5_sshd_maxauthtries.sh b/bin/hardening/9.3.5_sshd_maxauthtries.sh index cb4b309..d60ce1a 100755 --- a/bin/hardening/9.3.5_sshd_maxauthtries.sh +++ b/bin/hardening/9.3.5_sshd_maxauthtries.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.6_enable_sshd_ignorerhosts.sh b/bin/hardening/9.3.6_enable_sshd_ignorerhosts.sh index cc0f659..09f62fa 100755 --- a/bin/hardening/9.3.6_enable_sshd_ignorerhosts.sh +++ b/bin/hardening/9.3.6_enable_sshd_ignorerhosts.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.7_disable_sshd_hostbasedauthentication.sh b/bin/hardening/9.3.7_disable_sshd_hostbasedauthentication.sh index 0f8f17c..819eeab 100755 --- a/bin/hardening/9.3.7_disable_sshd_hostbasedauthentication.sh +++ b/bin/hardening/9.3.7_disable_sshd_hostbasedauthentication.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.8_disable_root_login.sh b/bin/hardening/9.3.8_disable_root_login.sh index d524981..317506a 100755 --- a/bin/hardening/9.3.8_disable_root_login.sh +++ b/bin/hardening/9.3.8_disable_root_login.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.3.9_disable_sshd_permitemptypasswords.sh b/bin/hardening/9.3.9_disable_sshd_permitemptypasswords.sh index 5f3fbf1..2338f84 100755 --- a/bin/hardening/9.3.9_disable_sshd_permitemptypasswords.sh +++ b/bin/hardening/9.3.9_disable_sshd_permitemptypasswords.sh @@ -77,11 +77,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.4_secure_tty.sh b/bin/hardening/9.4_secure_tty.sh index 6eafe24..f91700b 100755 --- a/bin/hardening/9.4_secure_tty.sh +++ b/bin/hardening/9.4_secure_tty.sh @@ -36,11 +36,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/9.5_restrict_su.sh b/bin/hardening/9.5_restrict_su.sh index ddeb580..5d5d379 100755 --- a/bin/hardening/9.5_restrict_su.sh +++ b/bin/hardening/9.5_restrict_su.sh @@ -60,11 +60,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/99.1_timeout_tty.sh b/bin/hardening/99.1_timeout_tty.sh index 2c1361d..66f2678 100755 --- a/bin/hardening/99.1_timeout_tty.sh +++ b/bin/hardening/99.1_timeout_tty.sh @@ -53,11 +53,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi diff --git a/bin/hardening/99.2_disable_usb_devices.sh b/bin/hardening/99.2_disable_usb_devices.sh index 4a27a3d..27e455d 100755 --- a/bin/hardening/99.2_disable_usb_devices.sh +++ b/bin/hardening/99.2_disable_usb_devices.sh @@ -62,11 +62,16 @@ if [ ! -r /etc/default/cis-hardening ]; then exit 128 else . /etc/default/cis-hardening - if [ -z $CIS_ROOT_DIR ]; then + if [ -z ${CIS_ROOT_DIR:-} ]; then echo "No CIS_ROOT_DIR variable, aborting" exit 128 fi fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) -[ -r $CIS_ROOT_DIR/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh +if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then + . $CIS_ROOT_DIR/lib/main.sh +else + echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" + exit 128 +fi