version 1.1.1.1, 2013/07/22 00:51:38
|
version 1.1.1.2, 2014/06/15 16:12:54
|
Line 45
|
Line 45
|
#include <grp.h> |
#include <grp.h> |
|
|
#include "missing.h" |
#include "missing.h" |
|
#include "sudo_util.h" |
|
|
#ifndef LINE_MAX |
#ifndef LINE_MAX |
# define LINE_MAX 2048 |
# define LINE_MAX 2048 |
Line 101 mygetgrent(void)
|
Line 102 mygetgrent(void)
|
static struct group gr; |
static struct group gr; |
static char grbuf[LINE_MAX], *gr_mem[GRMEM_MAX+1]; |
static char grbuf[LINE_MAX], *gr_mem[GRMEM_MAX+1]; |
size_t len; |
size_t len; |
|
id_t id; |
char *cp, *colon; |
char *cp, *colon; |
|
const char *errstr; |
int n; |
int n; |
|
|
|
next_entry: |
if ((colon = fgets(grbuf, sizeof(grbuf), grf)) == NULL) |
if ((colon = fgets(grbuf, sizeof(grbuf), grf)) == NULL) |
return NULL; |
return NULL; |
|
|
memset(&gr, 0, sizeof(gr)); |
memset(&gr, 0, sizeof(gr)); |
if ((colon = strchr(cp = colon, ':')) == NULL) |
if ((colon = strchr(cp = colon, ':')) == NULL) |
return NULL; | goto next_entry; |
*colon++ = '\0'; |
*colon++ = '\0'; |
gr.gr_name = cp; |
gr.gr_name = cp; |
if ((colon = strchr(cp = colon, ':')) == NULL) |
if ((colon = strchr(cp = colon, ':')) == NULL) |
return NULL; | goto next_entry; |
*colon++ = '\0'; |
*colon++ = '\0'; |
gr.gr_passwd = cp; |
gr.gr_passwd = cp; |
if ((colon = strchr(cp = colon, ':')) == NULL) |
if ((colon = strchr(cp = colon, ':')) == NULL) |
return NULL; | goto next_entry; |
*colon++ = '\0'; |
*colon++ = '\0'; |
gr.gr_gid = atoi(cp); | id = atoid(cp, NULL, NULL, &errstr); |
| if (errstr != NULL) |
| goto next_entry; |
| gr.gr_gid = (gid_t)id; |
len = strlen(colon); |
len = strlen(colon); |
if (len > 0 && colon[len - 1] == '\n') |
if (len > 0 && colon[len - 1] == '\n') |
colon[len - 1] = '\0'; |
colon[len - 1] = '\0'; |