]> source.dussan.org Git - rspamd.git/commitdiff
Set cloexec flag to sockets obtained from systemd.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Feb 2014 16:31:53 +0000 (16:31 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Feb 2014 16:31:53 +0000 (16:31 +0000)
src/main.c

index a8196ef062e80902e685798bdc36ab868a3f7c12..ba091a7f05cc155da94d88a010477090df085eee 100644 (file)
@@ -552,7 +552,7 @@ create_listen_socket (const gchar *addr, gint port, gint listen_type)
 static GList *
 systemd_get_socket (gint number, gint listen_type)
 {
-       int sock, max;
+       int sock, max, flags;
        GList *result = NULL;
        const gchar *e;
        gchar *err;
@@ -578,6 +578,10 @@ systemd_get_socket (gint number, gint listen_type)
                                        return NULL;
                                }
                        }
+                       flags = fcntl (sock, F_GETFD);
+                       if (flags != -1) {
+                               (void)fcntl (sock, F_SETFD, flags | FD_CLOEXEC);
+                       }
                        result = g_list_prepend (result, GINT_TO_POINTER (sock));
                }
                else if (max <= number + sd_listen_fds_start) {