Support spaces in group names.
MFC after: 2 weeks Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
77edd8fa00
commit
2d22bf634a
@ -176,7 +176,7 @@ sdump_group(struct group *grp, char *buffer, size_t buflen)
|
||||
char **cp;
|
||||
int written;
|
||||
|
||||
written = snprintf(buffer, buflen, "%s %s %d",
|
||||
written = snprintf(buffer, buflen, "%s:%s:%d:",
|
||||
grp->gr_name, grp->gr_passwd, grp->gr_gid);
|
||||
buffer += written;
|
||||
if (written > buflen)
|
||||
@ -186,7 +186,8 @@ sdump_group(struct group *grp, char *buffer, size_t buflen)
|
||||
if (grp->gr_mem != NULL) {
|
||||
if (*(grp->gr_mem) != '\0') {
|
||||
for (cp = grp->gr_mem; *cp; ++cp) {
|
||||
written = snprintf(buffer, buflen, " %s",*cp);
|
||||
written = snprintf(buffer, buflen, "%s%s",
|
||||
cp == grp->gr_mem ? "" : ",", *cp);
|
||||
buffer += written;
|
||||
if (written > buflen)
|
||||
return;
|
||||
@ -196,9 +197,9 @@ sdump_group(struct group *grp, char *buffer, size_t buflen)
|
||||
return;
|
||||
}
|
||||
} else
|
||||
snprintf(buffer, buflen, " nomem");
|
||||
snprintf(buffer, buflen, "nomem");
|
||||
} else
|
||||
snprintf(buffer, buflen, " (null)");
|
||||
snprintf(buffer, buflen, "(null)");
|
||||
}
|
||||
|
||||
static int
|
||||
@ -206,6 +207,7 @@ group_read_snapshot_func(struct group *grp, char *line)
|
||||
{
|
||||
StringList *sl;
|
||||
char *s, *ps, *ts;
|
||||
const char *sep;
|
||||
int i;
|
||||
|
||||
printf("1 line read from snapshot:\n%s\n", line);
|
||||
@ -213,8 +215,9 @@ group_read_snapshot_func(struct group *grp, char *line)
|
||||
i = 0;
|
||||
sl = NULL;
|
||||
ps = line;
|
||||
sep = ":";
|
||||
memset(grp, 0, sizeof(struct group));
|
||||
while ((s = strsep(&ps, " ")) != NULL) {
|
||||
while ((s = strsep(&ps, sep)) != NULL) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
grp->gr_name = strdup(s);
|
||||
@ -235,6 +238,8 @@ group_read_snapshot_func(struct group *grp, char *line)
|
||||
grp->gr_passwd = NULL;
|
||||
return (-1);
|
||||
}
|
||||
/* Change to parsing groups. */
|
||||
sep = ",";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user