🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by Edward S. Marshall Thu, 26 Mar 1998 00:00
inn-1.7.2 patch for Solaris YP support
#27186
Author: Edward S. Marshall
Date: Thu, 26 Mar 1998 00:00
194 lines
6414 bytes
Hi,

I've put together a quick hack for doing direct YP authentication under
Solaris with INN 1.7.2 (insync 1.1d, although it should patch against
anything from 1.5.1 and up; 1.8 will probably cause problems though). 
This affects the use of '+' in the username field in nnrp.access; instead
of doing getpwnam() lookups, it does a lookup of the user in your NIS
passwd table, and yanks the password from there for checking.

Note that this is NOT NIS+ authentication; only YP/NIS.

This is untested in anything but my environment (and it's only been
minimally tested here ;-), and I have no idea if it's portable to anything
but Solaris; we needed it here, so I figured someone else might find it
useful too. In other words: no warranty, minimal testing, and if it
breaks, you get to keep both pieces.

This patch adds a config.data parameter "HAVE_YP". When set to "DO" (the
default when the patch is applied), it will compile in the code for doing
direct YP lookups of users. You may need to change "passwd.byname" in
nnrpd/nnrpd.c if you've done something funky with that.

It's attached below, or you can grab it from:

        http://www.xnet.com/~emarshal/inn/

Comments, suggestions, etc. are appreciated.

-- 
.-----------------------------------------------------------------------------.
| Edward S. Marshall <emarshal@xnet.com> | Systems/Network Administrator,     |
| http://www.xnet.com/~emarshal/         | XNet Information Systems, Inc.     |
`-----------------------------------------------------------------------------'
[ Do you spam? Massmail? Crosspost heavily? Are you in violation of RFC 1855? ]
[        Then send email to spam@logic.net, and repent your evil ways.        ]

--- config/config.dist.old	Thu Mar 26 12:28:01 1998
+++ config/config.dist	Thu Mar 26 12:28:46 1998
@@ -529,6 +529,9 @@
 ##  Some versions of Solaris should set to DONT (pre 2.4 it seems)
 #### =()<SET_SOCKOPT		@<SET_SOCKOPT>@>()=
 SET_SOCKOPT		DO
+##  Do you use YP or regular password files?
+#### =()<HAVE_YP		@<HAVE_YP>@>()=
+HAVE_YP			DO
 
 
 ##
--- include/configdata.h.old	Mon Dec  8 17:48:50 1997
+++ include/configdata.h	Thu Mar 26 12:27:54 1998
@@ -336,6 +336,9 @@
     /* Should Inn be calling setsockopt() on network fds. */
     /* =()<#define @<SET_SOCKOPT>@_SET_SOCKOPT @<SET_SOCKOPT>@>()= */
 #define DO_SET_SOCKOPT DO
+    /* Do you use YP or regular password files? */
+    /* =()<#define @<HAVE_YP>@_HAVE_YP @<HAVE_YP>@>()= */
+#define DO_HAVE_YP DO
 
 
     /* Function that returns no value, and a pointer to it. */
--- nnrpd/nnrpd.c.old	Thu Mar 26 12:26:24 1998
+++ nnrpd/nnrpd.c	Thu Mar 26 12:30:10 1998
@@ -15,6 +15,8 @@
 #if	defined(HPUX)
 #include <sys/pstat.h>
 #endif	/* defined(HPUX) */
+#include <rpcsvc/ypclnt.h>
+#include <rpcsvc/yp_prot.h>
 
 
 /*
@@ -129,6 +131,95 @@
     {	NULL }
 };
 
+#ifdef DO_HAVE_YP
+/* getypnam
+ * Get a struct passwd entry from YP. */
+struct passwd * getypnam( char * username )
+{
+	register int i;
+	register char * p;
+	char * ypdomain;
+	char * ypuser;
+	int ypuserlen;
+	char * ypfields[ 6 ];
+	struct passwd * pwd;
+
+	ypdomain = NULL;
+	ypuser = NULL;
+	yp_get_default_domain( &ypdomain );
+	if( ypdomain )
+	{
+		yp_match( ypdomain, "passwd.byname", username,
+		  strlen( username ), &ypuser, &ypuserlen );
+	}
+	if( ypuser )
+	{
+		/* eliminate carriage returns */
+		if( ( p = strchr( ypuser, '\n' ) ) != NULL )
+			*p = '\0';
+
+		/* split up fields */
+		for( ypfields[ 0 ] = ypuser, i = 0, p = ypuser; *p; p++ )
+		{
+			if( *p == ':' )
+			{
+				*p = '\0';
+				ypfields[ ++i ] = p + 1;
+			}
+			/* simple sanity check */
+			if( i > 6 || p > ( ypuser + ypuserlen ) )
+				break;
+		}
+
+		/* did we get a "correct" entry? */
+		if( i != 6 )
+		{
+			free( ypuser );
+			yp_unbind( ypdomain );
+			return NULL;
+		}
+	
+		/* Build a struct passwd */
+		pwd = ( struct passwd * )malloc( sizeof( struct passwd ) );
+		pwd->pw_name = strdup( ypfields[ 0 ] );
+		pwd->pw_passwd = strdup( ypfields[ 1 ] );
+		pwd->pw_uid = atol( ypfields[ 2 ] );
+		pwd->pw_gid = atol( ypfields[ 3 ] );
+		pwd->pw_age = NULL;
+		pwd->pw_comment = NULL;
+		pwd->pw_gecos = strdup( ypfields[ 4 ] );
+		pwd->pw_dir = strdup( ypfields[ 5 ] );
+		pwd->pw_shell = strdup( ypfields[ 6 ] );
+
+		/* Free up resources. */
+		free( ypuser );
+		yp_unbind( ypdomain );
+
+		return pwd;
+	}
+	return NULL;
+}
+
+/* freepwd
+ * Free up the structure returned from getypnam(). */
+void freepwd( struct passwd * pwd )
+{
+	if( pwd == NULL )
+		return;
+	if( pwd->pw_name != NULL )
+		free( pwd->pw_name );
+	if( pwd->pw_passwd != NULL )
+		free( pwd->pw_passwd );
+	if( pwd->pw_gecos != NULL )
+		free( pwd->pw_gecos );
+	if( pwd->pw_dir != NULL )
+		free( pwd->pw_dir );
+	if( pwd->pw_shell != NULL )
+		free( pwd->pw_shell );
+	free( pwd );
+	pwd = NULL;
+}
+#endif /* DO_HAVE_YP */
 
 /*
 **  Log a summary status message and exit.
@@ -354,10 +445,22 @@
 
 	/* See if we should lookup a specific user in the passwd file */
 	if (user && pass && EQ(fields[2], "+")) {
+#ifdef DO_HAVE_YP
+	    if ((pwd = getypnam(user)) == NULL)
+#else
 	    if ((pwd = getpwnam(user)) == NULL)
+#endif /* DO_HAVE_YP */
 		continue;
 	    if (!EQ(pwd->pw_passwd, crypt(pass, pwd->pw_passwd)))
+#ifdef DO_HAVE_YP
+	    {
+		freepwd(pwd);
+#endif /* DO_HAVE_YP */
 		continue;
+#ifdef DO_HAVE_YP
+	    }
+	    freepwd(pwd);
+#endif /* DO_HAVE_YP */
 	}
 	/* Matching for a specific user or just the host? */
 	else if (user && (!EQ(user, fields[2]) || !EQ(pass, fields[3])))


Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads