strace/uid.c
Dmitry V. Levin e93ef1eb9d process.c: move get*uid and set*uid parsers to a separate file
* uid.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c (sys_getuid, sys_setfsuid, sys_setuid, sys_getresuid,
sys_setreuid, sys_setresuid): Move to uid.c.
2014-12-11 22:52:03 +00:00

78 lines
1.3 KiB
C

#include "defs.h"
#include <asm/posix_types.h>
int
sys_getuid(struct tcb *tcp)
{
if (exiting(tcp))
tcp->u_rval = (uid_t) tcp->u_rval;
return RVAL_UDECIMAL;
}
int
sys_setfsuid(struct tcb *tcp)
{
if (entering(tcp))
tprintf("%u", (uid_t) tcp->u_arg[0]);
else
tcp->u_rval = (uid_t) tcp->u_rval;
return RVAL_UDECIMAL;
}
int
sys_setuid(struct tcb *tcp)
{
if (entering(tcp)) {
tprintf("%u", (uid_t) tcp->u_arg[0]);
}
return 0;
}
int
sys_getresuid(struct tcb *tcp)
{
if (exiting(tcp)) {
__kernel_uid_t uid;
if (syserror(tcp))
tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
tcp->u_arg[1], tcp->u_arg[2]);
else {
if (umove(tcp, tcp->u_arg[0], &uid) < 0)
tprintf("%#lx, ", tcp->u_arg[0]);
else
tprintf("[%lu], ", (unsigned long) uid);
if (umove(tcp, tcp->u_arg[1], &uid) < 0)
tprintf("%#lx, ", tcp->u_arg[1]);
else
tprintf("[%lu], ", (unsigned long) uid);
if (umove(tcp, tcp->u_arg[2], &uid) < 0)
tprintf("%#lx", tcp->u_arg[2]);
else
tprintf("[%lu]", (unsigned long) uid);
}
}
return 0;
}
int
sys_setreuid(struct tcb *tcp)
{
if (entering(tcp)) {
printuid("", tcp->u_arg[0]);
printuid(", ", tcp->u_arg[1]);
}
return 0;
}
int
sys_setresuid(struct tcb *tcp)
{
if (entering(tcp)) {
printuid("", tcp->u_arg[0]);
printuid(", ", tcp->u_arg[1]);
printuid(", ", tcp->u_arg[2]);
}
return 0;
}