Patch: disable path sanitization for modules rooted at "/"

Thor Simon via rsync <[email protected]>
Newsgroups gmane.network.rsync.general
Message-ID <PH0PR08MB8226E80B32A4F1A3EFF97B3BF1419@PH0PR08MB8226.namprd08.prod.outlook.com>
When running in daemon mode with a module rooted at "/", it is not possible to "escape" the module.

Not by prefixing a link target with "../../../../../../..".
Not by prefixing a link target with "/" nor "////".

So it seems to me that path sanitization is not useful in this case.  And it breaks stuff.  In particular, I have a file distribution system where large numbers of authenticated users can use rsync in daemon mode as a forced SSH command, authenticating as themselves, and path sanitization damages links like "../../../../../../../etc/localtime" in user directories - which may be dubious in purpose, but which are harmless.  And I am not the arbiter of my users' data in this sense.  Turning on symlink munging of course damages these data even more - I would prefer to not have it damaged at all.

Trivial fix attached.

Thor

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
clientserver.diff (application/octet-stream, 687 B)
--- clientserver.c~	2022-09-07 00:46:45.217695027 +0000
+++ clientserver.c	2022-09-07 00:46:48.931684755 +0000
@@ -974,8 +974,14 @@ static int rsync_module(int f_in, int f_
 	if (!change_dir(module_chdir, CD_NORMAL))
 		return path_failure(f_out, module_chdir, True);
 	if (module_dirlen || (!use_chroot && !*lp_daemon_chroot()))
-		sanitize_paths = 1;
-
+		/*
+		 * If module_dir is /, it is not possible to "escape"
+		 * the module, and path sanitization can only break
+		 * stuff.
+		 */
+		if (strcmp(module_dir, "/"))
+			sanitize_paths = 1;
+			
 	if ((munge_symlinks = lp_munge_symlinks(module_id)) < 0)
 		munge_symlinks = !use_chroot || module_dirlen;
 	if (munge_symlinks) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.