<commit_before>/* Copyright (C) 2006 <NAME> */

#include "lib.h"
#include "deliver.h"
#include "smtp-client.h"

#include <unistd.h>
#include <sys/wait.h>

struct smtp_client {
	FILE *f;
	pid_t pid;
};

static struct smtp_client *smtp_client_devnull(FILE **file_r)
{
	struct smtp_client *client;

	client = i_new(struct smtp_client, 1);
	client->f = *file_r = fopen("/dev/null", "w");
	if (client->f == NULL)
		i_fatal("fopen() failed: %m");
	client->pid = (pid_t)-1;
	return client;
}

static void __attr_noreturn__
smtp_client_run_sendmail(const char *destination,
			 const char *return_path, int fd)
{
	const char *argv[7];

	argv[0] = deliver_set->sendmail_path;
	argv[1] = "-i"; /* ignore dots */
	argv[2] = "-f";
	argv[3] = return_path != NULL && *return_path != '\0' ?
		return_path : "<>";
	argv[4] = "--";
	argv[5] = destination;
	argv[6] = NULL;

	if (dup2(fd, STDIN_FILENO) < 0)
		i_fatal("dup2() failed: %m");

	deliver_env_clean();

	(void)execv(deliver_set->sendmail_path, (char **)argv);
	i_fatal("execv(%s) failed: %m", deliver_set->sendmail_path);
}
<commit_msg>If sendmail_path was set in config file, it was cleared just before trying to execute it.<commit_after>/* Copyright (C) 2006 <NAME> */

#include "lib.h"
#include "deliver.h"
#include "smtp-client.h"

#include <unistd.h>
#include <sys/wait.h>

struct smtp_client {
	FILE *f;
	pid_t pid;
};

static struct smtp_client *smtp_client_devnull(FILE **file_r)
{
	struct smtp_client *client;

	client = i_new(struct smtp_client, 1);
	client->f = *file_r = fopen("/dev/null", "w");
	if (client->f == NULL)
		i_fatal("fopen() failed: %m");
	client->pid = (pid_t)-1;
	return client;
}

static void __attr_noreturn__
smtp_client_run_sendmail(const char *destination,
			 const char *return_path, int fd)
{
	const char *argv[7], *sendmail_path;

	/* deliver_set's contents may point to environment variables.
	   deliver_env_clean() cleans them up, so they have to be copied. */
	sendmail_path = t_strdup(deliver_set->sendmail_path);

	argv[0] = sendmail_path;
	argv[1] = "-i"; /* ignore dots */
	argv[2] = "-f";
	argv[3] = return_path != NULL && *return_path != '\0' ?
		return_path : "<>";
	argv[4] = "--";
	argv[5] = destination;
	argv[6] = NULL;

	if (dup2(fd, STDIN_FILENO) < 0)
		i_fatal("dup2() failed: %m");

	deliver_env_clean();

	(void)execv(sendmail_path, (char **)argv);
	i_fatal("execv(%s) failed: %m", sendmail_path);
}

{'fraction_non_alphanumeric': 0.1775, 'fraction_numerical': 0.015, 'mean_word_length': 4.622950819672131, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5077990', 'n_tokens_mistral': 1015, 'n_tokens_neox': 963, 'n_words': 225}