summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2020-05-14 10:01:54 +1000
committerStefan Metzmacher <metze@samba.org>2020-06-22 16:44:22 +0200
commit19c3e87570954cb7fb4f6c105cbec9eabf4539b0 (patch)
tree4c3de2ef51a958af76def34e02a24e8b364d327e /src
parentdd428959713998d3f973bcf2762d489ef27d9f13 (diff)
downloadsocket_wrapper-19c3e87570954cb7fb4f6c105cbec9eabf4539b0.tar.gz
socket_wrapper-19c3e87570954cb7fb4f6c105cbec9eabf4539b0.tar.xz
socket_wrapper-19c3e87570954cb7fb4f6c105cbec9eabf4539b0.zip
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 <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c27
1 files changed, 25 insertions, 2 deletions
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);