summaryrefslogtreecommitdiff
path: root/debian/patches/03-cleanup_console_tags.patch
blob: fca530f9a9bf63ba2130c0f06aff314487c192a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Cleanup console tag files on application startup and shutdown.

Index: consolekit/src/main.c
===================================================================
--- consolekit.orig/src/main.c	2014-04-23 16:24:25.864069678 +0200
+++ consolekit/src/main.c	2014-04-23 16:24:46.320069405 +0200
@@ -148,6 +148,44 @@
         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);
+	}
+	g_dir_close (dir);
+}
+
+static void
+cleanup (void)
+{
+	delete_console_tags ();
+	delete_pid ();
+}
+
 /* copied from nautilus */
 static int debug_log_pipes[2];
 
@@ -228,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,
@@ -317,6 +355,8 @@
                 goto out;
         }
 
+	delete_console_tags ();
+
         create_pid_file ();
 
         loop = g_main_loop_new (NULL, FALSE);