summaryrefslogtreecommitdiff
path: root/libexec/ftpd/monitor.c
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2005-07-14 14:48:48 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2005-07-14 14:48:48 +0000
commit28cfc2e4e3b35c093b61089422cf0347e7df0890 (patch)
tree2ee8d2c09004b443d3d6d34b5ef03a78cfdc0de1 /libexec/ftpd/monitor.c
parent360daa1c380cde584c12fbc861a2b4ebcda22f3a (diff)
let root create the data socket. fixes PR 4287.
ok millert@ henning@
Diffstat (limited to 'libexec/ftpd/monitor.c')
-rw-r--r--libexec/ftpd/monitor.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/libexec/ftpd/monitor.c b/libexec/ftpd/monitor.c
index 94ac4b7b319..3b7c112160b 100644
--- a/libexec/ftpd/monitor.c
+++ b/libexec/ftpd/monitor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.c,v 1.10 2005/05/24 02:24:57 moritz Exp $ */
+/* $OpenBSD: monitor.c,v 1.11 2005/07/14 14:48:47 moritz Exp $ */
/*
* Copyright (c) 2004 Moritz Jodeit <moritz@openbsd.org>
@@ -39,6 +39,7 @@
enum monitor_command {
CMD_USER,
CMD_PASS,
+ CMD_SOCKET,
CMD_BIND
};
@@ -249,7 +250,7 @@ handle_cmds(void)
{
enum monitor_command cmd;
enum auth_ret auth;
- int err, s, slavequit, serrno;
+ int err, s, slavequit, serrno, domain;
pid_t preauth_slave_pid;
size_t len;
struct sockaddr sa;
@@ -324,6 +325,25 @@ handle_cmds(void)
/* NOTREACHED */
}
break;
+ case CMD_SOCKET:
+ debugmsg("CMD_SOCKET received");
+
+ if (state != POSTAUTH)
+ fatalx("CMD_SOCKET received in invalid state");
+
+ recv_data(fd_slave, &domain, sizeof(domain));
+ if (domain != AF_INET && domain != AF_INET6)
+ fatalx("monitor received invalid addr family");
+
+ s = socket(domain, SOCK_STREAM, 0);
+ serrno = errno;
+
+ send_fd(fd_slave, s);
+ if (s == -1)
+ send_data(fd_slave, &serrno, sizeof(serrno));
+ else
+ close(s);
+ break;
case CMD_BIND:
debugmsg("CMD_BIND received");
@@ -459,6 +479,25 @@ monitor_pass(char *pass)
}
int
+monitor_socket(int domain)
+{
+ enum monitor_command cmd;
+ int s, serrno;
+
+ cmd = CMD_SOCKET;
+ send_data(fd_monitor, &cmd, sizeof(cmd));
+ send_data(fd_monitor, &domain, sizeof(domain));
+
+ s = recv_fd(fd_monitor);
+ if (s == -1) {
+ recv_data(fd_monitor, &serrno, sizeof(serrno));
+ errno = serrno;
+ }
+
+ return (s);
+}
+
+int
monitor_bind(int s, struct sockaddr *name, socklen_t namelen)
{
enum monitor_command cmd;