From: Stefan Berger Subject: Re: [PATCH v3] 98integrity: Use /etc/ima as dir for IMA policy and config file Date: Wed, 30 Nov 2016 12:54:42 -0500 Message-ID: <155467b7-2361-337c-2b52-b68753f86f1e@linux.vnet.ibm.com> References: <1480522734-975-1-git-send-email-stefanb@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1428271074==" Return-path: In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: systemd-devel-bounces@lists.freedesktop.org Sender: "systemd-devel" To: Stefan Berger Cc: linux-ima-user@lists.sourceforge.net, initramfs@vger.kernel.org, systemd-devel@lists.freedesktop.org, harald@redhat.com This is a multi-part message in MIME format. --===============1428271074== Content-Type: multipart/alternative; boundary="------------B20F340D9E82082C0C516E4A" This is a multi-part message in MIME format. --------------B20F340D9E82082C0C516E4A Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Harald, please do not apply this patch. Stefan > > > > > From: Stefan Berger > > > > To sync with systemd, use the filepath /etc/ima/ima-policy as > > the default file location for the IMA policy. At the same time we > > move the ima config file location to /etc/ima/ima. Adapt the > > documentation to the new path. Maintain backwards compatibility > > by still reading the old files in case the new ones do not exist. > > > > Signed-off-by: Stefan Berger > > --- > > modules.d/98integrity/README | 8 ++++---- > > modules.d/98integrity/ima-keys-load.sh | 7 ++++++- > > modules.d/98integrity/ima-policy-load.sh | 20 +++++++++++++++++--- > > 3 files changed, 27 insertions(+), 8 deletions(-) > > > > diff --git a/modules.d/98integrity/README b/modules.d/98integrity/README > > index 64de0ae..c8ccee5 100644 > > --- a/modules.d/98integrity/README > > +++ b/modules.d/98integrity/README > > @@ -33,10 +33,10 @@ line. > > > > # Save the policy in a file. > > > > -# Create the configuration file '/etc/sysconfig/ima' to override > > the path name of > > +# Create the configuration file '/etc/ima/ima' to override the path > name of > > # the IMA custom policy. > > -------------- '/etc/sysconfig/ima' (with the default value) > ------------- > > -IMAPOLICY="/etc/sysconfig/ima-policy" > > +------------- '/etc/ima/ima' (with the default value) ------------- > > +IMAPOLICY="/etc/ima/ima-policy" > > > ------------------------------------------------------------------------- > > > > > > @@ -64,5 +64,5 @@ IMAPOLICY="/etc/sysconfig/ima-policy" > > > > # 98integrity/ima-keys-load.sh script loads the signed certificates > stored > > # in the $IMAKEYSDIR onto the trusted IMA keyring. The default > $IMAKEYSDIR > > -# directory is /etc/keys/ima, but can be specified in the > /etc/sysconfig/ima > > +# directory is /etc/keys/ima, but can be specified in the /etc/ima/ima > > # policy. > > diff --git a/modules.d/98integrity/ima-keys-load.sh b/modules.d/ > > 98integrity/ima-keys-load.sh > > index 659b722..922af1e 100755 > > --- a/modules.d/98integrity/ima-keys-load.sh > > +++ b/modules.d/98integrity/ima-keys-load.sh > > @@ -2,7 +2,10 @@ > > > > SECURITYFSDIR="/sys/kernel/security" > > IMASECDIR="${SECURITYFSDIR}/ima" > > -IMACONFIG="${NEWROOT}/etc/sysconfig/ima" > > +IMACONFIG="${NEWROOT}/etc/ima/ima" > > + > > +# for backwards compatibility > > +IMACONFIG_OLD="${NEWROOT}/etc/sysconfig/ima" > > > > load_x509_keys() > > { > > @@ -11,6 +14,8 @@ load_x509_keys() > > # override the default configuration > > if [ -f "${IMACONFIG}" ]; then > > . ${IMACONFIG} > > + elif [ -f "${IMACONFIG_OLD}" ]; then > > + . ${IMACONFIG_OLD} > > fi > > > > if [ -z "${IMAKEYDIR}" ]; then > > diff --git a/modules.d/98integrity/ima-policy-load.sh b/modules.d/ > > 98integrity/ima-policy-load.sh > > index 85cd3b9..a92b1bb 100755 > > --- a/modules.d/98integrity/ima-policy-load.sh > > +++ b/modules.d/98integrity/ima-policy-load.sh > > @@ -5,10 +5,19 @@ > > # Copyright (C) 2011 Politecnico di Torino, Italy > > # TORSEC group -- http://security.polito.it > > > # Roberto Sassu > > +# > > +# Copyright (C) 2016 IBM Corporation > > +# > > +# Stefan Berger > > +# > > > > IMASECDIR="${SECURITYFSDIR}/ima" > > -IMACONFIG="${NEWROOT}/etc/sysconfig/ima" > > -IMAPOLICY="/etc/sysconfig/ima-policy" > > +IMACONFIG="${NEWROOT}/etc/ima/ima" > > +IMAPOLICY="/etc/ima/ima-policy" > > + > > +# for backwards compatibility > > +IMACONFIG_OLD="${NEWROOT}/etc/sysconfig/ima" > > +IMAPOLICY_OLD="/etc/sysconfig/ima-policy" > > > > load_ima_policy() > > { > > @@ -21,11 +30,16 @@ load_ima_policy() > > fi > > > > # override the default configuration > > - [ -f "${IMACONFIG}" ] && \ > > + if [ -f "${IMACONFIG}" ]; then > > . ${IMACONFIG} > > + elif [ -f "${IMACONFIG_OLD}" ]; then > > + . ${IMACONFIG_OLD} > > + fi > > > > # set the IMA policy path name > > IMAPOLICYPATH="${NEWROOT}${IMAPOLICY}" > > + [ ! -f "${IMAPOLICYPATH}" ] && \ > > + IMAPOLICYPATH="${NEWROOT}${IMAPOLICY_OLD}" > > > > # check the existence of the IMA policy file > > [ -f "${IMAPOLICYPATH}" ] && { > > -- > > 2.8.3 > > > --------------B20F340D9E82082C0C516E4A Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Harald,

