Fedora Linux Support Community & Resources Center
  #1  
Old 22nd November 2007, 10:49 PM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #2  
Old 27th November 2007, 09:45 AM
leadgolem's Avatar
leadgolem Offline
Registered User
 
Join Date: Apr 2005
Location: Littleton, CO
Age: 28
Posts: 2,855
Again I shall shamelessly bump my own thread.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #3  
Old 27th November 2007, 10:12 AM
leadgolem's Avatar
leadgolem Offline
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
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.

Last edited by leadgolem; 27th November 2007 at 10:25 AM.
Reply With Quote
  #4  
Old 27th November 2007, 07:58 PM
alfal Offline
Registered User
 
Join Date: Nov 2007
Posts: 5
Hello!

What you think about use consolehelper?

Albert
Reply With Quote
  #5  
Old 28th November 2007, 12:08 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #6  
Old 28th November 2007, 01:04 AM
RJFUatHOME Offline
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!)
Reply With Quote
  #7  
Old 28th November 2007, 01:17 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #8  
Old 28th November 2007, 02:53 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #9  
Old 28th November 2007, 03:23 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #10  
Old 28th November 2007, 03:32 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #11  
Old 28th November 2007, 09:26 AM
alfal Offline
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.
Reply With Quote
  #12  
Old 28th November 2007, 09:46 PM
leadgolem's Avatar
leadgolem Offline
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?
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.

Last edited by leadgolem; 28th November 2007 at 09:58 PM.
Reply With Quote
  #13  
Old 28th November 2007, 11:19 PM
alfal Offline
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
Reply With Quote
  #14  
Old 29th November 2007, 01:14 AM
leadgolem's Avatar
leadgolem Offline
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.
__________________
Only two things are infinite, the universe and human stupidity, and I am not sure about the former. -Albert Einstein-
yum -y --enablerepo=morals install honesty&
remove piratedcontent
S.C.O.U.R.G.E. Heroes of lesser renown, contributor.
Wine Basics Logitech g15 How-To Community made packages.
Reply With Quote
  #15  
Old 29th November 2007, 06:18 AM
alfal Offline
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
Reply With Quote
Reply

Tags
bash, current, folder, nautilus, open, root, scripts

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open nautilus as root RimFrost Using Fedora 5 4th September 2009 10:27 PM
open nautilus as root? DennyCrane Using Fedora 4 16th April 2008 05:53 AM
nautilus takes 10-14 seconds to open home folder nandowong Using Fedora 5 6th December 2005 10:00 PM


Current GMT-time: 17:17 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat