Bug 752 - sudo doesn't match long command lines in sudoers file
sudo doesn't match long command lines in sudoers file
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudoers
1.8.17
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-07-16 14:59 MDT by jfharrigan
Modified: 2016-09-20 15:15 MDT (History)
0 users

See Also:


Attachments
revert arg_size calculation patch (549 bytes, application/octet-stream)
2016-07-16 14:59 MDT, jfharrigan
Details
Account for NUL byte when computing how much space we need (3.60 KB, patch)
2016-07-16 20:14 MDT, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jfharrigan 2016-07-16 14:59:57 MDT
Created attachment 478 [details]
revert arg_size calculation patch

sudo-1.8.17p1 doesn't work with a sudoers file that was previously working with sudo-1.8.16.  It seems like long command lines in the sudoers file are being truncated when attempting to match them against the input command line.  For me, the 1.8.17p1 sudoers command line limit is 142 characters.

I was able to fix my problem with the attached patch which reverts a few lines in toke_util.c to how they were in 1.8.16.
Comment 1 Todd C. Miller 2016-07-16 16:24:21 MDT
I'm unable to reproduce this problem.  Can you tell me more about what Linux distro you are running and whether you installed sudo from a package or built it yourself?  If you built it yourself, please also list what version compiler you used.
Comment 2 jfharrigan 2016-07-16 19:47:31 MDT
The distro is a fairly recent version of CROSS-LFS but I don't remember the exact version.  GCC is version 5.3.0.

I built sudo from source with the following options (no CFLAGS):
./configure \
  --prefix=/home/install/bad-sudo \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --with-rundir=/var/lib/sudo \
  --enable-shared \
  --disable-static \
  --enable-shell-sets-home \
  --without-pam \
  --without-sendmail

I created a new user called sudotest with a single sudo rule.  The rule doesn't do anything useful, it's just designed to trigger the problem:
sudotest  ALL=(root)  NOPASSWD: /usr/bin/find /usr/local -mindepth 1 -type d -exec /bin/echo 0 {} ; -exec /bin/echo 1 {} ; -exec /bin/echo 2 {} ; -exec /bin/echo 3 {} ; -exec /bin/echo 4 {} ; -exec /bin/echo 5 {} ; -exec /bin/echo 6 {} ; -exec /bin/echo 7 {} ;

Here is the output of "sudo -l" without my patch:
Matching Defaults entries for sudotest on graphite:
    timestamp_timeout=0, root_sudo

User sudotest may run the following commands on graphite:
    (root) NOPASSWD: /usr/bin/find /usr/local -mindepth 1 -type d -exec
        /bin/echo 0 {} ; -exec /bin/echo 1 {} ; -exec /bin/echo 2 {} ; -exec
        /bin/echo 3 {} ; -exe

Here is the output of "sudo -l" with my patch:
Matching Defaults entries for sudotest on graphite:
    timestamp_timeout=0, root_sudo

User sudotest may run the following commands on graphite:
    (root) NOPASSWD: /usr/bin/find /usr/local -mindepth 1 -type d -exec
        /bin/echo 0 {} ; -exec /bin/echo 1 {} ; -exec /bin/echo 2 {} ; -exec
        /bin/echo 3 {} ; -exec /bin/echo 4 {} ; -exec /bin/echo 5 {} ; -exec
        /bin/echo 6 {} ; -exec /bin/echo 7 {} ;

The following command asks for a password when using sudo built without the patch.  With the patch it runs as I expected:
sudo find /usr/local -mindepth 1 -type d -exec /bin/echo 0 {} \; -exec /bin/echo 1 {} \; -exec /bin/echo 2 {} \; -exec /bin/echo 3 {} \; -exec /bin/echo 4 {} \; -exec /bin/echo 5 {} \; -exec /bin/echo 6 {} \; -exec /bin/echo 7 {} \;
Comment 3 Todd C. Miller 2016-07-16 20:14:34 MDT
Created attachment 479 [details]
Account for NUL byte when computing how much space we need

Thanks for the sudoers line to reproduce the problem.  The attached patch fixes the issue.
Comment 4 jfharrigan 2016-07-17 08:30:20 MDT
I tested the patch and it fixes my problem.  Thanks.
Comment 5 Todd C. Miller 2016-09-20 15:15:19 MDT
Fixed in sudo 1.8.18