chiark / gitweb /
Add abstraction model for BPF programs
authorDaniel Mack <daniel@zonque.org>
Tue, 18 Oct 2016 15:57:10 +0000 (17:57 +0200)
committerSven Eden <yamakuzure@gmx.net>
Mon, 20 Nov 2017 16:28:50 +0000 (17:28 +0100)
This object takes a number of bpf_insn members and wraps them together with
the in-kernel reference id. Will be needed by the firewall code.

24 files changed:
meson.build
src/basic/cgroup-util.c
src/basic/def.h
src/basic/fileio.c
src/basic/fileio.h
src/basic/fs-util.c
src/basic/meson.build
src/basic/missing_syscall.h
src/basic/terminal-util.c
src/basic/time-util.c
src/libelogind/sd-bus/sd-bus.c
src/libelogind/sd-daemon/sd-daemon.c
src/libelogind/sd-event/test-event.c
src/libelogind/sd-login/test-login.c
src/login/logind-session.c
src/login/logind.c
src/shared/conf-parser.c
src/shared/udev-util.c
src/sleep/sleep.c
src/test/meson.build
src/test/test-cgroup.c
src/test/test-conf-parser.c
src/test/test-log.c
src/test/test-signal-util.c

index 06406b782896f18c101de804829077c4c732a158..dea963aa8e0ec1bedfdfb29b3aa76f0ab660ef3e 100644 (file)
@@ -496,6 +496,8 @@ foreach ident : [
                                  #include <keyutils.h>'''],
         ['copy_file_range',   '''#include <sys/syscall.h>
                                  #include <unistd.h>'''],
+        ['bpf',               '''#include <sys/syscall.h>
+                                 #include <unistd.h>'''],
         ['explicit_bzero' ,   '''#include <string.h>'''],
 ]
 
@@ -761,7 +763,7 @@ endif
 
 #if 0 /// UNNEEDED by elogind
 # libmount = dependency('mount',
-#                       version : '>= 2.27')
+#                       version : '>= 2.30')
 #
 # want_seccomp = get_option('seccomp')
 # if want_seccomp != 'false'
