diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-08-07 19:02:56 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-08-07 19:02:56 +0000 |
commit | a9f66ffef11f46a61dc8f5ee706eac4ff04e6ce0 (patch) | |
tree | 4f2649b32a3e25ff08cd9cbf8392a7137a39f86b | |
parent | 11355255a978e30421769371b8b003abcf8b9f48 (diff) |
wrap auth_userokay in a new function authenticate_user() and make sure
that only authenticate.c knows about bsd_auth, no functionnal change.
-rw-r--r-- | usr.sbin/smtpd/authenticate.c | 41 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd/Makefile | 10 |
4 files changed, 52 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/authenticate.c b/usr.sbin/smtpd/authenticate.c new file mode 100644 index 00000000000..f439dde8b87 --- /dev/null +++ b/usr.sbin/smtpd/authenticate.c @@ -0,0 +1,41 @@ +/* $OpenBSD: authenticate.c,v 1.1 2009/08/07 19:02:55 gilles Exp $ */ + +/* + * Copyright (c) 2009 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 <bsd_auth.h> +#include <err.h> +#include <event.h> +#include <pwd.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "smtpd.h" + +int +authenticate_user(char *username, char *password) +{ + return auth_userokay(username, NULL, "auth-smtp", password); +} diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 41f72e2a7ab..02bdf26240d 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.80 2009/08/06 16:46:57 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.81 2009/08/07 19:02:55 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -29,7 +29,6 @@ #include <sys/resource.h> #include <sys/mman.h> -#include <bsd_auth.h> #include <err.h> #include <errno.h> #include <event.h> @@ -574,8 +573,7 @@ parent_dispatch_smtp(int fd, short event, void *p) IMSG_SIZE_CHECK(req); - req->success = auth_userokay(req->user, NULL, - "auth-smtp", req->pass); + req->success = authenticate_user(req->user, req->pass); imsg_compose_event(iev, IMSG_PARENT_AUTHENTICATE, 0, 0, -1, req, sizeof(*req)); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 43d9a55495f..aac0017a85d 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.134 2009/08/06 16:46:57 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.135 2009/08/07 19:02:55 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -741,6 +741,9 @@ int aliases_virtual_exist(struct smtpd *, struct path *); int aliases_virtual_get(struct smtpd *, struct aliaseslist *, struct path *); int alias_parse(struct alias *, char *); +/* authenticate.c */ +int authenticate_user(char *, char *); + /* bounce.c */ void bounce_process(struct smtpd *, struct message *); int bounce_session(struct smtpd *, int, struct message *); diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile index f662500d88b..0bba5ba39ba 100644 --- a/usr.sbin/smtpd/smtpd/Makefile +++ b/usr.sbin/smtpd/smtpd/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.9 2009/08/06 13:40:45 gilles Exp $ +# $OpenBSD: Makefile,v 1.10 2009/08/07 19:02:55 gilles Exp $ PROG= smtpd -SRCS= parse.y log.c bounce.c config.c buffer.c imsg.c \ - smtpd.c lka.c mfa.c queue.c mta.c mda.c control.c \ - smtp.c smtp_session.c store.c \ - ssl.c ssl_privsep.c dns.c aliases.c forward.c \ +SRCS= parse.y authenticate.c log.c bounce.c config.c buffer.c \ + imsg.c smtpd.c lka.c mfa.c queue.c mta.c mda.c control.c \ + smtp.c smtp_session.c store.c \ + ssl.c ssl_privsep.c dns.c aliases.c forward.c \ map.c runner.c util.c queue_shared.c ruleset.c MAN= smtpd.8 smtpd.conf.5 BINDIR= /usr/sbin |