From: Timo Sirainen Date: Wed, 16 Apr 2003 13:38:17 +0000 (+0300) Subject: passwd-file fixes. passdb ignores now fields after password, so it can work X-Git-Tag: 1.1.alpha1~4745 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63c6eefc07085070733e702208101662bc5ccb45;p=thirdparty%2Fdovecot%2Fcore.git passwd-file fixes. passdb ignores now fields after password, so it can work with shadow-like file. --HG-- branch : HEAD --- diff --git a/src/auth/db-passwd-file.c b/src/auth/db-passwd-file.c index 4d2d72bb44..1d740a2f6f 100644 --- a/src/auth/db-passwd-file.c +++ b/src/auth/db-passwd-file.c @@ -153,7 +153,9 @@ static void passwd_file_open(struct passwd_file *pw) args = t_strsplit(line, ":"); if (args[1] != NULL) { /* at least two fields */ - passwd_file_add(pw, args[0], args[1], args+2); + const char *no_args = NULL; + passwd_file_add(pw, args[0], args[1], + pw->userdb ? args+2 : &no_args); } t_pop(); } @@ -191,13 +193,14 @@ static void passwd_file_sync(struct passwd_file *pw) } } -struct passwd_file *db_passwd_file_parse(const char *path) +struct passwd_file *db_passwd_file_parse(const char *path, int userdb) { struct passwd_file *pw; pw = i_new(struct passwd_file, 1); pw->refcount = 1; pw->path = i_strdup(path); + pw->userdb = userdb; passwd_file_open(pw); return pw; diff --git a/src/auth/db-passwd-file.h b/src/auth/db-passwd-file.h index e93386a519..40398ecb93 100644 --- a/src/auth/db-passwd-file.h +++ b/src/auth/db-passwd-file.h @@ -23,6 +23,7 @@ struct passwd_file { char *path; time_t stamp; int fd; + int userdb; struct hash_table *users; }; @@ -33,7 +34,7 @@ extern struct passwd_file *passdb_pwf; struct passwd_user * db_passwd_file_lookup(struct passwd_file *pw, const char *user); -struct passwd_file *db_passwd_file_parse(const char *path); +struct passwd_file *db_passwd_file_parse(const char *path, int userdb); void db_passwd_file_unref(struct passwd_file *pw); #endif diff --git a/src/auth/passdb-passwd-file.c b/src/auth/passdb-passwd-file.c index 42d471311a..84b7496a6d 100644 --- a/src/auth/passdb-passwd-file.c +++ b/src/auth/passdb-passwd-file.c @@ -73,7 +73,7 @@ static void passwd_file_init(const char *args) passdb_pwf = userdb_pwf; passdb_pwf->refcount++; } else { - passdb_pwf = db_passwd_file_parse(args); + passdb_pwf = db_passwd_file_parse(args, FALSE); } } diff --git a/src/auth/userdb-passwd-file.c b/src/auth/userdb-passwd-file.c index 0e0023f4d4..a7e8bd6b8c 100644 --- a/src/auth/userdb-passwd-file.c +++ b/src/auth/userdb-passwd-file.c @@ -40,9 +40,13 @@ static void passwd_file_init(const char *args) { if (passdb_pwf != NULL && strcmp(passdb_pwf->path, args) == 0) { userdb_pwf = passdb_pwf; - userdb_pwf->refcount++; + userdb_pwf->refcount++; + + /* resync */ + userdb_pwf->userdb = FALSE; + userdb_pwf->stamp = 0; } else { - userdb_pwf = db_passwd_file_parse(args); + userdb_pwf = db_passwd_file_parse(args, TRUE); } }