blob: 4dbd62575949778611cbd673b35487d6712e42f3 [file] [log] [blame]
# Clean up at_console compat files, bug #257761
# http://patches.ubuntu.com/by-release/extracted/ubuntu/c/consolekit/0.2.10-1ubuntu9/
--- a/src/main.c 2008-07-25 03:19:34.000000000 +0200
+++ b/src/main.c 2008-07-26 00:25:13.000000000 +0200
@@ -149,6 +149,43 @@
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 @@
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,
@@ -312,6 +349,8 @@
g_debug ("initializing console-kit-daemon %s", VERSION);
+ delete_console_tags ();
+
create_pid_file ();
manager = ck_manager_new ();