From 19c3e87570954cb7fb4f6c105cbec9eabf4539b0 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 14 May 2020 10:01:54 +1000 Subject: swrap: Add SOCKET_WRAPPER_DIR_ALLOW_ORIG to allow fall back Instead of failing when the path returned by realpath(3) is too long, if SOCKET_WRAPPER_DIR_ALLOW_ORIG is set then fall back to the original value. If this original path is too long or something else fails then abort. Signed-off-by: Martin Schwenke Reviewed-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- src/socket_wrapper.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 38df265..c5420fa 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -1454,8 +1454,31 @@ static char *socket_wrapper_dir(void) free(swrap_dir); - SWRAP_LOG(SWRAP_LOG_ERROR, "SOCKET_WRAPPER_DIR is too long"); - abort(); + ok = swrap_dir_usable(s); + if (!ok) { + SWRAP_LOG(SWRAP_LOG_ERROR, "SOCKET_WRAPPER_DIR is too long"); + abort(); + } + + t = getenv("SOCKET_WRAPPER_DIR_ALLOW_ORIG"); + if (t == NULL) { + SWRAP_LOG(SWRAP_LOG_ERROR, + "realpath(SOCKET_WRAPPER_DIR) too long and " + "SOCKET_WRAPPER_DIR_ALLOW_ORIG not set"); + abort(); + + } + + swrap_dir = strdup(s); + if (swrap_dir == NULL) { + SWRAP_LOG(SWRAP_LOG_ERROR, + "Unable to duplicate socket_wrapper dir path"); + abort(); + } + + SWRAP_LOG(SWRAP_LOG_WARN, + "realpath(SOCKET_WRAPPER_DIR) too long, " + "using original SOCKET_WRAPPER_DIR\n"); done: SWRAP_LOG(SWRAP_LOG_TRACE, "socket_wrapper_dir: %s", swrap_dir); -- cgit