Skip to content

Commit

Permalink
Shutdown polkitd properly on SIGTERM
Browse files Browse the repository at this point in the history
While trying to break polkit using dfuzzer I couldn't make ASan/LSan
report _any_ memory leaks no matter how obvious they were. After a lot
of tinkering I managed to get the reports only when calling
__lsan_do_recoverable_leak_check() explicitly, which told me that the
shutdown __lsan_do_leak_check() is somehow getting skipped.

Turns out that polkitd does a "proper" shutdown on SIGINT (with which
ASan/LSan worked as expected), but not for SIGTERM. Fixing this, by
stopping the even loop even on SIGTERM, makes ASan/LSan happy (except
for the couple of memory leaks that were unfortunately hidden by this
behavior).
  • Loading branch information
mrc0mmand authored and jrybar-rh committed Nov 6, 2024
1 parent 5a4ba7d commit a63afaf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/polkitbackend/polkitd.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ on_name_acquired (GDBusConnection *connection,
}

static gboolean
on_sigint (gpointer user_data)
on_sigint_sigterm (gpointer user_data)
{
g_print ("Handling SIGINT\n");
g_print ("Handling %s\n", (const char *) user_data);
g_main_loop_quit (loop);
return TRUE;
}
Expand Down Expand Up @@ -268,8 +268,12 @@ main (int argc,
loop = g_main_loop_new (NULL, FALSE);

sigint_id = g_unix_signal_add (SIGINT,
on_sigint,
NULL);
on_sigint_sigterm,
"SIGINT");

sigint_id = g_unix_signal_add (SIGTERM,
on_sigint_sigterm,
"SIGTERM");

sighup_id = g_unix_signal_add (SIGHUP,
on_sighup,
Expand Down

0 comments on commit a63afaf

Please sign in to comment.