Bugzilla – Bug 961
problems with xargs & parallel
Last modified: 2021-03-14 08:41:06 MDT
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
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.
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.
It would be good to add your answer to the documentation - it would be useful to others.
I added more information about escaping to the sudoers manual in 1.9.6