Blame SOURCES/bz2144530-fence_virtd-warn-files-not-mode-600.patch

316469
diff --color -uNr a/config/Makefile.am b/config/Makefile.am
316469
--- a/config/Makefile.am	2019-11-20 14:13:42.000000000 +0100
316469
+++ b/config/Makefile.am	2022-11-22 10:12:51.764545658 +0100
316469
@@ -37,5 +37,8 @@
316469
 config.c: y.tab.c config.l
316469
 	$(LEX) -oconfig.c $(srcdir)/config.l
316469
 
316469
+install-exec-hook:
316469
+	chmod 600 $(DESTDIR)$(sysconfdir)/fence_virt.conf
316469
+
316469
 clean-local:
316469
 	rm -f config.tab.c config.tab.h config.c y.tab.c y.tab.h
316469
diff --color -uNr a/include/simpleconfig.h b/include/simpleconfig.h
316469
--- a/include/simpleconfig.h	2018-01-15 15:02:31.000000000 +0100
316469
+++ b/include/simpleconfig.h	2022-11-22 10:15:06.440335062 +0100
316469
@@ -49,4 +49,8 @@
316469
 /* Frees a previously-allocated copy of our simple config object */
316469
 void sc_release(config_object_t *c);
316469
 
316469
+int check_file_permissions(const char *fname);
316469
+
316469
+int do_configure(config_object_t *config, const char *filename);
316469
+
316469
 #endif
316469
diff --color -uNr a/include/simpleconfig.h.rej b/include/simpleconfig.h.rej
316469
--- a/include/simpleconfig.h.rej	1970-01-01 01:00:00.000000000 +0100
316469
+++ b/include/simpleconfig.h.rej	2022-11-22 10:12:51.764545658 +0100
316469
@@ -0,0 +1,11 @@
316469
+--- include/simpleconfig.h
316469
++++ include/simpleconfig.h
316469
+@@ -49,6 +49,8 @@ config_object_t *sc_init(void);
316469
+ /* Frees a previously-allocated copy of our simple config object */
316469
+ void sc_release(config_object_t *c);
316469
+ 
316469
++int check_file_permissions(const char *fname);
316469
++
316469
+ int do_configure(config_object_t *config, const char *filename);
316469
+ 
316469
+ #endif
316469
diff --color -uNr a/server/config.c b/server/config.c
316469
--- a/server/config.c	2019-11-20 14:13:42.000000000 +0100
316469
+++ b/server/config.c	2022-11-22 10:17:25.539150364 +0100
316469
@@ -11,6 +11,7 @@
316469
 #include <fcntl.h>
316469
 #include <net/if.h>
316469
 #include <arpa/inet.h>
316469
+#include <errno.h>
316469
 
316469
 #include "simpleconfig.h"
316469
 #include "static_map.h"
316469
@@ -590,6 +591,31 @@
316469
 
316469
 
316469
 int
316469
+check_file_permissions(const char *fname)
316469
+{
316469
+	struct stat st;
316469
+	mode_t file_perms = 0600;
316469
+	int ret;
316469
+
316469
+	ret = stat(fname, &st);
316469
+	if (ret != 0) {
316469
+		printf("stat failed on file '%s': %s\n",
316469
+			 fname, strerror(errno));
316469
+		return 1;
316469
+	}
316469
+
316469
+	if ((st.st_mode & 0777) != file_perms) {
316469
+		printf("WARNING: invalid permissions on file "
316469
+			 "'%s': has 0%o should be 0%o\n", fname,
316469
+			 (unsigned int)(st.st_mode & 0777),
316469
+			 (unsigned int)file_perms);
316469
+		return 1;
316469
+	}
316469
+
316469
+	return 0;
316469
+}
316469
+
316469
+int
316469
 do_configure(config_object_t *config, const char *config_file)
316469
 {
316469
 	FILE *fp = NULL;
316469
diff --color -uNr a/server/main.c b/server/main.c
316469
--- a/server/main.c	2019-11-27 09:19:52.000000000 +0100
316469
+++ b/server/main.c	2022-11-22 10:19:06.647742990 +0100
316469
@@ -14,11 +14,12 @@
316469
 /* Local includes */
316469
 #include "simpleconfig.h"
316469
 #include "static_map.h"
316469
+#include "xvm.h"
316469
 #include "server_plugin.h"
316469
+#include "simple_auth.h"
316469
 #include "debug.h"
316469
 
316469
 /* configure.c */
316469
-int do_configure(config_object_t *config, const char *filename);
316469
 int daemon_init(const char *prog, const char *pid_file, int nofork);
316469
 int daemon_cleanup(void);
316469
 
316469
@@ -206,6 +207,18 @@
316469
 		snprintf(pid_file, PATH_MAX, "/var/run/%s.pid", basename(argv[0]));
316469
 	}
316469
 
316469
+	check_file_permissions(config_file);
316469
+
316469
+	sprintf(val, "listeners/%s/@key_file", listener_name);
316469
+	if (sc_get(config, val,
316469
+		   val, sizeof(val)-1) == 0) {
316469
+		dbg_printf(1, "Got %s for key_file\n", val);
316469
+	} else {
316469
+		snprintf(val, sizeof(val), "%s", DEFAULT_KEY_FILE);
316469
+	}
316469
+
316469
+	check_file_permissions(val);
316469
+
316469
 	openlog(basename(argv[0]), LOG_NDELAY | LOG_PID, LOG_DAEMON);
316469
 
316469
 	daemon_init(basename(argv[0]), pid_file, foreground);