httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@ai.mit.edu (Robert S. Thau)
Subject Patch to allow use of password file as auth DB (from USENET)
Date Sat, 06 May 1995 16:56:39 GMT
Patch originally from Kevin Ruddy, smiles@powerdog.com.  Note that it
uses YP routines directly, rather than using getpwnam (which invokes
YP on machines that use it, and *works* on machines that don't).
Still, the idea may be worth considering...




OK, actually, this is specifically for 1.4 but I had originally put it into
1.3, so you can do that too if you want.  It probably would fit fine into
Apache as well, but I haven't tried that yet.

What his patch does is permit people to say "AuthUserFile +" and then
it will allow the use of NIS to find username-password information
instead of special password files for httpd.

Regarding copyright: you can do anything you want with this patch.  A
mention of my name would satisfy my ego but I won't require it.  Guess
that makes it public domain.

Enjoy!!


*** http_config.c.orig	Thu Apr 27 17:15:40 1995
--- http_config.c	Fri May  5 17:38:01 1995
***************
*** 22,27 ****
--- 22,31 ----
  #include "httpd.h"
  #include "new.h"
  
+ #ifdef NIS
+ #include <rpcsvc/ypclnt.h>
+ #endif
+ 
  /* Server config globals */
  int standalone;
  int port;
***************
*** 970,975 ****
--- 974,1001 ----
      num_sec_config = num_sec;
  }
  
+ #ifdef NIS
+ static int
+ init_nis(char **dom)
+ {
+ 	static int	init = 0;
+ 	static char	*domain;
+ 	int		yperr;
+ 
+ 	if (init == 0) {
+ 		yperr = yp_get_default_domain(&domain);
+ 		if (yperr == 0)
+ 			init++;
+ 	}
+ 
+ 	if (init) {
+ 		*dom = domain;
+ 		return 0;
+ 	}
+ 	return 1;
+ }
+ #endif /* NIS */
+ 
  int get_pw(char *user, char *pw, FILE *errors) {
      FILE *f;
      char errstr[MAX_STRING_LEN];
***************
*** 976,981 ****
--- 1002,1030 ----
      char l[MAX_STRING_LEN];
      char w[MAX_STRING_LEN];
  
+ #ifdef NIS
+ 	if (strncmp(auth_pwfile, "+", 1) == 0) {
+ 		char	*domain,
+ 			*resptr;
+ 		int	yperr,
+ 			resize;
+ 
+ 		if (init_nis(&domain) != 0)
+ 			return 0;
+ 
+ 		yperr = yp_match(domain, "passwd.byname", user, strlen(user),
+ 				 &resptr, &resize);
+ 		if (yperr == 0) {
+ 			getword(w, resptr, ':');
+ 			if (strcmp(w, user) == 0) {
+ 				getword(w, resptr, ':');
+ 				(void) strcpy(pw, w);
+ 				return 1;
+ 			}
+ 		}
+ 		return 0;
+ 	}
+ #endif /* NIS */
      if(!(f=fopen(auth_pwfile,"r"))) {
          sprintf(errstr,"Could not open user file %s",auth_pwfile);
          die(SERVER_ERROR,errstr,errors);
-- 
Kevin Ruddy
Powerdog Industries



Mime
View raw message