summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2001-01-03 16:04:41 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2001-01-03 16:04:41 +0000
commit994cdb8d3b777662b6dba5a039c1d9a19e82a1cb (patch)
treec62445a704a87c84eeb6224e13a2089a0cfcc923 /usr.sbin
parent1fc55dfbde4a8de5d2139db13d4cef0f0689c4d3 (diff)
-Wall cleanup.
roll a function for writing out pidfile's instead of rolling it for each program. be careful with a few more buffers
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dhcp/common/bpf.c4
-rw-r--r--usr.sbin/dhcp/common/dispatch.c5
-rw-r--r--usr.sbin/dhcp/common/dns.c10
-rw-r--r--usr.sbin/dhcp/common/errwarn.c18
-rw-r--r--usr.sbin/dhcp/common/icmp.c4
-rw-r--r--usr.sbin/dhcp/common/inet.c2
-rw-r--r--usr.sbin/dhcp/common/packet.c3
-rw-r--r--usr.sbin/dhcp/common/parse.c5
-rw-r--r--usr.sbin/dhcp/common/resolv.c7
-rw-r--r--usr.sbin/dhcp/common/upf.c7
-rw-r--r--usr.sbin/dhcp/dhclient/clparse.c7
-rw-r--r--usr.sbin/dhcp/dhclient/dhclient.c30
-rw-r--r--usr.sbin/dhcp/includes/dhcpd.h1
-rw-r--r--usr.sbin/dhcp/relay/dhcrelay.c22
-rw-r--r--usr.sbin/dhcp/server/dhcp.c3
-rw-r--r--usr.sbin/dhcp/server/dhcpd.c31
16 files changed, 52 insertions, 107 deletions
diff --git a/usr.sbin/dhcp/common/bpf.c b/usr.sbin/dhcp/common/bpf.c
index c373004a2b7..cc248613716 100644
--- a/usr.sbin/dhcp/common/bpf.c
+++ b/usr.sbin/dhcp/common/bpf.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.1 1998/08/18 03:43:25 deraadt Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.2 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -174,9 +174,7 @@ void if_register_receive (info)
{
int flag = 1;
struct bpf_version v;
- u_int32_t addr;
struct bpf_program p;
- u_int32_t bits;
/* Open a BPF device and hang it on this interface... */
info -> rfdesc = if_register_bpf (info);
diff --git a/usr.sbin/dhcp/common/dispatch.c b/usr.sbin/dhcp/common/dispatch.c
index 0d66a3cde74..5470e19e758 100644
--- a/usr.sbin/dhcp/common/dispatch.c
+++ b/usr.sbin/dhcp/common/dispatch.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dispatch.c,v 1.3 2000/07/21 00:33:53 beck Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dispatch.c,v 1.4 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -61,6 +61,7 @@ void (*bootp_packet_handler) PROTO ((struct interface_info *,
unsigned char *, int, unsigned short,
struct iaddr, struct hardware *));
+int interface_status PROTO((struct interface_info *));
static void got_one PROTO ((struct protocol *));
int quiet_interface_discovery;
@@ -80,7 +81,6 @@ void discover_interfaces (state)
struct ifreq ifr;
int i;
int sock;
- int address_count = 0;
struct subnet *subnet;
struct shared_network *share;
struct sockaddr_in foo;
@@ -515,7 +515,6 @@ static void got_one (l)
struct sockaddr_in from;
struct hardware hfrom;
struct iaddr ifrom;
- static int death = 0;
size_t result;
static unsigned char packbuf [4095]; /* Packet input buffer.
Must be as large as largest
diff --git a/usr.sbin/dhcp/common/dns.c b/usr.sbin/dhcp/common/dns.c
index c57b7d0f219..6e2d539dc38 100644
--- a/usr.sbin/dhcp/common/dns.c
+++ b/usr.sbin/dhcp/common/dns.c
@@ -48,7 +48,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dns.c,v 1.2 2000/11/10 15:33:13 provos Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dns.c,v 1.3 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -69,7 +69,6 @@ u_int16_t dns_port;
void dns_startup ()
{
struct servent *srv;
- struct sockaddr_in from;
/* Only initialize icmp once. */
if (dns_protocol_initialized)
@@ -194,8 +193,7 @@ static int nslookup (id, qname, namelen, qtype, qclass)
HEADER *hdr;
unsigned char query [512];
u_int8_t *s;
- int len;
- int i, status;
+ int status;
struct sockaddr_in *server = pick_name_server ();
if (!server)
@@ -254,8 +252,7 @@ static int zonelookup (id, qname, namelen, qclass)
HEADER *hdr;
unsigned char query [512];
u_int8_t *s, *nptr;
- int len;
- int i, status, count;
+ int status, count;
struct sockaddr_in *server = pick_name_server ();
if (!server)
@@ -321,7 +318,6 @@ void dns_packet (protocol)
{
HEADER *ns_header;
struct sockaddr_in from;
- int fl;
unsigned char buf [4096];
unsigned char nbuf [512];
unsigned char *base;
diff --git a/usr.sbin/dhcp/common/errwarn.c b/usr.sbin/dhcp/common/errwarn.c
index faa946ab6e6..d370ff612ce 100644
--- a/usr.sbin/dhcp/common/errwarn.c
+++ b/usr.sbin/dhcp/common/errwarn.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: errwarn.c,v 1.2 2000/06/29 00:25:42 deraadt Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: errwarn.c,v 1.3 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -62,7 +62,6 @@ void error (ANSI_DECL(char *) fmt, VA_DOTDOTDOT)
va_dcl
{
va_list list;
- extern int logged_in;
do_percentm (fbuf, fmt);
@@ -252,6 +251,21 @@ int parse_warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
return 0;
}
+void
+write_pidfile(file, pid)
+ char *file;
+ pid_t pid;
+{
+ FILE *fp;
+
+ (void)unlink(file);
+
+ if ((fp = fopen(file , "w")) != NULL) {
+ fprintf(fp, "%d\n", pid);
+ (void)fclose(fp);
+ }
+}
+
#ifdef NO_STRERROR
char *strerror (err)
int err;
diff --git a/usr.sbin/dhcp/common/icmp.c b/usr.sbin/dhcp/common/icmp.c
index 157c2ed3ca8..d32553a02a3 100644
--- a/usr.sbin/dhcp/common/icmp.c
+++ b/usr.sbin/dhcp/common/icmp.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: icmp.c,v 1.1 1998/08/18 03:43:26 deraadt Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: icmp.c,v 1.2 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -61,8 +61,6 @@ void icmp_startup (routep, handler)
{
struct protoent *proto;
int protocol = 1;
- struct sockaddr_in from;
- int fd;
int state;
/* Only initialize icmp once. */
diff --git a/usr.sbin/dhcp/common/inet.c b/usr.sbin/dhcp/common/inet.c
index b7c4ba43848..9f43950c3f6 100644
--- a/usr.sbin/dhcp/common/inet.c
+++ b/usr.sbin/dhcp/common/inet.c
@@ -114,7 +114,7 @@ struct iaddr broadcast_addr (subnet, mask)
struct iaddr subnet;
struct iaddr mask;
{
- int i, j, k;
+ int i;
struct iaddr rv;
if (subnet.len != mask.len) {
diff --git a/usr.sbin/dhcp/common/packet.c b/usr.sbin/dhcp/common/packet.c
index 87e08d1f5a7..0266956aec0 100644
--- a/usr.sbin/dhcp/common/packet.c
+++ b/usr.sbin/dhcp/common/packet.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.1 1998/08/18 03:43:26 deraadt Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.2 2001/01/03 16:04:38 ericj Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -250,7 +250,6 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
struct ip *ip;
struct udphdr *udp;
u_int32_t ip_len = (buf [bufix] & 0xf) << 2;
- u_int32_t sum, usum;
ip = (struct ip *)(buf + bufix);
udp = (struct udphdr *)(buf + bufix + ip_len);
diff --git a/usr.sbin/dhcp/common/parse.c b/usr.sbin/dhcp/common/parse.c
index ca955cfa263..16390797650 100644
--- a/usr.sbin/dhcp/common/parse.c
+++ b/usr.sbin/dhcp/common/parse.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: parse.c,v 1.2 2000/11/10 15:33:13 provos Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: parse.c,v 1.3 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -192,9 +192,6 @@ int parse_ip_addr (cfile, addr)
FILE *cfile;
struct iaddr *addr;
{
- char *val;
- int token;
-
addr -> len = 4;
if (parse_numeric_aggregate (cfile, addr -> iabuf,
&addr -> len, DOT, 10, 8))
diff --git a/usr.sbin/dhcp/common/resolv.c b/usr.sbin/dhcp/common/resolv.c
index 7bd79e68093..a26608e40ee 100644
--- a/usr.sbin/dhcp/common/resolv.c
+++ b/usr.sbin/dhcp/common/resolv.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: resolv.c,v 1.1 1998/08/18 03:43:27 deraadt Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: resolv.c,v 1.2 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -58,10 +58,8 @@ void read_resolv_conf (parse_time)
FILE *cfile;
char *val;
int token;
- int declaration = 0;
struct name_server *sp, *sl, *ns;
struct domain_search_list *dp, *dl, *nd;
- struct iaddr *iaddr;
new_parse (path_resolv_conf);
@@ -181,7 +179,6 @@ void read_resolv_conf (parse_time)
struct sockaddr_in *pick_name_server ()
{
- FILE *rc;
static TIME rcdate;
struct stat st;
@@ -192,8 +189,6 @@ struct sockaddr_in *pick_name_server ()
return (struct sockaddr_in *)0;
}
if (st.st_mtime > rcdate) {
- char rcbuf [512];
- char *s, *t, *u;
rcdate = cur_time + 1;
read_resolv_conf (rcdate);
diff --git a/usr.sbin/dhcp/common/upf.c b/usr.sbin/dhcp/common/upf.c
index 6b4897b742b..a83ac5bf9c6 100644
--- a/usr.sbin/dhcp/common/upf.c
+++ b/usr.sbin/dhcp/common/upf.c
@@ -1,6 +1,7 @@
/* upf.c
-
- Ultrix PacketFilter interface code.
+ *
+ * Ultrix PacketFilter interface code.
+ */
/*
* Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
@@ -42,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: upf.c,v 1.1 1998/08/18 03:43:27 deraadt Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: upf.c,v 1.2 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
diff --git a/usr.sbin/dhcp/dhclient/clparse.c b/usr.sbin/dhcp/dhclient/clparse.c
index b3406ae01cf..9f89be5f199 100644
--- a/usr.sbin/dhcp/dhclient/clparse.c
+++ b/usr.sbin/dhcp/dhclient/clparse.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: clparse.c,v 1.5 1999/12/04 00:15:08 angelos Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: clparse.c,v 1.6 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -751,10 +751,9 @@ struct option *parse_option_decl (cfile, options)
skip_to_semi (cfile);
return (struct option *)0;
}
- vendor = malloc (strlen (val) + 1);
- if (!vendor)
+ if ((vendor = (char *)malloc (strlen (val))) == NULL)
error ("no memory for vendor information.");
- strcpy (vendor, val);
+ strlcpy(vendor, val, strlen(vendor));
token = peek_token (&val, cfile);
if (token == DOT) {
/* Go ahead and take the DOT token... */
diff --git a/usr.sbin/dhcp/dhclient/dhclient.c b/usr.sbin/dhcp/dhclient/dhclient.c
index 33cd3493066..6ff387acd26 100644
--- a/usr.sbin/dhcp/dhclient/dhclient.c
+++ b/usr.sbin/dhcp/dhclient/dhclient.c
@@ -56,7 +56,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dhclient.c,v 1.12 2000/12/29 14:36:04 angelos Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.13 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -82,7 +82,6 @@ struct tree_cache *global_options [256];
char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
char *path_dhclient_db = _PATH_DHCLIENT_DB;
-char *path_dhclient_pid = _PATH_DHCLIENT_PID;
int interfaces_requested = 0;
@@ -243,7 +242,7 @@ static void usage ()
void cleanup ()
{
/* Make sure the pidfile is gone. */
- (void) unlink (path_dhclient_pid);
+ (void) unlink (_PATH_DHCLIENT_PID);
}
/* Individual States:
@@ -2073,7 +2072,7 @@ void go_daemon ()
/* Don't become a daemon if the user requested otherwise. */
if (no_daemon) {
- write_client_pid_file ();
+ write_pidfile(_PATH_DHCLIENT_PID, getpid());
return;
}
@@ -2093,28 +2092,7 @@ void go_daemon ()
/* Become session leader and get pid... */
pid = setsid ();
- write_client_pid_file ();
-}
-
-void write_client_pid_file ()
-{
- FILE *pf;
- int pfdesc;
-
- pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
-
- if (pfdesc < 0) {
- warn ("Can't create %s: %m", path_dhclient_pid);
- return;
- }
-
- pf = fdopen (pfdesc, "w");
- if (!pf)
- warn ("Can't fdopen %s: %m", path_dhclient_pid);
- else {
- fprintf (pf, "%ld\n", (long)getpid ());
- fclose (pf);
- }
+ write_pidfile(_PATH_DHCLIENT_PID, getpid());
}
int check_option (struct client_lease *l, int option) {
diff --git a/usr.sbin/dhcp/includes/dhcpd.h b/usr.sbin/dhcp/includes/dhcpd.h
index 9ec584d9aea..183ff87bf93 100644
--- a/usr.sbin/dhcp/includes/dhcpd.h
+++ b/usr.sbin/dhcp/includes/dhcpd.h
@@ -473,6 +473,7 @@ int warn PROTO ((char *, ...));
int note PROTO ((char *, ...));
int debug PROTO ((char *, ...));
int parse_warn PROTO ((char *, ...));
+void write_pidfile PROTO((char *, pid_t));
/* dhcpd.c */
extern TIME cur_time;
diff --git a/usr.sbin/dhcp/relay/dhcrelay.c b/usr.sbin/dhcp/relay/dhcrelay.c
index 12e40d2eb50..ec53a883d68 100644
--- a/usr.sbin/dhcp/relay/dhcrelay.c
+++ b/usr.sbin/dhcp/relay/dhcrelay.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dhcrelay.c,v 1.1 1998/08/18 03:43:34 deraadt Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcrelay.c,v 1.2 2001/01/03 16:04:40 ericj Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -56,8 +56,6 @@ struct tree_cache *global_options [256];
int log_perror = 1;
-char *path_dhcrelay_pid = _PATH_DHCRELAY_PID;
-
#ifdef USE_FALLBACK
struct interface_info fallback_interface;
#endif
@@ -112,7 +110,7 @@ int main (argc, argv, envp)
usage ();
}
memset (tmp, 0, sizeof *tmp);
- strcpy (tmp -> name, argv [i]);
+ strlcpy (tmp -> name, argv [i], sizeof(tmp->name));
tmp -> next = interfaces;
tmp -> flags = INTERFACE_REQUESTED;
interfaces = tmp;
@@ -194,21 +192,7 @@ int main (argc, argv, envp)
else if (pid)
exit (0);
- pfdesc = open (path_dhcrelay_pid,
- O_CREAT | O_TRUNC | O_WRONLY, 0644);
-
- if (pfdesc < 0) {
- warn ("Can't create %s: %m", path_dhcrelay_pid);
- } else {
- pf = fdopen (pfdesc, "w");
- if (!pf)
- warn ("Can't fdopen %s: %m",
- path_dhcrelay_pid);
- else {
- fprintf (pf, "%ld\n", (long)getpid ());
- fclose (pf);
- }
- }
+ write_pidfile(_PATH_DHCRELAY_PID, getpid());
close (0);
close (1);
diff --git a/usr.sbin/dhcp/server/dhcp.c b/usr.sbin/dhcp/server/dhcp.c
index 5acd78cbd1a..05e0a515be3 100644
--- a/usr.sbin/dhcp/server/dhcp.c
+++ b/usr.sbin/dhcp/server/dhcp.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dhcp.c,v 1.2 2000/07/21 00:33:54 beck Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcp.c,v 1.3 2001/01/03 16:04:40 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1183,7 +1183,6 @@ struct lease *find_lease (packet, share, ours)
struct iaddr cip;
struct host_decl *hp, *host = (struct host_decl *)0;
struct lease *fixed_lease;
- int i;
/* Try to find a host or lease that's been assigned to the
specified unique client identifier. */
diff --git a/usr.sbin/dhcp/server/dhcpd.c b/usr.sbin/dhcp/server/dhcpd.c
index 5c2dcc6b903..dcbb746c78b 100644
--- a/usr.sbin/dhcp/server/dhcpd.c
+++ b/usr.sbin/dhcp/server/dhcpd.c
@@ -42,7 +42,7 @@
#ifndef lint
static char ocopyright[] =
-"$Id: dhcpd.c,v 1.2 2000/07/21 00:33:55 beck Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
+"$Id: dhcpd.c,v 1.3 2001/01/03 16:04:40 ericj Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
#endif
static char copyright[] =
@@ -76,7 +76,6 @@ int log_perror = 1;
char *path_dhcpd_conf = _PATH_DHCPD_CONF;
char *path_dhcpd_db = _PATH_DHCPD_DB;
-char *path_dhcpd_pid = _PATH_DHCPD_PID;
int main (argc, argv, envp)
int argc;
@@ -88,7 +87,7 @@ int main (argc, argv, envp)
int cftest = 0;
#ifndef DEBUG
int pidfilewritten = 0;
- int pid;
+ pid_t pid;
char pbuf [20];
int daemon = 1;
#endif
@@ -162,7 +161,7 @@ int main (argc, argv, envp)
error ("Insufficient memory to %s %s",
"record interface", argv [i]);
memset (tmp, 0, sizeof *tmp);
- strcpy (tmp -> name, argv [i]);
+ strlcpy(tmp->name, argv[i], IFNAMSIZ);
tmp -> next = interfaces;
tmp -> flags = INTERFACE_REQUESTED;
interfaces = tmp;
@@ -220,23 +219,17 @@ int main (argc, argv, envp)
}
/* Read previous pid file. */
- if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
+ if ((i = open (_PATH_DHCPD_PID, O_RDONLY)) >= 0) {
status = read (i, pbuf, (sizeof pbuf) - 1);
close (i);
pbuf [status] = 0;
- pid = atoi (pbuf);
+ pid = (pid_t)atoi(pbuf);
/* If the previous server process is not still running,
write a new pid file immediately. */
if (pid && kill (pid, 0) < 0) {
- unlink (path_dhcpd_pid);
- if ((i = open (path_dhcpd_pid,
- O_WRONLY | O_CREAT, 0640)) >= 0) {
- sprintf (pbuf, "%d\n", (int)getpid ());
- write (i, pbuf, strlen (pbuf));
- close (i);
- pidfilewritten = 1;
- }
+ write_pidfile(_PATH_DHCPD_PID, getpid());
+ pidfilewritten = 1;
}
}
@@ -260,14 +253,8 @@ int main (argc, argv, envp)
meaning nothing is listening on the bootp port, then write
the pid file out - what's in it now is bogus anyway. */
if (!pidfilewritten) {
- unlink (path_dhcpd_pid);
- if ((i = open (path_dhcpd_pid,
- O_WRONLY | O_CREAT, 0640)) >= 0) {
- sprintf (pbuf, "%d\n", (int)getpid ());
- write (i, pbuf, strlen (pbuf));
- close (i);
- pidfilewritten = 1;
- }
+ write_pidfile(_PATH_DHCPD_PID, getpid());
+ pidfilewritten = 1;
}
#endif /* !DEBUG */