Question on Verifying root's current directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question on Verifying root's current directory
# 1  
Old 04-02-2009
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.

DerekSmilie
# 2  
Old 04-02-2009
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  
Old 04-02-2009
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)
# 4  
Old 04-06-2009
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

SunOS confusing root directory and user home directory

Hello, I've just started using a Solaris machine with SunOS 5.10. After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me I'm at my home directory (someone configured "myuser" as default user after init). ... (2 Replies)
Discussion started by: egyassun
2 Replies

2. UNIX for Dummies Questions & Answers

Removing directory with leading hyphen from root directory

I know that this basic question has been asked many times and solutions all over the internet, but none of the are working for me. I have a directory in the root directory, named "-p". # ls -l / total 198 <snip> drwxr-xr-x 4 root root 4096 Dec 3 14:18 opt drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: edstevens
2 Replies

3. UNIX for Dummies Questions & Answers

Current working directory

Hi all, How do I print the name of my current working directory only to screen? Not pwd! For example, if I was in /home/work I am looking for 'work' only (4 Replies)
Discussion started by: jimjam
4 Replies

4. UNIX for Dummies Questions & Answers

Silly question-how i refer to the current directory when saving files

I want to save a bunch of files to a folder in my current directory. Ho do i refer to my current directory without writing all the path? (2 Replies)
Discussion started by: FelipeAd
2 Replies

5. UNIX for Dummies Questions & Answers

How to display only Owner and directory/sub directory names under particular root

hai, I am new to Unix, I have a requirement to display owner name , directory or sub directory name, who's owner name is not equal to "oasitqtc". (here "oasitqtc" is the owner of the directory or sub directory.) i have a command (below) which will display all folders and sub folders, but i... (6 Replies)
Discussion started by: gagan4599
6 Replies

6. Shell Programming and Scripting

Get current logged in user from a script run as root.

Ok, so, in order to install some dependencies of a program I made, a script has to be run as root. The thing is that I have to copy some things into the home folder of currently logged in user, but the variable $HOME returns '/root' and the $USER returns 'root' :( Is there any way to see who is... (7 Replies)
Discussion started by: hakermania
7 Replies

7. Solaris

Solaris 8 - Asks for current root password when trying to change root password.

Hello All, I have several solaris boxes running Solaris 8. When changing root passwords on them, all will simply ask for the new root password to change and of course to re-type the new password. One of the systems however asks for the existing root password before it will display the new password... (8 Replies)
Discussion started by: tferrazz
8 Replies

8. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

9. UNIX for Dummies Questions & Answers

Question about Restricting Search path of FIND to current directory

Hi, By default FIND command searches for matching files in all the subdirectories within the specified path. Is there a way to restrict FIND command's search path to only the specified directory and NOT TO scan its subdirectories. Any help would be more than appreciated. Thanks and Regards (2 Replies)
Discussion started by: super_duper_guy
2 Replies

10. UNIX for Dummies Questions & Answers

? question mark, how to get back to the root directory

hiyas I am trying to get back to the root directory: I went into MAIL directory and now I can't get back to the root directory. What are the commands... I have '?' coming up and I cannot proceed with this, HELP Cheers (1 Reply)
Discussion started by: etravels
1 Replies
Login or Register to Ask a Question