]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/dbus1-generator/dbus1-generator.c
util-lib: introduce dirent-util.[ch] for directory entry calls
[thirdparty/systemd.git] / src / dbus1-generator / dbus1-generator.c
index 25c8e209fd7b3fc607be5776ce1b7b81413d9bcf..66a0fe9ea229345967cea9f78ff8d8cbfb936cc0 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "util.h"
+#include "bus-internal.h"
+#include "bus-util.h"
+#include "cgroup-util.h"
 #include "conf-parser.h"
-#include "special.h"
+#include "dirent-util.h"
+#include "fd-util.h"
+#include "fileio.h"
 #include "mkdir.h"
-#include "bus-util.h"
-#include "bus-internal.h"
+#include "special.h"
 #include "unit-name.h"
-#include "cgroup-util.h"
+#include "util.h"
 
 static const char *arg_dest_late = "/tmp", *arg_dest = "/tmp";
 
@@ -84,8 +87,7 @@ static int create_dbus_files(
                         fprintf(f, "Environment=DBUS_STARTER_BUS_TYPE=%s\n", type);
 
                         if (streq(type, "system"))
-                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS=%s\n",
-                                        is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
+                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS=" DEFAULT_SYSTEM_BUS_ADDRESS "\n");
                         else if (streq(type, "session")) {
                                 char *run;
 
@@ -95,10 +97,8 @@ static int create_dbus_files(
                                         return -EINVAL;
                                 }
 
-                                if (is_kdbus_available())
-                                        fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_ADDRESS_FMT "\n", getuid());
-                                else
-                                        fprintf(f, "Environment=DBUS_STARTER_ADDRESS="UNIX_USER_BUS_ADDRESS_FMT "\n", run);
+                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT "\n",
+                                        getuid(), run);
                         }
                 }
 
@@ -106,8 +106,7 @@ static int create_dbus_files(
                 if (r < 0)
                         return log_error_errno(r, "Failed to write %s: %m", a);
 
-                fclose(f);
-                f = NULL;
+                f = safe_fclose(f);
 
                 service = s;
         }