LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to pass root permissions to other app? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-pass-root-permissions-to-other-app-83210/)

therut 08-18-2003 03:10 PM

How to pass root permissions to other app?
 
Hi,

My question:

when I am logged in as a normal user and I want to do something that requires root permissions I don't want to log out and log in every time. I know there is a way to pass the root permissions that you get when you "su" on a command line to any X-application you want to, for instance nautilus.
However I forgot how. Can anyone help me?

Thanks in advance

Therut

MacKtheHacK 08-18-2003 03:44 PM

Use the su command's -c option to start up the program you want to have root permissions. For example, if you want to run xmms as root, you could use: "su -c xmms". Of course, root won't be able to use your X display unless you grant it permission. Use "xhost localhost" if you're the only user on that system, or xauth for better security.

therut 08-18-2003 04:00 PM

Hi Mack,

thanks for replying so quickly.
I have a new question now, of course.
The main app I would like root permissions for when I'm logged in as a normal user is Nautilus (red hat 9). For instance, when I want to copy a group of folders from a cdrom to a mounted fat partition it's faster for me to do it with nautilus because i am not really used to working with the command line. However, when I want to do that Nautilus tells me, logically, that I don't have the permissions. So this way, with the -c option, i don't have to log out anymore.

But something strange happens: first of all the bash shell where I type the command "su -c nautilus" gives me the following reply, although it does start nautilus in the root folder:

"GnomeUI-WARNING **: While connecting to session manager:
Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.
Extra content at the end of the document."

Second of all I am now stuck with that bash terminal because when I close that terminal the nautilus windows closes as well?

I hope you don't mind me asking such a longwinded question.

Thanks in advance,

Therut

MacKtheHacK 08-18-2003 04:07 PM

Hmm... Not sure where that Gnome-UI-Warning is coming from. It's probably trying to authenticate to your X server and failing. Did you use "xhost localhost" so that any user on your system (including root) can access your X display?

The second question is easy: just run the command in the background by putting an ampersand at the end of the command line. Then when you exit the shell, the command will be left running in the "background".

therut 08-18-2003 04:29 PM

Hi Mack,

thanks for all the help.

yes I typed xhost localhost. Then the shell answers: "localhost being added to access control list"
I have really no idea what or why i do that but it didn't change that what follows the su -c nautilus command.

On the ampersand answer: Where should I put the ampersand? I tried every possible location in the line but it never does what i want it to do.

su& -c nautilus
su -c& nautilus
su -c & nautilus
su -c nautilus&
su -c nautilus &

?

Thanks in advance, again,

Therut

MacKtheHacK 08-18-2003 04:35 PM

The ampersand belongs at the end:
su -c nautilus &
because it's a command separator to the shell. Let's see if we can find out where that message is coming from. Try running a non-X command with su to see if it gets the error:
su -c "echo hello"
I'll bet that works just fine. Now, let's try a basic X application:
su -c xclock
If that gives the same warning, then the problem is with generic XWindows authentication somehow. If not, then it's something that nautilus is doing. I don't know anything about nautilus, so I can't be of much help there. Let us know your results!

therut 08-18-2003 04:49 PM

Hi Mack,

First I tried to put the ampersand at of the end of the line, nothing happens except an "answer" in the shell. Then I did the other things you said and you were right. The "echo hello" thing was no problem, but the "xclock" thing gives the same error message.

Now I will paste everything from that shell so you can see what I did and what happened:


[sander@localhost sander]$ su -c nautilus &
[1] 4637
Password: [sander@localhost sander]$ su -c "echo hello"
Password:
hello

[1]+ Stopped su -c nautilus
[sander@localhost sander]$ su -c xclock
Password:
Warning: Tried to connect to session manager, Authentication Rejected, reason :
None of the authentication protocols specified are supported and host-based authentication failed



Hope this helps, thanks still for helping,

Sander (Therut)

MacKtheHacK 08-19-2003 09:19 AM

I know why the ampersand thing isn't working. I wasn't thinking this through all the way. Sorry about that. What's happening is that your shell is running the su command in the background, so when it prompts for a password it isn't getting any input from your keyboard (your shell is still reading that). What I should have had you do is run su in the foreground, and have it run nautilus in the background. This can be done by including the ampersand in the argument to the -c option by quoting it:
su -c "nautilus &"
Doing that lets su prompt for and read a password from your terminal in ithe foreground.

But we still have the authentication problem. I'm no XWindows expert, but it looks like your X server doesn't support the protocols your X client is trying. What's even stranger is that host-based authentication failed. Run xhost with no arguments. Does i say:
access control enabled, only authorized clients can connect
then t list "localhost" as an authorized client? You could try "xhost +", which disables host-based authentication so that anyone can connect. Don't leave it like that after testing, though, enable it with "xhost -" again. If that worked, try adding your hostname to the list with "xhost `hostname`" (note the backticks) and see if that works.

Also what is the output of "xhost info"? And look at the output of "xhost list" to see if your display name has a MIT-MAGIC-COOKIE-1 protocol entry for it. But don't post the output of "xauth list"!


All times are GMT -5. The time now is 07:13 AM.