incron
incron copied to clipboard
Quoted arguments with embedded spaces in user incrontab not being properly parsed
In a user incrontab, quoted arguments with embedded spaces are not being properly parsed. For instance, if the user incrontab has this single line:
/home/paulo/Google\ Drive/.insync-trash/ IN_CREATE,IN_MOVED_TO
/home/paulo/bin/push -t 'Deleted from GDrive' $#
the single quoted argument Deleted from GDrive
is being treated as 3 separate arguments:
'Deleted
from
GDrive'
It looks as though the command line is not being handed to a shell for processing.
The changelog entry for version _0.5.10-2 (03/20/2014)_ mentions:
* Add a patch to fix bad handling of arguments with spaces in incrontabs
which seems to be the problem I'm facing. I couldn't find the issue in the bug tracker to confirm, I wonder if this patch has been removed ?
Steps to Reproduce:
- Create a directory under
/tmp
:
mkdir -p /tmp/deleteme
- Create a script that logs each of its arguments on syslog:
cat <<'EOF' >/tmp/x
#!/bin/bash
for arg in "$@"; do logger -t "$0" "$arg"; done
EOF
chmod +x /tmp/x
- Add this line to the user incrontab:
/tmp/deleteme IN_CREATE /tmp/x "File: $#" "Flags: $%"
- Install the incrontab
- Create a file under
/tmp/deleteme
touch /tmp/deleteme/xxx
- Look at the message on syslog:
Mar 12 22:32:46 monk incrond[1849]: (paulo) CMD (/tmp/x "File: xxx" "Flags: IN_CREATE")
Mar 12 22:32:46 monk /tmp/x: "File:
Mar 12 22:32:46 monk /tmp/x: xxx"
Mar 12 22:32:47 monk /tmp/x: "Flags:
Mar 12 22:32:47 monk /tmp/x: IN_CREATE"
There should be only 2 unquoted messages logged, one for each argument:
Mar 12 22:32:46 monk /tmp/x: File: xxx
Mar 12 22:32:47 monk /tmp/x: Flags: IN_CREATE
Additional Information: I'm running _incron 0.5.10-2ubuntu1_ on _Xubuntu 14.10_ with _kernel 3.16.0-31-generic_.
Please let me know how I can help debug this further.