mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Set CLOEXEC flag to prevent leaking descriptors
Both the new initctl API and the new pidfile watcher plugin failed to set CLOEXEC on their sockets. This caused forked-off and exec()'d children to inherit all these descriptors. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
da76cf4f75
commit
439d9df122
2 files changed
+2
-2
No files matched your search
@@ -346,7 +346,7 @@ int api_init(uev_ctx_t *ctx)
|
|||||||
.sun_path = INIT_SOCKET,
|
.sun_path = INIT_SOCKET,
|
||||||
};
|
};
|
||||||
|
|
||||||
sd = socket(AF_UNIX, SOCK_STREAM, 0);
|
sd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||||
if (-1 == sd) {
|
if (-1 == sd) {
|
||||||
_pe("Failed starting external API socket");
|
_pe("Failed starting external API socket");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ static plugin_t plugin = {
|
|||||||
|
|
||||||
PLUGIN_INIT(plugin_init)
|
PLUGIN_INIT(plugin_init)
|
||||||
{
|
{
|
||||||
pidfile_ctx.fd = inotify_init();
|
pidfile_ctx.fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||||
if (pidfile_ctx.fd < 0) {
|
if (pidfile_ctx.fd < 0) {
|
||||||
_pe("inotify_init()");
|
_pe("inotify_init()");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user