s3-smbd Avoid races creating 'ncaclrpc dir' with epmd in a child process
authorAndrew Bartlett <abartlet@samba.org>
Sat, 13 Aug 2011 03:30:16 +0000 (13:30 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 13 Aug 2011 10:18:41 +0000 (20:18 +1000)
source3/smbd/server.c

index d396289e0d5d6df94c4dada8d1b36623b0c52ed6..a9762e0b524ab62deb6d3eb6eb3b7c6c80c73c02 100644 (file)
@@ -1197,6 +1197,15 @@ extern void build_options(bool screen);
                return -1;
        }
 
                return -1;
        }
 
+       /* This MUST be done before start_epmd() because otherwise
+        * start_epmd() forks and races against dcesrv_ep_setup() to
+        * call directory_create_or_exist() */
+       if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
+               DEBUG(0, ("Failed to create pipe directory %s - %s\n",
+                         lp_ncalrpc_dir(), strerror(errno)));
+               return -1;
+       }
+
        if (is_daemon && !interactive) {
                enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
 
        if (is_daemon && !interactive) {
                enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();