How to run a Script as root, after Login as User, in GDM
Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to run a Script as root, after Login as User, in GDM
Well, the topic says everything:
How can I run a Script as `root` _after_ I Login into GDM using a simple User-account?
gnome-session-properties will only start Scripts as the User I logged in.
If I add the Scripts into `/etc/X11/gdm/PreSession/Default`, the Scripts will be executed as root - all right - but somehow they are executed during the Loading-Screen for the user - and this messes up the GUI for the Programs (don't ask me why though), which are `daemon`ed through the Scripts...
Uhm~ ..., about the problem:
I know how to run Scripts as root from the Terminal - thats not the real difficulty - but I want `GDM` to run a Script as `root`, _after_ somebody has Logged in using the Visual Login.
In the end, I want something like an "autostart"-file for GDM.
Something like `/etc/init.d/` or `/etc/rc.d/rc.local` - only, that it has to be executed _after_ a User logs in (and thus, the GUI (GDM) is Loaded) _and_ the Script has to be executed with User `root`.
This way I could start Scripts/Programs, which require a running GDM instance/server (call it whatever you want - I hope you know what I mean x!D).
I'm really sorry if my first post wasn't clear enough!
If you want an ordinary user to run it then you could set it suid root with "chmod +s /path/to/script.sh". Most window managers then have a way to autostart applications.
No, thats not it, I just have a Program which has it's config-files in `/root/.MyProg/` - the problem is, whenever a new User starts this Program, a new Directory (for config-files) will be created at `/home/$USER/.myProg/` - and this is exactly what I don't want.
Thats why I want GDM to run a Script, which first sets the appropiate $USER,$HOME,$PWD,... - Vars for `root` and then runs the actual Program - the Program will think the logged in User is `root` and thus will get the config-files from the `/root/.MyProg/` dir.
_But_, if the Script isn't run as `root`, then the Program can't be run as root - and thus it wouldn't have the access rights to the `/root/.MyProg/` dir.
So thats exactly where my Problem is x!D
I have to say that that sounds really insecure, I hope you are really confident about the way that program is coded. Either way I can't see why using a setuid script wouldn't work but maybe I'm missing something.
Hmm, I agree, this really is somehow insecure - but how else, can I give the program access to the `/root/.MyProg/` dir?
I tried changing the owner to `root:mygroup` (where `mygroup` is the group of the User I'm logging in with) and setting the rights to `0770`, but the Script (started through the User which is in `mygroup`) still wouldn't have access to the directory (`/root/.myprog/`).
I tried `chmod +s MyStartScript` as well, but it doesn't seem to work (what exactly does the `s` option? The man-page just says something about guid/suid being set, what exactly does this mean?).
What exactly is this "setuid script" you are refering to?
Well, I'm pretty new to linux... and thus I've set up the `/root` folder to ~50GB, while I've only got ~10 for the /home folder...
Since I've got 3 Programs, which are using ~10-15 GB space each, I won't be able to use them with any folder except the `/root` one.
if i not mistaken, suid on script is ignore by linux. i think if u just want to utilised the space in / then create directories at / & chown to the user xyz,then create a symlink /home/xyz/.myprog that link to that directory.
The User `myuser` is _definitely_ in the Group `mygroup`.
Maybe I did something wrong?
I wouldn't mind "swap" 'ing the partition layout, but I really have no clue about that - and `man -k swap` didn't find anything I could use in that context - so how exactly do I "swap" ?
There isn't a possibility of data-loss, is there?
first if /root is not accessible by mygroup then /root/.mygroup is not acessible also even with permision 777
second u dun need to chmod a symlink since it usually is 777.
if u insists to use /root then chown root:mygroup /root ; chmod 750 /root
chown -R /root/.myprog
& show us the result of grep mygroup /etc/group.
& make sure yr script does not change the permission of /root/.myprog
i recommed u use another directory mkdir /myuser for better sense; ln -s ... chown ... chmod ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.