Browse Source

Ordering/naming to make more sense

pull/1275/head
UltimateByte 8 years ago
committed by GitHub
parent
commit
416d15e76e
  1. 76
      lgsm/functions/check_permissions.sh

76
lgsm/functions/check_permissions.sh

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

Loading…
Cancel
Save