Decode struct ucred (pid, uid, gid) for getsockopt() with SO_PEERCRED.

Signed-off-by: Arkadiusz Miśkiewicz <[email protected]>
---
 net.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/net.c b/net.c
index f56664e..4c0f170 100644
--- a/net.c
+++ b/net.c
@@ -1774,6 +1774,25 @@ sys_getsockopt(struct tcb *tcp)
                                }
                                break;
 #endif
+#ifdef SO_PEERCRED
+                       case SO_PEERCRED:
+                               if (len == sizeof (struct ucred)) {
+                                       struct ucred ucred;
+                                       if (umove (tcp,
+                                                  tcp->u_arg[3],
+                                                  &ucred) < 0)
+                                               break;
+                                       tprintf("{pid=%lu, uid=%lu, gid=%lu}, "
+                                               "[%d]",
+                                               ucred.pid,
+                                               ucred.uid,
+                                               ucred.gid,
+                                               len);
+                                       return 0;
+                               }
+                               break;
+#endif
+
                        }
                        break;
                case SOL_PACKET:
-- 
1.7.3.2


------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to