incron does not properly handle filenames containing spaces

Tony Baldwin photodharma at gmail.com
Thu Jun 11 12:47:44 UTC 2009


Michael Wood wrote:
> Package: incron
> Version: 0.5.7-1
> Severity: normal
> 
> Assuming a rule like this:
> /path IN_CLOSE_WRITE cmd $#
> 
> When a file called "file with spaces" is created in /path, cmd will be
> invoked with three arguments: "file", "with" and "spaces" instead of a
> single argument of "file with spaces".
> 
> This could cause cmd to process the wrong file and so could potentially
> be a security risk depending on the details.
> 

Don't use filenames with spaces.
That's always a bad idea.

when passing a command to bash to act on a file with spaces, you would 
have to quote the file name.

ie.

rm some file.odt #  where the file name is really "some file.odt"
rm: cannot remove `some': No such file or directory
rm: cannot remove `file.odt': No such file or directory

better use

rm "some file.odt"

better yet, replace the spaces with _ with the above rename.
to remove spaces from name in all files in a dir do

rename 's/ /_/g' *

or

rename.ul \  _ *

/tony


-- 
http://www.baldwinsoftware.com
free/open source software
tcl yer os with a feather...




More information about the ubuntu-users mailing list