Skip to content

Commit

Permalink
ssh-notifier: make temporary variable for ignore users part
Browse files Browse the repository at this point in the history
  • Loading branch information
kreatoo committed Oct 16, 2024
1 parent 53d71d9 commit ecde63b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/monocloud/ssh-notifier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,18 @@ getlogininfo() {

if [[ -n "${EXCLUDE_USERS[*]}" ]]; then
for exclude_user in "${EXCLUDE_USERS[@]}"; do
usertmp="${user:-$PAM_USER}"
# if $user has @ in it
if [[ "${user:-$PAM_USER}" =~ "@" ]]; then
if [[ "$usertmp" =~ "@" ]]; then
# Remove everything after and including @
if [[ -n "$user" ]]; then
user="${user%%@*}"
usertmp="${user%%@*}"
else
user="${PAM_USER%%@*}"
usertmp="${PAM_USER%%@*}"
fi
fi

if [[ "${user:-$PAM_USER}" == "$exclude_user" && -n "${user-$PAM_USER}" ]]; then
if [[ "$usertmp" == "$exclude_user" && -n "$usertmp" ]]; then
return
fi
done
Expand Down

0 comments on commit ecde63b

Please sign in to comment.