From 9abb5a7a5ddcda0dc93d7be64eb085187e96d144 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 26 Aug 2020 22:54:30 +0000 Subject: [PATCH] add socket info for user and group for unix sockets in fstat. --- sys/kern/uipc_socket.c | 5 +++-- sys/kern/uipc_socket2.c | 5 +++-- sys/kern/uipc_usrreq.c | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 66b27d7c7b5f..702868f1cf5d 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.290 2020/06/07 15:19:05 maxv Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.290 2020/06/07 15:19:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -526,6 +526,7 @@ socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l, #endif uid = kauth_cred_geteuid(l->l_cred); so->so_uidinfo = uid_find(uid); + so->so_egid = kauth_cred_getegid(l->l_cred); so->so_cpid = l->l_proc->p_pid; /* diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 2c5b3a18f394..c5764afd968d 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket2.c,v 1.137 2020/05/23 23:42:43 ad Exp $ */ +/* $NetBSD: uipc_socket2.c,v 1.138 2020/08/26 22:54:30 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.137 2020/05/23 23:42:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.138 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -317,6 +317,7 @@ sonewconn(struct socket *head, bool soready) so->so_send = head->so_send; so->so_receive = head->so_receive; so->so_uidinfo = head->so_uidinfo; + so->so_egid = head->so_egid; so->so_cpid = head->so_cpid; /* diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 03c8c8ac1f06..6c1ca5a1cb3d 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_usrreq.c,v 1.198 2020/04/21 21:42:47 ad Exp $ */ +/* $NetBSD: uipc_usrreq.c,v 1.199 2020/08/26 22:54:30 christos Exp $ */ /*- * Copyright (c) 1998, 2000, 2004, 2008, 2009, 2020 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.198 2020/04/21 21:42:47 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.199 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -898,6 +898,8 @@ unp_stat(struct socket *so, struct stat *ub) unp->unp_ino = unp_ino++; ub->st_atimespec = ub->st_mtimespec = ub->st_ctimespec = unp->unp_ctime; ub->st_ino = unp->unp_ino; + ub->st_uid = so->so_uidinfo->ui_uid; + ub->st_gid = so->so_egid; return (0); }