summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2011-12-14 22:28:03 +0000
committerEric Faurot <eric@cvs.openbsd.org>2011-12-14 22:28:03 +0000
commita8539f1d7239a1e9c2f5b4704fe266505e648546 (patch)
treef7f19a644978f82e6961d7ffe923cf6f73b11835 /usr.sbin
parent96b58b906df89d84de475989137988cd0678b4ef (diff)
split auth_backend.c for consistency
ok chl@ gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/auth.c51
-rw-r--r--usr.sbin/smtpd/auth_bsd.c43
-rw-r--r--usr.sbin/smtpd/auth_pwd.c (renamed from usr.sbin/smtpd/auth_backend.c)40
-rw-r--r--usr.sbin/smtpd/smtpd.h6
-rw-r--r--usr.sbin/smtpd/smtpd/Makefile6
5 files changed, 104 insertions, 42 deletions
diff --git a/usr.sbin/smtpd/auth.c b/usr.sbin/smtpd/auth.c
new file mode 100644
index 00000000000..0c54f781173
--- /dev/null
+++ b/usr.sbin/smtpd/auth.c
@@ -0,0 +1,51 @@
+/* $OpenBSD: auth.c,v 1.1 2011/12/14 22:28:02 eric Exp $ */
+
+/*
+ * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/tree.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <event.h>
+#include <imsg.h>
+#include <stdio.h>
+
+#include "smtpd.h"
+#include "log.h"
+
+extern struct auth_backend auth_backend_bsd;
+extern struct auth_backend auth_backend_pwd;
+
+struct auth_backend *
+auth_backend_lookup(enum auth_type type)
+{
+ switch (type) {
+ case AUTH_BSD:
+ return &auth_backend_bsd;
+
+ case AUTH_PWD:
+ return &auth_backend_pwd;
+
+ default:
+ fatalx("bad auth type");
+ }
+
+ return (NULL);
+}
diff --git a/usr.sbin/smtpd/auth_bsd.c b/usr.sbin/smtpd/auth_bsd.c
new file mode 100644
index 00000000000..2ca0e19ee59
--- /dev/null
+++ b/usr.sbin/smtpd/auth_bsd.c
@@ -0,0 +1,43 @@
+/* $OpenBSD: auth_bsd.c,v 1.1 2011/12/14 22:28:02 eric Exp $ */
+
+/*
+ * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/tree.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <bsd_auth.h>
+#include <event.h>
+#include <imsg.h>
+#include <stdio.h>
+
+#include "smtpd.h"
+
+int auth_bsd(char *, char *);
+
+struct auth_backend auth_backend_bsd = {
+ auth_bsd,
+};
+
+int
+auth_bsd(char *username, char *password)
+{
+ return auth_userokay(username, NULL, "auth-smtp", password);
+}
diff --git a/usr.sbin/smtpd/auth_backend.c b/usr.sbin/smtpd/auth_pwd.c
index defffc2ff39..1e44f72a0b2 100644
--- a/usr.sbin/smtpd/auth_backend.c
+++ b/usr.sbin/smtpd/auth_pwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_backend.c,v 1.1 2011/05/17 16:42:06 gilles Exp $ */
+/* $OpenBSD: auth_pwd.c,v 1.1 2011/12/14 22:28:02 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -23,53 +23,23 @@
#include <sys/socket.h>
#include <sys/stat.h>
-#include <bsd_auth.h>
#include <event.h>
#include <imsg.h>
-#include <libgen.h>
#include <pwd.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "smtpd.h"
-#include "log.h"
-int auth_bsd(char *, char *);
-int auth_getpwnam(char *, char *);
-struct auth_backend *auth_backend_lookup(enum auth_type);
+int auth_pwd(char *, char *);
-struct auth_backend auth_backends[] = {
- { AUTH_BSD, auth_bsd },
- { AUTH_GETPWNAM, auth_getpwnam }
+struct auth_backend auth_backend_pwd = {
+ auth_pwd
};
-struct auth_backend *
-auth_backend_lookup(enum auth_type type)
-{
- u_int8_t i;
-
- for (i = 0; i < nitems(auth_backends); ++i)
- if (auth_backends[i].type == type)
- break;
-
- if (i == nitems(auth_backends))
- fatalx("invalid auth type");
-
- return &auth_backends[i];
-}
-
-
-int
-auth_bsd(char *username, char *password)
-{
- return auth_userokay(username, NULL, "auth-smtp", password);
-}
-
-
int
-auth_getpwnam(char *username, char *password)
+auth_pwd(char *username, char *password)
{
struct passwd *pw;
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index fe02ebb5a05..9aca791c89f 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.265 2011/12/14 18:42:27 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.266 2011/12/14 22:28:02 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -920,13 +920,11 @@ struct queue_backend {
/* auth structures */
enum auth_type {
- AUTH_INVALID=0,
AUTH_BSD,
- AUTH_GETPWNAM,
+ AUTH_PWD,
};
struct auth_backend {
- enum auth_type type;
int (*authenticate)(char *, char *);
};
diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile
index e2a7ba9df3b..e3c25eb0249 100644
--- a/usr.sbin/smtpd/smtpd/Makefile
+++ b/usr.sbin/smtpd/smtpd/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.35 2011/12/13 23:00:52 eric Exp $
+# $OpenBSD: Makefile,v 1.36 2011/12/14 22:28:02 eric Exp $
PROG= smtpd
-SRCS= aliases.c auth_backend.c bounce.c client.c \
- delivery.c delivery_filename.c \
+SRCS= aliases.c auth.c auth_bsd.c auth_pwd.c bounce.c \
+ client.c delivery.c delivery_filename.c \
delivery_maildir.c delivery_mbox.c delivery_mda.c \
config.c control.c dns.c expand.c forward.c \
lka.c lka_session.c log.c map.c map_db.c map_stdio.c \