0

I have a service that starts up at boot time that monitors a UPS. Each time a user logs in, I need to display a dialog saying that the UPS is connected, disconnected, etc. Is there a way my application can know when a user logs in and display the dialog?

The application must run at the login screen in case the UPS goes offline and the system needs to shutdown. Plus root permissions are required, so it can't just be ran in the user's startup script.

Every single user on the system needs to get the dialog, so it's not a simple matter of adding it the the user's .profile.

Thanks for any help you can provide.

3 Answers 3

1

If its solaris you're on then rather than set suid you might consider creating an rbac profile that allows the users to execute this ups status command with a uid of 0, and stick it in the system and/or default profiles.

0

A few things:

First, /etc/profile will be used for just about every login shell. Second, the SUID bit is used for making sure a program always runs as a specific user (e.g. root). So if you want to have the application run as root for each user who logs in, you would make sure the app is owned by root, run chmod u+s /the/app and add it to /etc/profile.

Third, though, is that what you probably want to do is to have the service run as root at startup, and then use syslog() to log these messages at emerg level, which is broadcast to every user by default. This would alert people who are already logged in if the UPS status changes while they're logged in.

0

So - are you asking the user to shut the machine down using the script if it reports the UPS as off line?

An alternative approach may be to just create a CRON job that polls the UPS every hour, half-hour, whatever interval you want, and shuts down if necessary. There are also daemons that will monitor live messages from the UPS and react accordingly - ie send email to sysadmin, warn users, and gracefully shut down the system.

Linux UPS Daemon: http://linux.die.net/man/8/upsd

Solaris UPS tools: http://blogs.oracle.com/mikey/entry/network_ups_tools_on_solaris

The latter explains both user notification and shutdown.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .