annotate src/auth/userdb-passwd-file.c @ 3474:9096b7957413 HEAD

Removed direct config.h including. I'm not sure why it was done before, probably to reduce compile times a few milliseconds. Ugly anyway..
author Timo Sirainen <tss@iki.fi>
date Tue, 12 Jul 2005 15:58:47 +0300
parents e6a487d80288
children ee0e39cf4ca5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2002-2003 Timo Sirainen */
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
3474
9096b7957413 Removed direct config.h including. I'm not sure why it was done before,
Timo Sirainen <tss@iki.fi>
parents: 3166
diff changeset
3 #include "common.h"
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #ifdef USERDB_PASSWD_FILE
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
3158
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
7 #include "str.h"
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "userdb.h"
1062
0522a0315d2f Cleanups, LDAP support compiles again and generally looks ok, even if it
Timo Sirainen <tss@iki.fi>
parents: 1046
diff changeset
9 #include "db-passwd-file.h"
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 struct passwd_file *userdb_pwf = NULL;
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12
2057
5e0167577399 Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents: 1443
diff changeset
13 static void passwd_file_lookup(struct auth_request *auth_request,
3166
e6a487d80288 Restructuring of auth code. Balancer auth processes were a bad idea. Usually
Timo Sirainen <tss@iki.fi>
parents: 3158
diff changeset
14 userdb_callback_t *callback)
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 {
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 struct passwd_user *pu;
3158
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
17 string_t *str;
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
2099
eac49325fa23 Logging changes. Make sure we don't write control characters to log and also
Timo Sirainen <tss@iki.fi>
parents: 2057
diff changeset
19 pu = db_passwd_file_lookup(userdb_pwf, auth_request);
1046
561da07883b6 Async userdb and passdb interface.
Timo Sirainen <tss@iki.fi>
parents: 1035
diff changeset
20 if (pu == NULL) {
3166
e6a487d80288 Restructuring of auth code. Balancer auth processes were a bad idea. Usually
Timo Sirainen <tss@iki.fi>
parents: 3158
diff changeset
21 callback(NULL, auth_request);
1046
561da07883b6 Async userdb and passdb interface.
Timo Sirainen <tss@iki.fi>
parents: 1035
diff changeset
22 return;
561da07883b6 Async userdb and passdb interface.
Timo Sirainen <tss@iki.fi>
parents: 1035
diff changeset
23 }
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24
3158
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
25 str = t_str_new(128);
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
26 str_printfa(str, "%s\tuid=%s\tgid=%s",
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
27 auth_request->user, dec2str(pu->uid), dec2str(pu->gid));
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
3158
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
29 if (pu->home != NULL)
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
30 str_printfa(str, "\thome=%s", pu->home);
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
31 if (pu->mail != NULL)
8849f2e380d1 userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents: 3127
diff changeset
32 str_printfa(str, "\tmail=%s", pu->mail);
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33
3166
e6a487d80288 Restructuring of auth code. Balancer auth processes were a bad idea. Usually
Timo Sirainen <tss@iki.fi>
parents: 3158
diff changeset
34 callback(str_c(str), auth_request);
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 }
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 static void passwd_file_init(const char *args)
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 {
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 if (passdb_pwf != NULL && strcmp(passdb_pwf->path, args) == 0) {
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 userdb_pwf = passdb_pwf;
1361
dc2163fafa70 passwd-file fixes. passdb ignores now fields after password, so it can work
Timo Sirainen <tss@iki.fi>
parents: 1191
diff changeset
41 userdb_pwf->refcount++;
dc2163fafa70 passwd-file fixes. passdb ignores now fields after password, so it can work
Timo Sirainen <tss@iki.fi>
parents: 1191
diff changeset
42
dc2163fafa70 passwd-file fixes. passdb ignores now fields after password, so it can work
Timo Sirainen <tss@iki.fi>
parents: 1191
diff changeset
43 /* resync */
3127
b5c20f0a9649 userdb passwd-file wasn't working. Patch by Joseph Tam.
Timo Sirainen <tss@iki.fi>
parents: 2942
diff changeset
44 userdb_pwf->userdb = TRUE;
1361
dc2163fafa70 passwd-file fixes. passdb ignores now fields after password, so it can work
Timo Sirainen <tss@iki.fi>
parents: 1191
diff changeset
45 userdb_pwf->stamp = 0;
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 } else {
1361
dc2163fafa70 passwd-file fixes. passdb ignores now fields after password, so it can work
Timo Sirainen <tss@iki.fi>
parents: 1191
diff changeset
47 userdb_pwf = db_passwd_file_parse(args, TRUE);
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 }
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 }
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 static void passwd_file_deinit(void)
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 {
1062
0522a0315d2f Cleanups, LDAP support compiles again and generally looks ok, even if it
Timo Sirainen <tss@iki.fi>
parents: 1046
diff changeset
53 db_passwd_file_unref(userdb_pwf);
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 }
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 struct userdb_module userdb_passwd_file = {
2942
c7d426f8cb58 Added name variable for userdb_module and passdb_module and changed their
Timo Sirainen <tss@iki.fi>
parents: 2648
diff changeset
57 "passwd-file",
3166
e6a487d80288 Restructuring of auth code. Balancer auth processes were a bad idea. Usually
Timo Sirainen <tss@iki.fi>
parents: 3158
diff changeset
58 FALSE,
2942
c7d426f8cb58 Added name variable for userdb_module and passdb_module and changed their
Timo Sirainen <tss@iki.fi>
parents: 2648
diff changeset
59
2648
cc2e39912eb3 Added preinit() call to userdb/passdbs, which is called before dropping
Timo Sirainen <tss@iki.fi>
parents: 2099
diff changeset
60 NULL,
1035
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
61 passwd_file_init,
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62 passwd_file_deinit,
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64 passwd_file_lookup
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 };
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
66
fe49ece0f3ea We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
67 #endif