-   Red Hat (
-   -   How to run a Script as root, after Login as User, in GDM (

MHOOO 03-06-2005 11:39 AM

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...

So what exactly do I have to do?

I'm using RedHat 9.0 and GDM.

Thanks & bye bye~,

david_ross 03-06-2005 01:05 PM

Welcome to LQ.

Just open up a terminal and type "su -", press return and enter the root password. You should now be able to type any commands as root.

MHOOO 03-06-2005 01:33 PM

Hi - and thanks for the warm welcome ;!D

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!

Thanks & bye bye~,

david_ross 03-06-2005 01:43 PM

If you want an ordinary user to run it then you could set it suid root with "chmod +s /path/to/". Most window managers then have a way to autostart applications.

MHOOO 03-06-2005 02:07 PM

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

Thanks & bye bye~,

david_ross 03-06-2005 02:11 PM

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.

MHOOO 03-06-2005 03:12 PM

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?

Thanks for the answers! & bye bye~,

david_ross 03-06-2005 03:19 PM

Is there a reason you need to use the /root/.Yourprog path as opposed to ~/.Yourprog?

MHOOO 03-06-2005 03:42 PM

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.

Thanks & bye bye~,

david_ross 03-06-2005 03:45 PM

Why not just swap the partition layout a little bit?

If you want to then post the output from:
fdisk -l
df -h

MHOOO 03-06-2005 03:55 PM

I'm sorry, I'm using the german version, I hope you will understand it:
`fdisk -l`

Platte /dev/hde: 80.0 GByte, 80026361856 Byte
255 Köpfe, 63 Sektoren/Spuren, 9729 Zylinder
Einheiten = Zylinder von 16065 * 512 = 8225280 Bytes

    Gerät boot.  Anfang      Ende    Blöcke  Id  Dateisystemtyp
/dev/hde1  *        1        13    104391  83  Linux
/dev/hde2            14      1925  15358140  83  Linux
/dev/hde3          1926      3200  10241437+  83  Linux
/dev/hde4          3201      9729  52444192+  f  Win95 Erw. (LBA)
/dev/hde5          3201      3454  2040223+  82  Linux Swap
/dev/hde6          3455      3556    819283+  83  Linux
/dev/hde7          3557      9665  49070511  83  Linux
/dev/hde8          9666      9729    514048+  83  Linux

`df -h`

Dateisystem          Gröe Benut  Verf Ben% Eingehängt auf
/dev/hde7              47G  20G  25G  45% /
/dev/hde1              99M  14M  80M  15% /boot
/dev/hde3            9.7G  58M  9.1G  1% /home
none                  504M    0  504M  0% /dev/shm
/dev/hde8            487M  8.6M  453M  2% /tmp
/dev/hde2              15G  1.9G  12G  14% /usr
/dev/hde6            788M  103M  645M  14% /var

Thanks & bye bye~,

lihmin 03-07-2005 11:39 AM

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.

MHOOO 03-07-2005 01:49 PM

Hi lihmin & thx for your answer, but somehow this isn't working :!(
I did everything like this:

chown root:mygroup /root/.myprog
chown root:mygroup /root/.myprog/*

chmod 0770 /root/.myprog
chmod 0770 /root/.myprog/*

ln -s /root/.myprog /home/myuser/.myprog
chown root:mygroup /home/myuser/.myprog
chmod 0770 /home/myuser/.myprog

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?

Thanks & bye bye~,

lihmin 03-07-2005 09:05 PM

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 ...

MHOOO 03-08-2005 09:41 AM

Alright, I got it :!)
It works like this - seems like the problem was because the User `myuser` didn't have any access to the `/root` dir.

Thanks for everything & bye bye~,

All times are GMT -5. The time now is 09:19 AM.