All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits
@ 2013-04-17 18:32 rjohnston
  2013-04-21  5:55 ` Eric Sandeen
  2013-04-22  2:45 ` Dave Chinner
  0 siblings, 2 replies; 3+ messages in thread
From: rjohnston @ 2013-04-17 18:32 UTC (permalink / raw)
  To: xfs

[-- Attachment #1: xfsprogs-xfs_quota-allow-user-or-group-names-beginning-with-digits.patch --]
[-- Type: text/plain, Size: 2279 bytes --]

xfs_quota does not properly parse users or groups that begin with a number.
Only call atoi when user or group consists of digits only.

Signed-off-by: Rich Johnston <rjohnston@sgi.com>

---
 include/input.h |    1 +
 libxcmd/input.c |   12 ++++++++++++
 quota/quota.c   |    4 ++--
 quota/quota.h   |    1 +
 4 files changed, 16 insertions(+), 2 deletions(-)

Index: b/include/input.h
===================================================================
--- a/include/input.h
+++ b/include/input.h
@@ -46,6 +46,7 @@ extern void	timestr(struct timeval *tv,
 extern uid_t	uid_from_string(char *user);
 extern gid_t	gid_from_string(char *group);
 extern prid_t	prid_from_string(char *project);
+extern boolean_t isdigits_only(const char *str);
 
 #define HAVE_FTW_H 1	/* TODO: configure me */
 
Index: b/libxcmd/input.c
===================================================================
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -398,6 +398,18 @@ gid_from_string(
 	return -1;
 }
 
+boolean_t isdigits_only(
+	const char *str)
+{
+	int i;
+
+	for (i=0; i < strlen(str); i++) {
+		if (!isdigit(str[i]))
+			return B_FALSE;
+	}
+	return B_TRUE;
+}
+
 #define HAVE_FTW_H 1	/* TODO: configure me */
 
 #ifndef HAVE_FTW_H
Index: b/quota/quota.c
===================================================================
--- a/quota/quota.c
+++ b/quota/quota.c
@@ -224,7 +224,7 @@ quota_user_type(
 	uid_t		id;
 
 	if (name) {
-		if (isdigit(name[0])) {
+		if (isdigits_only(name)) {
 			id = atoi(name);
 			name = getusername(id, flags & NO_LOOKUP_FLAG);
 		} else if ((u = getpwnam(name))) {
@@ -273,7 +273,7 @@ quota_group_type(
 	int		i, ngroups, dofree = 0;
 
 	if (name) {
-		if (isdigit(name[0])) {
+		if (isdigits_only(name)) {
 			gid = atoi(name);
 			name = getgroupname(gid, flags & NO_LOOKUP_FLAG);
 		} else {
Index: b/quota/quota.h
===================================================================
--- a/quota/quota.h
+++ b/quota/quota.h
@@ -80,4 +80,5 @@ enum {
 extern char *uid_to_name(__uint32_t __uid);
 extern char *gid_to_name(__uint32_t __gid);
 extern char *prid_to_name(__uint32_t __prid);
+extern boolean_t isdigits_only(const char *);
 


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

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

* Re: [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits
  2013-04-17 18:32 [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits rjohnston
@ 2013-04-21  5:55 ` Eric Sandeen
  2013-04-22  2:45 ` Dave Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2013-04-21  5:55 UTC (permalink / raw)
  To: rjohnston; +Cc: xfs

On 4/17/13 1:32 PM, rjohnston@sgi.com wrote:

<some kind of email that doesn't show up when I hit reply so repasting ;)>

> 
> 
> xfs_quota does not properly parse users or groups that begin with a number.
> Only call atoi when user or group consists of digits only.
> 
> Signed-off-by: Rich Johnston <rjohnston@sgi.com>

Seems sane to me.  I'd change i=0 to i = 0, but *shrug*

[xfsprogs]$ grep -r "i = 0" * | wc -l
404
[xfsprogs]$ grep -r "i=0" * | wc -l
10

Other than that,
Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  include/input.h |    1 +
>  libxcmd/input.c |   12 ++++++++++++
>  quota/quota.c   |    4 ++--
>  quota/quota.h   |    1 +
>  4 files changed, 16 insertions(+), 2 deletions(-)
> 
> Index: b/include/input.h
> ===================================================================
> --- a/include/input.h
> +++ b/include/input.h
> @@ -46,6 +46,7 @@ extern void	timestr(struct timeval *tv,
>  extern uid_t	uid_from_string(char *user);
>  extern gid_t	gid_from_string(char *group);
>  extern prid_t	prid_from_string(char *project);
> +extern boolean_t isdigits_only(const char *str);
>  
>  #define HAVE_FTW_H 1	/* TODO: configure me */
>  
> Index: b/libxcmd/input.c
> ===================================================================
> --- a/libxcmd/input.c
> +++ b/libxcmd/input.c
> @@ -398,6 +398,18 @@ gid_from_string(
>  	return -1;
>  }
>  
> +boolean_t isdigits_only(
> +	const char *str)
> +{
> +	int i;
> +
> +	for (i=0; i < strlen(str); i++) {
> +		if (!isdigit(str[i]))
> +			return B_FALSE;
> +	}
> +	return B_TRUE;
> +}
> +
>  #define HAVE_FTW_H 1	/* TODO: configure me */
>  
>  #ifndef HAVE_FTW_H
> Index: b/quota/quota.c
> ===================================================================
> --- a/quota/quota.c
> +++ b/quota/quota.c
> @@ -224,7 +224,7 @@ quota_user_type(
>  	uid_t		id;
>  
>  	if (name) {
> -		if (isdigit(name[0])) {
> +		if (isdigits_only(name)) {
>  			id = atoi(name);
>  			name = getusername(id, flags & NO_LOOKUP_FLAG);
>  		} else if ((u = getpwnam(name))) {
> @@ -273,7 +273,7 @@ quota_group_type(
>  	int		i, ngroups, dofree = 0;
>  
>  	if (name) {
> -		if (isdigit(name[0])) {
> +		if (isdigits_only(name)) {
>  			gid = atoi(name);
>  			name = getgroupname(gid, flags & NO_LOOKUP_FLAG);
>  		} else {
> Index: b/quota/quota.h
> ===================================================================
> --- a/quota/quota.h
> +++ b/quota/quota.h
> @@ -80,4 +80,5 @@ enum {
>  extern char *uid_to_name(__uint32_t __uid);
>  extern char *gid_to_name(__uint32_t __gid);
>  extern char *prid_to_name(__uint32_t __prid);
> +extern boolean_t isdigits_only(const char *);
>  
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

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

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

* Re: [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits
  2013-04-17 18:32 [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits rjohnston
  2013-04-21  5:55 ` Eric Sandeen
@ 2013-04-22  2:45 ` Dave Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2013-04-22  2:45 UTC (permalink / raw)
  To: rjohnston; +Cc: xfs

On Wed, Apr 17, 2013 at 01:32:53PM -0500, rjohnston@sgi.com wrote:
> xfs_quota does not properly parse users or groups that begin with a number.
> Only call atoi when user or group consists of digits only.
> 
> Signed-off-by: Rich Johnston <rjohnston@sgi.com>
> 
> ---
>  include/input.h |    1 +
>  libxcmd/input.c |   12 ++++++++++++
>  quota/quota.c   |    4 ++--
>  quota/quota.h   |    1 +
>  4 files changed, 16 insertions(+), 2 deletions(-)
> 
> Index: b/include/input.h
> ===================================================================
> --- a/include/input.h
> +++ b/include/input.h
> @@ -46,6 +46,7 @@ extern void	timestr(struct timeval *tv,
>  extern uid_t	uid_from_string(char *user);
>  extern gid_t	gid_from_string(char *group);
>  extern prid_t	prid_from_string(char *project);
> +extern boolean_t isdigits_only(const char *str);

bool is the correct type, not boolean_t. My CRC patchset makes
userspace fall in line with the removal of boolean_t from the kernel
code, so we should probably make this correct from the start. ;)

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

end of thread, other threads:[~2013-04-22  2:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-17 18:32 [PATCH] xfsprogs: xfs_quota allow user or group names beginning with digits rjohnston
2013-04-21  5:55 ` Eric Sandeen
2013-04-22  2:45 ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.