rpms/im-chooser/F-9 im-chooser-0.99.6-sanity-check-on-dbus-conn.patch, NONE, 1.1 im-chooser-0.99.6-validate-pid.patch, NONE, 1.1 im-chooser.spec, 1.39, 1.40

Akira TAGOH (tagoh) fedora-extras-commits at redhat.com
Tue Apr 29 03:56:50 UTC 2008


Author: tagoh

Update of /cvs/pkgs/rpms/im-chooser/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13896

Modified Files:
	im-chooser.spec 
Added Files:
	im-chooser-0.99.6-sanity-check-on-dbus-conn.patch 
	im-chooser-0.99.6-validate-pid.patch 
Log Message:
* Tue Apr 29 2008 Akira TAGOH <tagoh at redhat.com> - 0.99.6-3
- im-chooser-0.99.6-sanity-check-on-dbus-conn.patch: Do not abort even if
  getting the bus is failed. (#444494)
- im-chooser-0.99.6-validate-pid.patch: Validate the pid. (#443765)

im-chooser-0.99.6-sanity-check-on-dbus-conn.patch:

--- NEW FILE im-chooser-0.99.6-sanity-check-on-dbus-conn.patch ---
2008-04-29  Akira TAGOH  <tagoh at redhat.com>

	* utils/imsettings-reload.c (main): exit if opening session bus
	is failed.

Index: imsettings/utils/imsettings-reload.c
===================================================================
--- imsettings/utils/imsettings-reload.c	(revision 334)
+++ imsettings/utils/imsettings-reload.c	(revision 335)
@@ -67,6 +67,10 @@
 	g_option_context_free(ctx);
 
 	connection = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	if (connection == NULL) {
+		g_printerr("Failed to get a session bus.\n");
+		return 1;
+	}
 	imsettings = imsettings_request_new(connection, IMSETTINGS_INTERFACE_DBUS);
 	imgconf = imsettings_request_new(connection, IMSETTINGS_GCONF_INTERFACE_DBUS);
 	iminfo = imsettings_request_new(connection, IMSETTINGS_INFO_INTERFACE_DBUS);

im-chooser-0.99.6-validate-pid.patch:

--- NEW FILE im-chooser-0.99.6-validate-pid.patch ---
 2008-04-29  Akira TAGOH  <tagoh at redhat.com>
 
	* src/factory.c (_get_pid): new.
	(imsettings_manager_real_what_im_is_running): check if pid is valid
	or not.

Index: imsettings/src/factory.c
===================================================================
--- imsettings/src/factory.c	(revision 335)
+++ imsettings/src/factory.c	(revision 336)
@@ -77,7 +77,9 @@
 	PROP_DISPLAY_NAME,
 };
 
-GType imsettings_manager_get_type(void) G_GNUC_CONST;
+GType        imsettings_manager_get_type               (void) G_GNUC_CONST;
+const gchar *imsettings_manager_real_what_im_is_running(IMSettingsObserver  *observer,
+							GError             **error);
 
 G_DEFINE_TYPE (IMSettingsManager, imsettings_manager, IMSETTINGS_TYPE_OBSERVER);
 
@@ -251,17 +253,39 @@
 	return (*error == NULL);
 }
 
