The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Finding files in current directory when 100,000's files in current directory kewong007 Shell Programming and Scripting 2 02-26-2009 03:13 PM
filename in current directory calgone337 Shell Programming and Scripting 2 04-15-2007 03:21 PM
cannot determine current directory axes UNIX for Advanced & Expert Users 15 11-13-2006 07:39 AM
Question about Restricting Search path of FIND to current directory super_duper_guy UNIX for Dummies Questions & Answers 2 10-17-2005 10:10 AM
Using tar for current directory, but not subs beilstwh UNIX for Dummies Questions & Answers 3 09-13-2004 10:33 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-02-2009
sport sport is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
Question on Verifying root's current directory

From a script how would I verify that the current directory (.) is not in root's path. Now when the script is going to be run the auditor wil not be signed in as root, but rather running it via sudo, so I'm thinking the standard $path won't work for that case.

Derek
  #2 (permalink)  
Old 04-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,802
Do you mean verify that the PATH variable does not have a dot for the current directory?


Code:
echo $PATH | grep -q -e '\.:' -e ':\.$' && echo "PATH env variable fails . test"

Otherwise I don't understand...
  #3 (permalink)  
Old 04-06-2009
sport sport is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
The problem I am having is that the $PATH variable for the process running under sudo does not reflect the “run as” user’s $PATH, rather it remains set to the calling user’s $PATH.

For example roots actual $PATH when logged in is:

/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin

But, when a script is run as root, using sudo, the value of $PATH is the calling user’s $PATH:

/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/dcjones/bin:/usr/bin/X11:/sbin:.

What the script is checking for is that the root user does not have the current directory “.” in its $PATH; what the script is seeing is not root’s $PATH
  #4 (permalink)  
Old 04-02-2009
LisaS LisaS is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 59
I think he means that he is sitting in a filesystem - say
/audit
(so if you issued say "bdf ." it would be the same as "bdf /audit"

and he wants to make sure that /audit is not in root's $PATH
but if the auditor is signed on via sudo - will the $PATH command work properly to answer the question?

(I have no idea if that's the same as what you said Jim, but that's how I read the question)
Closed Thread

Bookmarks

Tags
path, root, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0