# error invalid STRACE_UID_SIZE
# endif
-# define SIZEIFY(x) SIZEIFY_(x,STRACE_UID_SIZE)
-# define SIZEIFY_(x,size) SIZEIFY__(x,size)
-# define SIZEIFY__(x,size) x ## size
+# define SIZEIFY(x) SIZEIFY_(x, STRACE_UID_SIZE)
+# define SIZEIFY_(x, size) SIZEIFY__(x, size)
+# define SIZEIFY__(x, size) x ## size
# define printuid SIZEIFY(printuid)
# define sys_chown SIZEIFY(sys_chown)
SYS_FUNC(setfsuid)
{
- tprintf("%u", (uid_t) tcp->u_arg[0]);
+ printuid("", tcp->u_arg[0]);
return RVAL_UDECIMAL | RVAL_DECODED;
}
}
static void
-get_print_uid(struct tcb *tcp, const char *prefix, const long addr)
+get_print_uid(struct tcb *const tcp, const char *const prefix,
+ const kernel_ulong_t addr)
{
uid_t uid;
tprints(prefix);
- if (!umove_or_printaddr(tcp, addr, &uid))
- tprintf("[%u]", uid);
+ if (!umove_or_printaddr(tcp, addr, &uid)) {
+ printuid("[", uid);
+ tprints("]");
+ }
}
SYS_FUNC(getresuid)
tprintf("%s%u", text, (uid_t) uid);
}
+static bool
+print_gid(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
+{
+ printuid("", (*(uid_t *) elem_buf));
+
+ return true;
+}
+
static void
-print_groups(struct tcb *tcp, const unsigned int len, const unsigned long addr)
+print_groups(struct tcb *const tcp, const unsigned int len,
+ const kernel_ulong_t addr)
{
static unsigned long ngroups_max;
if (!ngroups_max)
ngroups_max = sysconf(_SC_NGROUPS_MAX);
- const unsigned int size = len * sizeof(uid_t);
- const unsigned long end = addr + size;
- if (!addr || !verbose(tcp) || size / sizeof(uid_t) != len
- || len > ngroups_max || end < addr) {
+ if (len > ngroups_max) {
printaddr(addr);
return;
}
- if (len == 0) {
- tprints("[]");
- return;
- }
-
- const unsigned long abbrev_end =
- (abbrev(tcp) && max_strlen < len) ?
- addr + max_strlen * sizeof(uid_t) : end;
-
- unsigned long cur;
- for (cur = addr; cur < end; cur += sizeof(uid_t)) {
- if (cur != addr)
- tprints(", ");
-
- uid_t gid;
- if (umove_or_printaddr(tcp, cur, &gid))
- break;
-
- if (cur == addr)
- tprints("[");
-
- if (cur >= abbrev_end) {
- tprints("...");
- cur = end;
- break;
- }
-
- tprintf("%u", (unsigned int) gid);
- }
- if (cur != addr)
- tprints("]");
+ uid_t gid;
+ print_array(tcp, addr, len, &gid, sizeof(gid),
+ umoven_or_printaddr, print_gid, 0);
}
SYS_FUNC(setgroups)
{
- const unsigned int len = tcp->u_arg[0];
+ const int len = tcp->u_arg[0];
- tprintf("%u, ", len);
+ tprintf("%d, ", len);
print_groups(tcp, len, tcp->u_arg[1]);
return RVAL_DECODED;
}
SYS_FUNC(getgroups)
{
if (entering(tcp))
- tprintf("%u, ", (unsigned int) tcp->u_arg[0]);
+ tprintf("%d, ", (int) tcp->u_arg[0]);
else
print_groups(tcp, tcp->u_rval, tcp->u_arg[1]);
return 0;