[patch] Samba 2.09: /etc/passwd.samba instead of /etc/passwd
Thomas Jarosch
thomas.jarosch at styletec.de
Sun May 27 09:37:03 GMT 2001
> > I've developed a short, dirty patch for Samba 2.09
> > that allows me to have a separate /etc/passwd for Samba.
> > (and so allows me to have virtual users running under the UID of
"nobody")
> >
> > It's based upon the diet libc (www.fefe.de/dietlibc/)
> > getpwnam() and getpwuid() functions.
> >
> > Please CC: any comments as I'm not on the Samba list.
> >
> > Enjoy, Thomas.
> >
> > [demime 0.98b removed an attachment of type application/octet-stream
which had a name of samba-getpwnam.patch]
> > --
> > To unsubscribe from this list go to the following URL and read the
> > instructions: http://lists.samba.org/mailman/listinfo/samba
>
> You will need to send it as plain-text, as binary attachments are
> striped by the list. Also, the best destination is
> samba-patches at samba.org, possibly CCing this list or
> samba-techincal at samba.org, where they are indexed for future reference.
>
> However, based on your description I suspect that there may be some
> issues with the patch, but I would need to see it to tell. In
> particualar, I would worry about how it would work on PAM based systems
> and on the possiblity that different utilities might operate on one
> smbpasswd file with compleatly different world views, with 'interesting'
> results.
>
> Andrew Bartlet
Okay, I've resent it. I don't know much about PAM,
but if it provides a wrapper for the getpwent()/getfpwent() functions
then it could work. Someone should give it a try.
Thomas.
diff -r -u samba-2.0.7/source/lib/system.c
samba-2.0.7.pwnam/source/lib/system.c
--- samba-2.0.7/source/lib/system.c Wed Apr 26 01:06:52 2000
+++ samba-2.0.7.pwnam/source/lib/system.c Fri May 25 17:34:23 2001
@@ -718,9 +718,55 @@
Wrapper for getpwnam(). Always returns a static that can be modified.
****************************************************************************
/
+struct passwd *my_getpwnam(const char * name) {
+ struct passwd *tmp;
+ FILE *in = fopen ("/etc/passwd.samba", "rb");
+ if (in == NULL)
+ return 0;
+
+ for (;;) {
+ tmp=fgetpwent(in);
+ if (!tmp) {
+ fclose (in);
+ return 0;
+ }
+ if (!strcmp(tmp->pw_name,name)){
+ fclose (in);
+ return tmp;
+ }
+ }
+}
+
+/**************************************************************************
+ Wrapper for getpwuid(). Always returns a static that can be modified.
+***************************************************************************
*/
+
+struct passwd *my_getpwuid(uid_t uid) {
+ struct passwd *tmp;
+ FILE *in = fopen ("/etc/passwd.samba", "rb");
+ if (in == NULL)
+ return 0;
+
+ for (;;) {
+ tmp=fgetpwent(in);
+ if (!tmp) {
+ fclose (in);
+ return 0;
+ }
+ if (tmp->pw_uid==uid) {
+ fclose (in);
+ return tmp;
+ }
+ }
+}
+
+/**************************************************************************
+ Wrapper for getpwnam(). Always returns a static that can be modified.
+***************************************************************************
*/
+
struct passwd *sys_getpwnam(const char *name)
{
- return setup_pwret(getpwnam(name));
+ return setup_pwret(my_getpwnam(name));
}
/**************************************************************************
@@ -729,7 +775,7 @@
struct passwd *sys_getpwuid(uid_t uid)
{
- return setup_pwret(getpwuid(uid));
+ return setup_pwret(my_getpwuid(uid));
}
/**************************************************************************
More information about the samba-technical
mailing list