db-passwd-file.c revision d5cebe7f98e63d4e2822863ef2faa4971e8b3a5d
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "common.h"
#if defined (USERDB_PASSWD_FILE) || defined(PASSDB_PASSWD_FILE)
#include "userdb.h"
#include "db-passwd-file.h"
#include "buffer.h"
#include "istream.h"
#include "hash.h"
#include "str.h"
#include "var-expand.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
static struct db_passwd_file *passwd_files;
{
/* args = uid, gid, user info, home dir, shell, flags, mail */
struct passwd_user *pu;
const char *p;
i_error("passwd-file %s: User %s exists more than once",
return;
}
if (p == NULL) {
} else {
/* password[type] - we're being libpam-pwdfile compatible
here. it uses 13 = DES and 34 = MD5. For backwards
comaptibility with ourself, we have also 56 = Digest-MD5. */
if (p[1] == '3' && p[2] == '4') {
} else if (p[1] == '5' && p[2] == '6') {
i_error("passwd-file %s: User %s "
"has invalid password",
return;
}
} else {
}
}
i_error("passwd-file %s: User %s has invalid UID %s",
return;
}
args++;
}
i_error("passwd-file %s: User %s has invalid GID %s",
return;
}
args++;
}
/* user info */
args++;
/* home */
args++;
}
/* shell */
args++;
/* flags */
/* no flags currently */
args++;
}
/* rest is MAIL environment */
args++;
args++;
}
}
}
static struct passwd_file *
{
struct passwd_file *pw;
return pw;
}
{
const char *const *args;
const char *line;
int fd;
if (fd == -1) {
return FALSE;
}
return FALSE;
}
continue; /* no username or comment */
t_push();
/* at least username+password */
} else {
/* only username */
}
t_pop();
}
return TRUE;
}
{
}
}
}
}
{
}
{
/* with variables don't give hard errors, or errors about
nonexisting files */
return FALSE;
}
return passwd_file_open(pw);
}
return TRUE;
}
{
struct db_passwd_file *f;
return f;
}
return NULL;
}
{
struct db_passwd_file *db;
const char *p;
/* resync */
}
}
return db;
}
for (p = path; *p != '\0'; p++) {
if (*p == '%' && p[1] != '\0') {
p++;
if (*p == 'd') {
/* drop domains out only if %d is given
without modifiers */
}
if (var_get_key(p) == '%')
else
}
}
/* just extra escaped % chars. remove them. */
}
/* no variables, open the file immediately */
}
passwd_files = db;
return db;
}
{
struct db_passwd_file **p;
struct hash_iterate_context *iter;
return;
if (*p == db) {
break;
}
}
}
{
const char *p;
if (p == NULL)
return path;
/* most likely this is an invalid request. just cut off the '/' and
everything after it. */
return t_strdup_until(path, p);
}
struct passwd_user *
{
struct passwd_file *pw;
struct passwd_user *pu;
else {
const struct var_expand_table *table;
t_push();
/* doesn't exist yet. create lookup for it. */
}
t_pop();
}
if (!passwd_file_sync(pw)) {
"no passwd file");
return NULL;
}
t_push();
t_pop();
return pu;
}
#endif