device-mapper-multipath/0132-multipathd-move-uxsock_trigger-to-uxlsnr.c.patch
Benjamin Marzinski ddfd11c918 device-mapper-multipath-0.8.7-36
Add 0128-multipath-tools-move-DEFAULT_SOCKET-definition-into-.patch
Add 0129-multipath-tools-add-helper-mpath_fill_sockaddr__.patch
Add 0130-libmpathutil-add-support-for-Unix-pathname-sockets.patch
Add 0131-libmpathutil-move-systemd_listen_fds-support-into-mu.patch
Add 0132-multipathd-move-uxsock_trigger-to-uxlsnr.c.patch
Add 0133-multipathd-uxlsnr-use-symbolic-values-for-pollfd-ind.patch
Add 0134-multipathd-make-uxsock_listen-take-a-pointer-to-fd.patch
Add 0135-multipathd-allow-receiving-two-socket-fds-from-syste.patch
Add 0136-multipathd-listen-on-pathname-and-abstract-socket-by.patch
Add 0137-libmpathcmd-try-both-abstract-and-pathname-sockets.patch
Add 0138-libmpathcmd-honor-MULTIPATH_SOCKET_NAME-environment-.patch
Add 0139-multipathd-honor-MULTIPATH_SOCKET_NAME-environment-v.patch
  * Fixes RHEL-78758 ("RFE: Enable multipathd to communicate with a
    process in another network namespace")
Resolves: RHEL-78758
2025-03-05 00:15:17 -05:00

157 lines
4.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 8 Sep 2021 08:29:20 +0200
Subject: [PATCH] multipathd: move uxsock_trigger() to uxlsnr.c
uxsock_trigger() really belongs into cli.c. I suppose that way back in
the past there were strong reasons to call this function via a
pointer. I don't think these reasons are valid any more. Moving
the function to cli.c allows restructuring the code.
No functional changes.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/main.c | 44 +-------------------------------------------
multipathd/uxlsnr.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
multipathd/uxlsnr.h | 4 +---
3 files changed, 44 insertions(+), 48 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index 30c4938f..21f16b8f 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1615,48 +1615,6 @@ map_discovery (struct vectors * vecs)
return 0;
}
-int
-uxsock_trigger (char * str, char ** reply, int * len, bool is_root,
- void * trigger_data)
-{
- struct vectors * vecs;
- int r;
-
- *reply = NULL;
- *len = 0;
- vecs = (struct vectors *)trigger_data;
-
- if ((str != NULL) && (is_root == false) &&
- (strncmp(str, "list", strlen("list")) != 0) &&
- (strncmp(str, "show", strlen("show")) != 0)) {
- *reply = STRDUP("permission deny: need to be root");
- if (*reply)
- *len = strlen(*reply) + 1;
- return 1;
- }
-
- r = parse_cmd(str, reply, len, vecs, uxsock_timeout / 1000);
-
- if (r > 0) {
- if (r == ETIMEDOUT)
- *reply = STRDUP("timeout\n");
- else
- *reply = STRDUP("fail\n");
- if (*reply)
- *len = strlen(*reply) + 1;
- r = 1;
- }
- else if (!r && *len == 0) {
- *reply = STRDUP("ok\n");
- if (*reply)
- *len = strlen(*reply) + 1;
- r = 0;
- }
- /* else if (r < 0) leave *reply alone */
-
- return r;
-}
-
int
uev_trigger (struct uevent * uev, void * trigger_data)
{
@@ -1866,7 +1824,7 @@ uxlsnrloop (void * ap)
set_handler_callback(UNSETMARGINAL|MAP, cli_unset_all_marginal);
umask(077);
- uxsock_listen(&uxsock_trigger, ux_sock, ap);
+ uxsock_listen(ux_sock, ap);
out_sock:
pthread_cleanup_pop(1); /* uxsock_cleanup */
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index dbee0d6f..a320a0c6 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -283,11 +283,51 @@ static void handle_inotify(int fd, struct watch_descriptors *wds)
condlog(1, "Multipath configuration updated.\nReload multipathd for changes to take effect");
}
+static int uxsock_trigger(char *str, char **reply, int *len,
+ bool is_root, void *trigger_data)
+{
+ struct vectors * vecs;
+ int r;
+
+ *reply = NULL;
+ *len = 0;
+ vecs = (struct vectors *)trigger_data;
+
+ if ((str != NULL) && (is_root == false) &&
+ (strncmp(str, "list", strlen("list")) != 0) &&
+ (strncmp(str, "show", strlen("show")) != 0)) {
+ *reply = strdup("permission deny: need to be root");
+ if (*reply)
+ *len = strlen(*reply) + 1;
+ return 1;
+ }
+
+ r = parse_cmd(str, reply, len, vecs, uxsock_timeout / 1000);
+
+ if (r > 0) {
+ if (r == ETIMEDOUT)
+ *reply = strdup("timeout\n");
+ else
+ *reply = strdup("fail\n");
+ if (*reply)
+ *len = strlen(*reply) + 1;
+ r = 1;
+ }
+ else if (!r && *len == 0) {
+ *reply = strdup("ok\n");
+ if (*reply)
+ *len = strlen(*reply) + 1;
+ r = 0;
+ }
+ /* else if (r < 0) leave *reply alone */
+
+ return r;
+}
+
/*
* entry point
*/
-void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, long ux_sock,
- void * trigger_data)
+void *uxsock_listen(long ux_sock, void *trigger_data)
{
int rlen;
char *inbuf;
diff --git a/multipathd/uxlsnr.h b/multipathd/uxlsnr.h
index 18f008d7..60c3a2c7 100644
--- a/multipathd/uxlsnr.h
+++ b/multipathd/uxlsnr.h
@@ -3,10 +3,8 @@
#include <stdbool.h>
-typedef int (uxsock_trigger_fn)(char *, char **, int *, bool, void *);
-
void uxsock_cleanup(void *arg);
-void *uxsock_listen(uxsock_trigger_fn uxsock_trigger, long ux_sock,
+void *uxsock_listen(long ux_sock,
void * trigger_data);
#endif