find The current directory is included in the PATH environment variable


Recommended Posts

I'm trying to use find and run a execdir on .rar files for mass unpacking but i'm getting the error that . is in the $path. Should'nt that be removed?

 

"find: The current directory is included in the PATH environment variable, which is insecure in combination with the -execdir action of find.  Please remove the current directory from your $PATH (that is, remove "." or leading or trailing colons)"

 

https://askubuntu.com/questions/621132/why-using-the-execdir-action-is-insecure-for-directory-which-is-in-the-path

Edited by Tuumke
Link to comment
  • 1 year later...
  • 2 years later...

Sorry to resurrect an old thread... but to anyone coming across this problem in future, here is an easy solve applying a little beginner linux knowledge;

 

# Take a backup of $PATH to restore later
# Note: This will only keep the variable alive for the current session!
$ PATH_TEMP=$PATH

# ... just to make sure the $PATH_TEMP variable has been stored
$ echo $PATH_TEMP
.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

# Print the current $PATH so we can extract all paths except the current directory, so we can override it
$ echo $PATH
.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
#-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Copy everything BUT the first current directory marker (.) and break character (:)

# Next, export the modified $PATH to override it for the current session using the string you copied above
$ export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

# ... just to make sure the $PATH variable change has been stored
$ echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

# ---
# ... now you can run the find command!
# ---

# To restore the session $PATH either close your current terminal session and start a new one, or to manually restore
# the current session, lets load $PATH back from the $PATH_TEMP variable set earlier
$ export PATH=$PATH_TEMP

# ... verify everything is back to normal. Looking good!
$ echo $PATH
.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

 

Edited by unraidyn
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.