openbsd-ports/sysutils/consolekit/patches/patch-src_main_c
ajacoutot 031e2520b7 Fix socket credential support.
Tweak COMMENT while here.
2010-06-28 15:55:21 +00:00

100 lines
2.5 KiB
Plaintext

$OpenBSD: patch-src_main_c,v 1.2 2010/06/28 15:55:21 ajacoutot Exp $
From Debian:
Cleanup console tag files on application startup and shutdown.
https://bugs.freedesktop.org/show_bug.cgi?id=25744
--- src/main.c.orig Wed Apr 29 21:07:29 2009
+++ src/main.c Sun Jun 27 23:14:52 2010
@@ -149,6 +149,43 @@ delete_pid (void)
unlink (CONSOLE_KIT_PID_FILE);
}
+#define CONSOLE_TAGS_DIR "/var/run/console"
+
+static void
+delete_console_tags (void)
+{
+ GDir *dir;
+ GError *error = NULL;
+ const gchar *name;
+
+ g_debug ("Cleaning up %s", CONSOLE_TAGS_DIR);
+
+ dir = g_dir_open (CONSOLE_TAGS_DIR, 0, &error);
+ if (dir == NULL) {
+ g_debug ("Couldn't open directory %s: %s", CONSOLE_TAGS_DIR,
+ error->message);
+ g_error_free (error);
+ return;
+ }
+ while ((name = g_dir_read_name (dir)) != NULL) {
+ gchar *file;
+ file = g_build_filename (CONSOLE_TAGS_DIR, name, NULL);
+
+ g_debug ("Removing tag file: %s", file);
+ if (unlink (file) == -1) {
+ g_warning ("Couldn't delete tag file: %s", file);
+ }
+ g_free (file);
+ }
+}
+
+static void
+cleanup (void)
+{
+ delete_console_tags ();
+ delete_pid ();
+}
+
/* copied from nautilus */
static int debug_log_pipes[2];
@@ -229,7 +266,7 @@ create_pid_file (void)
snprintf (pid, sizeof (pid), "%lu\n", (long unsigned) getpid ());
written = write (pf, pid, strlen (pid));
close (pf);
- g_atexit (delete_pid);
+ g_atexit (cleanup);
} else {
g_warning ("Unable to write pid file %s: %s",
CONSOLE_KIT_PID_FILE,
@@ -294,11 +331,19 @@ main (int argc,
setup_debug_log (debug);
+ g_debug ("initializing console-kit-daemon %s", VERSION);
+
connection = get_system_bus ();
if (connection == NULL) {
goto out;
}
+ manager = ck_manager_new ();
+
+ if (manager == NULL) {
+ goto out;
+ }
+
bus_proxy = get_bus_proxy (connection);
if (bus_proxy == NULL) {
g_warning ("Could not construct bus_proxy object; bailing out");
@@ -310,15 +355,9 @@ main (int argc,
goto out;
}
- g_debug ("initializing console-kit-daemon %s", VERSION);
+ delete_console_tags ();
create_pid_file ();
-
- manager = ck_manager_new ();
-
- if (manager == NULL) {
- goto out;
- }
loop = g_main_loop_new (NULL, FALSE);