SOURCES: tpop3d-sql-getpwuid-optional.patch (NEW) - this patch cau...

romke romke at pld-linux.org
Fri Jul 22 01:54:17 CEST 2005


Author: romke                        Date: Thu Jul 21 23:54:17 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- this patch causes that tpop3d no longer do 'authentication failure' when
  getpwuid returns null (but you must provide numerical username and
  correct mailbox path - see info inside patch)

---- Files affected:
SOURCES:
   tpop3d-sql-getpwuid-optional.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/tpop3d-sql-getpwuid-optional.patch
diff -u /dev/null SOURCES/tpop3d-sql-getpwuid-optional.patch:1.1
--- /dev/null	Fri Jul 22 01:54:17 2005
+++ SOURCES/tpop3d-sql-getpwuid-optional.patch	Fri Jul 22 01:54:12 2005
@@ -0,0 +1,77 @@
+Normally tpop3d gets passwd structure for username/uid returned from SQL
+query. If getpwuid returns null (eg. if you don't have such user
+in /etc/passwd) whole authentication is failed.
+
+This patch changes that behaviour. tpop3d won't cause 'authorization failed'
+errors anymore but will fill authcontext structure with uid provided from
+SQL query and will set authcontext->home = mailbox (result column 0).
+
+You should use this patch if your virtual users using different uids
+AND ONLY IF you'll provide _UID_ in 3rd column of query (NOT USERNAME!).
+You also must provide (in SQL result) correct mailbox/maildir path.
+
+If you use this patch you can't use $(home) substitution string
+in auth-*sql-mailbox configuration.
+
+diff -ruNp auth_mysql.c.orig auth_mysql.c
+--- auth_mysql.c.orig	2005-07-21 23:48:54.000000000 +0200
++++ auth_mysql.c	2005-07-22 00:28:32.000000000 +0200
+@@ -273,12 +273,7 @@ authcontext auth_mysql_new_apop(const ch
+ 
+                 pw = getpwuid(uid);
+ 
+-                if (!pw) {
+-                    log_print(LOG_ERR, "auth_mysql_new_apop: getpwuid(%d): %m", (int)uid);
+-                    break;
+-                }
+-
+-                a = authcontext_new(pw->pw_uid, use_gid ? mail_gid : pw->pw_gid, row[3], row[0], pw->pw_dir);
++                a = authcontext_new(pw ? pw->pw_uid : uid, (use_gid || !pw ) ? mail_gid : pw->pw_gid, row[3], row[0], pw ? pw->pw_dir : row[0]);
+ 
+                 break;
+             }
+@@ -373,12 +368,7 @@ authcontext auth_mysql_new_user_pass(con
+ 
+                 pw = getpwuid(uid);
+ 
+-                if (!pw) {
+-                    log_print(LOG_ERR, "auth_mysql_new_user_pass: getpwuid(%d): %m", (int)uid);
+-                    break;
+-                }
+-
+-                a = authcontext_new(pw->pw_uid, use_gid ? mail_gid : pw->pw_gid, row[3], row[0], pw->pw_dir);
++                a = authcontext_new(pw ? pw->pw_uid : uid, (use_gid || !pw ) ? mail_gid : pw->pw_gid, row[3], row[0], pw ? pw->pw_dir : row[0]);
+                 break;
+             }
+ 
+diff -ruNp auth_pgsql.c.orig auth_pgsql.c
+--- auth_pgsql.c.orig	2005-07-21 23:49:06.000000000 +0200
++++ auth_pgsql.c	2005-07-22 00:29:09.000000000 +0200
+@@ -309,12 +309,7 @@ authcontext auth_pgsql_new_apop(const ch
+ 
+                 pw = getpwuid(uid);
+ 
+-                if (!pw) {
+-                    log_print(LOG_ERR, "auth_pgsql_apop: getpwuid(%d): %m", (int)uid);
+-                    break;
+-                }
+-
+-                a = authcontext_new(pw->pw_uid, use_gid ? mail_gid : pw->pw_gid, mboxdrv, mailbox, pw->pw_dir);
++                a = authcontext_new(pw ? pw->pw_uid : uid, (use_gid || !pw) ? mail_gid : pw->pw_gid, mboxdrv, mailbox, pw ? pw->pw_dir : mailbox);
+ 
+                 break;
+             }
+@@ -402,12 +397,7 @@ authcontext auth_pgsql_new_user_pass(con
+ 
+                 pw = getpwuid(uid);
+ 
+-                if (!pw) {
+-                    log_print(LOG_ERR, "auth_pgsql_new_user_pass: getpwuid(%d): %m", (int)uid);
+-                    break;
+-                }
+-
+-                a = authcontext_new(pw->pw_uid, use_gid ? mail_gid : pw->pw_gid, mboxdrv, mailbox, pw->pw_dir);
++                a = authcontext_new(pw ? pw->pw_uid : uid, (use_gid || !pw) ? mail_gid : pw->pw_gid, mboxdrv, mailbox, pw ? pw->pw_dir : mailbox);
+                 break;
+             }
+ 
================================================================



More information about the pld-cvs-commit mailing list