-/* $OpenBSD: user.c,v 1.77 2009/02/08 11:37:43 chl Exp $ */
+/* $OpenBSD: user.c,v 1.78 2010/07/26 10:55:17 miod Exp $ */
/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
/*
if (cc > 0 && buf[cc - 1] != '\n' && !feof(from)) {
while (fgetc(from) != '\n' && !feof(from))
cc++;
- warn("%s: line `%s' too long (%d bytes), skipping",
+ warnx("%s: line `%s' too long (%d bytes), skipping",
_PATH_GROUP, buf, cc);
continue;
}
if ((colon = strchr(buf, ':')) == NULL) {
- warn("badly formed entry `%s'", buf);
- continue;
- }
- entc = (int)(colon - buf);
- if (entc == groupc && strncmp(group, buf, entc) == 0) {
- if (newent == NULL) {
+ /*
+ * The only valid entry with no column is the all-YP
+ * line.
+ */
+ if (strcmp(buf, "+\n") != 0) {
+ warnx("badly formed entry `%.*s'", cc - 1, buf);
continue;
- } else {
- cc = strlcpy(buf, newent, sizeof(buf));
- if (cc >= sizeof(buf)) {
- warnx("group `%s' entry too long", newent);
- return (0);
+ }
+ } else {
+ entc = (int)(colon - buf);
+ if (entc == groupc && strncmp(group, buf, entc) == 0) {
+ if (newent == NULL) {
+ continue;
+ } else {
+ cc = strlcpy(buf, newent, sizeof(buf));
+ if (cc >= sizeof(buf)) {
+ warnx("group `%s' entry too long",
+ newent);
+ return (0);
+ }
}
}
}
if (cc > 0 && buf[cc - 1] != '\n' && !feof(from)) {
while (fgetc(from) != '\n' && !feof(from))
cc++;
- warn("%s: line `%s' too long (%d bytes), skipping",
+ warnx("%s: line `%s' too long (%d bytes), skipping",
_PATH_GROUP, buf, cc);
continue;
}
if (cc > 0 && buf[cc - 1] != '\n' && !feof(from)) {
while (fgetc(from) != '\n' && !feof(from))
cc++;
- warn("%s: line `%s' too long (%d bytes), skipping",
+ warnx("%s: line `%s' too long (%d bytes), skipping",
_PATH_GROUP, buf, cc);
continue;
}
if (cc > 0 && buf[cc - 1] != '\n' && !feof(fp)) {
while (fgetc(fp) != '\n' && !feof(fp))
cc++;
- warn("%s: line `%s' too long (%d bytes), skipping",
+ warnx("%s: line `%s' too long (%d bytes), skipping",
file, buf, cc);
continue;
}