1/* $OpenBSD: privsep.c,v 1.8 2004/03/14 19:17:05 otto Exp $ */ 2 3/* 4 * Copyright (c) 2003 Can Erkin Acar 5 * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ |
19 20#include <sys/cdefs.h> 21__FBSDID("$FreeBSD: head/contrib/pf/pflogd/privsep.c 130617 2004-06-16 23:39:33Z mlaier $"); 22 23#include <sys/param.h> |
24#include <sys/time.h> 25#include <sys/socket.h> |
26 27#include <net/if.h> 28#include <net/bpf.h> 29 30#include <err.h> 31#include <errno.h> 32#include <fcntl.h> |
33#include <pwd.h> 34#include <signal.h> 35#include <stdio.h> 36#include <stdlib.h> 37#include <string.h> |
38#include <pcap.h> 39#include <pcap-int.h> |
40#include <syslog.h> 41#include <unistd.h> 42#include "pflogd.h" 43 44enum cmd_types { 45 PRIV_SET_SNAPLEN, /* set the snaplength */ 46 PRIV_OPEN_LOG /* open logfile for appending */ 47}; --- 19 unchanged lines hidden (view full) --- 67/* based on syslogd privsep */ 68int 69priv_init(void) 70{ 71 int i, fd, socks[2], cmd; 72 int snaplen, ret; 73 struct passwd *pw; 74 |
75#ifdef __FreeBSD__ 76 for (i = 1; i < NSIG; i++) 77#else |
78 for (i = 1; i < _NSIG; i++) |
79#endif |
80 signal(i, SIG_DFL); 81 82 /* Create sockets */ 83 if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, socks) == -1) 84 err(1, "socketpair() failed"); 85 86 pw = getpwnam("_pflogd"); 87 if (pw == NULL) --- 224 unchanged lines hidden --- |