patch to support non-/etc/passwd passwd files

patch to support non-/etc/passwd passwd files

Post by Nate Bail » Thu, 27 Jun 1996 04:00:00



I was kind of surprised to note that Apache doesn't seem to
support ~-expansions (user dirs) for a password file other
than /etc/passwd.  The following patch allows you to specify
an arbitrary password file for your users.

In our case, no-one has an account on the actual web server,
all the users disks are mounted via NFS...

Only two lines need to be added to support this code, in
the Makefile, add fgetpwnam.o to the OBJS list, and in
mod_userdir.c, change line 108 from:
        if(!(pw=getpwnam(w)))
to:
        if(!(pw=fgetpwnam(w,"/wherever/mypasswdfile")))

Admittedly, it would be a much better solution to put the
password file name as a parameter in the config file, but
I'm still thinking that someone else *must* have done this
before me...  Does anyone know what address I can submit
these changes to?  (www.apache.org is noticably deficient
in listing any inward email address, other than bugs :-)

----------- BEGIN: fgetpwnam.c ----------------------------------
#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
struct passwd *fgetpwnam(const char *name, const char *filename);

struct passwd *fgetpwnam(const char *name, const char *filename)
{
        FILE *pw_file;
        struct passwd *p_entry;

        if ((pw_file=fopen(filename,"r"))!=NULL) {
                while(!feof(pw_file)) {
                        p_entry = fgetpwent(pw_file);
                        if (strcmp(name,p_entry->pw_name)==0) return p_entry;
                }
        }
        return NULL;

Quote:}

----------- END: fgetpwnam.c ----------------------------------

ciao,
Nate
--

Tomorrow may not come, (^JIS^)/ WWW/HTML/CGI/perl/C++/C/Internet/etc :)
This moment is but once in a lifetime.<-- David Meece--^Ask me how!^ -|

 
 
 

patch to support non-/etc/passwd passwd files

Post by Sven-Ove Westbe » Thu, 27 Jun 1996 04:00:00



|I was kind of surprised to note that Apache doesn't seem to
|support ~-expansions (user dirs) for a password file other
|than /etc/passwd.  The following patch allows you to specify
|an arbitrary password file for your users.
|
|In our case, no-one has an account on the actual web server,
|all the users disks are mounted via NFS...
|
|Only two lines need to be added to support this code, in
|the Makefile, add fgetpwnam.o to the OBJS list, and in
|mod_userdir.c, change line 108 from:
|        if(!(pw=getpwnam(w)))
|to:
|        if(!(pw=fgetpwnam(w,"/wherever/mypasswdfile")))
|
|Admittedly, it would be a much better solution to put the
|password file name as a parameter in the config file, but
|I'm still thinking that someone else *must* have done this
|before me...  Does anyone know what address I can submit
|these changes to?  (www.apache.org is noticably deficient
|in listing any inward email address, other than bugs :-)
|

Hmmm... your patch will broke things if you take the passwords from NIS/YP.
YOU should test if the "/wherever/mypasswdfile" in NULL and then call getpwnam.

Sven-Ove Westberg, CAD, University of Lulea, S-971 87 Lulea, Sweden.