Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Crear lista de usuarios del sistema
- arr_users=( $(cat /etc/passwd | cut -d ":" -f 1) )
- valid_shells () {
- local user
- local shell
- user=$1 # variable local
- shell=$(getent passwd $user | cut -d ":" -f 7)
- # cuando la variable esta vacia se rellena con
- # valor predeterminado
- #shell=${shell:-noshell}
- echo $shell
- grep "$shell" /etc/shells > /dev/null 2>&1 && return 0
- return 1
- }
- for user in ${arr_users[@]};do
- echo ${user}:
- id $user
- uuid=$(getent passwd $user | cut -d ":" -f 3)
- # true and true = true
- # false and true = false
- # true and false = false
- # true or false = true
- # false or true = true
- # false or false = false
- #
- if [ $uuid -lt 1000 ] && valid_shells $user ;then
- echo -e "\033[1;31mWARNING\033[0m: special user has shell"
- fi
- echo shell: $(getent passwd $user | cut -d ":" -f 7)
- echo "---"
- done
Advertisement