=A0 please do not apply this patch.

=A0=A0=A0 Stefan

>
> From: Stefan Berger <stefanb@us.ibm.com>
>
> To sync with systemd, use the filepath /etc/ima/ima-policy as
> the default file location for the IMA policy. At the same time we
> move the ima config file location to /etc/ima/ima. Adapt the
> documentation to the new path. Maintain backwards compatibility
> by still reading the old files in case the new ones do not exist.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
> =A0modules.d/98integrity/README =A0 =A0 =A0 =A0 =A0 =A0 | =A08 ++++----
> =A0modules.d/98integrity/ima-keys-load.sh =A0 | =A07 ++++++-=
> =A0modules.d/98integrity/ima-policy-load.sh | 20 +++++++++++++++++---
> =A03 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/modules.d/98integrity/README b/modules.d/98integrity/README
> index 64de0ae..c8ccee5 100644
> --- a/modules.d/98integrity/README
> +++ b/modules.d/98integrity/README
> @@ -33,10 +33,10 @@ line.
> =A0
> =A0# Save the policy in a file.
> =A0
> -# Create the configuration file '/etc/sysconfig/ima' to override
> the path name of
> +# Create the configuration file '/etc/ima/ima' to override the path name of
> =A0# the IMA custom policy.
> -------------- '/etc/sysconfig/ima' (with the default value) -------------
> -IMAPOLICY=3D"/etc/sysconfig/ima-policy"
> +------------- '/etc/ima/ima' (with the default value) -------------
> +IMAPOLICY=3D"/etc/ima/ima-policy"
> =A0------------------------------------------------------------------------= -
> =A0
> =A0
> @@ -64,5 +64,5 @@ IMAPOLICY=3D"/etc/sysconfig/ima-policy"
> =A0
> =A0# 98integrity/ima-keys-load.sh script loads the signed certificates stored
> =A0# in the $IMAKEYSDIR onto the trusted IMA keyring. =A0The default $IMAKEYSDIR
> -# directory is /etc/keys/ima, but can be specified in the /etc/sysconfig/ima
> +# directory is /etc/keys/ima, but can be specified in the /etc/ima/ima
> =A0# policy.
> diff --git a/modules.d/98integrity/ima-keys-load.sh b/modules.d/
> 98integrity/ima-keys-load.sh
> index 659b722..922af1e 100755
> --- a/modules.d/98integrity/ima-keys-load.sh
> +++ b/modules.d/98integrity/ima-keys-load.sh
> @@ -2,7 +2,10 @@
> =A0
> =A0SECURITYFSDIR=3D"/sys/kernel/security"
> =A0IMASECDIR=3D"${SECURITYFSDIR}/ima"
> -IMACONFIG=3D"${NEWROOT}/etc/sysconfig/ima"
> +IMACONFIG=3D"${NEWROOT}/etc/ima/ima"
> +
> +# for backwards compatibility
> +IMACONFIG_OLD=3D"${NEWROOT}/etc/sysconfig/ima"
> =A0
> =A0load_x509_keys()
> =A0{
> @@ -11,6 +14,8 @@ load_x509_keys()
> =A0 =A0 =A0# override the default configuration
> =A0 =A0 =A0if [ -f "${IMACONFIG}" ]; then
> =A0 =A0 =A0 =A0 =A0. ${IMACONFIG}
> + =A0 =A0elif [ -f "${IMACONFIG_OLD}" ]; then
> + =A0 =A0 =A0 =A0. ${IMACONFIG_OLD}
> =A0 =A0 =A0fi
> =A0
> =A0 =A0 =A0if [ -z "${IMAKEYDIR}" ]; then
> diff --git a/modules.d/98integrity/ima-policy-load.sh b/modules.d/
> 98integrity/ima-policy-load.sh
> index 85cd3b9..a92b1bb 100755
> --- a/modules.d/98integrity/ima-policy-load.sh
> +++ b/modules.d/98integrity/ima-policy-load.sh
> @@ -5,10 +5,19 @@
> =A0# Copyright (C) 2011 Politecnico di Torino, Italy
> =A0# =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TORSEC group --
http://sec= urity.polito.it
> =A0# Roberto Sassu <roberto.sassu@polito.it>
> +#
> +# Copyright (C) 2016 IBM Corporation
> +#
> +# Stefan Berger <stefanb@linux.vnet.ibm.com> > +#
> =A0
> =A0IMASECDIR=3D"${SECURITYFSDIR}/ima"
> -IMACONFIG=3D"${NEWROOT}/etc/sysconfig/ima"
> -IMAPOLICY=3D"/etc/sysconfig/ima-policy"
> +IMACONFIG=3D"${NEWROOT}/etc/ima/ima"
> +IMAPOLICY=3D"/etc/ima/ima-policy"
> +
> +# for backwards compatibility
> +IMACONFIG_OLD=3D"${NEWROOT}/etc/sysconfig/ima"
> +IMAPOLICY_OLD=3D"/etc/sysconfig/ima-policy"
> =A0
> =A0load_ima_policy()
> =A0{
> @@ -21,11 +30,16 @@ load_ima_policy()
> =A0 =A0 =A0fi
> =A0
> =A0 =A0 =A0# override the default configuration
> - =A0 =A0[ -f "${IMACONFIG}" ] && \
> + =A0 =A0if [ -f "${IMACONFIG}" ]; then
> =A0 =A0 =A0 =A0 =A0. ${IMACONFIG}
> + =A0 =A0elif [ -f "${IMACONFIG_OLD}" ]; then
> + =A0 =A0 =A0 =A0. ${IMACONFIG_OLD}
> + =A0 =A0fi
> =A0
> =A0 =A0 =A0# set the IMA policy path name
> =A0 =A0 =A0IMAPOLICYPATH=3D"${NEWROOT}${IMAPOLICY}"
> + =A0 =A0[ ! -f "${IMAPOLICYPATH}" ] && \
> + =A0 =A0 =A0 =A0IMAPOLICYPATH=3D"${NEWROOT}${IMAPOLICY_OLD}= "
> =A0
> =A0 =A0 =A0# check the existence of the IMA policy file
> =A0 =A0 =A0[ -f "${IMAPOLICYPATH}" ] && {
> --
> 2.8.3
>


--------------B20F340D9E82082C0C516E4A-- --===============1428271074== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18Kc3lzdGVtZC1k ZXZlbCBtYWlsaW5nIGxpc3QKc3lzdGVtZC1kZXZlbEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0 cHM6Ly9saXN0cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9zeXN0ZW1kLWRldmVs Cg== --===============1428271074==--