chiark / gitweb /
build-sys: fix configure output without libwrap
[elogind.git] / src / load-fragment.c
index a706880b9a1c653948a4fe22ad3bb8bcc5e332f5..1f082d57b3b78213aaad9872a22538c648f029e7 100644 (file)
@@ -1160,7 +1160,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
          * reached by a symlink. The old string will be freed. */
 
         for (;;) {
-                char *target, *k, *name;
+                char *target, *name;
 
                 if (c++ >= FOLLOW_MAX)
                         return -ELOOP;
@@ -1189,17 +1189,11 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
                         return -errno;
 
                 /* Hmm, so this is a symlink. Let's read the name, and follow it manually */
-                if ((r = readlink_malloc(*filename, &target)) < 0)
+                if ((r = readlink_and_make_absolute(*filename, &target)) < 0)
                         return r;
 
-                k = file_in_same_dir(*filename, target);
-                free(target);
-
-                if (!k)
-                        return -ENOMEM;
-
                 free(*filename);
-                *filename = k;
+                *filename = target;
         }
 
         if (!(f = fdopen(fd, "r"))) {
@@ -1366,7 +1360,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "Environment",            config_parse_strv,            &(context).environment,                          section   }, \
                 { "StandardInput",          config_parse_input,           &(context).std_input,                            section   }, \
                 { "StandardOutput",         config_parse_output,          &(context).std_output,                           section   }, \
-                { "StandardError",          config_parse_output,          &(context).std_output,                           section   }, \
+                { "StandardError",          config_parse_output,          &(context).std_error,                            section   }, \
                 { "TTYPath",                config_parse_path,            &(context).tty_path,                             section   }, \
                 { "SyslogIdentifier",       config_parse_string,          &(context).syslog_identifier,                    section   }, \
                 { "SyslogFacility",         config_parse_facility,        &(context).syslog_priority,                      section   }, \
@@ -1397,7 +1391,9 @@ static int load_from_path(Unit *u, const char *path) {
                 { "ReadOnlyDirectories",    config_parse_path_strv,       &(context).read_only_dirs,                       section   }, \
                 { "InaccessibleDirectories",config_parse_path_strv,       &(context).inaccessible_dirs,                    section   }, \
                 { "PrivateTmp",             config_parse_bool,            &(context).private_tmp,                          section   }, \
-                { "MountFlags",             config_parse_mount_flags,     &(context),                                      section   }
+                { "MountFlags",             config_parse_mount_flags,     &(context),                                      section   }, \
+                { "TCPWrapName",            config_parse_string,          &(context).tcpwrap_name,                         section   }, \
+                { "PAMName",                config_parse_string,          &(context).pam_name,                             section   }
 
         const ConfigItem items[] = {
                 { "Names",                  config_parse_names,           u,                                               "Unit"    },
@@ -1477,13 +1473,17 @@ static int load_from_path(Unit *u, const char *path) {
                 { "DirectoryNotEmpty",      config_parse_path_spec,       &u->path,                                        "Path"    },
                 { "Unit",                   config_parse_path_unit,       &u->path,                                        "Path"    },
 
+                /* The [Install] section is ignored here. */
+                { "Alias",                  NULL,                         NULL,                                            "Install" },
+                { "WantedBy",               NULL,                         NULL,                                            "Install" },
+                { "Also",                   NULL,                         NULL,                                            "Install" },
+
                 { NULL, NULL, NULL, NULL }
         };
 
 #undef EXEC_CONTEXT_CONFIG_ITEMS
 
-        const char *sections[3];
-        char *k;
+        const char *sections[4];
         int r;
         Set *symlink_names;
         FILE *f = NULL;
@@ -1501,7 +1501,8 @@ static int load_from_path(Unit *u, const char *path) {
 
         sections[0] = "Unit";
         sections[1] = section_table[u->meta.type];
-        sections[2] = NULL;
+        sections[2] = "Install";
+        sections[3] = NULL;
 
         if (!(symlink_names = set_new(string_hash_func, string_compare_func)))
                 return -ENOMEM;
@@ -1524,7 +1525,7 @@ static int load_from_path(Unit *u, const char *path) {
         } else  {
                 char **p;
 
-                STRV_FOREACH(p, u->meta.manager->unit_path) {
+                STRV_FOREACH(p, u->meta.manager->lookup_paths.unit_path) {
 
                         /* Instead of opening the path right away, we manually
                          * follow all symlinks and add their name to our unit
@@ -1570,7 +1571,7 @@ static int load_from_path(Unit *u, const char *path) {
         }
 
         /* Now, parse the file contents */
-        if ((r = config_parse(filename, f, sections, items, u)) < 0)
+        if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
                 goto finish;
 
         free(u->meta.fragment_path);
@@ -1581,10 +1582,7 @@ static int load_from_path(Unit *u, const char *path) {
         r = 0;
 
 finish:
-        while ((k = set_steal_first(symlink_names)))
-                free(k);
-
-        set_free(symlink_names);
+        set_free_free(symlink_names);
         free(filename);
 
         if (f)