Make proc failure loud but nonfatal

This commit is contained in:
Robbie Harwood 2017-05-25 18:57:34 +00:00
parent c1f4665d37
commit 35e3b9ed5e
2 changed files with 81 additions and 1 deletions

View File

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

View File

@ -1,6 +1,6 @@
Name: gssproxy
Version: 0.7.0
Release: 8%{?dist}
Release: 9%{?dist}
Summary: GSSAPI Proxy
Group: System Environment/Libraries
@ -22,6 +22,7 @@ Patch4: Update-systemd-file.patch
Patch5: Fix-unused-variables.patch
Patch6: Fix-segfault-when-no-config-files-are-present.patch
Patch7: Include-header-for-writev.patch
Patch8: Make-proc-file-failure-loud-but-nonfatal.patch
### Dependencies ###
Requires: krb5-libs >= 1.12.0
@ -65,6 +66,7 @@ A proxy for GSSAPI credential handling
%patch5 -p2 -b .Fix-unused-variables
%patch6 -p2 -b .Fix-segfault-when-no-config-files-are-present
%patch7 -p2 -b .Include-header-for-writev
%patch8 -p2 -b .Make-proc-file-failure-loud-but-nonfatal
%build
autoreconf -f -i
@ -120,6 +122,9 @@ rm -rf %{buildroot}
%systemd_postun_with_restart gssproxy.service
%changelog
* Thu May 25 2017 Robbie Harwood <rharwood@redhat.com> - 0.7.0-9
- Make proc failure loud but nonfatal
* Wed May 24 2017 Robbie Harwood <rharwood@redhat.com> - 0.7.0-8
- Remove (buggy?) logic around NFS snippet.