Lines Matching refs:pw
29 passwd_file_add(struct passwd_file *pw, const char *username,
38 if (hash_table_lookup(pw->users, username) != NULL) {
40 pw->path, username);
44 pu = p_new(pw->pool, struct passwd_user, 1);
45 user = p_strdup(pw->pool, username);
57 pu->password = p_strconcat(pw->pool, "{PLAIN-MD5}",
60 pu->password = p_strconcat(pw->pool, "{DIGEST-MD5}",
65 pw->path, username);
69 pu->password = p_strconcat(pw->pool, "{CRYPT}",
73 pu->password = p_strdup(pw->pool, pass);
81 else if (!pw->db->userdb || **args == '\0') {
87 pw->path, username, *args);
94 if (pw->db->userdb_warn_missing) {
96 "userdb info", pw->path, username);
101 } else if (!pw->db->userdb || **args == '\0')
107 pw->path, username, *args);
119 if (pw->db->userdb)
120 pu->home = p_strdup_empty(pw->pool, *args);
132 if (*args != NULL && **args != '\0' && pw->db->userdb) {
145 p_strsplit_spaces(pw->pool, extra_fields, " ");
148 hash_table_insert(pw->users, user, pu);
154 struct passwd_file *pw;
156 pw = i_new(struct passwd_file, 1);
157 pw->db = db;
158 pw->path = i_strdup(expanded_path);
159 pw->fd = -1;
162 hash_table_insert(db->files, pw->path, pw);
163 return pw;
166 static int passwd_file_open(struct passwd_file *pw, bool startup,
177 fd = open(pw->path, O_RDONLY);
180 *error_r = eacces_error_get("open", pw->path);
183 pw->path);
190 pw->path);
195 pw->fd = fd;
196 pw->stamp = st.st_mtime;
197 pw->size = st.st_size;
199 pw->pool = pool_alloconly_create(MEMPOOL_GROWING"passwd_file", 10240);
200 hash_table_create(&pw->users, pw->pool, 0, str_hash, strcmp);
203 input = i_stream_create_fd(pw->fd, (size_t)-1);
213 passwd_file_add(pw, args[0], args[1], args+2);
216 passwd_file_add(pw, args[0], NULL, &no_args);
227 pw->path, hash_table_count(pw->users), time_secs);
228 } else if (pw->db->debug) {
230 pw->path, hash_table_count(pw->users), time_secs);
235 static void passwd_file_close(struct passwd_file *pw)
237 i_close_fd_path(&pw->fd, pw->path);
239 if (hash_table_is_created(pw->users))
240 hash_table_destroy(&pw->users);
241 pool_unref(&pw->pool);
244 static void passwd_file_free(struct passwd_file *pw)
246 if (hash_table_is_created(pw->db->files))
247 hash_table_remove(pw->db->files, pw->path);
249 passwd_file_close(pw);
250 i_free(pw->path);
251 i_free(pw);
255 struct passwd_file *pw)
260 if (pw->last_sync_time == ioloop_time)
261 return hash_table_is_created(pw->users) ? 0 : -1;
262 pw->last_sync_time = ioloop_time;
264 if (stat(pw->path, &st) < 0) {
269 "%s", eacces_error_get("stat", pw->path));
272 "stat(%s) failed: %m", pw->path);
275 if (pw->db->default_file != pw)
276 passwd_file_free(pw);
280 if (st.st_mtime != pw->stamp || st.st_size != pw->size) {
281 passwd_file_close(pw);
282 if (passwd_file_open(pw, FALSE, &error) < 0) {
433 struct passwd_file *pw;
438 pw = db->default_file;
449 pw = hash_table_lookup(db->files, str_c(dest));
450 if (pw == NULL) {
452 pw = passwd_file_new(db, str_c(dest));
456 if (passwd_file_sync(request, pw) < 0) {
457 /* pw may be freed now */
472 str_c(username), pw->path);
474 *user_r = hash_table_lookup(pw->users, str_c(username));