public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* Patch: Fix user authentication + MKDB
@ 2002-09-24  7:17 Pankaj K Garg
  2002-09-25  8:25 ` Lars Henriksen
  0 siblings, 1 reply; 18+ messages in thread
From: Pankaj K Garg @ 2002-09-24  7:17 UTC (permalink / raw)
  To: help-gnats

[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]

Please take a look at the following patch that fixes the
following:

 1) MKDB: creates all parent directories in case they did
   not exist.

 2) MKDB: creates gnatsd.user_access instead of gnatsd.access

 3) PASSWORD CHECKING: The password checking in the current CVS
   directory is broken. It was not working as someone else also
   recenlty noted on this list. The problems were: (a) it was using
   the opposite logic of match(), (b) it did not default to plain
   text passwords, (c) an empty database list was confusing it, and
   (d) there was no fall-through. The last point needs a bit of
   explanation:

   Suppose I had a entry like so:
	foo:test:edit:
	*:*:view:

   The desired behavior should be that in case a user fails the password
   check for 'foo' then he should be allowed to have a 'view' access
   as everybody else. The current code will default 'foo' with a bad
   password to 'no_access'.

This should close BUG report number: 416

Pankaj

P.S. Patch file created by `cvs -up gnatsd.c misc.c mkdb.sh > patchfile.out`

---
Pankaj K Garg              gargp@acm.org
1684 Nightingale Avenue    408-373-4027
Sunnyvale, CA 94304
http://home.earthlink.net/~gargp

[-- Attachment #2: patchfile.out --]
[-- Type: text/plain, Size: 3043 bytes --]

Index: gnatsd.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/gnatsd.c,v
retrieving revision 1.47
diff -u -p -r1.47 gnatsd.c
--- gnatsd.c	4 Aug 2002 10:58:29 -0000	1.47
+++ gnatsd.c	24 Sep 2002 00:04:50 -0000
@@ -256,9 +256,9 @@ password_match (const char *password, co
   if (! strncmp (hash, "$0$", 3))
     {
       /* explicit plain-text password */
-      return ! match (password, hash, TRUE);
+      return match (password, hash+3, TRUE);
     }
-  else
+  else if (! strncmp (hash, "$1", 3))
     {
       /* DES crypt or MD5 hash of the password */
 #ifdef HAVE_LIBCRYPT
@@ -269,6 +269,9 @@ password_match (const char *password, co
       return FALSE;
 #endif
     }
+  else {
+    return match (password, hash, TRUE);
+  }
 }
 
 /*  */
@@ -451,7 +454,6 @@ findUserAccessLevel (const char *file, c
 		{
 		  /* Username matched but password didn't.  */
 		  *access = ACCESS_NONE;
-		  found = 1;
 		}
 	      else
 		{
@@ -460,7 +462,10 @@ findUserAccessLevel (const char *file, c
 		      /* Compare all given names against the name of the
 			 requested database. */
 		      const char *l2 = ent->admFields[3];
-
+		      
+		      if (l2 == NULL)
+			found = 1;
+		      
 		      while (l2 != NULL && ! found)
 			{
 			  char *token = get_next_field (&l2, ',');
Index: misc.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/misc.c,v
retrieving revision 1.36
diff -u -p -r1.36 misc.c
--- misc.c	6 Jan 2002 16:13:20 -0000	1.36
+++ misc.c	24 Sep 2002 00:04:50 -0000
@@ -287,7 +287,10 @@ get_next_field (const char **line_ptr, i
       *line_ptr = NULL;
     }
 
-  return res;
+  if (end_line == line)
+    return NULL ;
+  else
+    return res;
 }
 
 /* Adds quote-marks (") around the string, and escapes any quotes that
Index: mkdb.sh
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/mkdb.sh,v
retrieving revision 1.9
diff -u -p -r1.9 mkdb.sh
--- mkdb.sh	4 Aug 2002 10:57:17 -0000	1.9
+++ mkdb.sh	24 Sep 2002 00:04:50 -0000
@@ -28,7 +28,7 @@ DATADIR=xSYSCONFDIRx/gnats/defaults
 LIBEXECDIR=xLIBEXECDIRx
 
 domkdir() {
-    mkdir "$1" || { echo "Can't create directory $1, exiting"; exit 1 ; }
+    mkdir -p "$1" || { echo "Can't create directory $1, exiting"; exit 1 ; }
     chown "${GNATS_USER}" "$1"
 }
 
@@ -82,8 +82,8 @@ echo "Copying default files from ${DATAD
 docp categories "${dbdir}/gnats-adm/categories"
 docp submitters "${dbdir}/gnats-adm/submitters"
 docp responsible "${dbdir}/gnats-adm/responsible"
-docp gnatsd.access "${dbdir}/gnats-adm/gnatsd.access"
-chmod 600 "${dbdir}/gnats-adm/gnatsd.access"
+docp gnatsd.access "${dbdir}/gnats-adm/gnatsd.user_access"
+chmod 600 "${dbdir}/gnats-adm/gnatsd.user_access"
 docp addresses "${dbdir}/gnats-adm/addresses"
 docp states "${dbdir}/gnats-adm/states"
 docp classes "${dbdir}/gnats-adm/classes"

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

end of thread, other threads:[~2002-10-04 18:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-24  7:17 Patch: Fix user authentication + MKDB Pankaj K Garg
2002-09-25  8:25 ` Lars Henriksen
2002-09-25  8:25   ` Dirk Schenkewitz
2002-09-25  8:43     ` Pankaj K Garg
2002-09-27  6:01     ` Pankaj K Garg
2002-09-27 10:06       ` Yngve Svendsen
2002-09-27 11:40       ` Lars Henriksen
2002-09-27 14:28         ` Pankaj K Garg
2002-09-29  2:43           ` Lars Henriksen
2002-09-29 12:06             ` Pankaj K Garg
2002-09-29 20:31               ` Lars Henriksen
2002-09-30  3:21                 ` Pankaj K Garg
2002-10-03 21:27                   ` Lars Henriksen
2002-10-04  0:01                   ` Lars Henriksen
2002-10-04 10:25                     ` Pankaj K Garg
2002-10-04 11:41                       ` Yngve Svendsen
2002-09-25  8:59   ` Pankaj K Garg
2002-09-26  6:38     ` Lars Henriksen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).