[PATCH] fix sysquotas finding of mount point

Uri Simchoni uri at samba.org
Fri Oct 7 08:12:54 UTC 2016


Hi,

The attached fixes a bug in sysquotas code that wrongly handles the path
if the mount point is under root (such as /home...)

The bug is a regression due to my fix to sysquotas, that avoid stating
all mounts just to find our mount point.

Confirmed to fix an issue for a user.

Review appreciated.
Thanks,
Uri.
-------------- next part --------------
From 1212066a55609d50a657ca2a2660c44315b55c51 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Fri, 7 Oct 2016 11:05:07 +0300
Subject: [PATCH] s3-sysquotas: correctly restore path when finding mount point

When traversing the path backwards to find the mount point, if the
root '/' is reached, then the character to be restored is not a '/'.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12273

Signed-off-by: Uri Simchoni <uri at samba.org>
---
 source3/lib/sysquotas.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c
index c2d09da..eef87be 100644
--- a/source3/lib/sysquotas.c
+++ b/source3/lib/sysquotas.c
@@ -82,6 +82,8 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
 	}
 
 	while (true) {
+		char save_ch;
+
 		p = strrchr(stat_mntpath, '/');
 		if (p == NULL) {
 			DBG_ERR("realpath for %s does not begin with a '/'\n",
@@ -93,6 +95,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
 			++p;
 		}
 
+		save_ch = *p;
 		*p = 0;
 		if (sys_stat(stat_mntpath, &S, false) != 0) {
 			DBG_WARNING("cannot stat real path component %s - %s\n",
@@ -100,7 +103,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
 			goto out;
 		}
 		if (S.st_ex_dev != devno) {
-			*p = '/';
+			*p = save_ch;
 			break;
 		}
 
-- 
2.5.5



More information about the samba-technical mailing list