 |
 |
 |
 |
| Programming & Packaging A place to discuss programming and packaging. |

22nd November 2007, 10:49 PM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
|
Nautilus scripts, mostly bash, as root open nautilus in current folder.
On the CLI I would use a script like this.
Code:
#!/bin/bash
su -c 'nautilus ./'
exit
Things seem to be a little different with a nautilus script. For one thing, since there is no terminal I have no terminal location to use with ./. At least if I do it would probably be in /root or $HOME. Which is not what I want. So, instead of a ./ I use a variable passed by nautilus.
Code:
su -c "nautilus $NAUTILUS_SCRIPT_CURRENT_URI"
Now I run into the real problem. I don't have anywhere to enter my root password.  I have seen a recommendations to use the following command: gksu, gksudo, gnomesu, gnomesudo. Unfortunately none of these exist in fedora 8.
Please keep in mind that I will not use sudo, as I consider it to be too great a security risk.
The really question is, how do I launch a root login window from the CLI. I think that command, whatever it is, would work for my nautilus script.
|

27th November 2007, 09:45 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
Again I shall shamelessly bump my own thread.
|

27th November 2007, 10:12 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
I made a little progress. I should be able to ask for input via a gui with zenity. With a line something like this.
Code:
zenity --entry --text="Please enter the root password."
Now I need to know how to take that input and use it when prompted for a password.
Any ideas?
EDIT: I tried this.
Code:
zenity --entry --text="Please enter the root password." | su -c "nautilus $NAUTILUS_SCRIPT_CURRENT_URI"
And got that.
Code:
standard in must be a tty
Last edited by leadgolem; 27th November 2007 at 10:25 AM.
|

27th November 2007, 07:58 PM
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 5

|
|
|
Hello!
What you think about use consolehelper?
Albert
|

28th November 2007, 12:08 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
|
Hmm, consolehelper seems to be designed to solve problems like mine. I'm not sure how practical it is for usage within a script. It looks like I would need to setup nautilus to be managed by console helper, which could cause other problems, and create a PAM configuration for it. Which I don't know how to do. Also, this would make my nautilus script non-transportable.
From the description, consolehelper seems like the long way around. However, if you have a suggestion on how to use it for this function, your welcome to make it.
While reading the man page for consolehelper, I did see a mention of userhelper. I think using userhelper directly may be my solution. I've never used it before, so I need to do some reading up on it, and PAM.
|

28th November 2007, 01:04 AM
|
|
Registered User
|
|
Join Date: Aug 2007
Location: Fairfield, CA
Posts: 438

|
|
|
Well if you find out how, make sure you post back what you did. I used to use gnomesu in other distro's but just user terminal windows myself in fedora.
I just grew accustomed to having the terminal stay open. At least if there are errors involved I can spot them easily in the terminal windows. (But I still miss Gnomesu!)
|

28th November 2007, 01:17 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
|
Yeah, gksu would work also. I think the system apps are actually using consolehelper, but I could be wrong.
|

28th November 2007, 02:53 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
|
Ok, looks like this should be possible to do by passing the input from zenity to ksu. I have eliminated sudo as most users will not be on the sudoers list anyway, and this is supposed to be a transportable script.
|

28th November 2007, 03:23 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
I got it. Here is the incredibly simple completed script. 
Code:
#!/bin/bash
kdesu -c "nautilus $NAUTILUS_SCRIPT_CURRENT_URI"
exit
For this to work, you must have kdebase installed.
|

28th November 2007, 03:32 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
Here is a version that only requires xterm.
Code:
#!/bin/bash
xterm -e su -c "nautilus $NAUTILUS_SCRIPT_CURRENT_URI"
exit
EDIT: Though it is not as pretty.
|

28th November 2007, 09:26 AM
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 5

|
|
Hello!
Solution with consolehelper:
1. Create link:
Code:
ln -s /usr/bin/consolehelper /usr/bin/root-sh
2. Create file:
Code:
cat << EOF > /etc/security/console.apps/root-sh
USER=root
PROGRAM=/bin/sh
SESSION=true
FALLBACK=true
EOF
3.Create file:
Code:
cat << EOF > /etc/pam.d/root-sh
#%PAM-1.0
auth include config-util
account include config-util
session include config-util
EOF
You can modify it for your purpose.
4. From now you can use:
Code:
/usr/bin/root-sh -c " any command"
in your scripts.
Enjoy!
Albert
P.S.
Sorry, English isn't my native language
Last edited by alfal; 28th November 2007 at 11:03 PM.
|

28th November 2007, 09:46 PM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
|
Very nice. Would you care to create an rpm? Or would you like me to?
EDIT: One slight corrections. I should be /etc/security/console.apps/root-sh
EDIT2: Hmm, got all the files setup. Using this command though I keep getting a "unknown user". Suggestions?
Last edited by leadgolem; 28th November 2007 at 09:58 PM.
|

28th November 2007, 11:19 PM
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 5

|
|
Quote:
|
Originally Posted by leadgolem
Very nice. Would you care to create an rpm? Or would you like me to?
|
Feel free to do what you want.
Quote:
|
Originally Posted by leadgolem
EDIT: One slight corrections. I should be /etc/security/console.apps/root-sh
|
Corrected.
Quote:
|
Originally Posted by leadgolem
EDIT2: Hmm, got all the files setup. Using this command though I keep getting a "unknown user". Suggestions?
|
Yes, delete white spaces after every line of text in created files, if you copy and paste my code
Albert
|

29th November 2007, 01:14 AM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855

|
|
There is not white space issue.
Code:
/usr/bin/root-sh update
/usr/bin/root-sh "update"
/usr/bin/root-sh -c "update"
All of these resulted in an unknown user box popping up.
|

29th November 2007, 06:18 AM
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 5

|
|
|
Check line:
USER=root
for white spaces.
What is size your files ?
/etc/security/console.apps/root-sh - 53
/etc/pam.d/root-sh - 82
It works fine for me.
Albert
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 12:11 (Tuesday, 21-05-2013)
|
|
 |
 |
 |
 |
|
|