From 5d34c0068f64a930ad5e32143a4c2ab2f57a3153 Mon Sep 17 00:00:00 2001 From: suyuan168 <175338101@qq.com> Date: Sun, 22 May 2022 17:35:16 +0800 Subject: [PATCH] fix --- mptcpd/patches/log.patch | 24 ----- mptcpd/patches/remove_log.patch | 167 ++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 24 deletions(-) delete mode 100755 mptcpd/patches/log.patch create mode 100644 mptcpd/patches/remove_log.patch diff --git a/mptcpd/patches/log.patch b/mptcpd/patches/log.patch deleted file mode 100755 index c0bc52e3c..000000000 --- a/mptcpd/patches/log.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/src/configuration.c 2020-04-14 21:31:22.057292953 +0200 -+++ b/src/configuration.c 2020-04-14 21:32:13.712364449 +0200 -@@ -35,10 +35,10 @@ - */ - //@{ - /// Underlying string concatenation macro. --#define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__ -+//#define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__ - - /// Concatenate strings using the preprocessor. --#define MPTCPD_CONCAT(x, ...) MPTCPD_CONCAT_IMPL(x, __VA_ARGS__) -+//#define MPTCPD_CONCAT(x, ...) MPTCPD_CONCAT_IMPL(x, __VA_ARGS__) - //@} - - // Compile-time default logging choice -@@ -47,7 +47,7 @@ - # error Problem configuring default log message destination. - #endif - /// Name of the default logging function determined at compile-time. --#define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER) -+#define MPTCPD_SET_LOG_FUNCTION l_log_set_stderr - - /** - * @brief Get the function that sets the log message destination. diff --git a/mptcpd/patches/remove_log.patch b/mptcpd/patches/remove_log.patch new file mode 100644 index 000000000..ed077f859 --- /dev/null +++ b/mptcpd/patches/remove_log.patch @@ -0,0 +1,167 @@ +--- a/src/configuration.c 2021-06-29 17:44:20.481179981 +0200 ++++ b/src/configuration.c 2021-06-29 17:44:52.580655950 +0200 +@@ -37,21 +37,12 @@ + * Preprocessor concatenation that expands preprocessor tokens as + * needed by leveraging the usual indirection technique. + */ +-///@{ +-/// Underlying string concatenation macro. +-#define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__ +- +-/// Concatenate strings using the preprocessor. +-#define MPTCPD_CONCAT(x, ...) MPTCPD_CONCAT_IMPL(x, __VA_ARGS__) +-///@} + + // Compile-time default logging choice + #ifndef MPTCPD_LOGGER + // This should never occur! + # error Problem configuring default log message destination. + #endif +-/// Name of the default logging function determined at compile-time. +-#define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER) + + /** + * @brief Get the function that sets the log message destination. +@@ -474,7 +465,6 @@ + + struct mptcpd_config *mptcpd_config_create(int argc, char *argv[]) + { +- MPTCPD_SET_LOG_FUNCTION(); // For early logging. + + struct mptcpd_config *const config = + l_new(struct mptcpd_config, 1); +--- a/src/mptcpize.c 2021-06-29 19:29:57.810281053 +0200 ++++ b/src/mptcpize.c 2021-06-29 19:29:29.942701557 +0200 +@@ -17,7 +17,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -79,7 +78,7 @@ + nr++; + envp = calloc(nr + 3, sizeof(char *)); + if (!envp) +- error(1, errno, "can't allocate env list"); ++ fprintf(stderr, "can't allocate env list"); + + // ... filtering out any 'LD_PRELOAD' ... + nr = 0; +@@ -103,7 +102,7 @@ + // build the NULL terminated arg list + argv = calloc(argc + 1, sizeof(char *)); + if (!argv) +- error(1, errno, "can't allocate argument list"); ++ fprintf(stderr, "can't allocate argument list"); + + memcpy(argv, av, argc * sizeof(char*)); + return execvpe(argv[0], argv, envp); +@@ -124,33 +123,33 @@ + len = strlen(name) + 1 + strlen(SYSTEMCTL_SHOW); + cmd = malloc(len); + if (!cmd) +- error(1, 0, "can't allocate systemctl command string"); ++ fprintf(stderr, "can't allocate systemctl command string"); + + sprintf(cmd, SYSTEMCTL_SHOW"%s", name); + systemctl = popen(cmd, "r"); + if (!systemctl) +- error(1, errno, "can't execute %s", cmd); ++ fprintf(stderr, "can't execute %s", cmd); + + free(cmd); + while ((read = getline(&line, &len, systemctl)) != -1) { + if (strncmp(line, SYSTEMD_UNIT_VAR, strlen(SYSTEMD_UNIT_VAR)) == 0) { + char *ret = strdup(&line[strlen(SYSTEMD_UNIT_VAR)]); + if (!ret) +- error(1, errno, "failed to duplicate string"); ++ fprintf(stderr, "failed to duplicate string"); + + // trim trailing newline, if any + len = strlen(ret); + if (len > 0 && ret[len - 1] == '\n') + ret[--len] = 0; + if (len == 0) +- error(1, 0, "can't find unit file for service %s", name); ++ fprintf(stderr, "can't find unit file for service %s", name); + free(line); + pclose(systemctl); + return ret; + } + } + +- error(1, 0, "can't find FragmentPath attribute for unit %s", name); ++ fprintf(stderr, "can't find FragmentPath attribute for unit %s", name); + + // never reached: just silence gcc + return NULL; +@@ -175,12 +174,12 @@ + unit = locate_unit(argv[0]); + src = fopen(unit, "r"); + if (!src) +- error(1, errno, "can't open file %s", unit); ++ fprintf(stderr, "can't open file %s", unit); + + strcpy(dst_path, "/tmp/unit_XXXXXX"); + dst = mkstemp(dst_path); + if (dst < 0) +- error(1, errno, "can't create tmp file"); ++ fprintf(stderr, "can't create tmp file"); + + // reset any prior error, to allow later check on errno + errno = 0; +@@ -194,27 +193,27 @@ + + if (!is_env) { + if (write(dst, line, read) < 0) +- error(1, errno, "can't write '%s' into %s", line, dst_path); ++ fprintf(stderr, "can't write '%s' into %s", line, dst_path); + } + + if (append_env && + (is_env || strncmp(line, SYSTEMD_SERVICE_TAG, strlen(SYSTEMD_SERVICE_TAG)) == 0)) { + if (dprintf(dst, "%s%s\n", SYSTEMD_ENV_VAR, MPTCPWRAP_ENV) < 0) +- error(1, errno, "can't write to env string into %s", dst_path); ++ fprintf(stderr, "can't write to env string into %s", dst_path); + append_env = 0; + } + } + if (errno != 0) +- error(1, errno, "can't read from %s", unit); ++ fprintf(stderr, "can't read from %s", unit); + free(line); + fclose(src); + close(dst); + + if (rename(dst_path, unit) < 0) +- error(1, errno, "can't rename %s to %s", dst_path, unit); ++ fprintf(stderr, "can't rename %s to %s", dst_path, unit); + + if (system("systemctl daemon-reload") != 0) +- error(1, errno, "can't reload unit, manual 'systemctl daemon-reload' is required"); ++ fprintf(stderr, "can't reload unit, manual 'systemctl daemon-reload' is required"); + + printf("mptcp successfully %s on unit %s\n", + enable ? "enabled" : "disabled", unit); +@@ -239,7 +238,7 @@ + argp_program_version = "mptcpize "VERSION; + argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; + if (argp_parse(&argp, argc, argv, ARGP_IN_ORDER, &idx, 0) < 0) +- error(1, errno, "can't parse arguments"); ++ fprintf(stderr, "can't parse arguments"); + + argc -= idx; + argv += idx; +--- a/src/mptcpize.c 2021-07-05 20:06:07.035838944 +0200 ++++ b/src/mptcpize.c 2021-07-05 20:06:26.875505617 +0200 +@@ -7,8 +7,6 @@ + * Copyright (c) 2021, Red Hat, Inc. + */ + +-#define _GNU_SOURCE +- + #include + + #include