struct gc_arena gc = gc_new ();
set_nonblock (man->connection.sd_cli);
- set_cloexec (man->connection.sd_cli);
man_connection_settings_reset (man);
* Set misc socket properties
*/
set_nonblock (man->connection.sd_top);
- set_cloexec (man->connection.sd_top);
#if UNIX_SOCK_SUPPORT
if (man->settings.flags & MF_UNIX_SOCK)
}
#endif
+ /* set socket file descriptor to not pass across execs, so that
+ scripts don't have access to it */
+ set_cloexec (sd);
+
return sd;
}
}
}
#endif
+
+ /* set socket file descriptor to not pass across execs, so that
+ scripts don't have access to it */
+ set_cloexec (sd);
+
return sd;
}
openvpn_close_socket (new_sd);
new_sd = SOCKET_UNDEFINED;
}
+ else
+ {
+ /* set socket file descriptor to not pass across execs, so that
+ scripts don't have access to it */
+ set_cloexec (sd);
+ }
return new_sd;
}
ASSERT (sock->info.proto != PROTO_TCP_CLIENT);
ASSERT (socket_defined (inetd_socket_descriptor));
sock->sd = inetd_socket_descriptor;
+ set_cloexec (sock->sd); /* not created by create_socket*() */
}
else if (mode != LS_MODE_TCP_ACCEPT_FROM)
{
/* set socket to non-blocking mode */
set_nonblock (sock->sd);
- /* set socket file descriptor to not pass across execs, so that
- scripts don't have access to it */
- set_cloexec (sock->sd);
-
- if (socket_defined (sock->ctrl_sd))
- set_cloexec (sock->ctrl_sd);
-
/* set Path MTU discovery options on the socket */
set_mtu_discover_type (sock->sd, sock->mtu_discover_type, sock->info.af);
if ((sd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0)
msg (M_ERR, "Cannot create unix domain socket");
+
+ /* set socket file descriptor to not pass across execs, so that
+ scripts don't have access to it */
+ set_cloexec (sd);
+
return sd;
}
CLEAR (*remote);
ret = accept (sd, (struct sockaddr *) remote, &remote_len);
+ if ( ret >= 0 )
+ {
+ /* set socket file descriptor to not pass across execs, so that
+ scripts don't have access to it */
+ set_cloexec (ret);
+ }
return ret;
}