Skip to contentSkip to conversation

98integrity: Use /etc/ima as dir for IMA policy and config file

PATCH In review Stefan Berger 2 participants 3 messages Nov 30, 2016 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 98integrity: Use /etc/ima as dir for IMA policy and config file

From: Stefan Berger <[email protected]>

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.

---
 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(-)
modules.d/98integrity/README +4 -4
index 64de0ae..c8ccee5 100644
@@ -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.
modules.d/98integrity/ima-keys-load.sh +6 -1
index 659b722..922af1e 100755
@@ -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
modules.d/98integrity/ima-policy-load.sh +17 -3
index 85cd3b9..a92b1bb 100755
@@ -5,10 +5,19 @@
 # Copyright (C) 2011 Politecnico di Torino, Italy
 #                    TORSEC group -- http://security.polito.it
 # Roberto Sassu <[email protected]>
+#
+# Copyright (C) 2016 IBM Corporation
+#
+# Stefan Berger <[email protected]>
+#
 
 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}" ] && {
Signature · 6 lines
2.8.3

_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

A message that is not in the archive (sent off-list or not yet received): 1480522734-975-1-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): OFAB3B0DDA.C5BDF803-ON0025807B.00603714-8525807B.0060434C@notes.na.collabserv.com

#4 lore raw

Harald,

please do not apply this patch.

Stefan

Quoted 119 lines
Quoted 26 lines

From: Stefan Berger <[email protected]>

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.

---
 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(-)
modules.d/98integrity/README +0 -1
index 64de0ae..c8ccee5 100644
@@ -33,10 +33,10 @@ line.
 
 # Save the policy in a file.
 
-# Create the configuration file '/etc/sysconfig/ima' to override
Quoted 2 lines

the path name of
+# Create the configuration file '/etc/ima/ima' to override the path

name of

Quoted 2 lines
 # the IMA custom policy.
-------------- '/etc/sysconfig/ima' (with the default value) 

-------------

modules.d/98integrity/README line. · line 39

Quoted 4 lines
modules.d/98integrity/README +2 -1
-IMAPOLICY="/etc/sysconfig/ima-policy"
+------------- '/etc/ima/ima' (with the default value) -------------
+IMAPOLICY="/etc/ima/ima-policy"

-------------------------------------------------------------------------

modules.d/98integrity/README IMAPOLICY="/etc/sysconfig/ima-policy" · line 65

Quoted 5 lines
modules.d/98integrity/README +0 -0
@@ -64,5 +64,5 @@ IMAPOLICY="/etc/sysconfig/ima-policy"
 
 # 98integrity/ima-keys-load.sh script loads the signed certificates 

stored

modules.d/98integrity/README IMAPOLICY="/etc/sysconfig/ima-policy" · line 66

Quoted 1 line
modules.d/98integrity/README +0 -0
 # in the $IMAKEYSDIR onto the trusted IMA keyring.  The default 

$IMAKEYSDIR

modules.d/98integrity/README IMAPOLICY="/etc/sysconfig/ima-policy" · line 67

Quoted 1 line
modules.d/98integrity/README +0 -1
-# directory is /etc/keys/ima, but can be specified in the 

/etc/sysconfig/ima

Quoted 34 lines
modules.d/98integrity/README +1 -0
+# directory is /etc/keys/ima, but can be specified in the /etc/ima/ima
 # policy.
modules.d/ renamed from modules.d/98integrity/ima-keys-load.sh +0 -0

98integrity/ima-keys-load.sh
index 659b722..922af1e 100755

modules.d/98integrity/ima-keys-load.sh +6 -1
@@ -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
modules.d/ renamed from modules.d/98integrity/ima-policy-load.sh +0 -0

98integrity/ima-policy-load.sh
index 85cd3b9..a92b1bb 100755

modules.d/98integrity/ima-policy-load.sh line 6

Quoted 2 lines
modules.d/98integrity/ima-policy-load.sh +0 -0
@@ -5,10 +5,19 @@
 # Copyright (C) 2011 Politecnico di Torino, Italy
 #  TORSEC group -- http://security.polito.it 

<http://security.polito.it/>

Quoted 35 lines
modules.d/98integrity/ima-policy-load.sh +17 -3
 # Roberto Sassu <[email protected]>
+#
+# Copyright (C) 2016 IBM Corporation
+#
+# Stefan Berger <[email protected]>
+#
 
 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}"
 
Quoted 6 lines
Quoted 5 lines
modules.d/98integrity/ima-policy-load.sh +0 -1
     # check the existence of the IMA policy file
     [ -f "${IMAPOLICYPATH}" ] && {
--

2.8.3

_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel