View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 37 posts ] 
Go to page Previous  1, 2, 3  Next

Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject:
PostPosted: Sat Jul 30, 2005 11:02 am 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
you can search the wiki for sudo once you set that up the command would look more like

sudo /etc/init.d/gdm restart

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 11:07 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
What Xsecrets said. Remember to restrict the privileges to just that one program.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 11:53 am 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
Right. I understand that putting sudo in front means act as root, except then it demands the root password -- and that would break this, right?

For instance, in OS X, I can include the password on the same line to avoid this problem. Here's connect to file server via smb:

mount volume "smb://user_name:password@IP_Address/Users/"

This could be run as 3 separate operations, if you really wanted to:

sudo diskutil repairPermissions /

As you've guessed it repairs permissions no matter who owns the file as soon as you authenticate on the next line.

Naturally, any file with this info in it should have no read permissions for 'everyone' but only for whichever user needs to execute it.

And I know you can combine separate arguments into one line with ";", but that doesn't seem to help here.

I haven't really searched the KnoppMyth wiki for this, since it is more of a general Linux/UNIX issue. So I've searched the Linux newbie guides and googled:

authenticate "one line"

No help. running "man sudo", I see that:
-b makes it run in the background, which may be necessary here
-a might have something to do with the solution, since it references /etc/login.conf -- assuming BSD authentication is used.
-s runs a shell script, so it is too bad that doesn't work

Here's an interesting quote:
"...many programs (such as editors) allow the user to run commands via shell escapes, thus avoiding sudo's checks."

Just for the heck of it, I told fluxbox to call:

sudo /etc/init.d/gdm restart;root_password

but it didn't work. If it did work, I'd of course remove the everyone read permission from that file.

Am I even sort of close?


Bibliography:
http://www.basiclinux.net/
http://linux-newbie.sunsite.dk/
http://www.reallylinux.com/docs/admin.shtml

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 12:36 pm 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
well maybe you should go ahead and do as I said and search the wiki. you can setup sudo to not require a password for certain users, and one of the wiki pages I forget which one now goes over this.

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 12:46 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
One of the most important things to realize when reading man pages is how to follow the references to other man pages. Running man sudo should have lead you the config file /etc/sudoers described by:
Code:
man sudoers


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 3:02 pm 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
Hi. After studying the recommended stuff, I think this should have worked:

nano /etc/X11/fluxbox/keys

add at bottom:

Control Mod1 r :ExecCommand sudo /etc/init.d/gdm restart

Ctrl-x
y

visudo -f /etc/sudoers -s

There's already an entry for user mythtv, and it is flagged NOPASSWD. So you just go to the end of that line, add a "," No Space and add "/etc/init.d/gdm restart"

ctrl-x
y

It kills gdm, but doesn't restart it. Do you know why that is?

So I decided to see if

killall -HUP gdm

would work, but visudo always says syntax error. Same if I use:

killall gdm -HUP

BTW, visudo -c /etc/sudoers -s

doesn't work. I have to use the "-f" flag after visudo.

What am I doing wrong?

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 6:44 pm 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
I don't know what will accept arguments and what won't, so it might be easier to use your shell script you created earlier from the fluxbox keys, also I don't think sudoers accepts arguments, so it would just be /etc/init.d/gdm

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 6:55 pm 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
According to your colleague, that won't work because you can't make the shell script run as root.

However, you explained one thing. If it doesn't accept arguments, that's why it killed the process in one of my tests. I've noted you're allowed to make a ghetto-macro by putting two commands in braces offset by spaces. I wonder if entering the same command twice would kill then relaunch.

I'll explore this.

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 7:18 pm 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
No, nothing seems to work. That's too bad, cuz I bet there is some way. I've been throught the documentation for Fluxbox, gdm and not seeing anything.

It is too bad that fluxbox can't issue commands with arguments -- I would have thought that was pretty basic. And it's too bad I can't set the bit and have the shell script act as root. I had thought you could.

So, I guess it will be the less elegant Ctrl-Alt-Backspace. Unless you think of another resource for me to read.

Thanks.

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 1:12 am 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
you can execute the shell script as root if you use sudo to do it.

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 8:25 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
So to summarize... Create a shell script that looks like this:
Code:
#!/bin/bash
sudo /etc/init.d/gdm restart

