It is currently Wed Aug 16, 2017 5:17 pm



Welcome
Welcome to antiX-forum.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: cwd in $PATH, really ?
PostPosted: Sun Nov 06, 2016 7:51 pm 
Offline

Joined: Fri Oct 28, 2016 11:50 am
Posts: 69
Linux quasi-noobie question : I'm seeing my $PATH in antiX (regular user account) starts in dot (current working directory). Even twice fwiw ! I thought it was not good practice, what is the consensus ? How would I most easily remove/repair the double occurrence of dot in PATH, and would the removing possibly break some built-in script, functionality or program ?

Code:
$ echo $PATH
.:.:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Sun Nov 06, 2016 9:22 pm 
Offline

Joined: Thu Feb 09, 2012 7:29 am
Posts: 1263
If you check echo $PATH from console (Ctrl+Alt+F1--F6) you'll see a different result.
When you see that ( .:.: ) in terminal emulator, "how to get rid of it" could vary, depending on:
-- how the emulator is/was launched (affects whether $ENV is preserved)
-- directives within the emulator's config file
-- which shell (presumably bash) is running in the emulator
-- ^--> the content of your ~/.bashrc (or other rc file for other shell, as applicable)
-- the content of your ~/.profile
-- (certain situations) the content of /etc/bash.bashrc (hmm, or izzit /etc/profile ?)

You're probably seeing double dots because your chosen terminal emulator is naively stacking/concatenating the path stanzas read from those various configs. AFAIK, the status quo of double dots has never caused a problem for me. As for "best practice", shrug. If you would prefer incessantly typing full filepaths, knock yerself out. On my systems, I welcome the presence of leading dot (cwd) in the path envvar.


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Sun Nov 06, 2016 11:27 pm 
Offline

Joined: Fri Oct 28, 2016 11:50 am
Posts: 69
Quote:
As for "best practice", shrug. If you would prefer incessantly typing full filepaths, knock yerself out. On my systems, I welcome the presence of leading dot (cwd) in the path envvar.

OK, that's the micro$oft way, too :) The issue with cwd in path is somthing (malware...) could easily induce one to execute a malicious replacement for a legitimate command. Well, I guess malware is less a problem on antiX than in Windows (and I've never been "infected" running Windows, either). Thanks for the hint, Skidoo - I am going to leave the dot where it belongs and to ignore the double (triple, even, in a rxvt I'ne just opened now) occurrence.


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Mon Nov 07, 2016 12:09 am 
Offline

Joined: Wed Jul 13, 2016 1:02 pm
Posts: 57
Location: Freiburg, Germany
Ninho wrote:
How would I most easily remove/repair the double occurrence of dot in PATH [...],

Open the file /usr/local/lib/desktop-session/lib-desktop-session.sh in an editor and comment the line "PATH=.:$PATH" out.
Ninho wrote:
[...] and would the removing possibly break some built-in script, functionality or program ?

Well, I don't feel authorized to answer the second half of your question. But I have removed the double (in my case: triple) dots some hours ago and haven't observed any problems since.


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Mon Nov 07, 2016 1:00 am 
Offline

Joined: Fri Oct 28, 2016 11:50 am
Posts: 69
reverseDog wrote:
comment the line "PATH=.:$PATH" out.
... I have removed the double (in my case: triple) dots some hours ago and haven't observed any problems since.


Thanks, rD ! I'll follow your lead, not expecting problems either.


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Mon Nov 07, 2016 9:24 pm 
Offline

Joined: Thu Feb 09, 2012 7:29 am
Posts: 1263
Quote:
The issue with cwd in path is something (malware...)
could easily induce one to execute a malicious replacement for a legitimate command.

You've raised an excellent point. Considering all the other hoops I jump through trying to be safe, I realize that I really shouldn't "shrug".

The user environment isn't preserved by default for sudo user (and leading dot is absent from sudo/root $PATH), and I'm not inclined to
download and run stuff from untrusted sources. I suppose that's my rationalization for not adopting this particular "best practice".


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Tue Feb 07, 2017 10:30 am 
Offline

Joined: Thu Feb 09, 2012 7:29 am
Posts: 1263
Back in November, we didn't definitively resolve this, eh?
Quote:
I'm seeing my $PATH in antiX (regular user account) starts in dot (current working directory). Even twice...

I encountered this (.:.:.:.:.:.:.:.:.:.:.:/usr/bin...) recently while using lxterminal.
Checking roxterm, I found the $PATH was not similarly affected.
Comparing prefs set for the 2 emulators, I noticed that "treat shell as login shell" was checkmarked in my roxterm prefs.
Same wasn't marked in lxterminal prefs, and when I did so, that resolved lxterminal's "weird" pathstring.

Quote:
http://www.tldp.org/HOWTO/text/Path

sudo command has again a different approach to path handling.
It modifies the search path so that the current directory is always the last one.
However, it does not modify PATH environment variable.
That quoted linuxDocumentationProject page mentions about 8 or 9 places along the way
(between booting... and the context of using an xterm terminal emulator app)
where a configuration file may (re)set the default pathstring declaration for a user (or all users).

That bit I've quoted here, it overlaps with the configured behavior of gksu (and gexec).
IIRC, antiX default gksu configuration instructs "preserve environment" but does not set "treat as login shell".
Can check by typing "gksu" at a terminal emulator prompt... then clicking "advanced" in the gksu dialogbox.
man gksu explains that we can override the preconfigured default(s) by passing optional runtime args.
I checked and found that none of the launchstrings within ControlCenter pass those args to gksu.
(I'm not suggesting that any of the launchstrings should be changed, I'm just documenting the status quo.)
One of the cc launchers (sysv-rc-conf?) does present a confusing inconsistency -- it requires root user's password
Code:
--preserve-env, -k
        Preserve the current environments, does not set $HOME nor $PATH, for example.
--login, -l
       Make this a login shell.


Top
 Profile  
 
 Post subject: Re: cwd in $PATH, really ?
PostPosted: Wed Feb 08, 2017 10:21 pm 
Offline

Joined: Wed Jul 13, 2016 1:02 pm
Posts: 57
Location: Freiburg, Germany
skidoo wrote:
Checking roxterm, I found the $PATH was not similarly affected.
Comparing prefs set for the 2 emulators, I noticed that "treat shell as login shell" was checkmarked in my roxterm prefs.
Same wasn't marked in lxterminal prefs, and when I did so, that resolved lxterminal's "weird" pathstring.

Since /usr/local/lib/desktop-session/lib-desktop-session.sh is responsible for adding the current working directory (.) to $PATH but doesn't get sourced by login shell, your solution works.

Above I had suggested to comment out the line "PATH=.:$PATH" in /usr/local/lib/desktop-session/lib-desktop-session.sh. But I am not fond though of customizing system-wide files, so I found myself a better way to get rid of those weird cwds in $PATH. I simply added the line
Code:
export PATH=${PATH##+(.:)}

to my ~/.bashrc. :wink:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred