From: Sebastien Buisson Date: Mon, 22 Feb 2021 15:24:11 +0000 (+0900) Subject: LU-14462 gss: fix support for namespace in lgss_keyring X-Git-Tag: 2.14.51~77 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=0ab950762cdec28636b6033c50a2e563c28ba954;ds=sidebyside LU-14462 gss: fix support for namespace in lgss_keyring Fix the way lgss_keyring handles different mount namespaces, so that we do not try to bind to a namespace that does not exist. Fixes: 94c44c62de ("LU-7845 gss: support namespace in lgss_keyring") Signed-off-by: Sebastien Buisson Change-Id: Ia5a5213399decc683d5e9401b6594e7fe579123f Reviewed-on: https://review.whamcloud.com/41716 Tested-by: jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/gss/lgss_keyring.c b/lustre/utils/gss/lgss_keyring.c index 6748f7c..dfcb0ad 100644 --- a/lustre/utils/gss/lgss_keyring.c +++ b/lustre/utils/gss/lgss_keyring.c @@ -1067,13 +1067,15 @@ int main(int argc, char *argv[]) #ifdef HAVE_SETNS /* Is caller in different namespace? */ snprintf(path, sizeof(path), "/proc/%d/ns/mnt", getpid()); - if (stat(path, &parent_ns)) - logmsg(LL_ERR, "cannot stat %s: %s\n", path, strerror(errno)); - snprintf(path, sizeof(path), "/proc/%d/ns/mnt", uparam.kup_pid); - if (stat(path, &caller_ns)) - logmsg(LL_ERR, "cannot stat %s: %s\n", path, strerror(errno)); - if (caller_ns.st_ino != parent_ns.st_ino) { - other_ns = 1; + if (stat(path, &parent_ns)) { + logmsg(LL_DEBUG, "cannot stat %s: %s\n", path, strerror(errno)); + } else { + snprintf(path, sizeof(path), "/proc/%d/ns/mnt", uparam.kup_pid); + if (stat(path, &caller_ns)) + logmsg(LL_DEBUG, "cannot stat %s: %s\n", + path, strerror(errno)); + else if (caller_ns.st_ino != parent_ns.st_ino) + other_ns = 1; } #endif /* HAVE_SETNS */