From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 24 14:00:41 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 718FD16A4C0 for ; Fri, 24 Oct 2003 14:00:41 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AEA743F3F for ; Fri, 24 Oct 2003 14:00:40 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h9OL0eFY048562 for ; Fri, 24 Oct 2003 14:00:40 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h9OL0e2W048561; Fri, 24 Oct 2003 14:00:40 -0700 (PDT) (envelope-from gnats) Date: Fri, 24 Oct 2003 14:00:40 -0700 (PDT) Message-Id: <200310242100.h9OL0e2W048561@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Poul-Henning Kamp" Subject: Re: kern/58497: sysctl knob to return current process' jid X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Poul-Henning Kamp List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Oct 2003 21:00:41 -0000 The following reply was made to PR kern/58497; it has been noted by GNATS. From: "Poul-Henning Kamp" To: "C. Stephen Gunn" Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: kern/58497: sysctl knob to return current process' jid Date: Fri, 24 Oct 2003 22:57:39 +0200 >There is no easy way to tell if a process is operating in a Jail >environment. Yes, in fact there is: #include #include #include #include #include /* * Exit 0 = no * Exit 1 = maybe * Exit 2 = yes */ int main(int argc, char **argv) { int mib[4]; int i, l; struct kinfo_proc buf; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PID; mib[3] = getpid(); l = sizeof buf; i = sysctl(mib, 4, &buf, &l, NULL, 0); if (i != 0 || l != sizeof buf) exit(1); if (buf.kp_proc.p_flag & P_JAILED) exit(2); exit (0); } -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.