~ubuntu-branches/ubuntu/raring/sudo/raring

« back to all changes in this revision

Viewing changes to plugins/sample_group/sample_group.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:
29
29
#  include <stdlib.h>
30
30
# endif
31
31
#endif /* STDC_HEADERS */
 
32
#ifdef HAVE_STDBOOL_H
 
33
# include <stdbool.h>
 
34
#else
 
35
# include "compat/stdbool.h"
 
36
#endif /* HAVE_STDBOOL_H */
32
37
#ifdef HAVE_STRING_H
33
38
# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS)
34
39
#  include <memory.h>
56
61
 * same format as /etc/group.
57
62
 */
58
63
 
59
 
#undef TRUE
60
 
#define TRUE 1
61
 
#undef FALSE
62
 
#define FALSE 0
63
 
#undef ERROR
64
 
#define ERROR -1
65
 
 
66
64
static sudo_printf_t sudo_log;
67
65
 
68
66
extern void mysetgrfile(const char *);
82
80
            "sample_group: incompatible major version %d, expected %d\n",
83
81
            GROUP_API_VERSION_GET_MAJOR(version),
84
82
            GROUP_API_VERSION_MAJOR);
85
 
        return ERROR;
 
83
        return -1;
86
84
    }
87
85
 
88
86
    /* Sanity check the specified group file. */
89
87
    if (argv == NULL || argv[0] == NULL) {
90
88
        sudo_log(SUDO_CONV_ERROR_MSG,
91
89
            "sample_group: path to group file not specified\n");
92
 
        return ERROR;
 
90
        return -1;
93
91
    }
94
92
    if (stat(argv[0], &sb) != 0) {
95
93
        sudo_log(SUDO_CONV_ERROR_MSG,
96
94
            "sample_group: %s: %s\n", argv[0], strerror(errno));
97
 
        return ERROR;
 
95
        return -1;
98
96
    }
99
97
    if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
100
98
        sudo_log(SUDO_CONV_ERROR_MSG,
101
99
            "%s must be only be writable by owner\n", argv[0]);
102
 
        return ERROR;
 
100
        return -1;
103
101
    }
104
102
 
105
103
    mysetgrfile(argv[0]);
106
104
    mysetgrent();
107
105
 
108
 
    return TRUE;
 
106
    return true;
109
107
}
110
108
 
111
109
static void
115
113
}
116
114
 
117
115
/*
118
 
 * Returns TRUE if "user" is a member of "group", else FALSE.
 
116
 * Returns true if "user" is a member of "group", else false.
119
117
 */
120
118
static int
121
119
sample_query(const char *user, const char *group, const struct passwd *pwd)
127
125
    if (grp != NULL) {
128
126
        for (member = grp->gr_mem; *member != NULL; member++) {
129
127
            if (strcasecmp(user, *member) == 0)
130
 
                return TRUE;
 
128
                return true;
131
129
        }
132
130
    }
133
131
 
134
 
    return FALSE;
 
132
    return false;
135
133
}
136
134
 
137
135
struct sudoers_group_plugin group_plugin = {