Patches by Kjartan Maraas <kmaraas at gnome dot org>
[platform/upstream/dbus.git] / dbus / dbus-sysdeps-util.c
index 52298f8..ebe20b4 100644 (file)
@@ -56,7 +56,7 @@
  * Does the chdir, fork, setsid, etc. to become a daemon process.
  *
  * @param pidfile #NULL, or pidfile to create
- * @param print_pid_fd file descriptor to print pid to, or -1 for none
+ * @param print_pid_fd file descriptor to print daemon's pid to, or -1 for none
  * @param error return location for errors
  * @returns #FALSE on failure
  */
@@ -142,7 +142,7 @@ _dbus_become_daemon (const DBusString *pidfile,
              return FALSE;
            }
          
-         if (!_dbus_string_append_int (&pid, _dbus_getpid ()) ||
+         if (!_dbus_string_append_int (&pid, child_pid) ||
              !_dbus_string_append (&pid, "\n"))
            {
              _dbus_string_free (&pid);
@@ -219,6 +219,8 @@ _dbus_write_pid_file (const DBusString *filename,
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Failed to write to \"%s\": %s", cfilename,
                       _dbus_strerror (errno));
+      
+      fclose (f);
       return FALSE;
     }
 
@@ -295,7 +297,7 @@ _dbus_set_signal_handler (int               sig,
   act.sa_handler = handler;
   act.sa_mask    = empty_mask;
   act.sa_flags   = 0;
-  sigaction (sig,  &act, 0);
+  sigaction (sig,  &act, NULL);
 }
 
 
@@ -359,7 +361,7 @@ _dbus_user_at_console (const char *username,
       return FALSE;
     }
 
-  if (!_dbus_string_append (&f, DBUS_CONSOLE_DIR))
+  if (!_dbus_string_append (&f, DBUS_CONSOLE_AUTH_DIR))
     {
       _DBUS_SET_OOM (error);
       goto out;
@@ -590,7 +592,7 @@ fill_group_info (DBusGroupInfo    *info,
    * to add more configure checks.
    */
   
-#if defined (HAVE_POSIX_GETPWNAME_R) || defined (HAVE_NONPOSIX_GETPWNAME_R)
+#if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R)
   {
     struct group *g;
     int result;
@@ -598,7 +600,7 @@ fill_group_info (DBusGroupInfo    *info,
     struct group g_str;
 
     g = NULL;
-#ifdef HAVE_POSIX_GETPWNAME_R
+#ifdef HAVE_POSIX_GETPWNAM_R
 
     if (group_c_str)
       result = getgrnam_r (group_c_str, &g_str, buf, sizeof (buf),
@@ -607,9 +609,9 @@ fill_group_info (DBusGroupInfo    *info,
       result = getgrgid_r (gid, &g_str, buf, sizeof (buf),
                            &g);
 #else
-    p = getgrnam_r (group_c_str, &g_str, buf, sizeof (buf));
+    g = getgrnam_r (group_c_str, &g_str, buf, sizeof (buf));
     result = 0;
-#endif /* !HAVE_POSIX_GETPWNAME_R */
+#endif /* !HAVE_POSIX_GETPWNAM_R */
     if (result == 0 && g == &g_str)
       {
         return fill_user_info_from_group (g, info, error);
@@ -680,17 +682,6 @@ _dbus_group_info_fill_gid (DBusGroupInfo *info,
   return fill_group_info (info, gid, NULL, error);
 }
 
-/**
- * Frees the members of info (but not info itself).
- *
- * @param info the group info
- */
-void
-_dbus_group_info_free (DBusGroupInfo    *info)
-{
-  dbus_free (info->groupname);
-}
-
 /** @} */ /* End of DBusInternalsUtils functions */
 
 /**