c530df
From 938bd1adc15342e8ebed3d4e135d862e362a619e Mon Sep 17 00:00:00 2001
c530df
From: Robbie Harwood <rharwood@redhat.com>
c530df
Date: Thu, 25 May 2017 13:06:17 -0400
c530df
Subject: [PATCH] Make proc file failure loud but nonfatal
c530df
c530df
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
c530df
Reviewed-by: Simo Sorce <simo@redhat.com>
c530df
Resolves: #190
c530df
(cherry picked from commit 4f60bf02a1a68cbb26251e764357b753f80790f3)
c530df
---
c530df
 proxy/src/gp_init.c | 34 +++++++++++++++-------------------
c530df
 1 file changed, 15 insertions(+), 19 deletions(-)
c530df
c530df
diff --git a/proxy/src/gp_init.c b/proxy/src/gp_init.c
c530df
index bb7ba6b..d367f92 100644
c530df
--- a/proxy/src/gp_init.c
c530df
+++ b/proxy/src/gp_init.c
c530df
@@ -144,11 +144,11 @@ void init_proc_nfsd(struct gp_config *cfg)
c530df
 {
c530df
     char buf[] = "1";
c530df
     bool enabled = false;
c530df
-    int fd, i, ret;
c530df
+    int fd, ret;
c530df
 
c530df
     /* check first if any service enabled kernel support */
c530df
-    for (i = 0; i < cfg->num_svcs; i++) {
c530df
-        if (cfg->svcs[i]->kernel_nfsd == true) {
c530df
+    for (int i = 0; i < cfg->num_svcs; i++) {
c530df
+        if (cfg->svcs[i]->kernel_nfsd) {
c530df
             enabled = true;
c530df
             break;
c530df
         }
c530df
@@ -161,30 +161,26 @@ void init_proc_nfsd(struct gp_config *cfg)
c530df
     fd = open(LINUX_PROC_USE_GSS_PROXY_FILE, O_RDWR);
c530df
     if (fd == -1) {
c530df
         ret = errno;
c530df
-        fprintf(stderr, "GSS-Proxy is not supported by this kernel since "
c530df
-                "file %s could not be found: %d (%s)\n",
c530df
-                LINUX_PROC_USE_GSS_PROXY_FILE,
c530df
-                ret, gp_strerror(ret));
c530df
-        exit(1);
c530df
+        GPDEBUG("Kernel doesn't support GSS-Proxy (can't open %s: %d (%s))\n",
c530df
+                LINUX_PROC_USE_GSS_PROXY_FILE, ret, gp_strerror(ret));
c530df
+        goto fail;
c530df
     }
c530df
 
c530df
     ret = write(fd, buf, 1);
c530df
     if (ret != 1) {
c530df
         ret = errno;
c530df
-        fprintf(stderr, "Failed to write to %s: %d (%s)\n",
c530df
-                LINUX_PROC_USE_GSS_PROXY_FILE,
c530df
-                ret, gp_strerror(ret));
c530df
-        exit(1);
c530df
+        GPDEBUG("Failed to write to %s: %d (%s)\n",
c530df
+                LINUX_PROC_USE_GSS_PROXY_FILE, ret, gp_strerror(ret));
c530df
     }
c530df
 
c530df
-    ret = close(fd);
c530df
-    if (ret == -1) {
c530df
-        ret = errno;
c530df
-        fprintf(stderr, "Failed to close %s: %d (%s)\n",
c530df
-                LINUX_PROC_USE_GSS_PROXY_FILE,
c530df
-                ret, gp_strerror(ret));
c530df
-        exit(1);
c530df
+    close(fd);
c530df
+    if (ret != 0) {
c530df
+        goto fail;
c530df
     }
c530df
+
c530df
+    return;
c530df
+fail:
c530df
+    GPDEBUG("Problem with kernel communication!  NFS server will not work\n");
c530df
 }
c530df
 
c530df
 void write_pid(void)