summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2011-12-13 22:04:36 +0000
committerEric Faurot <eric@cvs.openbsd.org>2011-12-13 22:04:36 +0000
commit1b99a1058f37ecbe11e86d91331b1722307dd309 (patch)
tree6856f8efa8d384d0196f71732e8573c85b250218 /usr.sbin
parentc186c66598aa1d157332722bf0503f6450ed4983 (diff)
split user_backend.c into user.c and user_pwd.c to be consistent with the
backend scheme. Also rename USER_GETPWNAM to USER_PWD. ok chl@ gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka_session.c8
-rw-r--r--usr.sbin/smtpd/smtpd.c8
-rw-r--r--usr.sbin/smtpd/smtpd.h6
-rw-r--r--usr.sbin/smtpd/smtpd/Makefile4
-rw-r--r--usr.sbin/smtpd/user.c46
-rw-r--r--usr.sbin/smtpd/user_pwd.c (renamed from usr.sbin/smtpd/user_backend.c)25
6 files changed, 62 insertions, 35 deletions
diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c
index 4423cb4199c..5c7398c988c 100644
--- a/usr.sbin/smtpd/lka_session.c
+++ b/usr.sbin/smtpd/lka_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_session.c,v 1.15 2011/12/13 21:44:47 gilles Exp $ */
+/* $OpenBSD: lka_session.c,v 1.16 2011/12/13 22:04:35 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -109,7 +109,7 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
}
bzero(&u, sizeof (u));
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
if (! ub->getbyname(&u, username))
return 0;
@@ -511,7 +511,7 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep)
if (*(p + 1) == '/' || *(p + 1) == '\0') {
bzero(&u, sizeof (u));
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
if (! ub->getbyname(&u, ep->agent.mda.as_user))
return 0;
@@ -536,7 +536,7 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep)
*delim = '\0';
bzero(&u, sizeof (u));
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
if (! ub->getbyname(&u, username))
return 0;
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 5acc38e4b0b..fd216ae8262 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.141 2011/12/13 21:44:47 gilles Exp $ */
+/* $OpenBSD: smtpd.c,v 1.142 2011/12/13 22:04:35 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -702,7 +702,7 @@ forkmda(struct imsgev *iev, u_int32_t id,
log_debug("forkmda: to %s as %s", deliver->to, deliver->user);
bzero(&u, sizeof (u));
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
errno = 0;
if (! ub->getbyname(&u, deliver->user)) {
n = snprintf(ebuf, sizeof ebuf, "getpwnam: %s",
@@ -880,7 +880,7 @@ offline_enqueue(char *name)
_exit(1);
}
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
bzero(&u, sizeof (u));
errno = 0;
if (! ub->getbyuid(&u, sb.st_uid)) {
@@ -986,7 +986,7 @@ parent_forward_open(char *username)
int fd;
bzero(&u, sizeof (u));
- ub = user_backend_lookup(USER_GETPWNAM);
+ ub = user_backend_lookup(USER_PWD);
if (! ub->getbyname(&u, username))
return -1;
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 9aedaf19f95..5f088c0f4a6 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.261 2011/12/13 21:44:47 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.262 2011/12/13 22:04:35 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -933,8 +933,7 @@ struct auth_backend {
/* user structures */
enum user_type {
- USER_INVALID=0,
- USER_GETPWNAM,
+ USER_PWD,
};
#define MAXPASSWORDLEN 128
@@ -947,7 +946,6 @@ struct mta_user {
};
struct user_backend {
- enum user_type type;
int (*getbyname)(struct mta_user *, char *);
int (*getbyuid)(struct mta_user *, uid_t);
};
diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile
index bbabed1ccc3..3a461b0d2a8 100644
--- a/usr.sbin/smtpd/smtpd/Makefile
+++ b/usr.sbin/smtpd/smtpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.32 2011/12/13 21:44:47 gilles Exp $
+# $OpenBSD: Makefile,v 1.33 2011/12/13 22:04:35 eric Exp $
PROG= smtpd
SRCS= aliases.c auth_backend.c bounce.c client.c \
@@ -12,7 +12,7 @@ SRCS= aliases.c auth_backend.c bounce.c client.c \
smtp_session.c smtpd.c ssl.c ssl_privsep.c util.c asr.c \
print.c pack.c dname.c res_random.c sockaddr.c \
ramqueue.c queue_backend.c queue_fsqueue.c \
- queue_fsqueue_ascii.c user_backend.c stats.c
+ queue_fsqueue_ascii.c user.c user_pwd.c stats.c
MAN= smtpd.8 smtpd.conf.5
BINDIR= /usr/sbin
diff --git a/usr.sbin/smtpd/user.c b/usr.sbin/smtpd/user.c
new file mode 100644
index 00000000000..12aad9d6b26
--- /dev/null
+++ b/usr.sbin/smtpd/user.c
@@ -0,0 +1,46 @@
+/* $OpenBSD: user.c,v 1.1 2011/12/13 22:04:35 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 <event.h>
+#include <imsg.h>
+#include <stdio.h>
+
+#include "smtpd.h"
+#include "log.h"
+
+extern struct user_backend user_backend_pwd;
+
+struct user_backend *
+user_backend_lookup(enum user_type type)
+{
+ switch (type) {
+ case USER_PWD:
+ return &user_backend_pwd;
+
+ default:
+ fatalx("invalid user backend");
+ }
+
+ return (NULL);
+}
diff --git a/usr.sbin/smtpd/user_backend.c b/usr.sbin/smtpd/user_pwd.c
index e2efa68adde..29a30055866 100644
--- a/usr.sbin/smtpd/user_backend.c
+++ b/usr.sbin/smtpd/user_pwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user_backend.c,v 1.2 2011/12/08 17:00:28 todd Exp $ */
+/* $OpenBSD: user_pwd.c,v 1.1 2011/12/13 22:04:35 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -38,29 +38,12 @@
int user_getpw_ret(struct mta_user *, struct passwd *); /* helper */
int user_getpwnam(struct mta_user *, char *);
int user_getpwuid(struct mta_user *, uid_t);
-struct user_backend *user_backend_lookup(enum user_type);
-struct user_backend user_backends[] = {
- { USER_GETPWNAM, user_getpwnam, user_getpwuid }
+struct user_backend user_backend_pwd = {
+ user_getpwnam,
+ user_getpwuid,
};
-struct user_backend *
-user_backend_lookup(enum user_type type)
-{
- u_int8_t i;
-
- for (i = 0; i < nitems(user_backends); ++i)
- if (user_backends[i].type == type)
- break;
-
- if (i == nitems(user_backends))
- fatalx("invalid user type");
-
- return &user_backends[i];
-}
-
-
-
int
user_getpw_ret(struct mta_user *u, struct passwd *pw)
{