#!/usr/bin/env bash{output=""valid_shells="^($(sed-rn'/^\//{s,/,\\\\/,g;p}'/etc/shells|paste-s-d'|'-))$"awk-vpat="$valid_shells"-F:'$(NF) ~ pat { print $1 " " $(NF-1) }'/etc/passwd|(whileread-ruserhome;doowner="$(stat-L-c"%U""$home")"["$owner"!="$user"]&&output="$output\n - User \"$user\" home directory \"$home\" is owned by user \"$owner\""doneif[-z"$output"];thenecho-e"\n-PASSED: - All local interactive users have a home directory\n"elseecho-e"\n- FAILED:\n$output\n"fi)}
#!/usr/bin/env bash{output=""valid_shells="^($(sed-rn'/^\//{s,/,\\\\/,g;p}'/etc/shells|paste-s-d'|'-))$"awk-vpat="$valid_shells"-F:'$(NF) ~ pat { print $1 " " $(NF-1) }'/etc/passwd|whileread-ruserhome;doowner="$(stat-L-c"%U""$home")"if["$owner"!="$user"];thenecho-e"\n- User \"$user\" home directory \"$home\" is owned by user \"$owner\"\n - changing ownership to \"$user\"\n"chown"$user""$home"fidone}