public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_quota: allow create limit when user or group names beginning with digits
@ 2015-12-02  9:02 Zorro Lang
  2015-12-03  4:05 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Zorro Lang @ 2015-12-02  9:02 UTC (permalink / raw)
  To: xfs; +Cc: sandeen, Zorro Lang, rjohnston

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.

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 .... 12345678-user' command.

Signed-off-by: Zorro Lang <zlang@redhat.com>
---

Hi Eric,

This problem from a bug of ours, I have left message to you, please
help to check my simple patch. Thanks very much.

Hi Rich,

I don't understand why you fix commit fd537fc50eeade63bbd2a66105f39d04a011a7f5,
but didn't fix this. Or is this a feature, not a bug?

I'm not so familiar with xfsprogs code, so if I'm wrong, please tell me;)

Thanks,
Zorro

 libxcmd/input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libxcmd/input.c b/libxcmd/input.c
index c505ab3..5a7dce3 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;
-- 
1.9.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] xfs_quota: allow create limit when user or group names beginning with digits
@ 2016-04-02 15:59 Zorro Lang
  0 siblings, 0 replies; 4+ messages in thread
From: Zorro Lang @ 2016-04-02 15:59 UTC (permalink / raw)
  To: dchinner; +Cc: sandeen, Zorro Lang, xfs

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 <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---

Hi Dave,

I just found there's a missed patch in my local xfsprogs repo, it has
been reviewed for a long:

http://oss.sgi.com/archives/xfs/2015-12/msg00134.html

And the reproducer about this bug has been merged into xfstests for
several months, but I don't know why we can't merge this patch. Would
you please check it?

Due to long time has passed, so I rewrite this patch and re-send it
again now. If anything wrong in this patch, please let me know:)

Thanks very much,
Zorro

 libxcmd/input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libxcmd/input.c b/libxcmd/input.c
index c505ab3..5a7dce3 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.5.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-02 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02  9:02 [PATCH] xfs_quota: allow create limit when user or group names beginning with digits Zorro Lang
2015-12-03  4:05 ` Eric Sandeen
2016-02-12 17:05   ` Eric Sandeen
  -- strict thread matches above, loose matches on Subject: below --
2016-04-02 15:59 Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox