Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-distro / recipes-security / gssproxy / files / Make-proc-file-failure-loud-but-nonfatal.patch
1 From 938bd1adc15342e8ebed3d4e135d862e362a619e Mon Sep 17 00:00:00 2001
2 From: Robbie Harwood <rharwood@redhat.com>
3 Date: Thu, 25 May 2017 13:06:17 -0400
4 Subject: [PATCH] Make proc file failure loud but nonfatal
5
6 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
7 Reviewed-by: Simo Sorce <simo@redhat.com>
8 Resolves: #190
9 (cherry picked from commit 4f60bf02a1a68cbb26251e764357b753f80790f3)
10 ---
11  proxy/src/gp_init.c | 34 +++++++++++++++-------------------
12  1 file changed, 15 insertions(+), 19 deletions(-)
13
14 diff --git a/proxy/src/gp_init.c b/proxy/src/gp_init.c
15 index bb7ba6b..d367f92 100644
16 --- a/proxy/src/gp_init.c
17 +++ b/proxy/src/gp_init.c
18 @@ -144,11 +144,11 @@ void init_proc_nfsd(struct gp_config *cfg)
19  {
20      char buf[] = "1";
21      bool enabled = false;
22 -    int fd, i, ret;
23 +    int fd, ret;
24  
25      /* check first if any service enabled kernel support */
26 -    for (i = 0; i < cfg->num_svcs; i++) {
27 -        if (cfg->svcs[i]->kernel_nfsd == true) {
28 +    for (int i = 0; i < cfg->num_svcs; i++) {
29 +        if (cfg->svcs[i]->kernel_nfsd) {
30              enabled = true;
31              break;
32          }
33 @@ -161,30 +161,26 @@ void init_proc_nfsd(struct gp_config *cfg)
34      fd = open(LINUX_PROC_USE_GSS_PROXY_FILE, O_RDWR);
35      if (fd == -1) {
36          ret = errno;
37 -        fprintf(stderr, "GSS-Proxy is not supported by this kernel since "
38 -                "file %s could not be found: %d (%s)\n",
39 -                LINUX_PROC_USE_GSS_PROXY_FILE,
40 -                ret, gp_strerror(ret));
41 -        exit(1);
42 +        GPDEBUG("Kernel doesn't support GSS-Proxy (can't open %s: %d (%s))\n",
43 +                LINUX_PROC_USE_GSS_PROXY_FILE, ret, gp_strerror(ret));
44 +        goto fail;
45      }
46  
47      ret = write(fd, buf, 1);
48      if (ret != 1) {
49          ret = errno;
50 -        fprintf(stderr, "Failed to write to %s: %d (%s)\n",
51 -                LINUX_PROC_USE_GSS_PROXY_FILE,
52 -                ret, gp_strerror(ret));
53 -        exit(1);
54 +        GPDEBUG("Failed to write to %s: %d (%s)\n",
55 +                LINUX_PROC_USE_GSS_PROXY_FILE, ret, gp_strerror(ret));
56      }
57  
58 -    ret = close(fd);
59 -    if (ret == -1) {
60 -        ret = errno;
61 -        fprintf(stderr, "Failed to close %s: %d (%s)\n",
62 -                LINUX_PROC_USE_GSS_PROXY_FILE,
63 -                ret, gp_strerror(ret));
64 -        exit(1);
65 +    close(fd);
66 +    if (ret != 0) {
67 +        goto fail;
68      }
69 +
70 +    return;
71 +fail:
72 +    GPDEBUG("Problem with kernel communication!  NFS server will not work\n");
73  }
74  
75  void write_pid(void)