From: Ted Lemon Date: Sat, 29 Nov 1997 07:52:33 +0000 (+0000) Subject: Don't use sun_len on systems that don't support it X-Git-Tag: DHCP-971202~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba41d7a4eaec63fd59b4af732216ce348b0937a5;p=thirdparty%2Fdhcp.git Don't use sun_len on systems that don't support it --- diff --git a/common/sysconf.c b/common/sysconf.c index 2795d006d..f2a800475 100644 --- a/common/sysconf.c +++ b/common/sysconf.c @@ -44,7 +44,7 @@ #ifndef lint static char copyright[] = -"$Id: sysconf.c,v 1.2 1997/10/20 22:10:59 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: sysconf.c,v 1.3 1997/11/29 07:52:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -57,6 +57,7 @@ void sysconf_startup (handler) { struct sockaddr_un name; static int once; + int len; /* Only initialize sysconf once. */ if (sysconf_initialized) @@ -70,10 +71,13 @@ void sysconf_startup (handler) /* XXX for now... */ name.sun_family = PF_UNIX; strcpy (name.sun_path, "/var/run/sysconf"); - name.sun_len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); +#if defined (HAVE_SA_LEN) + name.sun_len = +#endif + len = ((sizeof name) - (sizeof name.sun_path) + + strlen (name.sun_path)); - if (connect (sysconf_fd, (struct sockaddr *)&name, name.sun_len) < 0) { + if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0) { if (!once) warn ("can't connect to sysconf socket: %m"); once = 1; diff --git a/statmsg/main.c b/statmsg/main.c index 1cd0e5d89..924b9cea5 100644 --- a/statmsg/main.c +++ b/statmsg/main.c @@ -44,7 +44,7 @@ #ifndef lint static char copyright[] = -"$Id: main.c,v 1.2 1997/10/20 22:04:23 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: main.c,v 1.3 1997/11/29 07:48:37 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -62,6 +62,7 @@ int main (argc, argv, envp) struct sysconf_header hdr; int status; char *buf; + int len; #ifdef SYSLOG_4_2 openlog ("statmsg", LOG_NDELAY); @@ -90,10 +91,13 @@ int main (argc, argv, envp) /* XXX for now... */ name.sun_family = PF_UNIX; strcpy (name.sun_path, "/var/run/sysconf"); - name.sun_len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); +#if defined (HAVE_SA_LEN) + name.sun_len = +#endif + len = ((sizeof name) - (sizeof name.sun_path) + + strlen (name.sun_path)); - if (connect (sysconf_fd, (struct sockaddr *)&name, name.sun_len) < 0) + if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0) error ("can't connect to sysconf socket: %m"); status = write (sysconf_fd, &hdr, sizeof hdr); diff --git a/sysconfd/sysconfd.c b/sysconfd/sysconfd.c index 5d59816ef..399b2fe83 100644 --- a/sysconfd/sysconfd.c +++ b/sysconfd/sysconfd.c @@ -44,7 +44,7 @@ #ifndef lint static char copyright[] = -"$Id: sysconfd.c,v 1.2 1997/10/20 22:11:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: sysconfd.c,v 1.3 1997/11/29 07:49:06 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -75,6 +75,7 @@ int main (argc, argv, envp) struct sockaddr_un name; int sysconf_fd; int pid; + int len; #ifdef SYSLOG_4_2 openlog ("sysconfd", LOG_NDELAY); @@ -95,12 +96,15 @@ int main (argc, argv, envp) /* XXX for now... */ name.sun_family = PF_UNIX; strcpy (name.sun_path, "/var/run/sysconf"); - name.sun_len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); +#if defined (HAVE_SA_LEN) + name.sun_len = +#endif + len = ((sizeof name) - (sizeof name.sun_path) + + strlen (name.sun_path)); unlink (name.sun_path); /* Bind to it... */ - if (bind (sysconf_fd, (struct sockaddr *)&name, name.sun_len) < 0) + if (bind (sysconf_fd, (struct sockaddr *)&name, len) < 0) error ("can't bind to sysconf socket: %m"); /* Listen for connections... */