summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/table_getpwnam.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/smtpd/table_getpwnam.c')
-rw-r--r--usr.sbin/smtpd/table_getpwnam.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/table_getpwnam.c b/usr.sbin/smtpd/table_getpwnam.c
index 83cbf797d7b..046eed56966 100644
--- a/usr.sbin/smtpd/table_getpwnam.c
+++ b/usr.sbin/smtpd/table_getpwnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_getpwnam.c,v 1.4 2015/01/20 17:37:54 deraadt Exp $ */
+/* $OpenBSD: table_getpwnam.c,v 1.5 2018/12/23 15:53:24 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -42,7 +42,7 @@ static int table_getpwnam_config(struct table *);
static int table_getpwnam_update(struct table *);
static void *table_getpwnam_open(struct table *);
static int table_getpwnam_lookup(void *, struct dict *, const char *, enum table_service,
- union lookup *);
+ char **);
static void table_getpwnam_close(void *);
struct table_backend table_backend_getpwnam = {
@@ -83,10 +83,9 @@ table_getpwnam_close(void *hdl)
static int
table_getpwnam_lookup(void *hdl, struct dict *params, const char *key, enum table_service kind,
- union lookup *lk)
+ char **dst)
{
struct passwd *pw;
- size_t s;
if (kind != K_USERINFO)
return -1;
@@ -101,19 +100,16 @@ table_getpwnam_lookup(void *hdl, struct dict *params, const char *key, enum tabl
return -1;
return 0;
}
- if (lk == NULL)
+ if (dst == NULL)
return 1;
- lk->userinfo.uid = pw->pw_uid;
- lk->userinfo.gid = pw->pw_gid;
- s = strlcpy(lk->userinfo.username, pw->pw_name,
- sizeof(lk->userinfo.username));
- if (s >= sizeof(lk->userinfo.username))
- return (-1);
- s = strlcpy(lk->userinfo.directory, pw->pw_dir,
- sizeof(lk->userinfo.directory));
- if (s >= sizeof(lk->userinfo.directory))
- return (-1);
+ if (asprintf(dst, "%d:%d:%s",
+ pw->pw_uid,
+ pw->pw_gid,
+ pw->pw_dir) == -1) {
+ *dst = NULL;
+ return -1;
+ }
return (1);
}