LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2012, 05:52 AM   #1
NeverOddOrEven
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Rep: Reputation: Disabled
problem starting gui app as different user from gnome launcher


Hi,
This is my first post ever. I hope I am in the right forum. If not,
my sincere apologies.

I'm trying to start a gui application (pgadmin3) from a gnome
launcher. Because the app needs to modify files that belong to user
postgres, I would like to run it as user postgres. So far I've had no
luck with any incantations I placed in the command field of the
launcher.

Code:
su -c 'pgadmin3' postgres
doesn't work because a) there is no terminal to input a password; and
b) user postgres does not have a set password (it is not a user that
would normally login).

Code:
sudo -u postgres pgadmin3
didn't work either. First I added an entry in the /etc/sudoers file to
bypass the need for a password; but then I ran into the problem that X
won't allow user postgres to start a gui app. In any case, I've read
that sudo is not safe to use with gui apps.

Code:
gksu -u postgres pgadmin3
didn't work because user postgres does not have a password.

Code:
gksudo -u postgres pgadmin3
didn't work because X won't allow user postgres to start a gui app.

Code:
gksudo pgadmin3
did successfully start the application; however any files subsequently
created by pgadmin3 were owned by root which causes permission problems
for all the other applications that need these files.

A script like so:
Code:
#!/bin/bash
xhost +local:local
gksudo -u postgres pgadmin3
xhost -local:local
does work but has the drawback that so long as its running any local,
possibly unauthorized, user can run X.

Finally I went off the deep end and wrote this:

Code:
#!/bin/bash 
# This grabs the X token from the current user's token file and puts it 
# in a target user's token file. Then it runs the target application.

# Set the target user and target application.
export TRG_USER=postgres
export TRG_PROG=pgadmin3

# Produce and store the path and name of the new token file for the
# target user. 
export FILE=`sudo su -c 'echo $HOME/temp_xauth' $TRG_USER`

# Get and store the X token for the current user. 
export TOKEN=`xauth -f $XAUTHORITY nextract - $DISPLAY`

# Create a command that does three things 
# a) It creates the token file for the target user. 
# b) It points the target user's XAUTHORITY environment variable to the
#    token file. 
# c) It runs the target application. 
export COMMAND=\ 
"sudo su -c '\ 
echo \""$TOKEN"\" | xauth -f "$FILE" nmerge -; \ 
export XAUTHORITY="$FILE"; "\ 
$TRG_PROG"' "\
$TRG_USER

# Run the command.
eval $COMMAND
Of course this doesn't work either because it contains all those "sudo"s
and "su"s.

Does anybody know whether there is an accepted way to do this? Any help
would be greatly appreciated.

Edward
 
Old 04-21-2012, 06:50 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
You forgot one important thing: info about the distro & desktop you're running.
My first suggestion is to install 'sux', it's a wrapper around su that makes it possible to run GUI-apps as other user. (This is not necessary in all distros, in some just 'su' works fine.)
I have never used it just to launch a single app so I can't promise it'll work, easy to try though!

Last edited by pingu; 04-21-2012 at 06:51 AM.
 
Old 04-24-2012, 12:13 AM   #3
NeverOddOrEven
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you for your reply. I am using gnome 2.30.2 on debian squeeze. I will try sux and report on what I find.

Edward
 
Old 04-24-2012, 06:17 PM   #4
NeverOddOrEven
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Solved

Thanks so much -
Code:
gksudo sux - postgres pgadmin3
works like a charm.
 
Old 04-24-2012, 06:41 PM   #5
NeverOddOrEven
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Maybe I should be more complete in my report. On gnome 2.30.2 on debian squeeze:

Code:
sux - postgres pgadmin3
works from a terminal, but not from a gnome launcher.

Code:
gsudo sux - postgres pgadmin3
works from a terminal and a gnome launcher.

Code:
gksu sux - postgres pgadmin3
works from a terminal and a gnome launcher.

Last edited by NeverOddOrEven; 04-24-2012 at 06:42 PM. Reason: misspelling
 
  


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
Gnome: Starting an app switches to a running instance instead of starting a new one SeppJ Linux - Newbie 0 05-28-2009 11:06 AM
GUI App for ripping CD's to MP3 (without Gnome/KDE) ChrisHenzel Linux - Desktop 4 12-13-2006 04:35 PM
Starting the gnome gui phil747 Linux - Software 2 11-06-2006 12:16 AM
Starting Firestarter GUI in GNOME as single user LinODE Slackware 1 01-28-2006 07:58 PM
Gnome Launcher Problem tonyfreeman Linux - Software 1 08-18-2004 06:09 AM


All times are GMT -5. The time now is 08:17 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration