#431 LXSession - systemd-logind support

-
closed-out-of-date
nobody
None
5
2014-11-15
2012-11-15
No

here I submit my own independent "implementation of systemd-logind for Shutdown, Reboot, Suspend and Hibernate with fallback on other mechanisms (ConsoleKit, UPower, HAL)" (please see Hugues Chabot's post)

the attached file is in "cut-here" plain text format and contains the whole dbus-interface.h, dbus-interface.c, lxsession-logout.c files for easier reference

this implementation closely resembles the Chabot's one, but it can help avoiding a potential memory management issue which may arise from returning char* right after doing dbus_message_unref(reply):

+/* Read a result for a method that returns string. */
+static char * dbus_read_result_string(DBusMessage * reply)
+{
+ char * result = FALSE;
+ if (reply != NULL)
+ {
+ /* Get the boolean result. */
+ DBusError error;
+ dbus_error_init(&error);
+ dbus_bool_t status = dbus_message_get_args(
+ reply,
+ &error,
+ DBUS_TYPE_STRING, &result,
+ DBUS_TYPE_INVALID);
+ dbus_message_unref(reply); <---------------------- isn't it the memory pointed to by result released here?
+ if ( ! status)
+ {
+ g_warning(G_STRLOC ": DBUS: %s", error.message);
+ dbus_error_free(&error);
+ return NULL;
+ }
+ }
+ return result;
+}

Discussion

  • gilir

    gilir - 2013-03-10

    Thanks. Could you provide a diff of your change from current git (which include Hugues Chabot's patches) ?

     
  • gilir

    gilir - 2014-11-08
    • status: open --> closed-out-of-date
    • Group: --> Unstable (example)
     
  • gilir

    gilir - 2014-11-08

    Closing the bug since we have systemd support. Feel free reopen if you have improvements on the current code.

     

Log in to post a comment.