aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2007-07-03 12:22:03 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2007-07-03 12:22:03 +0000
commit584d88c5d4272316a82591afbc6f0c3d59dc915d (patch)
tree91921065f355c81cab176bef5f2cd8c5c5ea1b97
parent67ecd4f3a477a0ca5b76a1694f89755df27a8679 (diff)
This commit was manufactured by cvs2svn to create tagvendor/pf/4.1
'pf-vendor-pf_openbsd_4_1'.
Notes
Notes: svn path=/vendor/pf/dist/; revision=171169 svn path=/vendor/pf/4.1/; revision=171171; tag=vendor/pf/4.1
-rw-r--r--contrib/pf/ftp-proxy/getline.c259
-rw-r--r--contrib/pf/ftp-proxy/util.c306
-rw-r--r--contrib/pf/ftp-proxy/util.h68
-rw-r--r--contrib/pf/pflogd/pidfile.c121
-rw-r--r--contrib/pf/pflogd/pidfile.h1
5 files changed, 0 insertions, 755 deletions
diff --git a/contrib/pf/ftp-proxy/getline.c b/contrib/pf/ftp-proxy/getline.c
deleted file mode 100644
index 97ffd48c6e30..000000000000
--- a/contrib/pf/ftp-proxy/getline.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* $OpenBSD: getline.c,v 1.16 2004/09/16 04:50:51 deraadt Exp $ */
-
-/*
- * Copyright (c) 1985, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ftpcmd.y 5.24 (Berkeley) 2/25/91
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/telnet.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sysexits.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include "util.h"
-
-int refill_buffer(struct csiob *iobp);
-
-/*
- * Refill the io buffer if we KNOW that data is available
- *
- * Returns 1 if any new data was obtained, 0 otherwise.
- */
-
-int
-refill_buffer(struct csiob *iobp)
-{
- int rqlen, rlen;
-
- if (!(iobp->data_available))
- return(0);
-
- if (iobp->got_eof)
- return(0);
-
- /*
- * The buffer has been entirely consumed if next_byte == io_buffer_len.
- * Otherwise, there is some still-to-be-used data in io_buffer.
- * Shuffle it to the start of the buffer.
- * Note that next_byte will never exceed io_buffer_len.
- * Also, note that we MUST use bcopy because the two regions could
- * overlap (memcpy isn't defined to work properly with overlapping
- * regions).
- */
- if (iobp->next_byte < iobp->io_buffer_len) {
- int dst_ix = 0;
- int src_ix = iobp->next_byte;
- int amount = iobp->io_buffer_len - iobp->next_byte;
-
- bcopy(&iobp->io_buffer[src_ix], &iobp->io_buffer[dst_ix],
- amount);
- iobp->io_buffer_len = amount;
- } else if (iobp->next_byte == iobp->io_buffer_len)
- iobp->io_buffer_len = 0;
- else {
- syslog(LOG_ERR, "next_byte(%d) > io_buffer_len(%d)",
- iobp->next_byte, iobp->io_buffer_len);
- exit(EX_OSERR);
- }
-
- iobp->next_byte = 0;
-
- /* don't do tiny reads, grow first if we need to */
- rqlen = iobp->io_buffer_size - iobp->io_buffer_len;
- if (rqlen <= 128) {
- unsigned char *tmp;
-
- iobp->io_buffer_size += 128;
- tmp = realloc(iobp->io_buffer, iobp->io_buffer_size);
- if (tmp == NULL) {
- syslog(LOG_INFO, "Insufficient memory");
- exit(EX_UNAVAILABLE);
- }
- iobp->io_buffer = tmp;
- rqlen = iobp->io_buffer_size - iobp->io_buffer_len;
- }
-
- /*
- * Always leave an unused byte at the end of the buffer
- * because the debug output uses that byte from time to time
- * to ensure that something that is being printed is \0 terminated.
- */
- rqlen -= 1;
-
- doread:
- rlen = read(iobp->fd, &iobp->io_buffer[iobp->io_buffer_len], rqlen);
- iobp->data_available = 0;
- switch (rlen) {
- case -1:
- if (errno == EAGAIN || errno == EINTR)
- goto doread;
- if (errno != ECONNRESET) {
- syslog(LOG_INFO, "read() failed on socket from %s (%m)",
- iobp->who);
- exit(EX_DATAERR);
- }
- /* fall through to EOF case */
- case 0:
- iobp->got_eof = 1;
- return(0);
- break;
- default:
- iobp->io_buffer_len += rlen;
- break;
- }
- return(1);
-}
-
-/*
- * telnet_getline - a hacked up version of fgets to ignore TELNET escape codes.
- *
- * This code is derived from the getline routine found in the UC Berkeley
- * ftpd code.
- *
- */
-
-int
-telnet_getline(struct csiob *iobp, struct csiob *telnet_passthrough)
-{
- unsigned char ch;
- int ix;
- unsigned char tbuf[100];
-
- iobp->line_buffer[0] = '\0';
-
- /*
- * If the buffer is empty then refill it right away.
- */
- if (iobp->next_byte == iobp->io_buffer_len)
- if (!refill_buffer(iobp))
- return(0);
-
- /*
- * Is there a telnet command in the buffer?
- */
- ch = iobp->io_buffer[iobp->next_byte];
- if (ch == IAC) {
- /*
- * Yes - buffer must have at least three bytes in it
- */
- if (iobp->io_buffer_len - iobp->next_byte < 3) {
- if (!refill_buffer(iobp))
- return(0);
- if (iobp->io_buffer_len - iobp->next_byte < 3)
- return(0);
- }
-
- iobp->next_byte++;
- ch = iobp->io_buffer[iobp->next_byte++];
-
- switch (ch) {
- case WILL:
- case WONT:
- case DO:
- case DONT:
- tbuf[0] = IAC;
- tbuf[1] = ch;
- tbuf[2] = iobp->io_buffer[iobp->next_byte++];
- (void)send(telnet_passthrough->fd, tbuf, 3,
- telnet_passthrough->send_oob_flags);
- break;
- case IAC:
- break;
- default:
- break;
- }
- return(1);
- } else {
- int clen;
-
- /*
- * Is there a newline in the buffer?
- */
- for (ix = iobp->next_byte; ix < iobp->io_buffer_len;
- ix += 1) {
- if (iobp->io_buffer[ix] == '\n')
- break;
- if (iobp->io_buffer[ix] == '\0') {
- syslog(LOG_INFO,
- "got NUL byte from %s - bye!",
- iobp->who);
- exit(EX_DATAERR);
- }
- }
-
- if (ix == iobp->io_buffer_len) {
- if (!refill_buffer(iobp))
- return(0);
- /*
- * Empty line returned
- * will try again soon!
- */
- return(1);
- }
-
- /*
- * Expand the line buffer if it isn't big enough. We
- * use a fudge factor of 5 rather than trying to
- * figure out exactly how to account for the '\0 \r\n' and
- * such. The correct fudge factor is 0, 1 or 2 but
- * anything higher also works. We also grow it by a
- * bunch to avoid having to do this often. Yes this is
- * nasty.
- */
- if (ix - iobp->next_byte > iobp->line_buffer_size - 5) {
- unsigned char *tmp;
-
- iobp->line_buffer_size = 256 + ix - iobp->next_byte;
- tmp = realloc(iobp->line_buffer,
- iobp->line_buffer_size);
- if (tmp == NULL) {
- syslog(LOG_INFO, "Insufficient memory");
- exit(EX_UNAVAILABLE);
- }
- iobp->line_buffer = tmp;
- }
-
- /* +1 is for the newline */
- clen = (ix+1) - iobp->next_byte;
- memcpy(iobp->line_buffer, &iobp->io_buffer[iobp->next_byte],
- clen);
- iobp->next_byte += clen;
- iobp->line_buffer[clen] = '\0';
- return(1);
- }
-}
diff --git a/contrib/pf/ftp-proxy/util.c b/contrib/pf/ftp-proxy/util.c
deleted file mode 100644
index 61c9f1f1bc8a..000000000000
--- a/contrib/pf/ftp-proxy/util.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/* $OpenBSD: util.c,v 1.19 2004/07/06 19:49:11 dhartmei Exp $ */
-
-/*
- * Copyright (c) 1996-2001
- * Obtuse Systems Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Obtuse Systems nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OBTUSE SYSTEMS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OBTUSE
- * SYSTEMS CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <net/if.h>
-#include <net/pfvar.h>
-
-#include <arpa/inet.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sysexits.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include "util.h"
-
-extern int ReverseMode;
-
-int Debug_Level;
-int Use_Rdns;
-in_addr_t Bind_Addr = INADDR_NONE;
-
-void debuglog(int debug_level, const char *fmt, ...);
-
-void
-debuglog(int debug_level, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
-
- if (Debug_Level >= debug_level)
- vsyslog(LOG_DEBUG, fmt, ap);
- va_end(ap);
-}
-
-int
-get_proxy_env(int connected_fd, struct sockaddr_in *real_server_sa_ptr,
- struct sockaddr_in *client_sa_ptr, struct sockaddr_in *proxy_sa_ptr)
-{
- struct pfioc_natlook natlook;
- socklen_t slen;
- int fd;
-
- slen = sizeof(*proxy_sa_ptr);
- if (getsockname(connected_fd, (struct sockaddr *)proxy_sa_ptr,
- &slen) != 0) {
- syslog(LOG_ERR, "getsockname() failed (%m)");
- return(-1);
- }
- slen = sizeof(*client_sa_ptr);
- if (getpeername(connected_fd, (struct sockaddr *)client_sa_ptr,
- &slen) != 0) {
- syslog(LOG_ERR, "getpeername() failed (%m)");
- return(-1);
- }
-
- if (ReverseMode)
- return(0);
-
- /*
- * Build up the pf natlook structure.
- * Just for IPv4 right now
- */
- memset((void *)&natlook, 0, sizeof(natlook));
- natlook.af = AF_INET;
- natlook.saddr.addr32[0] = client_sa_ptr->sin_addr.s_addr;
- natlook.daddr.addr32[0] = proxy_sa_ptr->sin_addr.s_addr;
- natlook.proto = IPPROTO_TCP;
- natlook.sport = client_sa_ptr->sin_port;
- natlook.dport = proxy_sa_ptr->sin_port;
- natlook.direction = PF_OUT;
-
- /*
- * Open the pf device and lookup the mapping pair to find
- * the original address we were supposed to connect to.
- */
- fd = open("/dev/pf", O_RDWR);
- if (fd == -1) {
- syslog(LOG_ERR, "cannot open /dev/pf (%m)");
- exit(EX_UNAVAILABLE);
- }
-
- if (ioctl(fd, DIOCNATLOOK, &natlook) == -1) {
- syslog(LOG_INFO,
- "pf nat lookup failed %s:%hu (%m)",
- inet_ntoa(client_sa_ptr->sin_addr),
- ntohs(client_sa_ptr->sin_port));
- close(fd);
- return(-1);
- }
- close(fd);
-
- /*
- * Now jam the original address and port back into the into
- * destination sockaddr_in for the proxy to deal with.
- */
- memset((void *)real_server_sa_ptr, 0, sizeof(struct sockaddr_in));
- real_server_sa_ptr->sin_port = natlook.rdport;
- real_server_sa_ptr->sin_addr.s_addr = natlook.rdaddr.addr32[0];
- real_server_sa_ptr->sin_len = sizeof(struct sockaddr_in);
- real_server_sa_ptr->sin_family = AF_INET;
- return(0);
-}
-
-
-/*
- * Transfer one unit of data across a pair of sockets
- *
- * A unit of data is as much as we get with a single read(2) call.
- */
-int
-xfer_data(const char *what_read,int from_fd, int to_fd, struct in_addr from,
- struct in_addr to)
-{
- int rlen, offset, xerrno, mark, flags = 0;
- char tbuf[4096];
-
- /*
- * Are we at the OOB mark?
- */
- if (ioctl(from_fd, SIOCATMARK, &mark) < 0) {
- xerrno = errno;
- syslog(LOG_ERR, "cannot ioctl(SIOCATMARK) socket from %s (%m)",
- what_read);
- errno = xerrno;
- return(-1);
- }
- if (mark)
- flags = MSG_OOB; /* Yes - at the OOB mark */
-
-snarf:
- rlen = recv(from_fd, tbuf, sizeof(tbuf), flags);
- if (rlen == -1 && flags == MSG_OOB && errno == EINVAL) {
- /* OOB didn't work */
- flags = 0;
- rlen = recv(from_fd, tbuf, sizeof(tbuf), flags);
- }
- if (rlen == 0) {
- debuglog(3, "EOF on read socket");
- return(0);
- } else if (rlen == -1) {
- if (errno == EAGAIN || errno == EINTR)
- goto snarf;
- xerrno = errno;
- syslog(LOG_ERR, "xfer_data (%s): failed (%m) with flags 0%o",
- what_read, flags);
- errno = xerrno;
- return(-1);
- } else {
- offset = 0;
- debuglog(3, "got %d bytes from socket", rlen);
-
- while (offset < rlen) {
- int wlen;
- fling:
- wlen = send(to_fd, &tbuf[offset], rlen - offset,
- flags);
- if (wlen == 0) {
- debuglog(3, "zero-length write");
- goto fling;
- } else if (wlen == -1) {
- if (errno == EAGAIN || errno == EINTR)
- goto fling;
- xerrno = errno;
- syslog(LOG_INFO, "write failed (%m)");
- errno = xerrno;
- return(-1);
- } else {
- debuglog(3, "wrote %d bytes to socket",wlen);
- offset += wlen;
- }
- }
- return(offset);
- }
-}
-
-/*
- * get_backchannel_socket gets us a socket bound somewhere in a
- * particular range of ports
- */
-int
-get_backchannel_socket(int type, int min_port, int max_port, int start_port,
- int direction, struct sockaddr_in *sap)
-{
- int count;
-
- /*
- * Make sure that direction is 'defined' and that min_port is not
- * greater than max_port.
- */
- if (direction != -1)
- direction = 1;
-
- /* by default we go up by one port until we find one */
- if (min_port > max_port) {
- errno = EINVAL;
- return(-1);
- }
-
- count = 1 + max_port - min_port;
-
- /*
- * Pick a port we can bind to from within the range we want.
- * If the caller specifies -1 as the starting port number then
- * we pick one somewhere in the range to try.
- * This is an optimization intended to speedup port selection and
- * has NOTHING to do with security.
- */
- if (start_port == -1)
- start_port = (arc4random() % count) + min_port;
-
- if (start_port < min_port || start_port > max_port) {
- errno = EINVAL;
- return(-1);
- }
-
- while (count-- > 0) {
- struct sockaddr_in sa;
- int one, fd;
-
- fd = socket(AF_INET, type, 0);
-
- bzero(&sa, sizeof sa);
- sa.sin_family = AF_INET;
- if (Bind_Addr == INADDR_NONE)
- if (sap == NULL)
- sa.sin_addr.s_addr = INADDR_ANY;
- else
- sa.sin_addr.s_addr = sap->sin_addr.s_addr;
- else
- sa.sin_addr.s_addr = Bind_Addr;
-
- /*
- * Indicate that we want to reuse a port if it happens that the
- * port in question was a listen port recently.
- */
- one = 1;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one,
- sizeof(one)) == -1)
- return(-1);
-
- sa.sin_port = htons(start_port);
-
- if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) == 0) {
- if (sap != NULL)
- *sap = sa;
- return(fd);
- }
-
- if (errno != EADDRINUSE)
- return(-1);
-
- /* if it's in use, try the next port */
- close(fd);
-
- start_port += direction;
- if (start_port < min_port)
- start_port = max_port;
- else if (start_port > max_port)
- start_port = min_port;
- }
- errno = EAGAIN;
- return(-1);
-}
diff --git a/contrib/pf/ftp-proxy/util.h b/contrib/pf/ftp-proxy/util.h
deleted file mode 100644
index ce1e9159393c..000000000000
--- a/contrib/pf/ftp-proxy/util.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $OpenBSD: util.h,v 1.5 2005/02/24 15:49:08 dhartmei Exp $ */
-
-/*
- * Copyright (c) 1996-2001
- * Obtuse Systems Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the Obtuse Systems nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL OBTUSE SYSTEMS CORPORATION OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-struct proxy_channel {
- int pc_to_fd, pc_from_fd;
- int pc_alive;
- int pc_nextbyte;
- int pc_flags;
- int pc_length;
- int pc_size;
- struct sockaddr_in pc_from_sa, pc_to_sa;
- int (*pc_filter)( void ** databuf, int datalen);
- char *pc_buffer;
-};
-
-struct csiob {
- int fd;
- int line_buffer_size, io_buffer_size, io_buffer_len, next_byte;
- unsigned char *io_buffer, *line_buffer;
- struct sockaddr_in sa, real_sa;
- const char *who;
- char alive, got_eof, data_available;
- int send_oob_flags;
-};
-
-extern int telnet_getline(struct csiob *iobp,
- struct csiob *telnet_passthrough);
-
-extern int get_proxy_env(int fd, struct sockaddr_in *server_sa_ptr,
- struct sockaddr_in *client_sa_ptr, struct sockaddr_in *proxy_sa_ptr);
-
-extern int get_backchannel_socket(int type, int min_port, int max_port,
- int start_port, int direction, struct sockaddr_in *sap);
-
-extern int xfer_data(const char *what_read, int from_fd, int to_fd,
- struct in_addr from, struct in_addr to);
-
-extern char *ProgName;
-
-
diff --git a/contrib/pf/pflogd/pidfile.c b/contrib/pf/pflogd/pidfile.c
deleted file mode 100644
index 61eca262efe2..000000000000
--- a/contrib/pf/pflogd/pidfile.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* $OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $ */
-/* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <errno.h>
-#include <paths.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#if defined(__FreeBSD__)
-#include "pidfile.h"
-#else
-#include <util.h>
-#endif
-
-static char *pidfile_path;
-static pid_t pidfile_pid;
-
-static void pidfile_cleanup(void);
-
-extern char *__progname;
-
-int
-pidfile(const char *basename)
-{
- FILE *f;
- int save_errno;
- pid_t pid;
-
- if (basename == NULL)
- basename = __progname;
-
- if (pidfile_path != NULL) {
- free(pidfile_path);
- pidfile_path = NULL;
- }
-
- /* _PATH_VARRUN includes trailing / */
- (void) asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename);
- if (pidfile_path == NULL)
- return (-1);
-
- if ((f = fopen(pidfile_path, "w")) == NULL) {
- save_errno = errno;
- free(pidfile_path);
- pidfile_path = NULL;
- errno = save_errno;
- return (-1);
- }
-
- pid = getpid();
- if (fprintf(f, "%ld\n", (long)pid) <= 0 || fclose(f) != 0) {
- save_errno = errno;
- (void) unlink(pidfile_path);
- free(pidfile_path);
- pidfile_path = NULL;
- errno = save_errno;
- return (-1);
- }
-
- pidfile_pid = pid;
- if (atexit(pidfile_cleanup) < 0) {
- save_errno = errno;
- (void) unlink(pidfile_path);
- free(pidfile_path);
- pidfile_path = NULL;
- pidfile_pid = 0;
- errno = save_errno;
- return (-1);
- }
-
- return (0);
-}
-
-static void
-pidfile_cleanup(void)
-{
-
- if (pidfile_path != NULL && pidfile_pid == getpid())
- (void) unlink(pidfile_path);
-}
diff --git a/contrib/pf/pflogd/pidfile.h b/contrib/pf/pflogd/pidfile.h
deleted file mode 100644
index 542325fdcdad..000000000000
--- a/contrib/pf/pflogd/pidfile.h
+++ /dev/null
@@ -1 +0,0 @@
-int pidfile(const char *);