version 1.1.1.1, 2012/02/21 16:23:02
|
version 1.1.1.2, 2012/05/29 12:26:49
|
Line 29
|
Line 29
|
# include <stdlib.h> |
# include <stdlib.h> |
# endif |
# endif |
#endif /* STDC_HEADERS */ |
#endif /* STDC_HEADERS */ |
|
#ifdef HAVE_STDBOOL_H |
|
# include <stdbool.h> |
|
#else |
|
# include "compat/stdbool.h" |
|
#endif /* HAVE_STDBOOL_H */ |
#ifdef HAVE_STRING_H |
#ifdef HAVE_STRING_H |
# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS) |
# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS) |
# include <memory.h> |
# include <memory.h> |
Line 56
|
Line 61
|
* same format as /etc/group. |
* same format as /etc/group. |
*/ |
*/ |
|
|
#undef TRUE |
|
#define TRUE 1 |
|
#undef FALSE |
|
#define FALSE 0 |
|
#undef ERROR |
|
#define ERROR -1 |
|
|
|
static sudo_printf_t sudo_log; |
static sudo_printf_t sudo_log; |
|
|
extern void mysetgrfile(const char *); |
extern void mysetgrfile(const char *); |
Line 82 sample_init(int version, sudo_printf_t sudo_printf, ch
|
Line 80 sample_init(int version, sudo_printf_t sudo_printf, ch
|
"sample_group: incompatible major version %d, expected %d\n", |
"sample_group: incompatible major version %d, expected %d\n", |
GROUP_API_VERSION_GET_MAJOR(version), |
GROUP_API_VERSION_GET_MAJOR(version), |
GROUP_API_VERSION_MAJOR); |
GROUP_API_VERSION_MAJOR); |
return ERROR; | return -1; |
} |
} |
|
|
/* Sanity check the specified group file. */ |
/* Sanity check the specified group file. */ |
if (argv == NULL || argv[0] == NULL) { |
if (argv == NULL || argv[0] == NULL) { |
sudo_log(SUDO_CONV_ERROR_MSG, |
sudo_log(SUDO_CONV_ERROR_MSG, |
"sample_group: path to group file not specified\n"); |
"sample_group: path to group file not specified\n"); |
return ERROR; | return -1; |
} |
} |
if (stat(argv[0], &sb) != 0) { |
if (stat(argv[0], &sb) != 0) { |
sudo_log(SUDO_CONV_ERROR_MSG, |
sudo_log(SUDO_CONV_ERROR_MSG, |
"sample_group: %s: %s\n", argv[0], strerror(errno)); |
"sample_group: %s: %s\n", argv[0], strerror(errno)); |
return ERROR; | return -1; |
} |
} |
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) { |
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) { |
sudo_log(SUDO_CONV_ERROR_MSG, |
sudo_log(SUDO_CONV_ERROR_MSG, |
"%s must be only be writable by owner\n", argv[0]); |
"%s must be only be writable by owner\n", argv[0]); |
return ERROR; | return -1; |
} |
} |
|
|
mysetgrfile(argv[0]); |
mysetgrfile(argv[0]); |
mysetgrent(); |
mysetgrent(); |
|
|
return TRUE; | return true; |
} |
} |
|
|
static void |
static void |
Line 115 sample_cleanup(void)
|
Line 113 sample_cleanup(void)
|
} |
} |
|
|
/* |
/* |
* Returns TRUE if "user" is a member of "group", else FALSE. | * Returns true if "user" is a member of "group", else false. |
*/ |
*/ |
static int |
static int |
sample_query(const char *user, const char *group, const struct passwd *pwd) |
sample_query(const char *user, const char *group, const struct passwd *pwd) |
Line 127 sample_query(const char *user, const char *group, cons
|
Line 125 sample_query(const char *user, const char *group, cons
|
if (grp != NULL) { |
if (grp != NULL) { |
for (member = grp->gr_mem; *member != NULL; member++) { |
for (member = grp->gr_mem; *member != NULL; member++) { |
if (strcasecmp(user, *member) == 0) |
if (strcasecmp(user, *member) == 0) |
return TRUE; | return true; |
} |
} |
} |
} |
|
|
return FALSE; | return false; |
} |
} |
|
|
struct sudoers_group_plugin group_plugin = { |
struct sudoers_group_plugin group_plugin = { |