Don't forget to make it executable! Add the name of this shell script to your sudoers list for mythtv with a NOPASSWD tag. Test it from the command line as the mythtv user. (For debugging purposes you can add an "id" command in there to make sure it's really being run as root). Set up the fluxbox keybinding to exec that script...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 11:00 am 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
Thanks for your persistence.

Curiously, it now half works. It kicks you out to the login window -- but doesn't restart gdm. Here's what I did:

nano /etc/X11/fluxbox/keys

add this at the bottom:
Mod1 Control r :ExecCommand sudo /etc/init.d/gdm restart

Ctrl-x
y

visudo -f /etc/sudoers -s

There's already an entry for user mythtv, so you just go to the end of that line, add a "," no space and add "/etc/init.d/gdm restart"

ctrl-x
y

nano /usr/local/bin/restart_gdm.sh

enter:
#!/bin/bash
sudo /etc/init.d/gdm restart

ctrl-x
y

chmod 751 /usr/local/bin/restart_gdm.sh

To check, run:
ls -al /usr/local/bin/restart_gdm.sh

Output:
-rwxr-x--x 1 root root 42 Jul 31 09:36 /usr/local/bin/restart_gdm.sh

Possible solution?

Thanks again. :D

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 11:15 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
The whole point of the script is to replace what you have in /etc/X11/fluxbox/keys, as for file permissions, making a shell script executable without read permissions doesn't work, so do a
Code:
chmod a+rx /usr/local/bin/restart_gdm.sh
if you expect a script owned by root to work for the mythtv user.

This might also be getting killed when the parent process (fluxbox) gets shutdown. Make the second line in the script look like this to get around that:
Code:
(nohup sudo /etc/init.d/gdm restart & exit)

OBTW - Leave off the argument to the comand in /etc/sudoers.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 12:03 pm 
Offline
Joined: Fri Jun 24, 2005 3:22 pm
Posts: 124
Sorry, you're right. The key command should now shell call the script, not the command. Unfortunately, now nothing happens.

Here are my revised instructions for myself, in case that shows you where I'm being dumb:

nano /etc/X11/fluxbox/keys

add this at the bottom:
Mod1 Control r :ExecCommand sudo ./usr/local/bin/restart_gdm.sh

Ctrl-x
y

visudo -f /etc/sudoers -s

There's already an entry for user mythtv, so you just go to the end of that line, add a "," No Space and add "/etc/init.d/gdm?"

ctrl-x
y

That "?" should mean this user is allowed to ANY command beginning /etc/init.d/gdm...

nano /usr/local/bin/restart_gdm.sh

enter:
#!/bin/bash
sudo /etc/init.d/gdm restart
(nohup sudo /etc/init.d/gdm restart & exit)

ctrl-x
y

chmod a+rx /usr/local/bin/restart_gdm.sh

ls -al /usr/local/bin/restart_gdm.sh
=
-rwxr-xr-x 1 root root 86 Jul 31 10:52 /usr/local/bin/restart_gdm.sh

To give the mythtv user read permissions without giving them to everyone, I also tried:

chgrp mythtv /usr/local/bin/restart_gdm.sh

but nothing happens with Ctrl-Alt-r.

_________________
AMD Athlon XP 2800+
MSI K7N2 Delta2 ATX w/FX5200 AGP video
2X256MB PC3200 RAM
Maxtor 250GB drive (master on IDE 1)
Pioneer DVR-109 (master on IDE 2)
Antec Overture II ATX case with 330watts
Hauppauge 250 in PCI slot 2


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 1:48 pm 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
ok a couple of things. In fluxbox keys there should not be a . infront of the command. basically with that you are telling it to look in curentdirectory/usr/local/bin/commandname, and of course this doesn't exist, unless you are in the root directory. so ditch the . Also I do not believe you should need to give the mythtv user sudo rights to gdm directly as long as they have sudo rights for the script, as long as the script gets run as root all the commands within it should get run as root, at least that's my understanding, though I do not use sudo too often tjc correct me if I'm wrong.

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ] 
Go to page Previous  1, 2, 3  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu