~ubuntu-branches/ubuntu/trusty/sudo/trusty-proposed

« back to all changes in this revision

Viewing changes to plugins/sudoers/goodpath.c

  • Committer: Package Import Robot
  • Author(s): Tyler Hicks
  • Date: 2012-07-16 14:01:42 UTC
  • mfrom: (1.3.22 sid)
  • Revision ID: package-import@ubuntu.com-20120716140142-b0tgau0k6nid4mrf
Tags: 1.8.5p2-1ubuntu1
* Merge from debian/testing (LP: #1024154), remaining changes:
  - debian/patches/keep_home_by_default.patch:
    + Set HOME in initial_keepenv_table.
  - debian/rules:
    + compile with --without-lecture --with-tty-tickets (Ubuntu specific)
    + install man/man8/sudo_root.8 in both flavours (Ubuntu specific)
    + install apport hooks
    + The ubuntu-sudo-as-admin-successful.patch was taken upstream by
      Debian however it requires a --enable-admin-flag configure flag to
      actually enable it in both flavours.
  - debian/control:
    + Mark Debian Vcs-* as XS-Debian-Vcs-*
    + update debian/control
  - debian/sudoers:
    + grant admin group sudo access
  - debian/source_sudo.py, debian/sudo-ldap.dirs, debian/sudo.dirs:
    + add usr/share/apport/package-hooks
  - debian/sudo.pam:
    + Use pam_env to read /etc/environment and /etc/default/locale
      environment files. Reading ~/.pam_environment is not permitted due to
      security reasons.
* Dropped changes:
  - debian/patches/lp927828-fix-abort-in-pam-modules-when-timestamp-valid.patch
    + Fixed upstream in 1.8.5
  - debian/patches/CVE-2012-2337.patch:
    + Fixed upstream in 1.8.4p5
  - debian/patches/pam_env_merge.patch:
    + Feature released upstream in 1.8.5
  - debian/{sudo,sudo-ldap}.{preinst,postinst,postrm}:
    + Drop Ubuntu-specific sudoers file migration code because the only
      upgrade path to quantal is from precise. All necessary sudoers file
      migration will have already been done by the time this version of the
      sudo package is installed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
/*
42
42
 * Verify that path is a normal file and executable by root.
43
43
 */
44
 
char *
 
44
bool
45
45
sudo_goodpath(const char *path, struct stat *sbp)
46
46
{
47
47
    struct stat sb;
48
 
 
49
 
    /* Check for brain damage */
50
 
    if (path == NULL || path[0] == '\0')
51
 
        return NULL;
52
 
 
53
 
    if (stat(path, &sb))
54
 
        return NULL;
55
 
 
56
 
    /* Make sure path describes an executable regular file. */
57
 
    if (!S_ISREG(sb.st_mode) || !(sb.st_mode & 0000111)) {
58
 
        errno = EACCES;
59
 
        return NULL;
 
48
    bool rval = false;
 
49
    debug_decl(sudo_goodpath, SUDO_DEBUG_UTIL)
 
50
 
 
51
    if (path != NULL && stat(path, &sb) == 0) {
 
52
        /* Make sure path describes an executable regular file. */
 
53
        if (S_ISREG(sb.st_mode) && ISSET(sb.st_mode, 0111))
 
54
            rval = true;
 
55
        else
 
56
            errno = EACCES;
 
57
        if (sbp)
 
58
            (void) memcpy(sbp, &sb, sizeof(struct stat));
60
59
    }
61
60
 
62
 
    if (sbp != NULL)
63
 
        (void) memcpy(sbp, &sb, sizeof(struct stat));
64
 
    return (char *)path;
 
61
    debug_return_bool(rval);
65
62
}