From 22b4e5d7ead524850203bf66e1d79d9d803057fc Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Fri, 28 Jul 2023 11:53:10 +0100 Subject: [PATCH] nfs: fix null pointer deref in generateSssdSidecarResources() 0a151e913 results in a bug which causes null pointer dereference when Kerberos is not setup. This causes a failure in Unit test TestReconcileCephNFS_addSecurityConfigsToPod Signed-off-by: Sachin Prabhu (cherry picked from commit 6cf4627ccd05ca90393c5e93bba8d91694fd6f11) --- pkg/operator/ceph/nfs/security.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/operator/ceph/nfs/security.go b/pkg/operator/ceph/nfs/security.go index b2f86427e..7d859858c 100644 --- a/pkg/operator/ceph/nfs/security.go +++ b/pkg/operator/ceph/nfs/security.go @@ -164,15 +164,16 @@ func generateSssdSidecarResources(nfs *cephv1.CephNFS, sidecarCfg *cephv1.SSSDSi SubPath: "krb5.conf", } sssdMounts = append(sssdMounts, krb5ConfD, krbConfMount) - } - if nfs.Spec.Security.Kerberos.KeytabFile.VolumeSource != nil { - volName := "krb5-keytab" - keytabMount := v1.VolumeMount{ - Name: volName, - MountPath: "/etc/krb5.keytab", - SubPath: "krb5.keytab", + + if nfs.Spec.Security.Kerberos.KeytabFile.VolumeSource != nil { + volName := "krb5-keytab" + keytabMount := v1.VolumeMount{ + Name: volName, + MountPath: "/etc/krb5.keytab", + SubPath: "krb5.keytab", + } + sssdMounts = append(sssdMounts, keytabMount) } - sssdMounts = append(sssdMounts, keytabMount) } // the init container is needed to copy the starting content from the /var/lib/sss/pipes