summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_ses_open
blob: 4ca474b90fde3ed93d580d9c604563cd9c4b3366 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# pam_script session open script.
# This script is executed by root when a new session is opened.
echo "[$PAM_TYPE] Creating new session for $PAM_USER."

min_uid=234299000
[ $(id -u $PAM_USER) -gt $min_uid ] || exit 0

session_counter=/tmp/$PAM_USER.sessioncount
num_user_proc=$(ps aux|grep $PAM_USER -c|grep -v grep)

if [ $num_user_proc -eq 0 ]
then
  # no running session, write 1 since we are creating a new session.
  echo "1" > $session_counter
else
  # running session, increment
  current_count=$(cat $session_counter)
  echo "$(($current_count+1))" > $session_counter
fi