changeset 291:bf200dccbce5 noffle

[svn] * src/authenticate.c: Extend news admins to all those in group news.
author bears
date Sun, 12 Jan 2003 17:05:49 +0000
parents f35a7d45efd5
children b1d5c55b76f6
files ChangeLog src/authenticate.c
diffstat 2 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 11 09:30:05 2003 +0000
+++ b/ChangeLog	Sun Jan 12 17:05:49 2003 +0000
@@ -1,3 +1,7 @@
+Sun Jan 12 2003 Jim Hague <jim.hague@acm.org>
+
+* src/authenticate.c: Extend news admins to all those in group news.
+	
 Sat Jan 11 2003 Jim Hague <jim.hague@acm.org>
 
 * docs/noffle.1,docs/noffle.conf.5: Correct footer date, add new RFCs,
--- a/src/authenticate.c	Sat Jan 11 09:30:05 2003 +0000
+++ b/src/authenticate.c	Sun Jan 12 17:05:49 2003 +0000
@@ -3,7 +3,7 @@
 
   Do client authentication
 
-  $Id: authenticate.c 420 2003-01-10 23:25:45Z bears $
+  $Id: authenticate.c 423 2003-01-12 17:05:49Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -356,9 +356,36 @@
 	return FALSE;
     }
     noffleGid = grnam->gr_gid;
-
+    
     ruid = getuid();
+
+    /* Determine if admin user - root, news... */
     adminUser = ( ruid == 0 || ruid == noffleUid );
+    if ( ! adminUser && grnam->gr_mem != NULL )
+    {
+	/* ... or member of group news. */
+	pwnam = getpwuid( ruid );
+	if ( pwnam != NULL )
+	{
+	    char* name = pwnam->pw_name;
+	    char** grpmembers = grnam->gr_mem;
+	    char* grpmember;
+
+	    for ( grpmember = *grpmembers;
+		  grpmember != NULL;
+		  grpmember = *++grpmembers )
+	    {
+		if ( strcmp( name, grpmember ) == 0 )
+		{
+		    adminUser = TRUE;
+		    break;
+		}
+	    }
+	}
+	else
+	    Log_err( "Cannot get user info for uid %d: %s",
+		     ruid, strerror( errno ) );
+    }
     
     /*
      * If we're really root, we will set the privs we require later. Otherwise