+static pid_t
+_get_pid(const gchar  *pidfile,
+	 const gchar  *type,
+	 GError      **error)
+{
+	pid_t pid;
+	gchar *contents = NULL;
+	gsize len = 0;
+
+	if (!g_file_get_contents(pidfile, &contents, &len, error))
+		return 0;
+
+	if ((pid = atoi(contents)) == 0) {
+		/* maybe invalid pidfile. */
+		g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_UNABLE_TO_TRACK_IM,
+			    _("Couldn't determine the pid for %s process."),
+			    type);
+	}
+	g_free(contents);
+
+	return pid;
+}
+
 static gboolean
 _stop_process(const gchar  *pidfile,
 	      const gchar  *type,
 	      GError      **error)
 {
-	gchar *contents = NULL;
-	gsize len = 0;
 	pid_t pid;
 	gboolean retval = FALSE;
 
-	if (!g_file_get_contents(pidfile, &contents, &len, error)) {
+	pid = _get_pid(pidfile, type, error);
+	if (pid == 0) {
 		if (g_error_matches(*error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
 			/* No pidfile is available. there aren't anything else to do.
 			 * basically this is no problem. someone may just did stop an IM
@@ -270,19 +294,8 @@
 			g_error_free(*error);
 			*error = NULL;
 			retval = TRUE;
-		} else {
-			/* Otherwise that shouldn't be happened.
-			 */
-			g_return_val_if_reached(FALSE);
 		}
 	} else {
-		if ((pid = atoi(contents)) == 0) {
-			/* maybe invalid pidfile. */
-			g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_UNABLE_TO_TRACK_IM,
-				    _("Couldn't determine the pid for %s process."),
-				    type);
-			goto end;
-		}
 		if (kill(-pid, SIGTERM) == -1) {
 			g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_UNABLE_TO_TRACK_IM,
 				    _("Couldn't send a signal to the %s process successfully."),
@@ -292,8 +305,6 @@
 			retval = TRUE;
 		}
 	}
-  end:
-	g_free(contents);
 
 	return retval;
 }
@@ -633,6 +644,7 @@
 	IMSettingsRequest *req;
 	DBusConnection *conn;
 	gchar *module, *xinputfile = NULL, *pidfile = NULL;
+	pid_t pid;
 
 	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
 	req = imsettings_request_new(conn, IMSETTINGS_INFO_INTERFACE_DBUS);
@@ -646,9 +658,15 @@
 			goto end;
 		}
 		pidfile = _build_pidfilename(xinputfile, priv->display_name, "xim");
-		if (!g_file_test(pidfile, G_FILE_TEST_EXISTS)) {
+		pid = _get_pid(pidfile, "xim", error);
+		if (pid == 0) {
 			g_free(module);
 			module = NULL;
+		} else {
+			if (kill(pid, 0) == -1) {
+				g_free(module);
+				module = NULL;
+			}
 		}
 	}
   end:


Index: im-chooser.spec
===================================================================
RCS file: /cvs/pkgs/rpms/im-chooser/F-9/im-chooser.spec,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- im-chooser.spec	25 Apr 2008 14:15:50 -0000	1.39
+++ im-chooser.spec	29 Apr 2008 03:56:14 -0000	1.40
@@ -1,6 +1,6 @@
 Name:		im-chooser
 Version:	0.99.6
-Release:	2%{?dist}
+Release:	3%{?dist}
 License:	GPLv2+
 URL:		http://fedorahosted.org/im-chooser/
 Buildroot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -11,6 +11,8 @@
 Patch0:		im-chooser-constraint-of-language.patch
 Patch1:		im-chooser-0.99.6-check-if-im-is-running.patch
 Patch2:		im-chooser-0.99.6-correct-build-order.patch
+Patch3:		im-chooser-0.99.6-sanity-check-on-dbus-conn.patch
+Patch4:		im-chooser-0.99.6-validate-pid.patch
 
 Summary:	Desktop Input Method configuration tool
 Group:		Applications/System
@@ -65,6 +67,8 @@
 %patch0 -p1 -b .language
 %patch1 -p0 -b .is_running
 %patch2 -p1 -b .build_order
+%patch3 -p0 -b .dbusconn
+%patch4 -p0 -b .pid
 autoreconf
 
 %build
@@ -149,6 +153,11 @@
 %{_libdir}/pkgconfig/imsettings.pc
 
 %changelog
+* Tue Apr 29 2008 Akira TAGOH <tagoh at redhat.com> - 0.99.6-3
+- im-chooser-0.99.6-sanity-check-on-dbus-conn.patch: Do not abort even if
+  getting the bus is failed. (#444494)
+- im-chooser-0.99.6-validate-pid.patch: Validate the pid. (#443765)
+
 * Wed Apr 23 2008 Akira TAGOH <tagoh at redhat.com> - 0.99.6-2
 - im-chooser-0.99.6-check-if-im-is-running.patch: Do not turn on the check box
   if IM isn't really running. (#443765)




More information about the fedora-extras-commits mailing list