Help!

environment variable or path shorthand for user that invok..


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 2) RSS
Next:  finding and terminating script that regularly acc..  
Author Message
consultmac2
External


Since: Jun 09, 2006
Posts: 5



PostPosted: Wed Dec 27, 2006 6:43 pm    Post subject: environment variable or path shorthand for user that invoked su?
Archived from groups: comp>os>linux>misc (more info?)

I'm working on a makefile to install my program, and it requires su
privileges, so I've written the associated documentation stating that
presumption. I'd like to put a shortcut to the program (via ln -s) on
the desktop of the user that invoked the 'make install', but I relying
on $HOME or ~/Desktop/ gives me root's home directory rather than the
desired user's home directory. Is there any environment variable or
shell command that I could perform that tell's me the desired user's
home directory even when running within 'su' ?

Thanks

-bC
Back to top
Bit Twister
External


Since: Dec 19, 2004
Posts: 1879



PostPosted: Wed Dec 27, 2006 8:52 pm    Post subject: Re: environment variable or path shorthand for user that invoked su? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 27 Dec 2006 18:43:34 -0800, consultmac2 wrote:
> Is there any environment variable or
> shell command that I could perform that tell's me the desired user's
> home directory even when running within 'su' ?

You may want to read http://www.catb.org/~esr/faqs/smart-questions.html
Which shell are you working in.

Does this work for you.
a=~user_login_here
echo $a
Back to top
Felix M. Palmen
External


Since: Aug 01, 2006
Posts: 20



PostPosted: Thu Dec 28, 2006 4:14 am    Post subject: Re: environment variable or path shorthand for user that invoked su? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hallo consultmac2,

* consultmac2 <barryc.ctr.TakeThisOut@gmail.com>:
> I'm working on a makefile to install my program, and it requires su
> privileges, so I've written the associated documentation stating that
> presumption. I'd like to put a shortcut to the program (via ln -s) on
> the desktop of the user that invoked the 'make install', but I relying
> on $HOME or ~/Desktop/ gives me root's home directory rather than the
> desired user's home directory. Is there any environment variable or
> shell command that I could perform that tell's me the desired user's
> home directory even when running within 'su' ?

You should not do this AT ALL. An experienced user will invoke 'make
install' with root privileges when he wants to install system-wide.
There are many possibilities to achieve this (su, sudo, ssh, logging in
as root on a vt, ...). So there is no practical and general solution
for you to know his user-name.

Maybe the user doesn't want to install system-wide but in his
home-directory, because he is not the machine's administrator - you
should support this. So don't call something like su INSIDE the
Makefile, this is not what people will expect.

For a nice and configurable build system, take a look at GNU autotools
and maybe some similar projects.

Greetings, Felix

--
Felix M. Palmen (Zirias) \ -PGP- <fmp.TakeThisOut@palmen.homeip.net> /"\ ASCII Ribbon
web: http://zirias.ath.cx/ \ http://zirias.ath.cx/pub.txt \ / Campaign
my open source projects: \ FP ED9B 62D0 BE39 32F9 2488 X Against HTML In
http://zirias.ath.cx/?pg=pro \ 5D0C 8177 9D80 5ECF F683 / \ Mail And News
Back to top
Milan Babuskov
External


Since: Oct 23, 2006
Posts: 247



PostPosted: Thu Jan 04, 2007 11:52 am    Post subject: Re: environment variable or path shorthand for user that invoked [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

consultmac2 wrote:
> I'm working on a makefile to install my program, and it requires su
> privileges, so I've written the associated documentation stating that
> presumption. I'd like to put a shortcut to the program (via ln -s) on
> the desktop of the user that invoked the 'make install', but I relying
> on $HOME or ~/Desktop/ gives me root's home directory rather than the
> desired user's home directory. Is there any environment variable or
> shell command that I could perform that tell's me the desired user's
> home directory even when running within 'su' ?

If you target KDE, Gnome or XFCE, you better take a look at
freedesktop.org. I'm not sure about dekstops stuff, but adding program's
link to start menu for all users is as easy as copying a .desktop file
to /usr/share/applications/

--
Milan Babuskov
http://njam.sourceforge.net
http://swoes.blogspot.com
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 2) All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum