Blame cairo-dock-fix-insecure-tmpfile.patch

2700223
--- trunk/plug-ins/compiz-icon/src/applet-notifications.c.tmpuse	2008-06-15 02:04:01.000000000 +0900
2700223
+++ trunk/plug-ins/compiz-icon/src/applet-notifications.c	2008-06-15 20:51:54.000000000 +0900
2700223
@@ -8,6 +8,8 @@
2700223
 
2700223
 ******************************************************************************/
2700223
 
2700223
+#define _BSD_SOURCE
2700223
+#include <unistd.h>
2700223
 #include <stdlib.h>
2700223
 #include <string.h>
2700223
 #include <glib/gi18n.h>
2700223
@@ -23,13 +25,26 @@
2700223
 CD_APPLET_ABOUT (D_("This is the compiz-icon applet\n made by ChAnGFu for Cairo-Dock"))
2700223
 
2700223
 static void _compiz_get_version (void) {
2700223
+	char *tmpfile = g_strdup("/tmp/cd-compiz-version.XXXXXX");
2700223
+	char *cmd_header = "compiz.real --version | awk '{print $2}' > ";
2700223
+	char *cmd = g_malloc(strlen(cmd_header) + strlen(tmpfile) + 2);
2700223
+	int fds = mkstemp(tmpfile);
2700223
+	if (fds == -1) {
2700223
+		free (tmpfile);
2700223
+		free (cmd);
2700223
+		return;
2700223
+	}
2700223
+	close(fds);
2700223
+
2700223
 	if (myData.iCompizMajor != 0 || myData.iCompizMinor != 0 || myData.iCompizMicro != 0)
2700223
 		return ;
2700223
-	system ("compiz.real --version | awk '{print $2}' > /tmp/cd-compiz-version");
2700223
+	sprintf(cmd, "%s%s", cmd_header, tmpfile);
2700223
+	system (cmd);
2700223
+	g_free (cmd);
2700223
 	GError *erreur = NULL;
2700223
 	gsize length = 0;
2700223
 	gchar *cContent = NULL;
2700223
-	g_file_get_contents ("/tmp/cd-compiz-version", &cContent, &length, &erreur);
2700223
+	g_file_get_contents (tmpfile, &cContent, &length, &erreur);
2700223
 	if (erreur != NULL) {
2700223
 		cd_warning ("Attention : couldn't guess Compiz's version [%s]", erreur->message);
2700223
 		g_error_free (erreur);
2700223
@@ -40,7 +55,9 @@
2700223
 		g_free (cContent);
2700223
 	}
2700223
 	cd_message ("Compiz : %d.%d.%d", myData.iCompizMajor, myData.iCompizMinor, myData.iCompizMicro);
2700223
-	g_remove ("/tmp/cd-compiz-version");
2700223
+	g_remove (tmpfile);
2700223
+	g_free (tmpfile);
2700223
+	tmpfile = NULL;
2700223
 }
2700223
 
2700223
 static void _compiz_dbus_action (const gchar *cCommand) {
2700223
--- trunk/plug-ins/nVidia/src/applet-nvidia.c.tmpuse	2008-06-15 12:37:12.000000000 +0900
2700223
+++ trunk/plug-ins/nVidia/src/applet-nvidia.c	2008-06-15 21:15:21.000000000 +0900
2700223
@@ -100,6 +100,7 @@
2700223
 	gchar *cCommand = g_strdup_printf ("bash %s/nvidia-config %s", MY_APPLET_SHARE_DATA_DIR, s_cTmpFileConfig);
2700223
 	system (cCommand);
2700223
 	g_free (cCommand);
2700223
+	close(fds);
2700223
 }
2700223
 
2700223
 static gboolean _nvidia_get_values_from_file (gchar *cContent) {