X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdbus1-generator%2Fdbus1-generator.c;h=dcfceecf6356e0ef26b00fa3c93303db7fe3e602;hb=be63641349b1350c6b33976791eb89af7427de7b;hp=cbe91868e91771fd65bc00f1ede68b29196d1b31;hpb=737dedebb8374aa8b600a9006311a10946acb492;p=elogind.git diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c index cbe91868e..dcfceecf6 100644 --- a/src/dbus1-generator/dbus1-generator.c +++ b/src/dbus1-generator/dbus1-generator.c @@ -66,7 +66,8 @@ static int create_dbus_files( "# Automatically generated by systemd-dbus1-generator\n\n" "[Unit]\n" "SourcePath=%s\n" - "Description=DBUS1: %s\n\n" + "Description=DBUS1: %s\n" + "Documentation=man:systemd-dbus1-generator(8)\n\n" "[Service]\n" "ExecStart=%s\n" "Type=dbus\n" @@ -84,9 +85,19 @@ 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=kernel:/dev/kdbus/0-system\n"); - else if (streq(type, "session")) - fprintf(f, "Environment=DBUS_STARTER_ADDRESS=kernel:/dev/kdbus/%lu-user\n", (unsigned long) getuid()); + fprintf(f, "Environment=DBUS_STARTER_ADDRESS=" DEFAULT_SYSTEM_BUS_PATH "\n"); + else if (streq(type, "session")) { + char *run; + + run = getenv("XDG_RUNTIME_DIR"); + if (!run) { + log_error("XDG_RUNTIME_DIR not set."); + return -EINVAL; + } + + fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT "\n", + getuid(), run); + } } fflush(f); @@ -112,10 +123,12 @@ static int create_dbus_files( "# Automatically generated by systemd-dbus1-generator\n\n" "[Unit]\n" "SourcePath=%s\n" - "Description=DBUS1: %s\n\n" + "Description=DBUS1: %s\n" + "Documentation=man:systemd-dbus1-generator(8)\n\n" "[BusName]\n" "Name=%s\n" - "Service=%s\n", + "Service=%s\n" + "AllowWorld=talk\n", path, name, name, @@ -143,34 +156,24 @@ static int create_dbus_files( static int add_dbus(const char *path, const char *fname, const char *type) { _cleanup_free_ char *name = NULL, *exec = NULL, *user = NULL, *service = NULL; - ConfigTableItem table[] = { + const ConfigTableItem table[] = { { "D-BUS Service", "Name", config_parse_string, 0, &name }, { "D-BUS Service", "Exec", config_parse_string, 0, &exec }, { "D-BUS Service", "User", config_parse_string, 0, &user }, { "D-BUS Service", "SystemdService", config_parse_string, 0, &service }, }; - _cleanup_fclose_ FILE *f = NULL; - _cleanup_free_ char *p = NULL; + char *p; int r; assert(path); assert(fname); - p = strjoin(path, "/", fname, NULL); - if (!p) - return log_oom(); - - f = fopen(p, "re"); - if (!f) { - if (errno == -ENOENT) - return 0; - - log_error("Failed to read %s: %m", p); - return -errno; - } - - r = config_parse(NULL, p, f, "D-BUS Service\0", config_item_table_lookup, table, true, false, NULL); + p = strappenda3(path, "/", fname); + r = config_parse(NULL, p, NULL, + "D-BUS Service\0", + config_item_table_lookup, table, + true, false, true, NULL); if (r < 0) return r;