chiark / gitweb /
Prep v233: Add missing includes in src/shared
[elogind.git] / src / basic / fileio.c
index c79a704661e093dbe6fe1eac9b0ad9d35aa9075b..03238151c64694ea3222292ce2acbfae3f2d2c7f 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "alloc-util.h"
 #include "ctype.h"
-#include "env-util.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -38,6 +37,7 @@
 #include "hexdecoct.h"
 //#include "log.h"
 //#include "macro.h"
+#include "missing.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "random-util.h"
@@ -553,13 +553,14 @@ static int parse_env_file_internal(
                 }
         }
 
-        if (state == PRE_VALUE ||
-            state == VALUE ||
-            state == VALUE_ESCAPE ||
-            state == SINGLE_QUOTE_VALUE ||
-            state == SINGLE_QUOTE_VALUE_ESCAPE ||
-            state == DOUBLE_QUOTE_VALUE ||
-            state == DOUBLE_QUOTE_VALUE_ESCAPE) {
+        if (IN_SET(state,
+                   PRE_VALUE,
+                   VALUE,
+                   VALUE_ESCAPE,
+                   SINGLE_QUOTE_VALUE,
+                   SINGLE_QUOTE_VALUE_ESCAPE,
+                   DOUBLE_QUOTE_VALUE,
+                   DOUBLE_QUOTE_VALUE_ESCAPE)) {
 
                 key[n_key] = 0;
 
@@ -712,6 +713,7 @@ int load_env_file(FILE *f, const char *fname, const char *newline, char ***rl) {
         *rl = m;
         return 0;
 }
+#endif // 0
 
 static int load_env_file_push_pairs(
                 const char *filename, unsigned line,
@@ -761,6 +763,7 @@ int load_env_file_pairs(FILE *f, const char *fname, const char *newline, char **
         *rl = m;
         return 0;
 }
+#if 0 /// UNNEEDED by elogind
 
 static int merge_env_file_push(
                 const char *filename, unsigned line,
@@ -773,6 +776,17 @@ static int merge_env_file_push(
 
         assert(env);
 
+        if (!value) {
+                log_error("%s:%u: invalid syntax (around \"%s\"), ignoring.", strna(filename), line, key);
+                return 0;
+        }
+
+        if (!env_name_is_valid(key)) {
+                log_error("%s:%u: invalid variable name \"%s\", ignoring.", strna(filename), line, key);
+                free(value);
+                return 0;
+        }
+
         expanded_value = replace_env(value, *env,
                                      REPLACE_ENV_USE_ENVIRONMENT|REPLACE_ENV_ALLOW_BRACELESS);
         if (!expanded_value)
@@ -1300,6 +1314,7 @@ int fputs_with_space(FILE *f, const char *s, const char *separator, bool *space)
 
         return fputs(s, f);
 }
+#endif // 0
 
 int open_tmpfile_unlinkable(const char *directory, int flags) {
         char *p;
@@ -1330,6 +1345,7 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
         return fd;
 }
 
+#if 0 /// UNNEEDED by elogind
 int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
         _cleanup_free_ char *tmp = NULL;
         int r, fd;
@@ -1373,6 +1389,7 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
 
         return fd;
 }
+#endif // 0
 
 int open_serialization_fd(const char *ident) {
         int fd = -1;
@@ -1393,6 +1410,7 @@ int open_serialization_fd(const char *ident) {
         return fd;
 }
 
+#if 0 /// UNNEEDED by elogind
 int link_tmpfile(int fd, const char *path, const char *target) {
 
         assert(fd >= 0);