LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-06-2005, 10:39 AM   #1
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Rep: Reputation: 15
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~,
MHOOO
 
Old 03-06-2005, 12:05 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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.
 
Old 03-06-2005, 12:33 PM   #3
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
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~,
MHOOO
 
Old 03-06-2005, 12:43 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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.
 
Old 03-06-2005, 01:07 PM   #5
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
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~,
MHOOO
 
Old 03-06-2005, 01:11 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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.
 
Old 03-06-2005, 02:12 PM   #7
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
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~,
MHOOO
 
Old 03-06-2005, 02:19 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Is there a reason you need to use the /root/.Yourprog path as opposed to ~/.Yourprog?
 
Old 03-06-2005, 02:42 PM   #9
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
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~,
MHOOO
 
Old 03-06-2005, 02:45 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Why not just swap the partition layout a little bit?

If you want to then post the output from:
fdisk -l
df -h
 
Old 03-06-2005, 02:55 PM   #11
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
I'm sorry, I'm using the german version, I hope you will understand it:
`fdisk -l`
Code:
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`
Code:
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~,
MHOOO
 
Old 03-07-2005, 10:39 AM   #12
lihmin
LQ Newbie
 
Registered: Sep 2003
Location: Singapore
Posts: 23

Rep: Reputation: 15
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.
 
Old 03-07-2005, 12:49 PM   #13
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
Hi lihmin & thx for your answer, but somehow this isn't working :!(
I did everything like this:
Code:
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~,
MHOOO
 
Old 03-07-2005, 08:05 PM   #14
lihmin
LQ Newbie
 
Registered: Sep 2003
Location: Singapore
Posts: 23

Rep: Reputation: 15
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 ...
 
Old 03-08-2005, 08:41 AM   #15
MHOOO
LQ Newbie
 
Registered: Mar 2005
Posts: 28

Original Poster
Rep: Reputation: 15
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~,
MHOOO
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run a script as root upon login zugvogel Linux - Newbie 7 09-09-2005 11:10 AM
allow sudo for www user to run root shell script cccc *BSD 12 07-23-2005 03:48 PM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 07:54 AM
Run program from root login as non-priveledged user? pr0wl3r Linux - Security 3 08-17-2004 09:52 PM
root cannot login through gdm bahadur Linux - Networking 3 06-12-2004 03:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration