Bug 961 - problems with xargs & parallel
problems with xargs & parallel
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.9.5
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-08 08:14 MST by Sergey
Modified: 2021-03-14 08:41 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey 2021-02-08 08:14:00 MST
install_manifest.txt:
/usr/local/test/test 1.txt
/usr/local/test/test 2.txt

test 1.txt:
aaaaaa

test 2.txt:
bbbbbb

If for /etc/sudoers for user u1 specifies:
  u1 ALL=(ALL:ALL) NOPASSWD: ALL

that works: cat install_manifest.txt | xargs -t -d \\n rm

but if in /etc/sudoerr point out
u1 ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d "\\n" rm
or  -d '\n'
or  -d '\\n'
or  -d "\\n"
or  -d \\n
or something else, then issued:

for: cat install_manifest.txt | sudo xargs -t -d '\n' rm
/etc/sudoers.d/f1:32:50: syntax error
u1	ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d '\n' rm
"\\n" rm
                                                 ^
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
/etc/sudoers.d/f1:32:50: syntax error
u1	ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d '\n' rm
"\\n" rm
                                                 ^
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
/etc/sudoers.d/f1:32:50: syntax error
u1	ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d '\n' rm
"\\n" rm
                                                 ^
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root on A1.prv.

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
/etc/sudoers.d/f1:32:50: syntax error
u1	ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d '\n' rm
"\\n" rm
                                                 ^
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
/etc/sudoers.d/f1:32:50: syntax error
u1	ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d "\n" rm
"\\n" rm
                                                 ^
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d "\\n" rm
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d '\\n' rm
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \\n rm' as root

for: cat install_manifest.txt | sudo xargs -t -d '\\n' rm
Sorry, user u1 is not allowed to execute '/usr/bin/xargs -t -d \\n rm' as root

The same thing happens for the 'parallel' command.

I wrote to Debian 2021-01-02, but so far I haven't received any response.
--------------------------------------------------------------------------------
Debian 64 10.7 SID

-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-3-amd64 (SMP w/8 CPU threads)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages sudo depends on:
ii libaudit1 1:3.0-2
ii libc6 2.31-9
ii libpam-modules 1.4.0-4
ii libpam0g 1.4.0-4
ii libselinux1 3.1-2+b2
ii lsb-base 11.1.0
ii zlib1g 1:1.2.11.dfsg-2

sudo recommends no packages.

sudo suggests no packages.

-- Configuration Files:
/etc/sudo.conf changed:
Debug sudo /var/log/sudo_debug all@debug

/etc/sudoers [Errno 13] Access denied: '/etc/sudoers'
/etc/sudoers.d/README [Errno 13] Access denied: '/etc/sudoers.d/README'

-- no debconf information
Comment 1 Todd C. Miller 2021-02-08 08:33:13 MST
You have a syntax error in your sudoers file, the '\n' is the problem.  The following sudoers entry will work:

u1 ALL=(ALL:ALL) NOPASSWD: /usr/bin/xargs -t -d \\\\n rm

Unfortunately, you need to escape the \n twice.  The first set of backslashes gets removed by the sudoers parser and fnmatch() removes the second set.
Comment 2 Sergey 2021-02-08 14:13:05 MST
Thank you, it helped. Confused that xargs without sudo managed '-d \\n'.
I didn't find anything useful on this topic on the Internet. I got to '-d \\\n ' myself, but it didn't help, and I didn't go any further.
Comment 3 Sergey 2021-02-09 05:29:00 MST
It would be good to add your answer to the documentation - it would be useful to others.
Comment 4 Todd C. Miller 2021-03-14 08:41:06 MDT
I added more information about escaping to the sudoers manual in 1.9.6