summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2012-05-12 15:29:17 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2012-05-12 15:29:17 +0000
commitf2cab7a55cbb2eeb92d5647ed32e588787cd62e0 (patch)
treee9cde077925a900c8b0f5a97c76546fa99d5b33d /usr.sbin
parent3710fda88171027596e7116ae79b9a2bf69ce1dc (diff)
- rename all occurences of K_SECRET to K_CREDENTIALS
- rename all occurences of struct map_secret to map_credentials - do not fatal if the credentials map has disappeared, instead make the auth fail with a lookup failure. the mail will be temporary failed so it stays in queue until admin fixes smtpd.conf, removes mail, or lets it expires
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka.c31
-rw-r--r--usr.sbin/smtpd/map_db.c32
-rw-r--r--usr.sbin/smtpd/map_stdio.c32
-rw-r--r--usr.sbin/smtpd/smtpd.h6
4 files changed, 53 insertions, 48 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index befbafc38d8..fad0f8cce16 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.131 2011/11/14 19:23:41 chl Exp $ */
+/* $OpenBSD: lka.c,v 1.132 2012/05/12 15:29:16 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -47,7 +47,7 @@ static void lka_imsg(struct imsgev *, struct imsg *);
static void lka_shutdown(void);
static void lka_sig_handler(int, short, void *);
static int lka_verify_mail(struct mailaddr *);
-static int lka_encode_credentials(char *, size_t, struct map_secret *);
+static int lka_encode_credentials(char *, size_t, struct map_credentials *);
void lka_session(struct submit_status *);
void lka_session_forward_reply(struct forward_req *, int);
@@ -110,24 +110,28 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg)
if (iev->proc == PROC_MTA) {
switch (imsg->hdr.type) {
case IMSG_LKA_SECRET: {
- struct map_secret *map_secret;
+ struct map_credentials *map_credentials;
secret = imsg->data;
map = map_findbyname(secret->mapname);
- if (map == NULL)
- fatalx("lka: secrets map not found");
- map_secret = map_lookup(map->m_id, secret->host, K_SECRET);
+ if (map == NULL) {
+ imsg_compose_event(iev, IMSG_LKA_SECRET, 0, 0,
+ -1, secret, sizeof *secret);
+ return;
+ }
+ map_credentials = map_lookup(map->m_id, secret->host,
+ K_CREDENTIALS);
log_debug("lka: %s secret lookup (%d)", secret->host,
- map_secret != NULL);
+ map_credentials != NULL);
secret->secret[0] = '\0';
- if (map_secret == NULL)
+ if (map_credentials == NULL)
log_warnx("%s secret not found", secret->host);
else if (lka_encode_credentials(secret->secret,
- sizeof secret->secret, map_secret) == 0)
+ sizeof secret->secret, map_credentials) == 0)
log_warnx("%s secret parse fail", secret->host);
imsg_compose_event(iev, IMSG_LKA_SECRET, 0, 0, -1, secret,
sizeof *secret);
- free(map_secret);
+ free(map_credentials);
return;
}
}
@@ -308,13 +312,14 @@ lka_verify_mail(struct mailaddr *maddr)
}
static int
-lka_encode_credentials(char *dst, size_t size, struct map_secret *map_secret)
+lka_encode_credentials(char *dst, size_t size,
+ struct map_credentials *map_credentials)
{
char *buf;
int buflen;
- if ((buflen = asprintf(&buf, "%c%s%c%s", '\0', map_secret->username,
- '\0', map_secret->password)) == -1)
+ if ((buflen = asprintf(&buf, "%c%s%c%s", '\0', map_credentials->username,
+ '\0', map_credentials->password)) == -1)
fatal(NULL);
if (__b64_ntop((unsigned char *)buf, buflen, dst, size) == -1) {
diff --git a/usr.sbin/smtpd/map_db.c b/usr.sbin/smtpd/map_db.c
index 17e8a1ae32d..860a8a54c6f 100644
--- a/usr.sbin/smtpd/map_db.c
+++ b/usr.sbin/smtpd/map_db.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: map_db.c,v 1.1 2011/12/13 23:00:52 eric Exp $ */
+/* $OpenBSD: map_db.c,v 1.2 2012/05/12 15:29:16 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -42,7 +42,7 @@ static void *map_db_lookup(void *, char *, enum map_kind);
static void map_db_close(void *);
static char *map_db_get_entry(void *, char *, size_t *);
-static void *map_db_secret(char *, char *, size_t);
+static void *map_db_credentials(char *, char *, size_t);
static void *map_db_alias(char *, char *, size_t);
static void *map_db_virtual(char *, char *, size_t);
@@ -85,8 +85,8 @@ map_db_lookup(void *hdl, char *key, enum map_kind kind)
ret = map_db_alias(key, line, len);
break;
- case K_SECRET:
- ret = map_db_secret(key, line, len);
+ case K_CREDENTIALS:
+ ret = map_db_credentials(key, line, len);
break;
case K_VIRTUAL:
@@ -129,9 +129,9 @@ map_db_get_entry(void *hdl, char *key, size_t *len)
}
static void *
-map_db_secret(char *key, char *line, size_t len)
+map_db_credentials(char *key, char *line, size_t len)
{
- struct map_secret *map_secret = NULL;
+ struct map_credentials *map_credentials = NULL;
char *p;
/* credentials are stored as user:password */
@@ -150,24 +150,24 @@ map_db_secret(char *key, char *line, size_t len)
return NULL;
*p++ = '\0';
- map_secret = calloc(1, sizeof(struct map_secret));
- if (map_secret == NULL)
+ map_credentials = calloc(1, sizeof(struct map_credentials));
+ if (map_credentials == NULL)
fatalx("calloc");
- if (strlcpy(map_secret->username, line,
- sizeof(map_secret->username)) >=
- sizeof(map_secret->username))
+ if (strlcpy(map_credentials->username, line,
+ sizeof(map_credentials->username)) >=
+ sizeof(map_credentials->username))
goto err;
- if (strlcpy(map_secret->password, p,
- sizeof(map_secret->password)) >=
- sizeof(map_secret->password))
+ if (strlcpy(map_credentials->password, p,
+ sizeof(map_credentials->password)) >=
+ sizeof(map_credentials->password))
goto err;
- return map_secret;
+ return map_credentials;
err:
- free(map_secret);
+ free(map_credentials);
return NULL;
}
diff --git a/usr.sbin/smtpd/map_stdio.c b/usr.sbin/smtpd/map_stdio.c
index 9b9b0198a33..2e6e55a1788 100644
--- a/usr.sbin/smtpd/map_stdio.c
+++ b/usr.sbin/smtpd/map_stdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: map_stdio.c,v 1.1 2011/12/13 23:00:52 eric Exp $ */
+/* $OpenBSD: map_stdio.c,v 1.2 2012/05/12 15:29:16 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -41,7 +41,7 @@ static void *map_stdio_lookup(void *, char *, enum map_kind);
static void map_stdio_close(void *);
static char *map_stdio_get_entry(void *, char *, size_t *);
-static void *map_stdio_secret(char *, char *, size_t);
+static void *map_stdio_credentials(char *, char *, size_t);
static void *map_stdio_alias(char *, char *, size_t);
static void *map_stdio_virtual(char *, char *, size_t);
@@ -84,8 +84,8 @@ map_stdio_lookup(void *hdl, char *key, enum map_kind kind)
ma = map_stdio_alias(key, line, len);
break;
- case K_SECRET:
- ma = map_stdio_secret(key, line, len);
+ case K_CREDENTIALS:
+ ma = map_stdio_credentials(key, line, len);
break;
case K_VIRTUAL:
@@ -151,9 +151,9 @@ map_stdio_get_entry(void *hdl, char *key, size_t *len)
static void *
-map_stdio_secret(char *key, char *line, size_t len)
+map_stdio_credentials(char *key, char *line, size_t len)
{
- struct map_secret *map_secret = NULL;
+ struct map_credentials *map_credentials = NULL;
char *p;
/* credentials are stored as user:password */
@@ -172,24 +172,24 @@ map_stdio_secret(char *key, char *line, size_t len)
return NULL;
*p++ = '\0';
- map_secret = calloc(1, sizeof(struct map_secret));
- if (map_secret == NULL)
+ map_credentials = calloc(1, sizeof(struct map_credentials));
+ if (map_credentials == NULL)
fatalx("calloc");
- if (strlcpy(map_secret->username, line,
- sizeof(map_secret->username)) >=
- sizeof(map_secret->username))
+ if (strlcpy(map_credentials->username, line,
+ sizeof(map_credentials->username)) >=
+ sizeof(map_credentials->username))
goto err;
- if (strlcpy(map_secret->password, p,
- sizeof(map_secret->password)) >=
- sizeof(map_secret->password))
+ if (strlcpy(map_credentials->password, p,
+ sizeof(map_credentials->password)) >=
+ sizeof(map_credentials->password))
goto err;
- return map_secret;
+ return map_credentials;
err:
- free(map_secret);
+ free(map_credentials);
return NULL;
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 94a5fcd09ba..478b73750b4 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.288 2012/05/11 12:12:02 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.289 2012/05/12 15:29:16 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -250,7 +250,7 @@ enum map_kind {
K_NONE,
K_ALIAS,
K_VIRTUAL,
- K_SECRET
+ K_CREDENTIALS
};
enum mapel_type {
@@ -878,7 +878,7 @@ struct mta_batch {
};
/* maps return structures */
-struct map_secret {
+struct map_credentials {
char username[MAX_LINE_SIZE];
char password[MAX_LINE_SIZE];
};