From a7a55cec17bd780eb467556d178c0c84ded141b3 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 7 Feb 2022 22:57:47 +0000 Subject: [PATCH] New status flag: 'c' - process is chrooted. Feedback and tweaks from deraadt@ guenther@ Ok bluhm@ deraadt@ --- bin/ps/print.c | 4 +++- bin/ps/ps.1 | 4 +++- sys/sys/sysctl.h | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/ps/print.c b/bin/ps/print.c index 40e0622420f..4e49a7fc3c6 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.79 2022/01/05 04:10:36 guenther Exp $ */ +/* $OpenBSD: print.c,v 1.80 2022/02/07 22:57:47 rob Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -289,6 +289,8 @@ printstate(const struct kinfo_proc *kp, VARENT *ve) else *cp++ = 'u'; } + if (kp->p_eflag & EPROC_CHROOT) + *cp++ = 'c'; *cp = '\0'; if (state == 'R' && kp->p_cpuid != KI_NOCPU) { diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 8586836e8f4..55a6e9f3d70 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ps.1,v 1.121 2022/02/07 19:28:14 rob Exp $ +.\" $OpenBSD: ps.1,v 1.122 2022/02/07 22:57:47 rob Exp $ .\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -451,6 +451,8 @@ swapped. .\" for example, .\" .Xr lisp 1 .\" in a garbage collect). +.It c +The process is chrooted. .It E The process is trying to exit. .It K diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 6ff6e3cffaf..0f2cb6b5733 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.222 2022/01/25 04:04:41 gnezdo Exp $ */ +/* $OpenBSD: sysctl.h,v 1.223 2022/02/07 22:57:47 rob Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -382,6 +382,7 @@ struct kinfo_proc { #define EPROC_SLEADER 0x02 /* session leader */ #define EPROC_UNVEIL 0x04 /* has unveil settings */ #define EPROC_LKUNVEIL 0x08 /* unveil is locked */ +#define EPROC_CHROOT 0x10 /* chrooted */ int32_t p_exitsig; /* unused, always zero. */ int32_t p_flag; /* INT: P_* flags. */ @@ -654,6 +655,8 @@ do { \ strlcpy((kp)->p_login, (sess)->s_login, \ MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \ \ + if ((pr)->ps_fd->fd_rdir != NULL) \ + (kp)->p_eflag |= EPROC_CHROOT; \ if ((sess)->s_ttyvp) \ (kp)->p_eflag |= EPROC_CTTY; \ if ((pr)->ps_uvpaths) \ -- 2.20.1