GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/smtpd/smtpd/../delivery_mbox.c Lines: 0 10 0.0 %
Date: 2017-11-13 Branches: 0 2 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: delivery_mbox.c,v 1.12 2015/12/22 07:54:57 sunil Exp $	*/
2
3
/*
4
 * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <sys/types.h>
20
#include <sys/queue.h>
21
#include <sys/tree.h>
22
#include <sys/socket.h>
23
24
#include <ctype.h>
25
#include <err.h>
26
#include <event.h>
27
#include <fcntl.h>
28
#include <imsg.h>
29
#include <paths.h>
30
#include <stdio.h>
31
#include <stdlib.h>
32
#include <string.h>
33
#include <unistd.h>
34
#include <limits.h>
35
36
#include "smtpd.h"
37
#include "log.h"
38
39
#define	PATH_MAILLOCAL	"/usr/libexec/mail.local"
40
41
extern char	**environ;
42
43
/* mbox backend */
44
static void delivery_mbox_open(struct deliver *);
45
46
struct delivery_backend delivery_backend_mbox = {
47
	1, delivery_mbox_open
48
};
49
50
51
static void
52
delivery_mbox_open(struct deliver *deliver)
53
{
54
	char	*environ_new[2];
55
56
	environ_new[0] = "PATH=" _PATH_DEFPATH;
57
	environ_new[1] = (char *)NULL;
58
	environ = environ_new;
59
60
	if (deliver->from[0] == '\0')
61
		(void)strlcpy(deliver->from, "MAILER-DAEMON",
62
		    sizeof deliver->from);
63
	execle(PATH_MAILLOCAL, PATH_MAILLOCAL, "-f", deliver->from,
64
	    deliver->to, (char *)NULL, environ_new);
65
	perror("execle");
66
	_exit(1);
67
}