Reputation: 61
I'm trying to write a script in order to notify all active users in my host when somebody logs in.
For this I'm creating a script in /etc/profile.d/login_notify.sh For testing purposes I'm just trying to write to some ttys with something like this:
echo "Somebody loged in.." > /dev/pts/0
It works when running like root, but not when used by a normal user (it needs to be able to be run by any possible user who logs in to the system). So, I gave the script the g+s setgid like this:
Also, the group for the script is tty (like the "write" command is), so that it have permissions to write to the tty and pts files (I guess).
But for some reason, the script is not able to do it's job. I get some permissions errors, and nothing is writen to the ttys or pts:
Please, could anybody try to help me with this approach?
If you know any other way for the system to let me know if somebody logs in, at the momento, and using the terminal, please, let me know.
Thanks a lot in advance
I tried using setgid Also using the write program, but it's difficult for me to write to all the active ttys or pts, and all the active users in the sistem in that moment
I'm expecting my script to be able to write to all the active user's terminals (ttys or pts) something like that: 'the user $user has just loged to the system using the ip $ip and tty $tty, at $date'
Upvotes: 1
Views: 83