diff --git a/Makefile.am b/Makefile.am index 52f7f46d..c4f33265 100644 --- a/Makefile.am +++ b/Makefile.am @@ -90,6 +90,7 @@ strace_SOURCES = \ term.c \ time.c \ truncate.c \ + uid.c \ umask.c \ umount.c \ uname.c \ diff --git a/process.c b/process.c index 720559d2..cf47c81d 100644 --- a/process.c +++ b/process.c @@ -71,8 +71,6 @@ # define PTRACE_SETREGS PTRACE_SETREGS64 #endif -#include - #if defined(IA64) # include # include @@ -268,78 +266,6 @@ sys_fork(struct tcb *tcp) return 0; } -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; -} - #include "xlat/ptrace_cmds.h" #include "xlat/ptrace_setoptions_flags.h" #include "xlat/nt_descriptor_types.h" diff --git a/uid.c b/uid.c new file mode 100644 index 00000000..0991074a --- /dev/null +++ b/uid.c @@ -0,0 +1,77 @@ +#include "defs.h" + +#include + +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; +}