Skip to content

Commit

Permalink
Merge pull request #689 from yakara-ltd/sendmail
Browse files Browse the repository at this point in the history
Allow maild to send through a sendmail-like executable
  • Loading branch information
ddpbsd committed Dec 15, 2015
2 parents 822dcdc + cecdbca commit 2684c8c
Show file tree
Hide file tree
Showing 13 changed files with 522 additions and 379 deletions.
3 changes: 2 additions & 1 deletion src/agentlessd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ int main(int argc, char **argv)
ErrorExit(SETUID_ERROR, ARGV0, user, errno, strerror(errno));
}

debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(CHROOT_MSG, ARGV0, dir);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
3 changes: 2 additions & 1 deletion src/analysisd/analysisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ int main_analysisd(int argc, char **argv)
}

/* Verbose message */
debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(CHROOT_MSG, ARGV0, dir);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
12 changes: 8 additions & 4 deletions src/config/global-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,14 @@ int Read_Global(XML_NODE node, void *configp, void *mailp)
} else if (strcmp(node[i]->element, xml_smtpserver) == 0) {
#ifndef WIN32
if (Mail && (Mail->mn)) {
Mail->smtpserver = OS_GetHost(node[i]->content, 5);
if (!Mail->smtpserver) {
merror(INVALID_SMTP, __local_name, node[i]->content);
return (OS_INVALID);
if (node[i]->content[0] == '/') {
os_strdup(node[i]->content, Mail->smtpserver);
} else {
Mail->smtpserver = OS_GetHost(node[i]->content, 5);
if (!Mail->smtpserver) {
merror(INVALID_SMTP, __local_name, node[i]->content);
return (OS_INVALID);
}
}
free(Mail->smtpserver);
os_strdup(node[i]->content, Mail->smtpserver);
Expand Down
3 changes: 2 additions & 1 deletion src/error_messages/error_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@

/* Verbose messages */
#define STARTUP_MSG "%s: INFO: Started (pid: %d)."
#define PRIVSEP_MSG "%s: INFO: Chrooted to directory: %s, using user: %s"
#define CHROOT_MSG "%s: INFO: Chrooted to directory: %s"
#define PRIVSEP_MSG "%s: INFO: Using user: %s"
#define MSG_SOCKET_SIZE "%s: INFO: (unix_domain) Maximum send buffer set to: '%d'."

#define NO_SYSLOG "%s(1501): ERROR: No IP or network allowed in the access list" \
Expand Down
1 change: 1 addition & 0 deletions src/headers/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ published by the Free Software Foundation. For more details, go to \n\
#define EVENTS "/logs/archives"
#define EVENTS_DAILY "/logs/archives/archives.log"
#define ALERTS "/logs/alerts"
#define ALERTS_PATH DEFAULTDIR ALERTS
#define ALERTS_DAILY "/logs/alerts/alerts.log"
#define ALERTSJSON_DAILY "/logs/alerts/alerts.json"
#define FWLOGS "/logs/firewall"
Expand Down
3 changes: 2 additions & 1 deletion src/monitord/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ int main(int argc, char **argv)
ErrorExit(SETUID_ERROR, ARGV0, user, errno, strerror(errno));
}

debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(CHROOT_MSG, ARGV0, dir);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
3 changes: 2 additions & 1 deletion src/os_csyslogd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ int main(int argc, char **argv)
}

/* Basic start up completed */
debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(CHROOT_MSG, ARGV0, dir);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
3 changes: 2 additions & 1 deletion src/os_dbd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ int main(int argc, char **argv)
}

/* Basic start up completed */
debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(CHROOT_MSG, ARGV0, dir);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
13 changes: 8 additions & 5 deletions src/os_maild/maild.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,21 @@ int main(int argc, char **argv)
ErrorExit(SETGID_ERROR, ARGV0, group, errno, strerror(errno));
}

/* chroot */
if (Privsep_Chroot(dir) < 0) {
ErrorExit(CHROOT_ERROR, ARGV0, dir, errno, strerror(errno));
if (mail.smtpserver[0] != '/') {
/* chroot */
if (Privsep_Chroot(dir) < 0) {
ErrorExit(CHROOT_ERROR, ARGV0, dir, errno, strerror(errno));
}
nowChroot();
debug1(CHROOT_MSG, ARGV0, dir);
}
nowChroot();

/* Change user */
if (Privsep_SetUser(uid) < 0) {
ErrorExit(SETUID_ERROR, ARGV0, user, errno, strerror(errno));
}

debug1(PRIVSEP_MSG, ARGV0, dir, user);
debug1(PRIVSEP_MSG, ARGV0, user);

/* Signal manipulation */
StartSIG(ARGV0);
Expand Down
Loading

0 comments on commit 2684c8c

Please sign in to comment.