4

A script that requires root privileges needs to be executed when a non-root privileged user signs in/out. How do I handle this?

bambuntu
  • 1,001

2 Answers2

2

Use the PAM session hooks module.

poolie
  • 9,358
1

lightdm, the display manager in Ubuntu allows running session setup scripts as root if you add appropriate entry to /etc/lightdm/lightdm.conf file (Note, that this file doesn't exist as of 14.04, you have to manually create it).

Example of how it might look like

[SeatDefaults]
# session-setup-script = Script to run when starting a user session (runs as root)
session-setup-script=/opt/myscripts/print_hello.sh
# session-cleanup-script = Script to run when quitting a user session (runs as root)
session-cleanup-script=/opt/myscripts/print_hello.sh