From cef37d5a0ef68351ea97518249b0c91746e700e3 Mon Sep 17 00:00:00 2001 From: Zorro Lang Date: Tue, 10 May 2016 17:16:06 +1000 Subject: [PATCH] xfs_quota: fully support users and groups beginning with digits A normal user or group name allow beginning with digits, but xfs_quota can't create a limit for that user or group. The reason is 'strtoul' function only translate digits at the beginning, it will ignore letters after digits. There's a commit fd537fc50eeade63bbd2a66105f39d04a011a7f5, it try to fix "xfsprogs: xfs_quota allow user or group names beginning with digits". But it doesn't effect 'limit' command, so a command likes: xfs_quota 'limit .... 12345678-user' xxxx will try to create limit for username="12345678", not "12345678-user". This patch will fix this problem, and a test case xfs/138 in xfstests is used to reproduce this bug. Signed-off-by: Zorro Lang Reviewed-by: Eric Sandeen Signed-off-by: Dave Chinner --- libxcmd/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libxcmd/input.c b/libxcmd/input.c index c505ab3d4..5a7dce353 100644 --- a/libxcmd/input.c +++ b/libxcmd/input.c @@ -366,7 +366,7 @@ uid_from_string( char *sp; uid_long = strtoul(user, &sp, 10); - if (sp != user) { + if (sp != user && *sp == '\0') { if ((uid_long == ULONG_MAX && errno == ERANGE) || (uid_long > (uid_t)-1)) return -1; @@ -387,7 +387,7 @@ gid_from_string( char *sp; gid_long = strtoul(group, &sp, 10); - if (sp != group) { + if (sp != group && *sp == '\0') { if ((gid_long == ULONG_MAX && errno == ERANGE) || (gid_long > (gid_t)-1)) return -1; -- 2.47.2