|
|
@ -129,7 +129,7 @@ fn_check_permissions(){ |
|
|
|
## The following fn_sys_perm_* functions checks for permission errors in /sys directory |
|
|
|
|
|
|
|
# Checks for permission errors in /sys directory |
|
|
|
fn_sys_perm_errors(){ |
|
|
|
fn_sys_perm_errors_detect(){ |
|
|
|
# Reset test variables |
|
|
|
sysdirpermerror="0" |
|
|
|
classdirpermerror="0" |
|
|
@ -146,29 +146,14 @@ fn_sys_perm_errors(){ |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
# Displays /sys related permission errors to the user |
|
|
|
fn_sys_perm_error_display(){ |
|
|
|
# /sys, /sys/class and /sys/class/net should be readable & executable |
|
|
|
# If any error was found |
|
|
|
if [ "${sysdirpermerror}" == "1" ]||[ "${classdirpermerror}" == "1" ]||[ "${netdirpermerror}" == "1" ]; then |
|
|
|
fn_print_error_nl "Permission error(s) found:" |
|
|
|
fn_script_log_error "Permission error(s) found:" |
|
|
|
if [ "${sysdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys permissions are $(stat -c %a /sys) instead of expected 555" |
|
|
|
fn_script_log "/sys permissions are $(stat -c %a /sys) instead of expected 555" |
|
|
|
fi |
|
|
|
if [ "${classdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys/class permissions are $(stat -c %a /sys/class) instead of expected 755" |
|
|
|
fn_script_log "/sys/class permissions are $(stat -c %a /sys/class) instead of expected 755" |
|
|
|
fi |
|
|
|
if [ "${netdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys/class/net permissions are $(stat -c %a /sys/class/net) instead of expected 755" |
|
|
|
fn_script_log "/sys/class/net permissions are $(stat -c %a /sys/class/net) instead of expected 755" |
|
|
|
fi |
|
|
|
echo "" |
|
|
|
fn_print_information_nl "This error causes servers to fail starting properly" |
|
|
|
fn_script_log_info "This error causes servers to fail starting properly." |
|
|
|
fi |
|
|
|
# Display a message on how to fix the issue manually |
|
|
|
fn_sys_perm_fix_manually_msg(){ |
|
|
|
echo "" |
|
|
|
fn_print_information_nl "To fix this issue, run this command as root:" |
|
|
|
fn_script_log_info "To fix this issue, run this command as root:" |
|
|
|
echo " * chmod a+rx /sys /sys/class /sys/class/net" |
|
|
|
fn_script_log "chmod a+rx /sys /sys/class /sys/class/net" |
|
|
|
core_exit.sh |
|
|
|
} |
|
|
|
|
|
|
|
# Attempt to fix /sys related permission errors if sudo is available, exits otherwise |
|
|
@ -187,7 +172,7 @@ fn_sys_perm_errors_fix(){ |
|
|
|
sudo a+rx "/sys/class/net" |
|
|
|
fi |
|
|
|
# Run check again to see if it's fixed |
|
|
|
fn_sys_perm_errors |
|
|
|
fn_sys_perm_errors_detect |
|
|
|
if [ "${sysdirpermerror}" == "1" ]||[ "${classdirpermerror}" == "1" ]||[ "${netdirpermerror}" == "1" ]; then |
|
|
|
fn_print_error "Could not fix permissions" |
|
|
|
fn_script_log_error "Could not fix permissions." |
|
|
@ -200,24 +185,37 @@ fn_sys_perm_errors_fix(){ |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
# Display a message on how to fix the issue manually |
|
|
|
fn_sys_perm_fix_manually_msg(){ |
|
|
|
echo "" |
|
|
|
fn_print_information_nl "To fix this issue, run this command as root:" |
|
|
|
fn_script_log_info "To fix this issue, run this command as root:" |
|
|
|
echo " * chmod a+rx /sys /sys/class /sys/class/net" |
|
|
|
fn_script_log "chmod a+rx /sys /sys/class /sys/class/net" |
|
|
|
core_exit.sh |
|
|
|
# Processes to the /sys related permission errors check & fix/info |
|
|
|
fn_sys_perm_error_process(){ |
|
|
|
fn_sys_perm_errors |
|
|
|
# /sys, /sys/class and /sys/class/net should be readable & executable |
|
|
|
# If any error was found |
|
|
|
if [ "${sysdirpermerror}" == "1" ]||[ "${classdirpermerror}" == "1" ]||[ "${netdirpermerror}" == "1" ]; then |
|
|
|
fn_print_error_nl "Permission error(s) found:" |
|
|
|
fn_script_log_error "Permission error(s) found:" |
|
|
|
if [ "${sysdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys permissions are $(stat -c %a /sys) instead of expected 555" |
|
|
|
fn_script_log "/sys permissions are $(stat -c %a /sys) instead of expected 555" |
|
|
|
fi |
|
|
|
if [ "${classdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys/class permissions are $(stat -c %a /sys/class) instead of expected 755" |
|
|
|
fn_script_log "/sys/class permissions are $(stat -c %a /sys/class) instead of expected 755" |
|
|
|
fi |
|
|
|
if [ "${netdirpermerror}" == "1" ]; then |
|
|
|
echo " * /sys/class/net permissions are $(stat -c %a /sys/class/net) instead of expected 755" |
|
|
|
fn_script_log "/sys/class/net permissions are $(stat -c %a /sys/class/net) instead of expected 755" |
|
|
|
fi |
|
|
|
echo "" |
|
|
|
fn_print_information_nl "This error causes servers to fail starting properly" |
|
|
|
fn_script_log_info "This error causes servers to fail starting properly." |
|
|
|
# Run the fix |
|
|
|
fn_sys_perm_errors_fix |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
# Run perm error detect & fix/alert functions on /sys directories |
|
|
|
fn_fix_sum_perm_run(){ |
|
|
|
fn_sys_perm_errors |
|
|
|
fn_sys_perm_error_display |
|
|
|
fn_sys_perm_errors_fix |
|
|
|
} |
|
|
|
|
|
|
|
## Run checks |
|
|
|
fn_check_ownership |
|
|
|
fn_check_permissions |
|
|
|
fn_fix_sum_perm_run |
|
|
|
fn_sys_perm_error_process |
|
|
|