From owner-svn-src-all@freebsd.org Wed Aug 15 18:35:44 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DB5E106BBD5; Wed, 15 Aug 2018 18:35:44 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C7E6A735DF; Wed, 15 Aug 2018 18:35:43 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A47F66457; Wed, 15 Aug 2018 18:35:43 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7FIZhE2094706; Wed, 15 Aug 2018 18:35:43 GMT (envelope-from netchild@FreeBSD.org) Received: (from netchild@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7FIZgW7094701; Wed, 15 Aug 2018 18:35:42 GMT (envelope-from netchild@FreeBSD.org) Message-Id: <201808151835.w7FIZgW7094701@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: netchild set sender to netchild@FreeBSD.org using -f From: Alexander Leidinger Date: Wed, 15 Aug 2018 18:35:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337863 - in head: sys/sys usr.sbin/jail X-SVN-Group: head X-SVN-Commit-Author: netchild X-SVN-Commit-Paths: in head: sys/sys usr.sbin/jail X-SVN-Commit-Revision: 337863 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 18:35:44 -0000 Author: netchild Date: Wed Aug 15 18:35:42 2018 New Revision: 337863 URL: https://svnweb.freebsd.org/changeset/base/337863 Log: - Add exec hook "exec.created". This is called when the jail is created and before exec.start is called. [1] - Bump __FreeBSD_version. This allows to attach ZFS datasets and various other things to be done before any command/service/rc-script is started in the new jail. PR: 228066 [1] Reviewed by: jamie [1] Submitted by: Stefan Grönke [1] Differential Revision: https://reviews.freebsd.org/D15330 [1] Modified: head/sys/sys/param.h head/usr.sbin/jail/command.c head/usr.sbin/jail/config.c head/usr.sbin/jail/jail.8 head/usr.sbin/jail/jail.c head/usr.sbin/jail/jailp.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed Aug 15 18:19:45 2018 (r337862) +++ head/sys/sys/param.h Wed Aug 15 18:35:42 2018 (r337863) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200077 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200078 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, Modified: head/usr.sbin/jail/command.c ============================================================================== --- head/usr.sbin/jail/command.c Wed Aug 15 18:19:45 2018 (r337862) +++ head/usr.sbin/jail/command.c Wed Aug 15 18:35:42 2018 (r337863) @@ -147,8 +147,8 @@ next_command(struct cfjail *j) } if (j->comstring == NULL || j->comstring->len == 0 || (create_failed && (comparam == IP_EXEC_PRESTART || - comparam == IP_EXEC_START || comparam == IP_COMMAND || - comparam == IP_EXEC_POSTSTART))) + comparam == IP_EXEC_CREATED || comparam == IP_EXEC_START || + comparam == IP_COMMAND || comparam == IP_EXEC_POSTSTART))) continue; switch (run_command(j)) { case -1: Modified: head/usr.sbin/jail/config.c ============================================================================== --- head/usr.sbin/jail/config.c Wed Aug 15 18:19:45 2018 (r337862) +++ head/usr.sbin/jail/config.c Wed Aug 15 18:35:42 2018 (r337863) @@ -73,6 +73,7 @@ static const struct ipspec intparams[] = { [IP_EXEC_POSTSTOP] = {"exec.poststop", PF_INTERNAL}, [IP_EXEC_PRESTART] = {"exec.prestart", PF_INTERNAL}, [IP_EXEC_PRESTOP] = {"exec.prestop", PF_INTERNAL}, + [IP_EXEC_CREATED] = {"exec.created", PF_INTERNAL}, [IP_EXEC_START] = {"exec.start", PF_INTERNAL}, [IP_EXEC_STOP] = {"exec.stop", PF_INTERNAL}, [IP_EXEC_SYSTEM_JAIL_USER]= {"exec.system_jail_user", Modified: head/usr.sbin/jail/jail.8 ============================================================================== --- head/usr.sbin/jail/jail.8 Wed Aug 15 18:19:45 2018 (r337862) +++ head/usr.sbin/jail/jail.8 Wed Aug 15 18:35:42 2018 (r337863) @@ -706,6 +706,9 @@ The pseudo-parameters are: .Bl -tag -width indent .It Va exec.prestart Command(s) to run in the system environment before a jail is created. +.It Va exec.created +Command(s) to run in the system environment right after a jail has been +created, but before commands (or services) get executed in the jail. .It Va exec.start Command(s) to run in the jail environment when a jail is created. A typical command to run is Modified: head/usr.sbin/jail/jail.c ============================================================================== --- head/usr.sbin/jail/jail.c Wed Aug 15 18:19:45 2018 (r337862) +++ head/usr.sbin/jail/jail.c Wed Aug 15 18:35:42 2018 (r337863) @@ -98,6 +98,7 @@ static const enum intparam startcommands[] = { IP_MOUNT_PROCFS, IP_EXEC_PRESTART, IP__OP, + IP_EXEC_CREATED, IP_VNET_INTERFACE, IP_EXEC_START, IP_COMMAND, Modified: head/usr.sbin/jail/jailp.h ============================================================================== --- head/usr.sbin/jail/jailp.h Wed Aug 15 18:19:45 2018 (r337862) +++ head/usr.sbin/jail/jailp.h Wed Aug 15 18:35:42 2018 (r337863) @@ -88,6 +88,7 @@ enum intparam { IP_EXEC_POSTSTOP, /* Commands run outside jail after removing */ IP_EXEC_PRESTART, /* Commands run outside jail before creating */ IP_EXEC_PRESTOP, /* Commands run outside jail before removing */ + IP_EXEC_CREATED, /* Commands run outside jail right after it was started */ IP_EXEC_START, /* Commands run inside jail on creation */ IP_EXEC_STOP, /* Commands run inside jail on removal */ IP_EXEC_SYSTEM_JAIL_USER,/* Get jail_user from system passwd file */