version 1.11, 2019/03/31 09:26:05 |
version 1.12, 2019/05/08 20:00:25 |
|
|
else |
else |
ids[i].mapped = id; |
ids[i].mapped = id; |
|
|
LOG4(sess, "remapped identifier %s: %d -> %d", |
LOG4("remapped identifier %s: %d -> %d", |
ids[i].name, ids[i].id, ids[i].mapped); |
ids[i].name, ids[i].id, ids[i].mapped); |
} |
} |
} |
} |
|
|
assert(i == *idsz); |
assert(i == *idsz); |
if (isgid) { |
if (isgid) { |
if ((grp = getgrgid((gid_t)id)) == NULL) { |
if ((grp = getgrgid((gid_t)id)) == NULL) { |
ERR(sess, "%d: unknown gid", id); |
ERR("%d: unknown gid", id); |
return 0; |
return 0; |
} |
} |
name = grp->gr_name; |
name = grp->gr_name; |
} else { |
} else { |
if ((usr = getpwuid((uid_t)id)) == NULL) { |
if ((usr = getpwuid((uid_t)id)) == NULL) { |
ERR(sess, "%d: unknown uid", id); |
ERR("%d: unknown uid", id); |
return 0; |
return 0; |
} |
} |
name = usr->pw_name; |
name = usr->pw_name; |
} |
} |
|
|
if ((sz = strlen(name)) > UINT8_MAX) { |
if ((sz = strlen(name)) > UINT8_MAX) { |
ERRX(sess, "%d: name too long: %s", id, name); |
ERRX("%d: name too long: %s", id, name); |
return 0; |
return 0; |
} else if (sz == 0) { |
} else if (sz == 0) { |
ERRX(sess, "%d: zero-length name", id); |
ERRX("%d: zero-length name", id); |
return 0; |
return 0; |
} |
} |
|
|
|
|
|
|
pp = reallocarray(*ids, *idsz + 1, sizeof(struct ident)); |
pp = reallocarray(*ids, *idsz + 1, sizeof(struct ident)); |
if (pp == NULL) { |
if (pp == NULL) { |
ERR(sess, "reallocarray"); |
ERR("reallocarray"); |
return 0; |
return 0; |
} |
} |
*ids = pp; |
*ids = pp; |
(*ids)[*idsz].id = id; |
(*ids)[*idsz].id = id; |
(*ids)[*idsz].name = strdup(name); |
(*ids)[*idsz].name = strdup(name); |
if ((*ids)[*idsz].name == NULL) { |
if ((*ids)[*idsz].name == NULL) { |
ERR(sess, "strdup"); |
ERR("strdup"); |
return 0; |
return 0; |
} |
} |
|
|
LOG4(sess, "adding identifier to list: %s (%u)", |
LOG4("adding identifier to list: %s (%u)", |
(*ids)[*idsz].name, (*ids)[*idsz].id); |
(*ids)[*idsz].name, (*ids)[*idsz].id); |
(*idsz)++; |
(*idsz)++; |
return 1; |
return 1; |
|
|
sz = strlen(ids[i].name); |
sz = strlen(ids[i].name); |
assert(sz > 0 && sz <= UINT8_MAX); |
assert(sz > 0 && sz <= UINT8_MAX); |
if (!io_write_uint(sess, fd, ids[i].id)) { |
if (!io_write_uint(sess, fd, ids[i].id)) { |
ERRX1(sess, "io_write_uint"); |
ERRX1("io_write_uint"); |
return 0; |
return 0; |
} else if (!io_write_byte(sess, fd, sz)) { |
} else if (!io_write_byte(sess, fd, sz)) { |
ERRX1(sess, "io_write_byte"); |
ERRX1("io_write_byte"); |
return 0; |
return 0; |
} else if (!io_write_buf(sess, fd, ids[i].name, sz)) { |
} else if (!io_write_buf(sess, fd, ids[i].name, sz)) { |
ERRX1(sess, "io_write_buf"); |
ERRX1("io_write_buf"); |
return 0; |
return 0; |
} |
} |
} |
} |
|
|
if (!io_write_int(sess, fd, 0)) { |
if (!io_write_int(sess, fd, 0)) { |
ERRX1(sess, "io_write_int"); |
ERRX1("io_write_int"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
|
|
for (;;) { |
for (;;) { |
if (!io_read_uint(sess, fd, &id)) { |
if (!io_read_uint(sess, fd, &id)) { |
ERRX1(sess, "io_read_uint"); |
ERRX1("io_read_uint"); |
return 0; |
return 0; |
} else if (id == 0) |
} else if (id == 0) |
break; |
break; |
|
|
pp = reallocarray(*ids, |
pp = reallocarray(*ids, |
*idsz + 1, sizeof(struct ident)); |
*idsz + 1, sizeof(struct ident)); |
if (pp == NULL) { |
if (pp == NULL) { |
ERR(sess, "reallocarray"); |
ERR("reallocarray"); |
return 0; |
return 0; |
} |
} |
*ids = pp; |
*ids = pp; |
|
|
*/ |
*/ |
|
|
if (!io_read_byte(sess, fd, &sz)) { |
if (!io_read_byte(sess, fd, &sz)) { |
ERRX1(sess, "io_read_byte"); |
ERRX1("io_read_byte"); |
return 0; |
return 0; |
} else if (sz == 0) |
} else if (sz == 0) |
WARNX(sess, "zero-length name in identifier list"); |
WARNX("zero-length name in identifier list"); |
|
|
(*ids)[*idsz].id = id; |
(*ids)[*idsz].id = id; |
(*ids)[*idsz].name = calloc(sz + 1, 1); |
(*ids)[*idsz].name = calloc(sz + 1, 1); |
if ((*ids)[*idsz].name == NULL) { |
if ((*ids)[*idsz].name == NULL) { |
ERR(sess, "calloc"); |
ERR("calloc"); |
return 0; |
return 0; |
} |
} |
if (!io_read_buf(sess, fd, (*ids)[*idsz].name, sz)) { |
if (!io_read_buf(sess, fd, (*ids)[*idsz].name, sz)) { |
ERRX1(sess, "io_read_buf"); |
ERRX1("io_read_buf"); |
return 0; |
return 0; |
} |
} |
(*idsz)++; |
(*idsz)++; |