Run script at user login as root, with a catch
Posted
by
tubaguy50035
on Ask Ubuntu
See other posts from Ask Ubuntu
or by tubaguy50035
Published on 2012-09-28T16:41:43Z
Indexed on
2012/10/18
11:15 UTC
Read the original article
Hit count: 213
I'm trying to run a PHP script as root on user login. The PHP script adds a Samba share to the Samba config, thus the need for root privileges. The only issue here, is that the user doesn't exist yet. This system is integrated with active directory. So when a user logs in for the first time, a home directory for them is created under /home/DOMAIN/username
.
I've found this question and that seems like the correct way to get what I want, but I'm having trouble with the syntax since I don't know the user's name.
Would it be something like:
ALL ALL=(ALL) NOPASSWD: /home/DOMAIN/*/createSambaShare.php
This doesn't seem to work as it is currently. Anyone have any ideas or a "scripted" way to add a Samba share on user login?
Since I've made other changes to /etc/skel
, I just added the bash necessary to run the PHP script in .profile in there. This then gets copied to the "new" user's home and it tries to run the PHP script. But it fails, because these are not privileged users.
Changing permissions on the PHP script will not help. It needs to be run as sudo because it opens the Samba config file for writing. Letting any user run the PHP script would result in a PHP error.
The homes
Samba directive doesn't work for my use case. I need the Samba share to exist once they exist on the server, even when they're not logged in.
© Ask Ubuntu or respective owner