Blame SOURCES/net-snmp-5.7.2-fsync.patch

b5ae06
diff -urNp old/configure new/configure
b5ae06
--- old/configure	2018-09-06 11:04:16.372792568 +0200
b5ae06
+++ new/configure	2018-09-06 11:04:44.475765043 +0200
b5ae06
@@ -25265,7 +25265,7 @@ fi
b5ae06
 
b5ae06
 
b5ae06
 #  Agent:
b5ae06
-for ac_func in cgetnext        chown          execv                           gai_strerror                   getgrnam                        gethostname     getloadavg                                     getpid          getpwnam                                       hasmntopt       initgroups                                     if_nameindex    if_indextoname if_nametoindex                  localtime_r     mkstemp        mktime                          poll            regcomp                                        setgid          setgroups                                      setmntent       setuid                                         sigaction       sigblock      sighold                          sigprocmask                                                    statfs          statvfs       stime                            strncasecmp     system                                         uname           usleep
b5ae06
+for ac_func in cgetnext        chown          execv                           forkall       fsync     gai_strerror                   getgrnam                        gethostname     getloadavg                                     getpid          getpwnam                                       hasmntopt       initgroups                                     if_nameindex    if_indextoname if_nametoindex                  localtime_r     mkstemp        mktime                          poll            regcomp                                        setgid          setgroups                                      setmntent       setuid                                         sigaction       sigblock      sighold                          sigprocmask                                                    statfs          statvfs       stime                            strncasecmp     system                                         uname           usleep
b5ae06
 do :
b5ae06
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
b5ae06
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
b5ae06
diff -urNp old/configure.d/config_os_functions new/configure.d/config_os_functions
b5ae06
--- old/configure.d/config_os_functions	2018-09-06 11:04:16.396792546 +0200
b5ae06
+++ new/configure.d/config_os_functions	2018-09-06 11:04:44.508765009 +0200
b5ae06
@@ -88,7 +88,8 @@ AC_REPLACE_FUNCS([getopt        inet_nto
b5ae06
 
b5ae06
 #  Agent:
b5ae06
 AC_CHECK_FUNCS([cgetnext        chown          execv           ] dnl
b5ae06
-               [gai_strerror                   getgrnam        ] dnl
b5ae06
+               [forkall         fsync                          ] dnl
b5ae06
+               [gai_strerror    getgrnam                       ] dnl
b5ae06
                [gethostname     getloadavg                     ] dnl
b5ae06
                [getpid          getpwnam                       ] dnl
b5ae06
                [hasmntopt       initgroups                     ] dnl
b5ae06
diff -urNp old/include/net-snmp/net-snmp-config.h.in new/include/net-snmp/net-snmp-config.h.in
b5ae06
--- old/include/net-snmp/net-snmp-config.h.in	2018-09-06 11:04:16.370792571 +0200
b5ae06
+++ new/include/net-snmp/net-snmp-config.h.in	2018-09-06 11:04:44.492765026 +0200
b5ae06
@@ -176,6 +176,9 @@
b5ae06
 /* Define to 1 if you have the <fstab.h> header file. */
b5ae06
 #undef HAVE_FSTAB_H
b5ae06
 
b5ae06
+/* Define to 1 if you have the `fsync' function. */
b5ae06
+#undef HAVE_FSYNC
b5ae06
+
b5ae06
 /* Define to 1 if you have the `funlockfile' function. */
b5ae06
 #undef HAVE_FUNLOCKFILE
b5ae06
 
b5ae06
diff -urNp old/net-snmp-create-v3-user.in new/net-snmp-create-v3-user.in
b5ae06
--- old/net-snmp-create-v3-user.in	2018-09-06 11:04:16.372792568 +0200
b5ae06
+++ new/net-snmp-create-v3-user.in	2018-09-13 09:17:05.427712857 +0200
b5ae06
@@ -148,3 +148,4 @@ if test ! -d $outfile ; then
b5ae06
     touch $outfile
b5ae06
 fi
b5ae06
 echo $line >> $outfile
b5ae06
+sync
b5ae06
diff -urNp old/snmplib/read_config.c new/snmplib/read_config.c
b5ae06
--- old/snmplib/read_config.c	2018-09-06 11:04:16.395792547 +0200
b5ae06
+++ new/snmplib/read_config.c	2018-09-07 06:53:33.671501357 +0200
b5ae06
@@ -1508,6 +1508,9 @@ read_config_store(const char *type, cons
b5ae06
 #ifdef NETSNMP_PERSISTENT_MASK
b5ae06
     mode_t          oldmask;
b5ae06
 #endif
b5ae06
+#if HAVE_FSYNC
b5ae06
+    int fd;
b5ae06
+#endif
b5ae06
 
b5ae06
     if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
b5ae06
                                NETSNMP_DS_LIB_DONT_PERSIST_STATE)
b5ae06
@@ -1538,6 +1541,11 @@ read_config_store(const char *type, cons
b5ae06
         if (line[strlen(line)] != '\n')
b5ae06
             fprintf(fout, "\n");
b5ae06
         DEBUGMSGTL(("read_config:store", "storing: %s\n", line));
b5ae06
+#if HAVE_FSYNC
b5ae06
+        fd = fileno(fout);
b5ae06
+        fflush(fout);
b5ae06
+        fsync(fd);
b5ae06
+#endif
b5ae06
         fclose(fout);
b5ae06
     } else {
b5ae06
         if (strcmp(NETSNMP_APPLICATION_CONFIG_TYPE, type) != 0) {