process.c: move get*uid and set*uid parsers to a separate file
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 22:52:03 +0000 (22:52 +0000)
* 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.

Makefile.am
process.c
uid.c [new file with mode: 0644]

index 52f7f46db83fdfc77d1ff9f2ca21fff9b83cf6cc..c4f3326534d7ee681326e2b57fc9a63fb282add6 100644 (file)
@@ -90,6 +90,7 @@ strace_SOURCES =      \
        term.c          \
        time.c          \
        truncate.c      \
+       uid.c           \
        umask.c         \
        umount.c        \
        uname.c         \
index 720559d2bb35955d6074a90b33126596c47b3556..cf47c81d38d77f1e1326f0c7ebd632805bf13dd5 100644 (file)
--- a/process.c
+++ b/process.c
@@ -71,8 +71,6 @@
 # define PTRACE_SETREGS PTRACE_SETREGS64
 #endif
 
-#include <asm/posix_types.h>
-
 #if defined(IA64)
 # include <asm/ptrace_offsets.h>
 # include <asm/rse.h>
@@ -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 (file)
index 0000000..0991074
--- /dev/null
+++ b/uid.c
@@ -0,0 +1,77 @@
+#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;
+}