@@ -2460,17 +2462,17 @@ executable('elogind-cgroups-agent',
 #                    install_rpath : rootlibexecdir,
 #                    install : true,
 #                    install_dir : rootlibexecdir)
-# endif
 #
 #         exe = executable('networkctl',
-#                  networkctl_sources,
-#                  include_directories : includes,
-#                  link_with : [libsystemd_network,
+#                    networkctl_sources,
+#                    include_directories : includes,
+#                    link_with : [libsystemd_network,
 #                               libshared],
-#                  install_rpath : rootlibexecdir,
-#                  install : true,
-#                  install_dir : rootbindir)
-# public_programs += [exe]
+#                    install_rpath : rootlibexecdir,
+#                    install : true,
+#                    install_dir : rootbindir)
+#         public_programs += [exe]
+# endif
 #endif // 0
 
 ############################################################
index 49441156f4dece18eed8bc697badeaf5766af7e2..83fd7e5f814c7abcdbb5319e48bbfdefca238edd 100644 (file)
@@ -1007,7 +1007,7 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi
 int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
         _cleanup_fclose_ FILE *f = NULL;
         char line[LINE_MAX];
-        const char *fs, *controller_str = NULL;
+        const char *fs, *controller_str;
         size_t cs = 0;
         int unified;
 
@@ -2385,6 +2385,7 @@ int cg_mask_supported(CGroupMask *ret) {
 #if 0 /// UNNEEDED by elogind
 int cg_kernel_controllers(Set *controllers) {
         _cleanup_fclose_ FILE *f = NULL;
+        char buf[LINE_MAX];
         int r;
 
         assert(controllers);
@@ -2402,7 +2403,7 @@ int cg_kernel_controllers(Set *controllers) {
         }
 
         /* Ignore the header line */
-        (void) read_line(f, (size_t) -1, NULL);
+        (void) fgets(buf, sizeof(buf), f);
 
         for (;;) {
                 char *controller;
index 1571f921b739c48ddcd14724f5cfaf5a42c4367d..d30b4a106b9ba04ee2639a19dbb8a3969e338098 100644 (file)
@@ -96,5 +96,3 @@
         "/usr/local/lib/" n "\0"                \
         "/usr/lib/" n "\0"                      \
         _CONF_PATHS_SPLIT_USR(n)
-
-#define LONG_LINE_MAX (1U*1024U*1024U)
index 196d6204d21a38bd7b33c7ff2bade9eba9cf6e2d..412c80f1ef8b3e6f9925f6bcbd74f863aab5e484 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "alloc-util.h"
 #include "ctype.h"
-#include "def.h"
+#include "env-util.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -177,7 +177,7 @@ fail:
 
 int read_one_line_file(const char *fn, char **line) {
         _cleanup_fclose_ FILE *f = NULL;
-        int r;
+        char t[LINE_MAX], *c;
 
         assert(fn);
         assert(line);
@@ -186,8 +186,21 @@ int read_one_line_file(const char *fn, char **line) {
         if (!f)
                 return -errno;
 
-        r = read_line(f, LONG_LINE_MAX, line);
-        return r < 0 ? r : 0;
+        if (!fgets(t, sizeof(t), f)) {
+
+                if (ferror(f))
+                        return errno > 0 ? -errno : -EIO;
+
+                t[0] = 0;
+        }
+
+        c = strdup(t);
+        if (!c)
+                return -ENOMEM;
+        truncate_nl(c);
+
+        *line = c;
+        return 0;
 }
 
 int verify_file(const char *fn, const char *blob, bool accept_extra_nl) {
@@ -1525,77 +1538,3 @@ int mkdtemp_malloc(const char *template, char **ret) {
         return 0;
 }
 #endif // 0
-
-static inline void funlockfilep(FILE **f) {
-        funlockfile(*f);
-}
-
-int read_line(FILE *f, size_t limit, char **ret) {
-        _cleanup_free_ char *buffer = NULL;
-        size_t n = 0, allocated = 0, count = 0;
-
-        assert(f);
-
-        /* Something like a bounded version of getline().
-         *
-         * Considers EOF, \n and \0 end of line delimiters, and does not include these delimiters in the string
-         * returned.
-         *
-         * Returns the number of bytes read from the files (i.e. including delimiters — this hence usually differs from
-         * the number of characters in the returned string). When EOF is hit, 0 is returned.
-         *
-         * The input parameter limit is the maximum numbers of characters in the returned string, i.e. excluding
-         * delimiters. If the limit is hit we fail and return -ENOBUFS.
-         *
-         * If a line shall be skipped ret may be initialized as NULL. */
-
-        if (ret) {
-                if (!GREEDY_REALLOC(buffer, allocated, 1))
-                        return -ENOMEM;
-        }
-
-        {
-                _cleanup_(funlockfilep) FILE *flocked = f;
-                flockfile(f);
-
-                for (;;) {
-                        int c;
-
-                        if (n >= limit)
-                                return -ENOBUFS;
-
-                        errno = 0;
-                        c = fgetc_unlocked(f);
-                        if (c == EOF) {
-                                /* if we read an error, and have no data to return, then propagate the error */
-                                if (ferror_unlocked(f) && n == 0)
-                                        return errno > 0 ? -errno : -EIO;
-
-                                break;
-                        }
-
-                        count++;
-
-                        if (IN_SET(c, '\n', 0)) /* Reached a delimiter */
-                                break;
-
-                        if (ret) {
-                                if (!GREEDY_REALLOC(buffer, allocated, n + 2))
-                                        return -ENOMEM;
-
-                                buffer[n] = (char) c;
-                        }
-
-                        n++;
-                }
-        }
-
-        if (ret) {
-                buffer[n] = 0;
-
-                *ret = buffer;
-                buffer = NULL;
-        }
-
-        return (int) count;
-}
index 2ff3b434dfde8477fab24d98d2d383b77896590e..f76c3243e39b246927bcb0ccdf7e85a9fc32d52f 100644 (file)
@@ -113,5 +113,3 @@ int read_nul_string(FILE *f, char **ret);
 
 int mkdtemp_malloc(const char *template, char **ret);
 #endif // 0
-
-int read_line(FILE *f, size_t limit, char **ret);
index c8b5ad4322f680f11fb070b12b1a00385e51af32..3701528eda8247a2c57a67d553c61ce56165d49f 100644 (file)
@@ -38,8 +38,8 @@
 #include "mkdir.h"
 #include "parse-util.h"
 #include "path-util.h"
-#include "process-util.h"
 #include "stat-util.h"
+#include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 //#include "time-util.h"
index 10acb9aefb51557d9b62700f790bb255e723e719..51e5b1b161f0dc72ffcf3f375d17c68391848a55 100644 (file)
@@ -1,5 +1,7 @@
 #if 0 /// elogind has a shorter list
 # basic_sources_plain = files('''
+#         MurmurHash2.c
+#         MurmurHash2.h
 #         af-list.c
 #         af-list.h
 #         alloc-util.c
@@ -17,6 +19,8 @@
 #         bitmap.c
 #         bitmap.h
 #         blkid-util.h
+#         bpf-program.c
+#         bpf-program.h
 #         btrfs-ctree.h
 #         btrfs-util.c
 #         btrfs-util.h
 #         bus-label.h
 #         calendarspec.c
 #         calendarspec.h
-#         capability-util.c
-#         capability-util.h
 #         cap-list.c
 #         cap-list.h
+#         capability-util.c
+#         capability-util.h
 #         cgroup-util.c
 #         cgroup-util.h
 #         chattr-util.c
 #         extract-word.h
 #         fd-util.c
 #         fd-util.h
-#         fileio.c
-#         fileio.h
 #         fileio-label.c
 #         fileio-label.h
+#         fileio.c
+#         fileio.h
 #         format-util.h
 #         fs-util.c
 #         fs-util.h
@@ -83,9 +87,9 @@
 #         hostname-util.h
 #         in-addr-util.c
 #         in-addr-util.h
-#         ioprio.h
 #         io-util.c
 #         io-util.h
+#         ioprio.h
 #         journal-importer.c
 #         journal-importer.h
 #         khash.c
 #         mempool.c
 #         mempool.h
 #         missing_syscall.h
+#         mkdir-label.c
 #         mkdir.c
 #         mkdir.h
-#         mkdir-label.c
 #         mount-util.c
 #         mount-util.h
-#         MurmurHash2.c
-#         MurmurHash2.h
 #         nss-util.h
 #         ordered-set.c
 #         ordered-set.h
 #         rlimit-util.h
 #         rm-rf.c
 #         rm-rf.h
-#         securebits.h
 #         securebits-util.c
 #         securebits-util.h
+#         securebits.h
 #         selinux-util.c
 #         selinux-util.h
 #         set.h
index 664724c00b5e741bda4b1debda56fb47180374fb..2f596cf546d653c0a4e72dd460f3a52333ea1811 100644 (file)
@@ -23,6 +23,8 @@
 /* Missing glibc definitions to access certain kernel APIs */
 
 #if 0 /// UNNEEDED by elogind
+#include <sys/types.h>
+
 #if !HAVE_DECL_PIVOT_ROOT
 static inline int pivot_root(const char *new_root, const char *put_old) {
         return syscall(SYS_pivot_root, new_root, put_old);
@@ -318,3 +320,33 @@ static inline ssize_t copy_file_range(int fd_in, loff_t *off_in,
 #  endif
 }
 #endif
+
+#if !HAVE_DECL_BPF
+#  ifndef __NR_bpf
+#    if defined __i386__
+#      define __NR_bpf 357
+#    elif defined __x86_64__
+#      define __NR_bpf 321
+#    elif defined __aarch64__
+#      define __NR_bpf 280
+#    elif defined __sparc__
+#      define __NR_bpf 349
+#    elif defined __s390__
+#      define __NR_bpf 351
+#    else
+#      warning "__NR_bpf not defined for your architecture"
+#    endif
+#  endif
+
+union bpf_attr;
+
+static inline int bpf(int cmd, union bpf_attr *attr, size_t size) {
+#ifdef __NR_bpf
+        return (int) syscall(__NR_bpf, cmd, attr, size);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+
+#endif
index d580c6dac06d826424d8b9bb229cb2f16f130b3f..6de7721174dc8089f6f3683b0cf898d70c2602d0 100644 (file)
@@ -47,7 +47,6 @@
 #include "log.h"
 #include "macro.h"
 #include "parse-util.h"
-#include "path-util.h"
 #include "process-util.h"
 #include "socket-util.h"
 #include "stat-util.h"
index fc94c945eaf3169b523542fd2737e6140f9b98fc..f0b9cc183f4c12a312abfc9853fd22e7af52cc63 100644 (file)
@@ -861,13 +861,13 @@ parse_usec:
         }
 
 from_tm:
-        if (weekday >= 0 && tm.tm_wday != weekday)
-                return -EINVAL;
-
         x = mktime_or_timegm(&tm, utc);
         if (x < 0)
                 return -EINVAL;
 
+        if (weekday >= 0 && tm.tm_wday != weekday)
+                return -EINVAL;
+
         ret = (usec_t) x * USEC_PER_SEC + x_usec;
         if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
                 return -EINVAL;
@@ -895,18 +895,20 @@ typedef struct ParseTimestampResult {
 } ParseTimestampResult;
 
 int parse_timestamp(const char *t, usec_t *usec) {
-        char *last_space, *tz = NULL;
+        char *last_space, *timezone = NULL;
         ParseTimestampResult *shared, tmp;
         int r;
         pid_t pid;
 
         last_space = strrchr(t, ' ');
         if (last_space != NULL && timezone_is_valid(last_space + 1))
-                tz = last_space + 1;
+                timezone = last_space + 1;
 
-        if (tz == NULL || endswith_no_case(t, " UTC"))
+        if (timezone == NULL || endswith_no_case(t, " UTC"))
                 return parse_timestamp_impl(t, usec, false);
 
+        t = strndupa(t, last_space - t);
+
         shared = mmap(NULL, sizeof *shared, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
         if (shared == MAP_FAILED)
                 return negative_errno();
@@ -920,24 +922,14 @@ int parse_timestamp(const char *t, usec_t *usec) {
         }
 
         if (pid == 0) {
-                bool with_tz = true;
-
-                if (setenv("TZ", tz, 1) != 0) {
+                if (setenv("TZ", timezone, 1) != 0) {
                         shared->return_value = negative_errno();
                         _exit(EXIT_FAILURE);
                 }
 
                 tzset();
 
-                /* If there is a timezone that matches the tzname fields, leave the parsing to the implementation.
-                 * Otherwise just cut it off */
-                with_tz = !STR_IN_SET(tz, tzname[0], tzname[1]);
-
-                /*cut off the timezone if we dont need it*/
-                if (with_tz)
-                        t = strndupa(t, last_space - t);
-
-                shared->return_value = parse_timestamp_impl(t, &shared->usec, with_tz);
+                shared->return_value = parse_timestamp_impl(t, &shared->usec, true);
 
                 _exit(EXIT_SUCCESS);
         }
index d9800f1cd81063d232ae440951e7e1352c603980..7bc0c056b8c55dc5f3e3ddd360d3ba056a80076e 100644 (file)
@@ -49,7 +49,6 @@
 #include "macro.h"
 #include "missing.h"
 #include "parse-util.h"
-#include "process-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "util.h"
index 06d3c64ff33279c4cb1504c863dfc001314aec66..85459e166115d1fb0eb3e7e24c4f0fb6ba81bb85 100644 (file)
@@ -38,7 +38,6 @@
 #include "fs-util.h"
 #include "parse-util.h"
 #include "path-util.h"
-#include "process-util.h"
 #include "socket-util.h"
 #include "strv.h"
 #include "util.h"
index 656f08d5618ffdecc6c61016028b94705f517096..1a581ae23eb8cdf40e99190f9710d80060d4f573 100644 (file)
@@ -24,7 +24,6 @@
 #include "fd-util.h"
 #include "log.h"
 #include "macro.h"
-#include "process-util.h"
 #include "signal-util.h"
 #include "util.h"
 
index 58a1cedde5f4cce706bb51713dbb76bf5c707937..d874677094019964144f43024f129fb15b3aabc7 100644 (file)
@@ -306,4 +306,3 @@ int main(int argc, char* argv[]) {
 
         return 0;
 }
-
index d2125112d7a02436638eb3b09d3d7cc51053f062..142ba55e947d100988d208f40281ac8f1c8f61c7 100644 (file)
@@ -33,7 +33,6 @@
 #include "bus-error.h"
 #include "bus-util.h"
 #include "escape.h"
-#include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
index 7452c5b82c125e06c8af6327a627c2d0f7ea9476..89c6a49e89f43e3265127570905dfe4c6bb131e3 100644 (file)
@@ -1140,7 +1140,6 @@ static int manager_dispatch_reload_signal(sd_event_source *s, const struct signa
 #if 1 /// elogind needs an Add-On for sleep configuration
         elogind_manager_reset_config(m);
 #endif // 1
-
         return 0;
 }
 
@@ -1164,7 +1163,6 @@ static int manager_startup(Manager *m) {
 #if 1 /// elogind needs some extra preparations before connecting...
         elogind_manager_startup(m);
 #endif // 1
-
         /* Connect to console */
         r = manager_connect_console(m);
         if (r < 0)
@@ -1343,14 +1341,13 @@ int main(int argc, char *argv[]) {
 #if 1 /// elogind needs an Add-On for sleep configuration
         elogind_manager_reset_config(m);
 #endif // 1
-
         r = manager_startup(m);
         if (r < 0) {
                 log_error_errno(r, "Failed to fully start up daemon: %m");
                 goto finish;
         }
 
-        log_debug("elogind running as pid "PID_FMT, getpid());
+        log_debug("elogind running as pid "PID_FMT, getpid_cached());
 
         sd_notify(false,
                   "READY=1\n"
index 2005671fe4579bc8f865c309b399b82b12af5786..ab66bfe6049dc13cafd31a8bf8df652e556b30f1 100644 (file)
 #include "alloc-util.h"
 #include "conf-files.h"
 #include "conf-parser.h"
-#include "def.h"
 #include "extract-word.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "fs-util.h"
 #include "log.h"
 #include "macro.h"
@@ -317,44 +315,24 @@ int config_parse(const char *unit,
         fd_warn_permissions(filename, fileno(f));
 
         for (;;) {
-                _cleanup_free_ char *buf = NULL;
-                char *l, *p, *c = NULL, *e;
+                char buf[LINE_MAX], *l, *p, *c = NULL, *e;
                 bool escaped = false;
 
-                r = read_line(f, LONG_LINE_MAX, &buf);
-                if (r == 0)
-                        break;
-                if (r == -ENOBUFS) {
-                        if (warn)
-                                log_error_errno(r, "%s:%u: Line too long", filename, line);
+                if (!fgets(buf, sizeof buf, f)) {
+                        if (feof(f))
+                                break;
 
-                        return r;
-                }
-                if (r < 0) {
-                        if (warn)
-                                log_error_errno(r, "%s:%u: Error while reading configuration file: %m", filename, line);
-
-                        return r;
+                        return log_error_errno(errno, "Failed to read configuration file '%s': %m", filename);
                 }
 
                 l = buf;
-                if (allow_bom) {
-                        char *q;
+                if (allow_bom && startswith(l, UTF8_BYTE_ORDER_MARK))
+                        l += strlen(UTF8_BYTE_ORDER_MARK);
+                allow_bom = false;
 
-                        q = startswith(buf, UTF8_BYTE_ORDER_MARK);
-                        if (q) {
-                                l = q;
-                                allow_bom = false;
-                        }
-                }
+                truncate_nl(l);
 
                 if (continuation) {
-                        if (strlen(continuation) + strlen(l) > LONG_LINE_MAX) {
-                                if (warn)
-                                        log_error("%s:%u: Continuation line too long", filename, line);
-                                return -ENOBUFS;
-                        }
-
                         c = strappend(continuation, l);
                         if (!c) {
                                 if (warn)
@@ -408,7 +386,8 @@ int config_parse(const char *unit,
 
                 if (r < 0) {
                         if (warn)
-                                log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line);
+                                log_warning_errno(r, "Failed to parse file '%s': %m",
+                                                  filename);
                         return r;
                 }
         }
@@ -755,6 +734,11 @@ int config_parse_path(
         assert(rvalue);
         assert(data);
 
+        if (isempty(rvalue)) {
+                n = NULL;
+                goto finalize;
+        }
+
         if (!utf8_is_valid(rvalue)) {
                 log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
                 return fatal ? -ENOEXEC : 0;
@@ -773,6 +757,7 @@ int config_parse_path(
 
         path_kill_slashes(n);
 
+finalize:
         free(*s);
         *s = n;
 
index ed32f0305a8ee8c00d62ea838b4b5e322f0cef0c..f708dcfa146371fa8acd6b38fca123c89d9d0f11 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <string.h>
 
-#include "alloc-util.h"
 #include "fileio.h"
 #include "log.h"
 #include "string-util.h"
index c6dd13197eb46a0b10f4b2aea602e6fda18ee289..01fa223490e2fd84b7150909c9819419e2594a06 100644 (file)
@@ -69,7 +69,7 @@ static int write_state(FILE **f, char **states) {
         STRV_FOREACH(state, states) {
                 int k;
 
-                k = write_string_stream(*f, *state, 0);
+                k = write_string_stream(*f, *state, true);
                 if (k == 0)
                         return 0;
                 log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m",
index e39ab46e8b84eea0b6e2e15d492487294ed100c3..7e1adb3d1399e8e0454eea715fc1a7c90f016b72 100644 (file)
@@ -300,11 +300,11 @@ tests += [
 #          [],
 #          []],
 #
-#         [['src/test/test-barrier.c'],
+#         [['src/test/test-in-addr-util.c'],
 #          [],
 #          []],
 #
-#         [['src/test/test-in-addr-util.c'],
+#         [['src/test/test-barrier.c'],
 #          [],
 #          []],
 #
index 2ed91c78098f0f37ad1233f37cb4a2b97a6157fc..71e318a15bc19926a457aa183f0ce235b5a884fc 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "cgroup-util.h"
 #include "path-util.h"
-#include "process-util.h"
 #include "string-util.h"
 #include "util.h"
 
index fe94b336a5a8979988aff26396c2718833434d70..a66ed1bd3947f7a332a04591e3936e136a33e748 100644 (file)
@@ -18,8 +18,6 @@
 ***/
 
 #include "conf-parser.h"
-#include "fd-util.h"
-#include "fileio.h"
 #include "log.h"
 #include "macro.h"
 #include "string-util.h"
 #include "util.h"
 
 static void test_config_parse_path_one(const char *rvalue, const char *expected) {
-        _cleanup_free_ char *path = NULL;
+        char *path = NULL;
 
         assert_se(config_parse_path("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &path, NULL) >= 0);
         assert_se(streq_ptr(expected, path));
+
+        free(path);
 }
 
 static void test_config_parse_log_level_one(const char *rvalue, int expected) {
@@ -80,10 +80,12 @@ static void test_config_parse_unsigned_one(const char *rvalue, unsigned expected
 }
 
 static void test_config_parse_strv_one(const char *rvalue, char **expected) {
-        _cleanup_strv_free_ char **strv = NULL;
+        char **strv = 0;
 
         assert_se(config_parse_strv("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &strv, NULL) >= 0);
         assert_se(strv_equal(expected, strv));
+
+        strv_free(strv);
 }
 
 static void test_config_parse_mode_one(const char *rvalue, mode_t expected) {
@@ -237,130 +239,7 @@ static void test_config_parse_iec_uint64(void) {
 }
 #endif // 0
 
-#define x10(x) x x x x x x x x x x
-#define x100(x) x10(x10(x))
-#define x1000(x) x10(x100(x))
-
-static const char* const config_file[] = {
-        "[Section]\n"
-        "setting1=1\n",
-
-        "[Section]\n"
-        "setting1=1",        /* no terminating newline */
-
-        "\n\n\n\n[Section]\n\n\n"
-        "setting1=1",        /* some whitespace, no terminating newline */
-
-        "[Section]\n"
-        "[Section]\n"
-        "setting1=1\n"
-        "setting1=2\n"
-        "setting1=1\n",      /* repeated settings */
-
-        "[Section]\n"
-        "setting1=1\\\n"     /* normal continuation */
-        "2\\\n"
-        "3\n",
-
-        "[Section]\n"
-        "setting1=1\\\\\\\n" /* continuation with trailing escape symbols */
-        "\\\\2\n",           /* note that C requires one level of escaping, so the
-                              * parser gets "…1 BS BS BS NL BS BS 2 NL", which
-                              * it translates into "…1 BS BS SP BS BS 2" */
-
-        "\n[Section]\n\n"
-        "setting1="          /* a line above LINE_MAX length */
-        x1000("ABCD")
-        "\n",
-
-        "[Section]\n"
-        "setting1="          /* a line above LINE_MAX length, with continuation */
-        x1000("ABCD") "\\\n"
-        "foobar",
-
-        "[Section]\n"
-        "setting1="          /* a line above the allowed limit: 9 + 1050000 + 1 */
-        x1000(x1000("x") x10("abcde")) "\n",
-
-        "[Section]\n"
-        "setting1="          /* many continuation lines, together above the limit */
-        x1000(x1000("x") x10("abcde") "\\\n") "xxx",
-};
-
-static void test_config_parse(unsigned i, const char *s) {
-        char name[] = "/tmp/test-conf-parser.XXXXXX";
-        int fd, r;
-        _cleanup_fclose_ FILE *f = NULL;
-        _cleanup_free_ char *setting1 = NULL;
-
-        const ConfigTableItem items[] = {
-                { "Section", "setting1",  config_parse_string,   0, &setting1},
-                {}
-        };
-
-        log_info("== %s[%i] ==", __func__, i);
-
-        fd = mkostemp_safe(name);
-        assert_se(fd >= 0);
-        assert_se((size_t) write(fd, s, strlen(s)) == strlen(s));
-
-        assert_se(lseek(fd, 0, SEEK_SET) == 0);
-        assert_se(f = fdopen(fd, "r"));
-
-        /*
-        int config_parse(const char *unit,
-                         const char *filename,
-                         FILE *f,
-                         const char *sections,
-                         ConfigItemLookup lookup,
-                         const void *table,
-                         bool relaxed,
-                         bool allow_include,
-                         bool warn,
-                         void *userdata)
-        */
-
-        r = config_parse(NULL, name, f,
-                         "Section\0",
-                         config_item_table_lookup, items,
-                         false, false, true, NULL);
-
-        switch (i) {
-        case 0 ... 3:
-                assert_se(r == 0);
-                assert_se(streq(setting1, "1"));
-                break;
-
-        case 4:
-                assert_se(r == 0);
-                assert_se(streq(setting1, "1 2 3"));
-                break;
-
-        case 5:
-                assert_se(r == 0);
-                assert_se(streq(setting1, "1\\\\ \\\\2"));
-                break;
-
-        case 6:
-                assert_se(r == 0);
-                assert_se(streq(setting1, x1000("ABCD")));
-                break;
-
-        case 7:
-                assert_se(r == 0);
-                assert_se(streq(setting1, x1000("ABCD") " foobar"));
-                break;
-
-        case 8 ... 9:
-                assert_se(r == -ENOBUFS);
-                assert_se(setting1 == NULL);
-                break;
-        }
-}
-
 int main(int argc, char **argv) {
-        unsigned i;
-
         log_parse_environment();
         log_open();
 
@@ -383,8 +262,5 @@ int main(int argc, char **argv) {
         test_config_parse_iec_uint64();
 #endif // 0
 
-        for (i = 0; i < ELEMENTSOF(config_file); i++)
-                test_config_parse(i, config_file[i]);
-
         return 0;
 }
index ec1bc2a635389222424ede4cdcbfa6fab7199ba8..8ab569f477fced5505f9e7e06ed0798d25a7d90e 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "format-util.h"
 #include "log.h"
-#include "process-util.h"
 #include "util.h"
 
 assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, LOG_FTP | LOG_DEBUG))
index 1830396acfa85741c6577ca014af599ed5efd85b..92e39277849c46ca1ac0a3e422e60a26d9114117 100644 (file)
@@ -21,7 +21,6 @@
 #include <unistd.h>
 
 #include "macro.h"
-#include "process-util.h"
 #include "signal-util.h"
 
 static void test_block_signals(void) {