[PATCH] Decode struct ucred for getsockopt() with SO_PEERCRED.

Arkadiusz Miśkiewicz arekm at maven.pl
Wed Dec 1 13:42:37 UTC 2010


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

Signed-off-by: Arkadiusz Miśkiewicz <arekm at maven.pl>
---
 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





More information about the Strace-devel mailing list