SHA256
1
0
forked from pool/dhcp

- Initially switched to use systemd service files under systemd

and enabled Restart=on-abort (fate#315133).
- Update to ISC dhcp-4.2.6 release. See RELNOTES file for the
  complete list of changes -- digest of fixes not in dhcp-4.2.5:
  - Tidy up receive packet processing.
    Thanks to Brad Plank of GTA for reporting the issue and
    suggesting a possible patch. [ISC-Bugs #34447]
  - Fix the socket handling for DHCPv6 clients to allow multiple
    instances of a client on a single machine to work properly.
    Previously only one client would receive the packets.
    Thanks to Jiri Popelka at Red Hat for the bug report and a
    potential patch. [ISC-Bugs #34784]
  - Added support for gentle shutdown after signal is received.
    [ISC-Bugs #32692] [ISC-Bugs 34945]
  - Enhance the DHCPv6 server logging to include the addresses
    that are assigned to the clients.  This can be enabled by
    defining LOG_V6_ADDRESSES in site.h. [ISC-Bugs #26377]
  - Fix an operation in the DDNS code to be a bitwise instead
    of logical or. [ISC-Bugs #35138]
- Merged patches for dhcp-4.2.6 version to apply without fuzzy,
  prepended patch number prefixes to match spec file patch nr,
  added patch markup tags / bug numbers to the spec file.
- Applied contrib-lease-path pach to contrib.tar.gz
  [- contrib-lease-path.diff]
- Changed to require automake and use its config.sub and guess
  files instead of maintaining a patch.
  [- config-guess-sub-update.patch]
- Enabled to log DHCPv6 addresses assigned by server to clients
  [+ 0016-server-log-DHCPv6-addresses-assigned-to-clients.patch]
- Cleaned up documentation, rpmlint adjustments.

OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=121
This commit is contained in:
Marius Tomaschewski 2014-02-10 18:14:12 +00:00 committed by Git OBS Bridge
parent f1f840f0e7
commit d059c507b7
44 changed files with 3627 additions and 4360 deletions

View File

@ -1,8 +1,17 @@
From b6ba495cc0b6f578a5cc444af39cab424f63d996 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 09:50:30 +0200
Subject: [PATCH] dhcp-4.1.1-default-paths
---
includes/dhcpd.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 90f8a73..6fa5b9e 100644
index b0f73fb..5830bdb 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -1285,11 +1285,11 @@ typedef unsigned char option_mask [16];
@@ -1420,11 +1420,11 @@ typedef unsigned char option_mask [16];
#endif /* DEBUG */
#ifndef _PATH_DHCPD_DB
@ -16,7 +25,7 @@ index 90f8a73..6fa5b9e 100644
#endif
#ifndef _PATH_DHCPD_PID
@@ -1319,11 +1319,11 @@ typedef unsigned char option_mask [16];
@@ -1454,11 +1454,11 @@ typedef unsigned char option_mask [16];
#endif
#ifndef _PATH_DHCLIENT_DB
@ -30,3 +39,6 @@ index 90f8a73..6fa5b9e 100644
#endif
#ifndef _PATH_RESOLV_CONF
--
1.8.4

View File

@ -1,8 +1,17 @@
From 1561b8cb9bacabc5e6064b84ba7a187bfb97d0ad Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 09:53:00 +0200
Subject: [PATCH] dhcp-4.1.1-paranoia
---
server/dhcpd.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/server/dhcpd.c b/server/dhcpd.c
index f0cacb6..6e30d33 100644
index 7dc7dd2..b4c1bef 100644
--- a/server/dhcpd.c
+++ b/server/dhcpd.c
@@ -210,7 +210,11 @@ static void omapi_listener_start (void *foo)
@@ -207,7 +207,11 @@ static void omapi_listener_start (void *foo)
#if defined (PARANOIA)
/* to be used in one of two possible scenarios */
static void setup_chroot (char *chroot_dir) {
@ -15,7 +24,7 @@ index f0cacb6..6e30d33 100644
log_fatal ("you must be root to use chroot");
if (chroot(chroot_dir)) {
@@ -402,7 +406,7 @@ main(int argc, char **argv) {
@@ -413,7 +417,7 @@ main(int argc, char **argv) {
log_fatal ("Insufficient memory to %s %s: %s",
"record interface", argv [i],
isc_result_totext (result));
@ -24,7 +33,7 @@ index f0cacb6..6e30d33 100644
if (interfaces) {
interface_reference (&tmp -> next,
interfaces, MDL);
@@ -487,7 +491,15 @@ main(int argc, char **argv) {
@@ -499,7 +503,15 @@ main(int argc, char **argv) {
if (set_user) {
struct passwd *tmp_pwd;
@ -41,7 +50,7 @@ index f0cacb6..6e30d33 100644
log_fatal ("you must be root to set user");
if (!(tmp_pwd = getpwnam(set_user)))
@@ -505,7 +517,10 @@ main(int argc, char **argv) {
@@ -517,7 +529,10 @@ main(int argc, char **argv) {
#define group real_group
struct group *tmp_grp;
@ -53,7 +62,7 @@ index f0cacb6..6e30d33 100644
log_fatal ("you must be root to set group");
if (!(tmp_grp = getgrnam(set_group)))
@@ -751,6 +766,7 @@ main(int argc, char **argv) {
@@ -771,6 +786,7 @@ main(int argc, char **argv) {
/* change uid to the specified one */
if (set_gid) {
@ -61,3 +70,6 @@ index f0cacb6..6e30d33 100644
if (setgroups (0, (void *)0))
log_fatal ("setgroups: %m");
if (setgid (set_gid))
--
1.8.4

View File

@ -1,8 +1,18 @@
From 3c393c65c158048f55017e48aedcc304c9ebd075 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 10:01:04 +0200
Subject: [PATCH] dhcp-4.2.2-man-includes
---
dhcpctl/dhcpctl.3 | 4 ++--
omapip/omapi.3 | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dhcpctl/dhcpctl.3 b/dhcpctl/dhcpctl.3
index 9aa1851..7497612 100644
index ae42a71..d699f4a 100644
--- a/dhcpctl/dhcpctl.3
+++ b/dhcpctl/dhcpctl.3
@@ -430,8 +430,8 @@ that most error checking has been ommitted for brevity.
@@ -430,8 +430,8 @@ that most error checking has been omitted for brevity.
#include <netinet/in.h>
#include <arpa/inet.h>
@ -14,7 +24,7 @@ index 9aa1851..7497612 100644
int main (int argc, char **argv) {
dhcpctl_data_string ipaddrstring = NULL;
diff --git a/omapip/omapi.3 b/omapip/omapi.3
index 4868d7c..23389b0 100644
index 8fa8105..a616fd3 100644
--- a/omapip/omapi.3
+++ b/omapip/omapi.3
@@ -88,7 +88,7 @@ the lease ends.
@ -26,3 +36,6 @@ index 4868d7c..23389b0 100644
#include <dhcpctl/dhcpctl.h>
int main (int argc, char **argv) {
--
1.8.4

View File

@ -1,8 +1,17 @@
From 1638d046d2a914164e19c6244df5b4deadaf6938 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 10:06:01 +0200
Subject: [PATCH] dhcp-4.1.1-tmpfile
---
server/db.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/server/db.c b/server/db.c
index a4e1558..1d5f5b0 100644
index 82f3841..c2630ea 100644
--- a/server/db.c
+++ b/server/db.c
@@ -1059,21 +1059,16 @@ int new_lease_file ()
@@ -1088,21 +1088,16 @@ int new_lease_file ()
db_validity = lease_file_is_corrupt;
@ -30,3 +39,6 @@ index a4e1558..1d5f5b0 100644
if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
log_error("Can't fdopen new lease file: %m");
close(db_fd);
--
1.8.4

View File

@ -1,8 +1,17 @@
From 92a611b4b05ef420e81c2c78f8c1eb3b38c31627 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 10:28:04 +0200
Subject: [PATCH] dhcp-4.1.1-dhclient-exec-filedes
---
client/dhclient.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/client/dhclient.c b/client/dhclient.c
index 69dcc91..15c31a5 100644
index 52121be..203d3d1 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -3173,6 +3173,12 @@ int script_go (client)
@@ -3369,6 +3369,12 @@ int script_go (client)
*/
if (leaseFile != NULL)
fclose(leaseFile);
@ -15,3 +24,6 @@ index 69dcc91..15c31a5 100644
execve (scriptName, argv, envp);
log_error ("execve (%s, ...): %m", scriptName);
exit (0);
--
1.8.4

View File

@ -1,15 +1,15 @@
From ebc6e17683e4a4d7f2316c1ea46d680955df7d26 Mon Sep 17 00:00:00 2001
From 94cff63e89710f5e67944d57d76edaec968fe139 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 10:49:07 +0200
Subject: [PATCH] dhcp-4.2.5-dhclient-send-hostname-rml
---
client/dhclient.8 | 8 ++++++++
client/dhclient.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 Dateien geändert, 56 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
client/dhclient.8 | 8 ++++++++
client/dhclient.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/client/dhclient.8 b/client/dhclient.8
index 3539591..4a7647a 100644
index 0aa1119..bc34c6a 100644
--- a/client/dhclient.8
+++ b/client/dhclient.8
@@ -60,6 +60,10 @@ dhclient - Dynamic Host Configuration Protocol Client
@ -35,7 +35,7 @@ index 3539591..4a7647a 100644
.\" mockup relay
Set the giaddr field of all packets to the \fIrelay\fR IP address
diff --git a/client/dhclient.c b/client/dhclient.c
index 0c1ed24..de93499 100644
index 203d3d1..b7a14fe 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -119,6 +119,7 @@ main(int argc, char **argv) {
@ -69,7 +69,7 @@ index 0c1ed24..de93499 100644
} else if (!strcmp(argv[i], "-nw")) {
nowait = 1;
} else if (!strcmp(argv[i], "-n")) {
@@ -484,6 +501,35 @@ main(int argc, char **argv) {
@@ -491,6 +508,35 @@ main(int argc, char **argv) {
/* Parse the dhclient.conf file. */
read_client_conf();
@ -105,7 +105,7 @@ index 0c1ed24..de93499 100644
/* Parse the lease database. */
read_client_leases();
@@ -708,9 +754,9 @@ static void usage()
@@ -719,9 +765,9 @@ static void usage()
log_fatal("Usage: dhclient "
#ifdef DHCPv6
@ -118,5 +118,5 @@ index 0c1ed24..de93499 100644
" [-s server-addr] [-cf config-file] "
"[-lf lease-file]\n"
--
1.7.10.4
1.8.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
From a9d31f9f8356fba3fc49ead5afdfd8cca5a4a535 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Tue, 12 Jun 2012 08:54:23 +0200
Subject: [PATCH] dhcp-4.1.1-P1-lpf-bind-msg-fix
---
common/lpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/lpf.c b/common/lpf.c
index 44f5f54..82c8b76 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -94,7 +94,7 @@ int if_register_lpf (info)
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EINVAL) {
- log_error ("socket: %m - make sure");
+ log_error ("bind: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",
--
1.8.4

View File

@ -1,21 +1,36 @@
From 16e50fd8fbd606ba04ac814f9fff883ecb9e110c Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Fri, 18 Feb 2011 13:18:32 +0100
Subject: [PATCH] dhcp-4.2.6-xen-checksum
---
common/bpf.c | 2 +-
common/dlpi.c | 2 +-
common/lpf.c | 84 ++++++++++++++++++++++++++++++++++++++++++--------------
common/nit.c | 2 +-
common/packet.c | 4 +--
common/upf.c | 2 +-
includes/dhcpd.h | 2 +-
7 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/common/bpf.c b/common/bpf.c
index b0ef657..8bd5727 100644
index d6d6013..559b414 100644
--- a/common/bpf.c
+++ b/common/bpf.c
@@ -485,7 +485,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
offset = decode_udp_ip_header (interface,
interface -> rbuf,
interface -> rbuf_offset,
@@ -480,7 +480,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header(interface, interface->rbuf,
interface->rbuf_offset,
- from, hdr.bh_caplen, &paylen);
+ from, hdr.bh_caplen, &paylen, 0);
+ from, hdr.bh_caplen, &paylen, 0);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0) {
diff --git a/common/dlpi.c b/common/dlpi.c
index 8f2c73d..b9eb1d3 100644
index 391fb91..14e95d2 100644
--- a/common/dlpi.c
+++ b/common/dlpi.c
@@ -693,7 +693,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
@@ -691,7 +691,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
length -= offset;
#endif
offset = decode_udp_ip_header (interface, dbuf, bufix,
@ -25,10 +40,10 @@ index 8f2c73d..b9eb1d3 100644
/*
* If the IP or UDP checksum was bad, skip the packet...
diff --git a/common/lpf.c b/common/lpf.c
index 16eecc9..4bdb0f1 100644
index 82c8b76..6639809 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -29,19 +29,33 @@
@@ -30,19 +30,33 @@
#include "dhcpd.h"
#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
#include <sys/ioctl.h>
@ -63,7 +78,7 @@ index 16eecc9..4bdb0f1 100644
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
@@ -67,10 +81,14 @@ int if_register_lpf (info)
@@ -68,10 +82,14 @@ int if_register_lpf (info)
struct interface_info *info;
{
int sock;
@ -80,7 +95,7 @@ index 16eecc9..4bdb0f1 100644
htons((short)ETH_P_ALL))) < 0) {
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
@@ -85,11 +103,16 @@ int if_register_lpf (info)
@@ -86,11 +104,16 @@ int if_register_lpf (info)
log_fatal ("Open a socket for LPF: %m");
}
@ -100,7 +115,7 @@ index 16eecc9..4bdb0f1 100644
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EINVAL) {
@@ -171,9 +194,18 @@ static void lpf_gen_filter_setup (struct interface_info *);
@@ -172,9 +195,18 @@ static void lpf_gen_filter_setup (struct interface_info *);
void if_register_receive (info)
struct interface_info *info;
{
@ -119,7 +134,7 @@ index 16eecc9..4bdb0f1 100644
#if defined (HAVE_TR_SUPPORT)
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
lpf_tr_filter_setup (info);
@@ -295,7 +327,6 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
@@ -296,7 +328,6 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
double hh [16];
double ih [1536 / sizeof (double)];
unsigned char *buf = (unsigned char *)ih;
@ -127,7 +142,7 @@ index 16eecc9..4bdb0f1 100644
int result;
int fudge;
@@ -316,17 +347,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
@@ -317,17 +348,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
(unsigned char *)raw, len);
memcpy (buf + ibufp, raw, len);
@ -146,7 +161,7 @@ index 16eecc9..4bdb0f1 100644
if (result < 0)
log_error ("send_packet: %m");
return result;
@@ -343,14 +364,35 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
@@ -344,14 +365,35 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
{
int length = 0;
int offset = 0;
@ -184,7 +199,7 @@ index 16eecc9..4bdb0f1 100644
bufix = 0;
/* Decode the physical header... */
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
@@ -367,7 +409,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
@@ -368,7 +410,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix, from,
@ -194,10 +209,10 @@ index 16eecc9..4bdb0f1 100644
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
diff --git a/common/nit.c b/common/nit.c
index 3822206..0da9c36 100644
index a43bcf3..3fdef1d 100644
--- a/common/nit.c
+++ b/common/nit.c
@@ -369,7 +369,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
@@ -363,7 +363,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
@ -207,10 +222,10 @@ index 3822206..0da9c36 100644
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
diff --git a/common/packet.c b/common/packet.c
index 42bca69..fd2d975 100644
index 45e96e8..73e786d 100644
--- a/common/packet.c
+++ b/common/packet.c
@@ -211,7 +211,7 @@ ssize_t
@@ -226,7 +226,7 @@ ssize_t
decode_udp_ip_header(struct interface_info *interface,
unsigned char *buf, unsigned bufix,
struct sockaddr_in *from, unsigned buflen,
@ -219,7 +234,7 @@ index 42bca69..fd2d975 100644
{
unsigned char *data;
struct ip ip;
@@ -322,7 +322,7 @@ decode_udp_ip_header(struct interface_info *interface,
@@ -337,7 +337,7 @@ decode_udp_ip_header(struct interface_info *interface,
8, IPPROTO_UDP + ulen))));
udp_packets_seen++;
@ -229,10 +244,10 @@ index 42bca69..fd2d975 100644
if (udp_packets_seen > 4 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
diff --git a/common/upf.c b/common/upf.c
index feb82a2..fff3949 100644
index de2129e..6a02077 100644
--- a/common/upf.c
+++ b/common/upf.c
@@ -320,7 +320,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
@@ -314,7 +314,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
@ -242,10 +257,10 @@ index feb82a2..fff3949 100644
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index adf04cc..ded57a9 100644
index 63d58e5..68262e9 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -2793,7 +2793,7 @@ ssize_t decode_hw_header (struct interface_info *, unsigned char *,
@@ -2788,7 +2788,7 @@ ssize_t decode_hw_header (struct interface_info *, unsigned char *,
unsigned, struct hardware *);
ssize_t decode_udp_ip_header (struct interface_info *, unsigned char *,
unsigned, struct sockaddr_in *,
@ -255,5 +270,5 @@ index adf04cc..ded57a9 100644
/* ethernet.c */
void assemble_ethernet_header (struct interface_info *, unsigned char *,
--
1.7.3.4
1.8.4

View File

@ -1,8 +1,18 @@
From 48c1bbb9cbd6d6e71178e82fd45a7409efbb9d72 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Wed, 27 Apr 2011 13:56:47 +0200
Subject: [PATCH] dhcp-4.2.2-dhclient-option-checks
---
client/dhclient.c | 6 +++---
common/options.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index 1afccd5..37ec809 100644
index b7a14fe..19a527b 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -3275,7 +3275,7 @@ void script_write_params (client, prefix, lease)
@@ -3301,7 +3301,7 @@ void script_write_params (client, prefix, lease)
} else {
log_error("suspect value in %s "
"option - discarded",
@ -11,7 +21,7 @@ index 1afccd5..37ec809 100644
}
}
@@ -3288,7 +3288,7 @@ void script_write_params (client, prefix, lease)
@@ -3314,7 +3314,7 @@ void script_write_params (client, prefix, lease)
} else {
log_error("suspect value in %s "
"option - discarded",
@ -20,7 +30,7 @@ index 1afccd5..37ec809 100644
}
}
@@ -4216,7 +4216,7 @@ static int check_domain_name(const char *ptr, size_t len, int dots)
@@ -4283,7 +4283,7 @@ static int check_domain_name(const char *ptr, size_t len, int dots)
const char *p;
/* not empty or complete length not over 255 characters */
@ -30,10 +40,10 @@ index 1afccd5..37ec809 100644
/* consists of [[:alnum:]-]+ labels separated by [.] */
diff --git a/common/options.c b/common/options.c
index e485222..bc9bb97 100644
index 56bb151..be44a70 100644
--- a/common/options.c
+++ b/common/options.c
@@ -3918,7 +3918,7 @@ pretty_escape(char **dst, char *dend, const unsigned char **src,
@@ -3979,7 +3979,7 @@ pretty_escape(char **dst, char *dend, const unsigned char **src,
}
} else if (**src == '"' || **src == '\'' || **src == '$' ||
**src == '`' || **src == '\\' || **src == '|' ||
@ -42,3 +52,6 @@ index e485222..bc9bb97 100644
if (*dst + 2 > dend)
return -1;
--
1.8.4

View File

@ -1,8 +1,32 @@
From 0ae45af28ebda5770465f84ac0f69f28ed6b7b07 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 14:09:06 +0200
Subject: [PATCH] dhcp-4.2.6-close-on-exec
---
client/clparse.c | 4 ++--
client/dhclient.c | 10 +++++-----
common/bpf.c | 2 +-
common/discover.c | 4 ++--
common/dlpi.c | 2 +-
common/nit.c | 2 +-
common/resolv.c | 2 +-
common/upf.c | 2 +-
dst/dst_api.c | 8 ++++----
dst/prandom.c | 4 ++--
omapip/trace.c | 6 +++---
relay/dhcrelay.c | 5 +++--
server/confpars.c | 2 +-
server/db.c | 6 +++---
server/dhcpd.c | 4 ++--
server/ldap.c | 2 +-
16 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/client/clparse.c b/client/clparse.c
index 9de4ce2..ca24ba6 100644
index 646229f..3e9f9b1 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -220,7 +220,7 @@ int read_client_conf_file (const char *name, struct interface_info *ip,
@@ -221,7 +221,7 @@ int read_client_conf_file (const char *name, struct interface_info *ip,
int token;
isc_result_t status;
@ -11,7 +35,7 @@ index 9de4ce2..ca24ba6 100644
return uerr2isc (errno);
cfile = NULL;
@@ -257,7 +257,7 @@ void read_client_leases ()
@@ -258,7 +258,7 @@ void read_client_leases ()
/* Open the lease file. If we can't open it, just return -
we can safely trust the server to remember our state. */
@ -21,19 +45,19 @@ index 9de4ce2..ca24ba6 100644
cfile = NULL;
diff --git a/client/dhclient.c b/client/dhclient.c
index 82c26bb..a1cab01 100644
index 19a527b..dbc6f38 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -423,7 +423,7 @@ main(int argc, char **argv) {
@@ -422,7 +422,7 @@ main(int argc, char **argv) {
long temp;
int e;
oldpid = 0;
- if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
+ if ((pidfd = fopen(path_dhclient_pid, "re")) != NULL) {
e = fscanf(pidfd, "%ld\n", &temp);
oldpid = (pid_t)temp;
@@ -2689,7 +2689,7 @@ void rewrite_client_leases ()
@@ -2728,7 +2728,7 @@ void rewrite_client_leases ()
if (leaseFile != NULL)
fclose (leaseFile);
@ -42,7 +66,7 @@ index 82c26bb..a1cab01 100644
if (leaseFile == NULL) {
log_error ("can't create %s: %m", path_dhclient_db);
return;
@@ -2799,7 +2799,7 @@ write_duid(struct data_string *duid)
@@ -2849,7 +2849,7 @@ write_duid(struct data_string *duid)
return DHCP_R_INVALIDARG;
if (leaseFile == NULL) { /* XXX? */
@ -51,7 +75,7 @@ index 82c26bb..a1cab01 100644
if (leaseFile == NULL) {
log_error("can't create %s: %m", path_dhclient_db);
return ISC_R_IOERROR;
@@ -2847,7 +2847,7 @@ write_client6_lease(struct client_state *client, struct dhc6_lease *lease,
@@ -2897,7 +2897,7 @@ write_client6_lease(struct client_state *client, struct dhc6_lease *lease,
return DHCP_R_INVALIDARG;
if (leaseFile == NULL) { /* XXX? */
@ -60,7 +84,7 @@ index 82c26bb..a1cab01 100644
if (leaseFile == NULL) {
log_error("can't create %s: %m", path_dhclient_db);
return ISC_R_IOERROR;
@@ -2979,7 +2979,7 @@ int write_client_lease (client, lease, rewrite, makesure)
@@ -3029,7 +3029,7 @@ int write_client_lease (client, lease, rewrite, makesure)
return 1;
if (leaseFile == NULL) { /* XXX */
@ -70,7 +94,7 @@ index 82c26bb..a1cab01 100644
log_error ("can't create %s: %m", path_dhclient_db);
return 0;
diff --git a/common/bpf.c b/common/bpf.c
index 8bd5727..7b8f1d4 100644
index 559b414..076d9bc 100644
--- a/common/bpf.c
+++ b/common/bpf.c
@@ -94,7 +94,7 @@ int if_register_bpf (info)
@ -83,10 +107,10 @@ index 8bd5727..7b8f1d4 100644
if (errno == EBUSY) {
continue;
diff --git a/common/discover.c b/common/discover.c
index 1d84219..93a278e 100644
index 4b40a70..6a0540b 100644
--- a/common/discover.c
+++ b/common/discover.c
@@ -421,7 +421,7 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
@@ -412,7 +412,7 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
int len;
int i;
@ -95,7 +119,7 @@ index 1d84219..93a278e 100644
if (ifaces->fp == NULL) {
log_error("Error opening '/proc/net/dev' to list interfaces");
return 0;
@@ -456,7 +456,7 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
@@ -447,7 +447,7 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
#ifdef DHCPv6
if (local_family == AF_INET6) {
@ -105,10 +129,10 @@ index 1d84219..93a278e 100644
log_error("Error opening '/proc/net/if_inet6' to "
"list IPv6 interfaces; %m");
diff --git a/common/dlpi.c b/common/dlpi.c
index b9eb1d3..c044ec6 100644
index 14e95d2..efaba3a 100644
--- a/common/dlpi.c
+++ b/common/dlpi.c
@@ -806,7 +806,7 @@ dlpiopen(const char *ifname) {
@@ -804,7 +804,7 @@ dlpiopen(const char *ifname) {
}
*dp = '\0';
@ -118,10 +142,10 @@ index b9eb1d3..c044ec6 100644
/*
diff --git a/common/nit.c b/common/nit.c
index 0da9c36..896cbb6 100644
index 3fdef1d..dc62081 100644
--- a/common/nit.c
+++ b/common/nit.c
@@ -81,7 +81,7 @@ int if_register_nit (info)
@@ -75,7 +75,7 @@ int if_register_nit (info)
struct strioctl sio;
/* Open a NIT device */
@ -131,10 +155,10 @@ index 0da9c36..896cbb6 100644
log_fatal ("Can't open NIT device for %s: %m", info -> name);
diff --git a/common/resolv.c b/common/resolv.c
index b29d4cf..d946ccc 100644
index 526cebf..2ac8d43 100644
--- a/common/resolv.c
+++ b/common/resolv.c
@@ -49,7 +49,7 @@ void read_resolv_conf (parse_time)
@@ -44,7 +44,7 @@ void read_resolv_conf (parse_time)
struct domain_search_list *dp, *dl, *nd;
isc_result_t status;
@ -144,10 +168,10 @@ index b29d4cf..d946ccc 100644
return;
}
diff --git a/common/upf.c b/common/upf.c
index fff3949..4f9318e 100644
index 6a02077..e5cafcf 100644
--- a/common/upf.c
+++ b/common/upf.c
@@ -77,7 +77,7 @@ int if_register_upf (info)
@@ -71,7 +71,7 @@ int if_register_upf (info)
/* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
sprintf(filename, "/dev/pf/pfilt%d", b);
@ -157,7 +181,7 @@ index fff3949..4f9318e 100644
if (errno == EBUSY) {
continue;
diff --git a/dst/dst_api.c b/dst/dst_api.c
index 8925c66..fa4eb5f 100644
index 3993b1e..aadcc1f 100644
--- a/dst/dst_api.c
+++ b/dst/dst_api.c
@@ -437,7 +437,7 @@ dst_s_write_private_key(const DST_KEY *key)
@ -169,7 +193,7 @@ index 8925c66..fa4eb5f 100644
int nn;
if ((nn = fwrite(encoded_block, 1, len, fp)) != len) {
EREPORT(("dst_write_private_key(): Write failure on %s %d != %d errno=%d\n",
@@ -494,7 +494,7 @@ dst_s_read_public_key(const char *in_name, const unsigned in_id, int in_alg)
@@ -495,7 +495,7 @@ dst_s_read_public_key(const char *in_name, const unsigned in_id, int in_alg)
* flags, proto, alg stored as decimal (or hex numbers FIXME).
* (FIXME: handle parentheses for line continuation.)
*/
@ -178,7 +202,7 @@ index 8925c66..fa4eb5f 100644
EREPORT(("dst_read_public_key(): Public Key not found %s\n",
name));
return (NULL);
@@ -620,7 +620,7 @@ dst_s_write_public_key(const DST_KEY *key)
@@ -621,7 +621,7 @@ dst_s_write_public_key(const DST_KEY *key)
return (0);
}
/* create public key file */
@ -187,7 +211,7 @@ index 8925c66..fa4eb5f 100644
EREPORT(("DST_write_public_key: open of file:%s failed (errno=%d)\n",
filename, errno));
return (0);
@@ -854,7 +854,7 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, unsigned in_id,
@@ -855,7 +855,7 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, unsigned in_id,
return (0);
}
/* first check if we can find the key file */
@ -197,10 +221,10 @@ index 8925c66..fa4eb5f 100644
filename, dst_path[0] ? dst_path :
(char *) getcwd(NULL, PATH_MAX - 1)));
diff --git a/dst/prandom.c b/dst/prandom.c
index 4de3fe4..fbbe07c 100644
index d207993..775cb23 100644
--- a/dst/prandom.c
+++ b/dst/prandom.c
@@ -269,7 +269,7 @@ get_dev_random(u_char *output, unsigned size)
@@ -270,7 +270,7 @@ get_dev_random(u_char *output, unsigned size)
s = stat("/dev/random", &st);
if (s == 0 && S_ISCHR(st.st_mode)) {
@ -219,10 +243,10 @@ index 4de3fe4..fbbe07c 100644
for (no = 0; (i = fread(buf, sizeof(*buf), sizeof(buf), fp)) > 0;
no += i)
diff --git a/omapip/trace.c b/omapip/trace.c
index 9fd3fb5..9c4e11e 100644
index 23e4e50..846b42b 100644
--- a/omapip/trace.c
+++ b/omapip/trace.c
@@ -141,10 +141,10 @@ isc_result_t trace_begin (const char *filename,
@@ -138,10 +138,10 @@ isc_result_t trace_begin (const char *filename,
return DHCP_R_INVALIDARG;
}
@ -235,7 +259,7 @@ index 9fd3fb5..9c4e11e 100644
0600);
}
@@ -431,7 +431,7 @@ void trace_file_replay (const char *filename)
@@ -429,7 +429,7 @@ void trace_file_replay (const char *filename)
isc_result_t result;
int len;
@ -245,10 +269,10 @@ index 9fd3fb5..9c4e11e 100644
log_error("Can't open tracefile %s: %m", filename);
return;
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index f21f16f..d2aa90e 100644
index 6f42927..4ef6737 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -540,13 +540,14 @@ main(int argc, char **argv) {
@@ -539,13 +539,14 @@ main(int argc, char **argv) {
if (no_pid_file == ISC_FALSE) {
pfdesc = open(path_dhcrelay_pid,
@ -266,10 +290,10 @@ index f21f16f..d2aa90e 100644
log_error("Can't fdopen %s: %m",
path_dhcrelay_pid);
diff --git a/server/confpars.c b/server/confpars.c
index c0742d4..62568e9 100644
index 684f9c1..3b5a840 100644
--- a/server/confpars.c
+++ b/server/confpars.c
@@ -116,7 +116,7 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
@@ -110,7 +110,7 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
}
#endif
@ -279,10 +303,10 @@ index c0742d4..62568e9 100644
log_error ("Can't open lease database %s: %m --",
path_dhcpd_db);
diff --git a/server/db.c b/server/db.c
index dc75321..be5db26 100644
index c2630ea..59e96dd 100644
--- a/server/db.c
+++ b/server/db.c
@@ -1035,7 +1035,7 @@ void db_startup (testp)
@@ -1050,7 +1050,7 @@ void db_startup (testp)
}
#endif
if (!testp) {
@ -291,7 +315,7 @@ index dc75321..be5db26 100644
if (!db_file)
log_fatal ("Can't open %s for append.", path_dhcpd_db);
expire_all_pools ();
@@ -1074,7 +1074,7 @@ int new_lease_file ()
@@ -1089,7 +1089,7 @@ int new_lease_file ()
db_validity = lease_file_is_corrupt;
snprintf (newfname, sizeof(newfname), "%s.XXXXXX", path_dhcpd_db);
@ -300,7 +324,7 @@ index dc75321..be5db26 100644
if (db_fd < 0) {
log_error ("Can't create new lease file: %m");
return 0;
@@ -1083,7 +1083,7 @@ int new_lease_file ()
@@ -1098,7 +1098,7 @@ int new_lease_file ()
log_error ("Can't fchmod new lease file: %m");
goto fail;
}
@ -310,10 +334,10 @@ index dc75321..be5db26 100644
close(db_fd);
goto fdfail;
diff --git a/server/dhcpd.c b/server/dhcpd.c
index 27e04e4..9233d26 100644
index b4c1bef..41a9efe 100644
--- a/server/dhcpd.c
+++ b/server/dhcpd.c
@@ -809,7 +809,7 @@ main(int argc, char **argv) {
@@ -805,7 +805,7 @@ main(int argc, char **argv) {
*/
if (no_pid_file == ISC_FALSE) {
/*Read previous pid file. */
@ -322,7 +346,7 @@ index 27e04e4..9233d26 100644
status = read(i, pbuf, (sizeof pbuf) - 1);
close (i);
if (status > 0) {
@@ -828,7 +828,7 @@ main(int argc, char **argv) {
@@ -824,7 +824,7 @@ main(int argc, char **argv) {
}
/* Write new pid file. */
@ -332,10 +356,10 @@ index 27e04e4..9233d26 100644
sprintf(pbuf, "%d\n", (int) getpid());
IGNORE_RET (write(i, pbuf, strlen(pbuf)));
diff --git a/server/ldap.c b/server/ldap.c
index 68acbbb..77efe26 100644
index 6e7f508..d1cde27 100644
--- a/server/ldap.c
+++ b/server/ldap.c
@@ -1098,7 +1098,7 @@ ldap_start (void)
@@ -1252,7 +1252,7 @@ ldap_start (void)
if (ldap_debug_file != NULL && ldap_debug_fd == -1)
{
@ -345,5 +369,5 @@ index 68acbbb..77efe26 100644
log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
strerror (errno));
--
1.7.3.4
1.8.4

View File

@ -0,0 +1,26 @@
From 61b4b713b630febf170c58c9ebbba2e01bb28eff Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 15:09:01 +0200
Subject: [PATCH] dhcp-4.2.2-quiet-dhclient
---
client/dhclient.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/client/dhclient.c b/client/dhclient.c
index dbc6f38..65d9eeb 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -451,6 +451,9 @@ main(int argc, char **argv) {
} else {
log_perror = 0;
quiet_interface_discovery = 1;
+#if !defined(DEBUG)
+ setlogmask(LOG_UPTO(LOG_NOTICE));
+#endif
}
/* If we're given a relay agent address to insert, for testing
--
1.8.4

View File

@ -0,0 +1,25 @@
From d571408b5386b9bd72fd123b30298bdca8103b18 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Tue, 12 Jun 2012 10:21:57 +0200
Subject: [PATCH] dhcp-4.2.3-P1-dhclient-log-pid
---
client/dhclient.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index 65d9eeb..8af0a42 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -141,7 +141,7 @@ main(int argc, char **argv) {
else if (fd != -1)
close(fd);
- openlog("dhclient", LOG_NDELAY, LOG_DAEMON);
+ openlog("dhclient", LOG_NDELAY | LOG_PID, LOG_DAEMON);
#if !(defined(DEBUG) || defined(__CYGWIN32__))
setlogmask(LOG_UPTO(LOG_INFO));
--
1.8.4

View File

@ -1,8 +1,6 @@
From 29ef7e3c25a709e8f0daadc41f34360ac6d88435 Mon Sep 17 00:00:00 2001
From bd50ec560d7bec064190e4d430c066e170732c0e Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Tue, 27 Nov 2012 17:44:06 +0100
References: bnc#791289
Upstream: sent [ISC-Bugs #31992]
Subject: [PATCH] Fixed linux interface discovery using getifaddrs
Unlike dhcp 3.x, dhcp 4.x scans interfaces from /proc/net/dev,
@ -15,17 +13,15 @@ dhcp-server is unable to find any address and fails to start.
Changed to use getifaddrs() function, which retrieves all IP
addresses on linux systems and is available since GLIBC 2.3.
Signed-off-by: Marius Tomaschewski <mt@suse.de>
---
common/discover.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 Datei geändert, 44 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
common/discover.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/common/discover.c b/common/discover.c
index 1d84219..cbcb1b9 100644
index 6a0540b..1dcaa02 100644
--- a/common/discover.c
+++ b/common/discover.c
@@ -379,7 +379,7 @@ end_iface_scan(struct iface_conf_list *ifaces) {
@@ -370,7 +370,7 @@ end_iface_scan(struct iface_conf_list *ifaces) {
ifaces->sock = -1;
}
@ -34,7 +30,7 @@ index 1d84219..cbcb1b9 100644
/*
* Linux support
* -------------
@@ -388,6 +388,14 @@ end_iface_scan(struct iface_conf_list *ifaces) {
@@ -379,6 +379,14 @@ end_iface_scan(struct iface_conf_list *ifaces) {
* about interfaces, along with selected ioctl() calls.
*
* Linux low level access is documented in the netdevice man page.
@ -49,7 +45,7 @@ index 1d84219..cbcb1b9 100644
*/
/*
@@ -760,11 +768,11 @@ end_iface_scan(struct iface_conf_list *ifaces) {
@@ -751,11 +759,11 @@ end_iface_scan(struct iface_conf_list *ifaces) {
#else
/*
@ -64,7 +60,7 @@ index 1d84219..cbcb1b9 100644
*
* The getifaddrs() man page describes the use.
*/
@@ -821,10 +829,39 @@ next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
@@ -812,10 +820,39 @@ next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
*err = 1;
return 0;
}
@ -108,5 +104,5 @@ index 1d84219..cbcb1b9 100644
*err = 0;
return 1;
--
1.7.10.4
1.8.4

View File

@ -1,9 +1,7 @@
From 633817ad53adbdeb4054b750e1f0bd4ce58f341b Mon Sep 17 00:00:00 2001
From d9b443ef38da92bd325f5118a2a6ddc21fae098e Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 20 Dec 2012 10:25:53 +0100
Subject: [PATCH] Ignore SIGPIPE to not die in socket code
References: bnc#794578
Upstream: sent [ISC-Bugs #32222]
Installed SIG_IGN handler for SIGPIPE to not die before
the errno==EPIPE checks in the socket code are reached.
@ -13,25 +11,15 @@ dhcp, does not set any signal handlers.
Reported upstream as [ISC-Bugs #32222], IMO regression
to [ISC-Bugs #22269] as the SO_NOSIGPIPE socket option
isn't available e.g. on Linux.
Signed-off-by: Marius Tomaschewski <mt@suse.de>
---
omapip/isclib.c | 33 ++++++++++++++++++++++++++++++++-
1 Datei geändert, 32 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
omapip/isclib.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/omapip/isclib.c b/omapip/isclib.c
index 1534dde..27bb887 100644
index afab262..9b7ff5f 100644
--- a/omapip/isclib.c
+++ b/omapip/isclib.c
@@ -28,6 +28,7 @@
#include "dhcpd.h"
#include <sys/time.h>
+#include <signal.h>
dhcp_context_t dhcp_gbl_ctx;
@@ -67,6 +68,23 @@ isclib_cleanup(void)
@@ -69,6 +69,23 @@ isclib_cleanup(void)
return;
}
@ -55,7 +43,7 @@ index 1534dde..27bb887 100644
isc_result_t
dhcp_context_create(void) {
isc_result_t result;
@@ -104,7 +122,20 @@ dhcp_context_create(void) {
@@ -106,7 +123,20 @@ dhcp_context_create(void) {
result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
if (result != ISC_R_SUCCESS)
@ -78,5 +66,5 @@ index 1534dde..27bb887 100644
result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
--
1.7.10.4
1.8.4

View File

@ -0,0 +1,23 @@
From 39c796224826836f0b0d1ab42f93a973545a94b0 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Mon, 10 Feb 2014 15:12:49 +0100
Subject: [PATCH] server: log DHCPv6 addresses assigned to clients
---
includes/site.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/site.h b/includes/site.h
index 3de180c..1b6d0c0 100644
--- a/includes/site.h
+++ b/includes/site.h
@@ -281,5 +281,5 @@
This default to off to avoid changes to what is currently
logged. */
-/* #define LOG_V6_ADDRESSES */
+#define LOG_V6_ADDRESSES
--
1.8.4

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
--- contrib/leasestate
+++ contrib/leasestate 2010/09/29 10:07:09
@@ -16,7 +16,7 @@ my %Update;
my $level = 1;
my $IP = '';
my ($ip, $bs, $nbs, $join);
-open(FILE, "/var/lib/dhcp/dhcpd.leases");
+open(FILE, "/var/lib/dhcp/db/dhcpd.leases");
while(my $line = <FILE>) {
next if ($line =~ /^\#/);
if ($level == 1) {
--- contrib/listlease
+++ contrib/listlease 2010/09/29 10:08:10
@@ -14,7 +14,7 @@ use strict;
my $LastLease = '';
my $savelease = 0;
my $prlease = 0;
-my $LFILE = "/var/lib/dhcp/dhcpd.leases";
+my $LFILE = "/var/lib/dhcp/db/dhcpd.leases";
$LFILE = $ARGV[1] if ($ARGV[1] ne '');
open(FILE, $LFILE);

BIN
contrib.tar.gz (Stored with Git LFS)

Binary file not shown.

View File

@ -1,11 +0,0 @@
--- dhcp-4.1.1-P1/common/lpf.c
+++ dhcp-4.1.1-P1/common/lpf.c 2010/07/02 10:39:33
@@ -92,7 +92,7 @@ int if_register_lpf (info)
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EINVAL) {
- log_error ("socket: %m - make sure");
+ log_error ("bind: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",

View File

@ -1,17 +0,0 @@
diff --git a/client/dhclient.c b/client/dhclient.c
index a1cab01..ff5ede5 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -444,6 +444,9 @@ main(int argc, char **argv) {
} else {
log_perror = 0;
quiet_interface_discovery = 1;
+#if !defined(DEBUG)
+ setlogmask(LOG_UPTO(LOG_NOTICE));
+#endif
}
/* If we're given a relay agent address to insert, for testing
--
1.7.3.4

View File

@ -1,29 +0,0 @@
From 1f30e4707e13cb09315cbda2cf36bae099285a79 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 5 Jan 2012 16:25:18 +0100
Subject: [PATCH] Use pid number in dhclient log messages
Troubleshooting help to make it visible which client is reporting
as there may be more than one running (v4 + v6 multiple interfaces).
Signed-off-by: Marius Tomaschewski <mt@suse.de>
---
client/dhclient.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index ff5ede5..bee8e1d 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -141,7 +141,7 @@ main(int argc, char **argv) {
else if (fd != -1)
close(fd);
- openlog("dhclient", LOG_NDELAY, LOG_DAEMON);
+ openlog("dhclient", LOG_NDELAY | LOG_PID, LOG_DAEMON);
#if !(defined(DEBUG) || defined(__CYGWIN32__))
setlogmask(LOG_UPTO(LOG_INFO));
--
1.7.7

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:59b06c9f5d775e46999b422c45b9229402c462b114ce1685617bfb2b8b028250
size 8255960

View File

@ -1,11 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (NetBSD)
iQEcBAABAgAGBQJRS2FeAAoJEEWseFcYnNvFjYIH/3S6p2g7sqAbTJaNA81UdIQc
mw2JgfejtbNGIdBhD+iM3AazwO9zVIQfD7mpHhIgSwtBXu2kYlCOaLy+GSTRLLWv
gu1/0J2JPJTx9WoMWYEOPG/qhYYQKX+Xj7ldIFat/7ADOGCYCfZWNhsYZ79T0GCL
tj/jX2bQXDzTeEMHHywBr8MdGGzn1k6mCduyENXpmTBlLT5PfdABWku5iu6efFMS
doLZ5rUYGxxBTmbZJLZjScNI2DNH2UTIxRx58rVYPaXNi91pPRflXoIDpwiKHYfK
6uqshS8z8bMGhSMTLdm5NcWS16ABCFOTmr2RCeQ144VD8L/FNgPEj+vNTMKb9Rs=
=klp9
-----END PGP SIGNATURE-----

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b300b487032a9eac6a0935351ef45415d58aaf1a196408a6209f43e72e70e622
size 16766

3
dhcp-4.2.6.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ab3aaab3c938a1c0e44fd75ee4d51682d35eb8328e991006cc6ee17514bfe291
size 8935311

11
dhcp-4.2.6.tar.gz.asc Normal file
View File

@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (NetBSD)
iQEcBAABAgAGBQJS79gLAAoJEEWseFcYnNvFa08H+wRSA6dSHI6I86Qth7rDLvUX
JpGUILrypagAadb6a+UzpvEluhP8hg8Lex/PnskgOHDhkBqqiQLKp38B+2/LqxhU
Tx+yh9TikCLEf/I5vj6CWhZT7nip3WqfhXv+Z0EeIxsjgXPw6VEgGPpj/M6F8qqM
dmGmuzBWeXSnMEIwDGGW03dijN0ngfWl+9Be9A3l7dzfUAUVM6PwtLt72GA60K98
/X8ZOgsRy6vOI9Nc7R6JPPD9lxx7Qp6meN0y3OtXjSZ1tvdeEjk2HGNJaNh4P/oZ
vzwi1yxAVA7JY8XPPJsBydruFfTB2Qx5M/Kn57bQOZnlWwSgXds2pEbv2JfgpYU=
=sDT9
-----END PGP SIGNATURE-----

View File

@ -1,106 +0,0 @@
/* README.SuSE zum ISC DHCP-Server */
Bevor Sie dhcpd benutzen koennen, muessen Sie ihn ueber
- /etc/sysconfig/dhcpd (grundsaetzliche Einst.)
und
- /etc/dhcpd.conf (Konfigurationsdatei)
konfigurieren. Eine Beispielkonfiguration finden Sie unter
/usr/share/doc/packages/dhcp-server/
Paketfilter
===========
Dieses Paket enthaelt ein zusaetzliches dhcpd-Binary (/usr/sbin/dhcpd.bsd), das
so kompiliert ist, dass es BSD Sockets anstatt LPF (Linux Packet
Filter) verwendet.
Mit diesem binary ist es moeglich, den Netzwerkverkehr des Servers mit dem
Paketfilter des Kernels zu filtern, waehrend die sonst verwendeten Raw Sockets
den Paketfilter umgehen. Allerdings kann es dadurch in seltenen Faellen zu
Inkompatibilitaeten mit manchen DHCP-Clients (oder dazwischengeschalteten
DHCP-Gateways) kommen. Mehr Informationen und moegliche Seiteneffekte wurden
hier diskutiert:
http://marc.theaimsgroup.com/?l=dhcp-server&m=108791973729847&w=2
Es besteht die Moeglichkeit, das verwendete Binary ueber DHCPD_BINARY in
/etc/sysconfig/dhcpd festzulegen.
Option 119 (Searchlist)
=======================
Fuer diese relativ neue Option (DHCP Option 119, RFC3397) gibt es noch keinen
direkten Support im DHCP Server. Sie muss als freie Option definiert werden,
wenn der zu sendende String im DNS-Format komprimiert wurde, und kann
folgendermassen in die Konfiguration geschrieben werden:
option searchlist code 119 = string;
option searchlist "\x07domain1\x07example\x03com\x00\x07domain2\xc0\x08";
Die erste Anweisung ist immer global zu verwenden; die zweite kann sich auch in
einem Subnet befinden.
Der komprimierte String kann mit dem Programm
/usr/share/doc/packages/dhcp-server/dnscompr.py wie folgt erzeugt werden (Beispiel):
# python /usr/share/doc/packages/dhcp-server/dnscompr.py domain1.example.com domain2.example.com
'\x07domain1\x07example\x03com\x00\x07domain2\xc0\x08'
dnscompr.py benoetigt das python-dnspython Paket, das mit 10.0 ausgeliefert
wird. Fuer aeltere SUSE Linux Versionen gibt es das Python-Modul unter
http://ftp.suse.com/pub/people/poeml/python-dnspython/
Die Kompression ist in RFC 3397 sowie, in detaillierterer Form, in RFC1035
beschrieben.
Chroot-"Gefaengnis"
===================
Unsere Version des ISC DHCP-Servers enthaelt einen modifizierten
'non-root/chroot'-Patch nach Ari Edelkind. Damit kann der dhcpd
- als unprivilegierter Benutzer laufen
- in einer chroot-Umgebung laufen (/var/lib/dhcp)
was (in dieser Kombination) die sicherste Moeglichkeit ist, den Server zu
betreiben.
Die Konfigurationsdatei muss dafuer in /var/lib/dhcp/etc liegen, und wird
deshalb vom Init-Skript beim Start automatisch dorthin kopiert. Weitere Dateien
(Include-Dateien) koennen in /etc/sysconfig/dhcpd:DHCPD_CONF_INCLUDE_FILES
aufgefuehrt werden.
Damit der dhcp-Daemon aus der chroot-Umgebung heraus weiter loggen kann, auch
wenn der Syslog-Daemon neu gestartet wird, wird in /etc/sysconfig/syslog
automatisch "-a /var/lib/dhcp/dev/log" hinzugefuegt.
WICHTIG: In der chroot-Umgebung kann dhcpcd nur dann Hostnamen
aufloesen, wenn folgende Dateien vorhanden sind:
/etc/localtime
/etc/host.conf
/etc/hosts
/etc/resolv.conf
/lib/libresolv.so.2
/lib/libnss_dns.so.2
/lib/libnss_dns6.so.2
Beim Start des Init-Skriptes werden diese (zus. etwa 100 kB) deshalb nach
/var/lib/dhcp/ kopiert. (Diese Dateien muessen eventuell auf dem Laufenden
gehalten werden, wenn sie durch Skript wie /etc/ppp/ip-up dynamisch modifiziert
werden.) Wenn in der Konfigurationsdatei nur IP-Adressen anstelle von Hostnamen
verwenden, sind hier keine Probleme zu erwarten.
Das chroot-Feature kann ueber DHCPD_RUN_CHROOTED in /etc/sysconfig/dhcpd zur
Not auch abgeschaltet werden.
Weitere Informationen finden Sie unter
<http://www.isc.org/ml-archives/dhcp-server/2000/04/msg00097.html>
und
<http://www.securityportal.com/closet/closet20001129.html>.
Have a lot of fun!
Your SuSE Team

View File

@ -1,55 +1,21 @@
/* README.SuSE for the ISC DHCP server */
/* README.SUSE for the ISC DHCP server */
Before you can run dhcpd, you have to configure it via
- /etc/sysconfig/dhcpd (general settings)
and
- /etc/dhcpd.conf (configuration file)
- /etc/dhcpd.conf (DHCPv4 configuration file)
- /etc/dhcpd6.conf (DHCPv6 configuration file)
See /usr/share/doc/packages/dhcp-server for example configurations.
Note on packet filtering
========================
This dhcp package contains an additional dhcpd binary (/usr/sbin/dhcpd.bsd)
which is compiled using BSD sockets instead of LPF (linux packet filter).
Option 119 (domain-search) vs. option 15 (domain-name)
======================================================
Using that binary, the network traffic handled by dhcpd can be filtered by the
packet filter of the Linux kernel, while the raw sockets used normally would
bypass any filtering. However, there is a tiny number of setups where this can
result in incompatibilities with certain DHCP clients, or with DHCP relay
agents in between. More information and a discussion of side effects was
discussed here:
See http://marc.theaimsgroup.com/?l=dhcp-server&m=108791973729847&w=2
It is possible to choose the binary by adjusting DHCPD_BINARY in
/etc/sysconfig/dhcpd.
Option 119 (Searchlist)
=======================
For this relatively new option (DHCP Option 119, RFC3397) the server does not
have a dedicated configuration option yet. It must be declared as free option,
after compressing the search string with DNS compression (see below), and put
into the configuration like this:
option searchlist code 119 = string;
option searchlist "\x07domain1\x07example\x03com\x00\x07domain2\xc0\x08";
The first line is always used globally; the second one could be placed in a
subnet block.
The compressed string can be generated with the program
/usr/share/doc/packages/dhcp-server/dnscompr.py as shown here (example):
# python /usr/share/doc/packages/dhcp-server/dnscompr.py domain1.example.com domain2.example.com
'\x07domain1\x07example\x03com\x00\x07domain2\xc0\x08'
dnscompr.py needs the python-dnspython package installed, which is shipping
since 10.0. For older SUSE Linux versions the python-module can be found at
http://ftp.suse.com/pub/people/poeml/python-dnspython/
The compression is described in RFC 3397, and (with more detail) in RFC1035.
The domain-name option supports only one, signgle domain (default domain).
The domain-search option supports a list of domain names. Please do not
abuse the domain-name option to provide a list -- it may be discarded by
dhcp clients.
Chroot Jail
@ -66,11 +32,10 @@ which, in this combination, is the safest possible way of running dhcpd.
In order to be found by dhcpd in the chroot jail, the configuration file
will automatically copied to /var/lib/dhcp/etc/ when the server is started.
Further conf files (include files) can be listed in DHCPD_CONF_INCLUDE_FILES
in /etc/sysconfig/dhcpd.
To enable dhcpd to continue logging from the chroot environment even after
syslogd has been restarted, "-a /var/lib/dhcp/dev/log" is automatically added to the syslog configuration in /etc/sysconfig/syslog.
or DHCPD6_CONF_INCLUDE_FILES in /etc/sysconfig/dhcpd.
The /var/lib/dhcp/dev/log syslog socked is automatically provided in the
chroot environment as soon as it is initially set up.
NOTE:
In the chroot jail, dhcpd can't resolve hostnames unless it can find
@ -82,6 +47,7 @@ the following files:
/lib/libresolv.so.2
/lib/libnss_dns.so.2
/lib/libnss_dns6.so.2
....
Thererore, these files (about 100 kB) will automatically copied to the chroot
jail when the server is started. (You might have to keep these current if
they are modified dynamically by other programs (e.g./etc/ppp/ip-up) while
@ -89,14 +55,8 @@ dhcpd is running.) This is not a problem at all when you use IP addresses
instead of host names in the config file.
In case of trouble, you can also disable the chroot feature by setting
DHCPD_RUN_CHROOTED in /etc/sysconfig/dhcpd to "no".
See
<http://www.isc.org/ml-archives/dhcp-server/2000/04/msg00097.html>
and
<http://www.securityportal.com/closet/closet20001129.html>
for more information.
DHCPD_RUN_CHROOTED/DHCPD6_RUN_CHROOTED in /etc/sysconfig/dhcpd to "no".
Have a lot of fun!
Your SuSE Team
Your SUSE Linux Team

View File

@ -1,36 +0,0 @@
When upgrading from version 2 to version 3, there are three things that are
helpful to know:
- you must use the ddns-update-style keyword. Either set it to "none", e.g.
like this:
ddns-update-style none; ddns-updates off;
If you don't have a statement about ddns at all, dhcpd-3 will not start,
and give you a message about "ddns-update-style ad-hoc;". (Don't use that
one -- the ad-hoc style is depracated. Use the interim style instead.)
If you used DDNS with 3.0beta1 versions and want to upgrade, you can
convert the lease file with this script:
/usr/share/doc/packages/dhcp/3.0b1-lease-convert
- in version 3, if you define an IP address range for dynamic allocation, it
will not work for bootp by default. Contrary to version 2 you have to
explicitely allow bootp like this:
range dynamic-bootp 192.168.0.10 192.168.0.20;
- version 3 will not act as an "authoritative" server by default. That means
that it will not send DHCPNAKs for addresses that can't be requested. If you
run the principal DHCP server of your network, add the
authoritative;
statement to the subnet declaration.
Apart from that, you should be able to use the same configuration as before!
Please send comments to poeml@suse.de.

View File

@ -1,3 +1,37 @@
-------------------------------------------------------------------
Mon Feb 10 17:52:15 UTC 2014 - mt@suse.com
- Initially switched to use systemd service files under systemd
and enabled Restart=on-abort (fate#315133).
- Update to ISC dhcp-4.2.6 release. See RELNOTES file for the
complete list of changes -- digest of fixes not in dhcp-4.2.5:
- Tidy up receive packet processing.
Thanks to Brad Plank of GTA for reporting the issue and
suggesting a possible patch. [ISC-Bugs #34447]
- Fix the socket handling for DHCPv6 clients to allow multiple
instances of a client on a single machine to work properly.
Previously only one client would receive the packets.
Thanks to Jiri Popelka at Red Hat for the bug report and a
potential patch. [ISC-Bugs #34784]
- Added support for gentle shutdown after signal is received.
[ISC-Bugs #32692] [ISC-Bugs 34945]
- Enhance the DHCPv6 server logging to include the addresses
that are assigned to the clients. This can be enabled by
defining LOG_V6_ADDRESSES in site.h. [ISC-Bugs #26377]
- Fix an operation in the DDNS code to be a bitwise instead
of logical or. [ISC-Bugs #35138]
- Merged patches for dhcp-4.2.6 version to apply without fuzzy,
prepended patch number prefixes to match spec file patch nr,
added patch markup tags / bug numbers to the spec file.
- Applied contrib-lease-path pach to contrib.tar.gz
[- contrib-lease-path.diff]
- Changed to require automake and use its config.sub and guess
files instead of maintaining a patch.
[- config-guess-sub-update.patch]
- Enabled to log DHCPv6 addresses assigned by server to clients
[+ 0016-server-log-DHCPv6-addresses-assigned-to-clients.patch]
- Cleaned up documentation, rpmlint adjustments.
-------------------------------------------------------------------
Fri Jan 10 12:05:22 UTC 2014 - mt@suse.com

256
dhcp.spec
View File

@ -16,7 +16,7 @@
#
%define isc_version 4.2.5-P1
%define isc_version 4.2.6
%define susefw2dir %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
%define omc_prefix /usr/share/omc
%define omc_svcdir %{omc_prefix}/svcinfo.d
@ -26,6 +26,11 @@
%define with_ldapcasa 0%{?sles_version} >= 10 || (%suse_version >= 1110 && %suse_version < 1140)
# doc package is new on 11.3
%define with_doc_package %suse_version >= 1130
%if 0%{?suse_version} >= 1310
%bcond_without systemd
%else
%bcond_with systemd
%endif
Name: dhcp
%if %{with_ldap}
@ -36,7 +41,7 @@ BuildRequires: openldap2-devel
%endif
BuildRequires: dos2unix
BuildRequires: libtool
Version: 4.2.5.P1
Version: 4.2.6
Release: 0.<RELEASE0>
Summary: Common Files Used by ISC DHCP Software
License: BSD-3-Clause
@ -46,59 +51,74 @@ Source0: dhcp-%{isc_version}.tar.gz
Source1: dhcp-%{isc_version}.tar.gz.asc
Source2: %{name}.keyring
#
Source10: rc.dhcpd
Source11: rc.dhcpd6
Source12: rc.dhcrelay
Source13: rc.dhcrelay6
Source14: sysconfig.dhcpd
Source15: sysconfig.syslog-dhcpd
Source16: sysconfig.dhcrelay
Source10: dhcpd.script
Source11: dhcrelay.script
%if %{with systemd}
Source12: dhcpd.service
Source13: dhcpd6.service
Source14: dhcrelay.service
Source15: dhcrelay6.service
%else
Source12: rc.dhcpd
Source13: rc.dhcpd6
Source14: rc.dhcrelay
Source15: rc.dhcrelay6
%endif
Source17: sysconfig.dhcpd
Source18: sysconfig.dhcrelay
Source19: if-up.d.dhcpd-restart-hook
#
Source20: dhclient.conf
Source21: dhclient6.conf
Source22: dhcpd.conf
Source23: dhcpd6.conf
Source24: dhclient-script
Source26: sysconfig.syslog-dhcpd
Source27: dhclient-script
#
Source30: dhcpd.xml
Source31: dhcpd6.xml
Source32: SuSEfirewall2.dhcp-server
Source33: SuSEfirewall2.dhcp6-server
#
Source40: dhcp.LIESMICH
Source41: dhcp.README
Source42: dhcp.README.upgrade
Source43: DDNS-howto.txt
Source44: contrib.tar.gz
Source45: examples.tar.gz
#
Patch10: dhcp-4.1.1-default-paths.diff
Patch1: 0001-dhcp-4.1.1-default-paths.patch
# paranoia patch is included now, but not the
# additional patch by thomas@suse.de not ...
Patch11: dhcp-4.1.1-paranoia.diff
Patch12: dhcp-4.2.2-man-includes.diff
Patch13: dhcp-4.1.1-tmpfile.diff
Patch15: contrib-lease-path.diff
Patch20: dhcp-4.1.1-dhclient-exec-filedes.diff
Patch21: dhcp-4.2.5-dhclient-send-hostname-rml.patch
## my patch repo lives here: http://users.suse.com/~mt/dhcp-ldap/dhcp-ldap.git/
Patch30: dhcp-4.2.5-ldap-mt01.patch.bz2
Patch40: dhcp-4.1.1-P1-lpf-bind-msg-fix.diff
Patch44: dhcp-4.2.2-xen-checksum.diff
Patch45: dhcp-4.2.4-dhclient-option-checks.bnc675052.diff
Patch46: dhcp-4.2.2-close-on-exec.diff
Patch47: dhcp-4.2.2-quiet-dhclient.bnc711420.diff
Patch48: dhcp-4.2.3-P1-dhclient-log-pid.diff
Patch49: dhcp-4.2.4-interface-discovery-using-getifaddrs.patch
Patch50: dhcp-4.2.4-P2-do-not-die-on-sigpipe.patch
Patch2: 0002-dhcp-4.1.1-paranoia.patch
Patch3: 0003-dhcp-4.2.2-man-includes.patch
Patch4: 0004-dhcp-4.1.1-tmpfile.patch
Patch5: 0005-dhcp-4.1.1-dhclient-exec-filedes.patch
Patch6: 0006-dhcp-4.2.5-dhclient-send-hostname-rml.patch
# PATCH-FIX-UPSTREAM ldap-patch bnc#788787,bnc#784640
Patch7: 0007-dhcp-4.2.6-ldap-mt01.patch
# PATCH-FIX-UPSTREAM lpf-bind-msg-fix bnc#617795
Patch8: 0008-dhcp-4.1.1-P1-lpf-bind-msg-fix.patch
# PATCH-FIX-SLE xen-checksum bnc#668194
Patch9: 0009-dhcp-4.2.6-xen-checksum.patch
# PATCH-FIX-SLE dhclient-option-checks bnc#675052
Patch10: 0010-dhcp-4.2.2-dhclient-option-checks.patch
# PATCH-FIX-OPENSUSE close-on-exec bnc#732910
Patch11: 0011-dhcp-4.2.6-close-on-exec.patch
# PATCH-FIX-OPENSUSE quiet-dhclient bnc#711420
Patch12: 0012-dhcp-4.2.2-quiet-dhclient.patch
# PATCH-FIX-OPENSUSE dhclient-log-pid
Patch13: 0013-dhcp-4.2.3-P1-dhclient-log-pid.patch
# PATCH-FIX-UPSTREAM use-getifaddrs bnc#791289,ISC-Bugs#31992
Patch14: 0014-Fixed-linux-interface-discovery-using-getifaddrs.patch
# PATCH-FIX-UPSTREAM no-die-on-SIGPIPE bnc#794578,ISC-Bugs#32222
Patch15: 0015-Ignore-SIGPIPE-to-not-die-in-socket-code.patch
# PATCH-FEATURE-UPSTREAM log-dhcpv6-client-addresses ISC-Bugs#26377
Patch16: 0016-server-log-DHCPv6-addresses-assigned-to-clients.patch
##
Patch60: config-guess-sub-update.patch
PreReq: /bin/touch /sbin/chkconfig sysconfig
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1220
BuildRequires: gpg-offline
%endif
BuildRequires: automake
%package server
Summary: ISC DHCP Server
@ -210,24 +230,24 @@ Authors:
%endif
%setup -q -n %{name}-%{isc_version} -a 44 -a 45
##
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%if %{with_ldap}
%patch7 -p1
%endif
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch15 -p0
%patch20 -p1
%patch21 -p1
%if %{with_ldap}
%patch30 -p1
%endif
%patch40 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
##
find . -type f -name \*.cat\* -exec rm -f {} \;
dos2unix contrib/ms2isc/*
@ -236,7 +256,10 @@ dos2unix contrib/ms2isc/*
pushd bind
gunzip -c bind.tar.gz | tar xf -
rm -rf bind-*/contrib/dbus
patch -p0 -d bind-* < %{P:60}
bind_dir=$(ls -1d bind-*)
for i in /usr/share/automake-*/config.{sub,guess} ; do
install -v -m755 $i $bind_dir/
done
popd
##
@ -299,15 +322,16 @@ cat bind/install.log
make %{?_smp_mflags}
%check
# with a minimal config, see if it runs
echo "ddns-update-style interim;" > testconf
./server/dhcpd -4 -t -cf testconf || exit 1
./server/dhcpd -6 -t -cf testconf || exit 1
# check example config, see if it runs
./server/dhcpd -4 -t -cf $RPM_SOURCE_DIR/dhcpd.conf
./server/dhcpd -6 -t -cf $RPM_SOURCE_DIR/dhcpd6.conf
# check syntax in our scripts
bash -n $RPM_SOURCE_DIR/rc.dhcpd
bash -n $RPM_SOURCE_DIR/rc.dhcpd6
bash -n $RPM_SOURCE_DIR/rc.dhcrelay
bash -n $RPM_SOURCE_DIR/rc.dhcrelay6
bash -n $RPM_SOURCE_DIR/dhcpd.script
bash -n $RPM_SOURCE_DIR/dhcrelay.script
bash -n $RPM_SOURCE_DIR/dhclient-script
%install
@ -316,7 +340,6 @@ make install DESTDIR="$RPM_BUILD_ROOT"
#
# directories
install -d -m0755 $RPM_BUILD_ROOT/sbin
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/init.d
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/dhcpd{,6}.d
install -d -m0755 $RPM_BUILD_ROOT/%{susefw2dir}
install -d -m0755 $RPM_BUILD_ROOT/%{omc_svcdir}
@ -343,23 +366,45 @@ install -m0644 $RPM_SOURCE_DIR/dhcpd6.conf $RPM_BUILD_ROOT%{_sysconfdir}/
install -m0644 $RPM_SOURCE_DIR/dhclient.conf $RPM_BUILD_ROOT%{_sysconfdir}/
install -m0644 $RPM_SOURCE_DIR/dhclient6.conf $RPM_BUILD_ROOT%{_sysconfdir}/
install -m0750 $RPM_SOURCE_DIR/dhclient-script $RPM_BUILD_ROOT/sbin/
# init scripts
# helper / wrapper scripts
install -d -m0755 $RPM_BUILD_ROOT/usr/lib/dhcp
install -m0755 $RPM_SOURCE_DIR/dhcpd.script \
$RPM_BUILD_ROOT/usr/lib/dhcp/dhcpd
install -m0755 $RPM_SOURCE_DIR/dhcrelay.script \
$RPM_BUILD_ROOT/usr/lib/dhcp/dhcrelay
%if %{with systemd}
# service units
install -d -m0755 $RPM_BUILD_ROOT%{_unitdir}
install -m0644 $RPM_SOURCE_DIR/dhcpd.service \
$RPM_BUILD_ROOT%{_unitdir}/dhcpd.service
install -m0644 $RPM_SOURCE_DIR/dhcpd6.service \
$RPM_BUILD_ROOT%{_unitdir}/dhcpd6.service
install -m0644 $RPM_SOURCE_DIR/dhcrelay.service \
$RPM_BUILD_ROOT%{_unitdir}/dhcrelay.service
install -m0644 $RPM_SOURCE_DIR/dhcrelay6.service \
$RPM_BUILD_ROOT%{_unitdir}/dhcrelay6.service
# rcservice links
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd6
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay6
%else
# service scripts
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/init.d
install -m0755 $RPM_SOURCE_DIR/rc.dhcpd \
$RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd
ln -sf %{_sysconfdir}/init.d/dhcpd \
$RPM_BUILD_ROOT%{_sbindir}/rcdhcpd
install -m0755 $RPM_SOURCE_DIR/rc.dhcpd6 \
$RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd6
ln -sf %{_sysconfdir}/init.d/dhcpd6 \
$RPM_BUILD_ROOT%{_sbindir}/rcdhcpd6
install -m0755 $RPM_SOURCE_DIR/rc.dhcrelay \
$RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay
ln -sf %{_sysconfdir}/init.d/dhcrelay \
$RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay
install -m0755 $RPM_SOURCE_DIR/rc.dhcrelay6 \
$RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay6
ln -sf %{_sysconfdir}/init.d/dhcrelay6 \
$RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay6
# rcservice links
ln -sf %{_sysconfdir}/init.d/dhcpd $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd
ln -sf %{_sysconfdir}/init.d/dhcpd6 $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd6
ln -sf %{_sysconfdir}/init.d/dhcrelay $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay
ln -sf %{_sysconfdir}/init.d/dhcrelay6 $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay6
%endif
# sysconfig files
install -m0644 $RPM_SOURCE_DIR/sysconfig.dhcpd \
$RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/
@ -388,14 +433,13 @@ ln -sf ../scripts/dhcpd-restart-hook \
# fix manual page permissions
find $RPM_BUILD_ROOT/%{_mandir} -type f | xargs chmod 644
# copy some documentation and examples from src dir
install -m0644 $RPM_SOURCE_DIR/dhcp.LIESMICH LIESMICH.SuSE
install -m0644 $RPM_SOURCE_DIR/dhcp.README README.SuSE
install -m0644 $RPM_SOURCE_DIR/dhcp.README.upgrade README.upgrade
install -m0644 $RPM_SOURCE_DIR/dhcp.README README.SUSE
install -m0644 $RPM_SOURCE_DIR/DDNS-howto.txt .
cp doc/examples/* ./examples/
rm -f doc/{References.xml,Makefile*}
rm -f contrib/dhcp.spec
rm -f $RPM_BUILD_ROOT/etc/{dhcpd,dhclient}.conf.example
find contrib doc/examples -type f | xargs chmod -x
# install bind libs+includes needed for dhcp-devel
pushd bind
install -d -m0755 $RPM_BUILD_ROOT%_includedir/
@ -412,9 +456,16 @@ popd
/usr/sbin/useradd -r -g nogroup -s /bin/false -c "DHCP server daemon" -d /var/lib/dhcp dhcpd 2> /dev/null ||:
%post server
%if %{with systemd}
%{fillup_only -ans dhcpd dhcpd}
%{fillup_only -ans syslog dhcpd}
%service_add_post dhcpd.service
%service_add_post dhcpd6.service
%else
%{fillup_and_insserv -n dhcpd dhcpd dhcpd6}
%{fillup_only -ans syslog dhcpd}
# update?
%endif
# FIXME: update?
if [ ${FIRST_ARG:-0} -gt 1 ]; then
if grep -q '^DHCPD_RUN_AS=.*nobody' etc/sysconfig/dhcpd; then
tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX)
@ -431,29 +482,73 @@ if [ ${FIRST_ARG:-0} -gt 1 ]; then
fi
%preun server
%stop_on_removal dhcpd
%stop_on_removal dhcpd6
%if %{with systemd}
%service_del_preun dhcpd.service
%service_del_preun dhcpd6.service
%else
if test -x /etc/init.d/dhcpd ; then
%stop_on_removal dhcpd
fi
if test -x /etc/init.d/dhcpd6 ; then
%stop_on_removal dhcpd6
fi
%endif
%postun server
%restart_on_update dhcpd
%restart_on_update dhcpd6
%if %{with systemd}
%service_del_postun dhcpd.service
%service_del_postun dhcpd6.service
%else
if test -x /etc/init.d/dhcpd ; then
%restart_on_update dhcpd
fi
if test -x /etc/init.d/dhcpd6 ; then
%restart_on_update dhcpd6
fi
%insserv_cleanup
%endif
%post relay
#
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
DHCRELAY6_LOWER_INTERFACES_ARGS DHCRELAY6_LOWER_INTERFACES}
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
DHCRELAY6_UPPER_INTERFACES_ARGS DHCRELAY6_UPPER_INTERFACES}
#
%if %{with systemd}
%{fillup_only -n dhcrelay dhcrelay}
%service_add_post dhcrelay.service
%service_add_post dhcrelay6.service
%else
%{fillup_and_insserv -n dhcrelay dhcrelay dhcrelay6}
%endif
%preun relay
%stop_on_removal dhcrelay
%stop_on_removal dhcrelay6
%if %{with systemd}
%service_del_preun dhcrelay.service
%service_del_preun dhcrelay6.service
%else
if test -x /etc/init.d/dhcrelay ; then
%stop_on_removal dhcrelay
fi
if test -x /etc/init.d/dhcrelay6 ; then
%stop_on_removal dhcrelay6
fi
%endif
%postun relay
%restart_on_update dhcrelay
%restart_on_update dhcrelay6
%if %{with systemd}
%service_del_postun dhcrelay.service
%service_del_postun dhcrelay6.service
%else
if test -x /etc/init.d/dhcrelay ; then
%restart_on_update dhcrelay
fi
if test -x /etc/init.d/dhcrelay6 ; then
%restart_on_update dhcrelay6
fi
%insserv_cleanup
%endif
%post client
test -e %{_localstatedir}/lib/dhcp/dhclient.leases || \
@ -479,12 +574,19 @@ if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi
%{_sbindir}/dhcpd6
%{_sbindir}/rcdhcpd
%{_sbindir}/rcdhcpd6
%if %{with systemd}
%{_unitdir}/dhcpd.service
%{_unitdir}/dhcpd6.service
%else
%config %{_sysconfdir}/init.d/dhcpd
%config %{_sysconfdir}/init.d/dhcpd6
%endif
%config(noreplace) %{_sysconfdir}/dhcpd.conf
%config(noreplace) %{_sysconfdir}/dhcpd6.conf
%attr(755,root,root) %dir %config(noreplace) %ghost %{_sysconfdir}/dhcpd.d/
%attr(755,root,root) %dir %config(noreplace) %ghost %{_sysconfdir}/dhcpd6.d/
%dir /usr/lib/dhcp
/usr/lib/dhcp/dhcpd
%dir %{_localstatedir}/lib/dhcp
%dir %{_localstatedir}/lib/dhcp/etc
%dir %{_localstatedir}/lib/dhcp/dev
@ -519,8 +621,7 @@ if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi
%defattr(-,root,root)
%endif
%doc LICENSE README RELNOTES
%doc LIESMICH.* README.*
%doc DDNS-howto.txt doc/*
%doc README.* DDNS-howto.txt doc/*
%doc contrib examples
%files client
@ -543,8 +644,15 @@ if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi
%{_sbindir}/dhcrelay6
%{_sbindir}/rcdhcrelay
%{_sbindir}/rcdhcrelay6
%dir /usr/lib/dhcp
/usr/lib/dhcp/dhcrelay
%if %{with systemd}
%{_unitdir}/dhcrelay.service
%{_unitdir}/dhcrelay6.service
%else
%config %{_sysconfdir}/init.d/dhcrelay
%config %{_sysconfdir}/init.d/dhcrelay6
%endif
%doc %{_mandir}/man8/dhcrelay.8.gz
%{_localstatedir}/adm/fillup-templates/sysconfig.dhcrelay

475
dhcpd.script Normal file
View File

@ -0,0 +1,475 @@
#! /bin/bash
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
# Copyright (c) 2002, 2003 SuSE Linux AG
# Copyright (c) 2004-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.
#
# Author: Rolf Haberrecker <rolf@suse.de>, 1997-1999
# Peter Poeml <poeml@suse.de>, 2000-2006
# Marius Tomaschewski <mt@suse.de>, 2006-2010
#
# /usr/lib/dhcp/dhcpd helper script, fromer /etc/init.d/dhcpd init script.
#
###
test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd
SUPPORTS_CHROOT="yes"
SUPPORTS_RUN_AS="yes"
SUPPORTS_HUP="no"
# note: $DAEMON_PIDFILE is a symlink to the
# $DAEMON_STATE$DAEMON_PIDFILE (also
# while DHCPD_RUN_CHROOTED=no) now,
# as DHCPD_RUN_AS is not allowed to
# create pid files in /var/run.
DHCPv_OPT=$1 ; shift
case $DHCPv_OPT in
-4)
DAEMON='ISC DHCPv4 Server'
DAEMON_BIN=/usr/sbin/dhcpd
DAEMON_CONF=/etc/dhcpd.conf
DAEMON_STATE=/var/lib/dhcp
DAEMON_LEASES=dhcpd.leases
DAEMON_PIDFILE=/var/run/dhcpd.pid
STARTPROC_LOGFILE=/var/log/rc.dhcpd.log
LDAP_CONF=/etc/openldap/ldap.conf
test "$DHCPD_RUN_CHROOTED" = "yes" && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
DHCPD_CONF_INCLUDE_FILES=${DHCPD_CONF_INCLUDE_FILES:-/etc/dhcpd.d}
;;
-6)
DAEMON='ISC DHCPv6 Server'
DAEMON_BIN=/usr/sbin/dhcpd
DAEMON_CONF=/etc/dhcpd6.conf
DAEMON_STATE=/var/lib/dhcp6
DAEMON_LEASES=dhcpd6.leases
DAEMON_PIDFILE=/var/run/dhcpd6.pid
STARTPROC_LOGFILE=/var/log/rc.dhcpd6.log
LDAP_CONF=""
test "$DHCPD6_RUN_CHROOTED" = "yes" && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
DHCPD_RUN_AS=$DHCPD6_RUN_AS
DHCPD_INTERFACE=$DHCPD6_INTERFACE
DHCPD_OTHER_ARGS=$DHCPD6_OTHER_ARGS
DHCPD_CONF_INCLUDE_FILES=${DHCPD6_CONF_INCLUDE_FILES:-/etc/dhcpd6.d}
;;
*)
echo >&2 "Usage: $0 <-4|-6> <action>"
exit 2
;;
esac
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "\"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
if ! [ -r "$DAEMON_CONF" ] ; then
case $1 in
stop|status)
if test ! -s /etc/sysconfig/dhcpd ; then
test -e $DAEMON_STATE/$DAEMON_PIDFILE && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
fi
;;
*)
echo -n >&2 "\"$DAEMON_CONF\" config file missed. Exiting."
rc_failed 6
rc_status -v
rc_exit
;;
esac
fi
# remove empty pid files to avoid disturbing warnings by checkproc/killproc
# (these can occur if dhcpd does not start correctly)
test -e $DAEMON_PIDFILE && ! test -s $DAEMON_PIDFILE && rm $DAEMON_PIDFILE
test -e $DAEMON_STATE/$DAEMON_PIDFILE && ! test -s $DAEMON_STATE/$DAEMON_PIDFILE && rm $DAEMON_STATE/$DAEMON_PIDFILE
case "$1" in
start)
echo -n "Starting $DAEMON "
## If there is no conf file, skip starting of dhcpd
## and return with "program not configured"
if ! [ -f $DAEMON_CONF ]; then
echo -n "... no configuration file found";
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
## If the interfaces are not set, skip starting of dhcpd
## and return with "program not configured"
if [ -z "$DHCPD_INTERFACE" ]; then
var="DHCPD_INTERFACE"
case $DHCPv_OPT in -6) var=DHCPD6_INTERFACE ;; esac
echo -n "... set $var in /etc/sysconfig/dhcpd"
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
if [ "$DHCPD_INTERFACE" = "ANY" ]; then
DHCPD_INTERFACE=""
fi
jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES
if ! [ -e $jail/db/$leases ]; then
# until 9.0, the lease file was in /var/lib/dhcp and part of the package
if test -e $jail/$leases -a '!' -L $jail/$leases; then
# this is the case where the %post script runs _before_ the old package is
# removed (i.e., dhcpd.leases has not renamed to .rpmsave yet)
mv $jail/$leases $jail/db/$leases && \
ln -s db/$leases $jail/
elif test -e $jail/$leases.rpmsave; then
# this is what's left when the package is already gone.
mv $jail/$leases.rpmsave $jail/db/$leases && \
ln -s db/$leases $jail/
else
# fresh installation:
# a lease file must be present. the server won't start without
touch $jail/db/$leases
fi
fi
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
## copy the conf file to the chroot jail (dhcpd has to be restarted anyway,
## when it has changed) and change path to leases file
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do
if test -d "${i}" ; then
test -d "$CHROOT_PREFIX/${i}" || \
mkdir -p "$CHROOT_PREFIX/${i}"
elif test -e "${i}" ; then
test -d "$CHROOT_PREFIX/${i%/*}" || \
mkdir -p "$CHROOT_PREFIX/${i%/*}"
fi
done
rm -f $CHROOT_PREFIX/dev/urandom
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc/{gai.conf,nsswitch.conf,resolv.conf,host.conf,hosts,localtime,bindresvport.blacklist} /dev/urandom; do
if ! test -e "$i"; then continue; fi # neither of them is absolutely necessary
cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
done
libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*))
if test -x /usr/bin/ldd ; then
get_ldd_deps()
{
ldd_wl="\/${libdir}\/lib"
ldd_bl="\/${libdir}\/libc\."
/usr/bin/ldd "$1" | \
while read -sr a b c d ; do
[ -n "$c" ] || continue
[[ $c =~ $ldd_wl ]] || continue
[[ $c =~ $ldd_bl ]] && continue
echo $c
done
}
else
get_ldd_deps() { :; }
fi
cplibs=`for i in /$libdir/{libresolv.so.*,libnss_*.so.*} \
/$libdir/{libpthread.so.0,libdl.so.2,libgcc_s.so.*} ;
do
if [ -s "$i" ] ; then
echo "$i"
get_ldd_deps "$i"
fi
done | sort -u`
for i in $cplibs ; do
if [ -s "$i" ]; then
cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
fi
done
# mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6}
mkdir -p ${CHROOT_PREFIX}/proc
mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null
DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES"
## If there is a pid file containing a pid, the machine might have crashed. pid files in
## /var/run are always cleaned up at boot time, but this is not the case for the pid file in
## the chroot jail. Therefore, and old pid file may exist. This is only a problem if it
## incidentally contains the pid of a running process. If this process is not a 'dhcpd',
## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.)
if test -s $DAEMON_STATE/$DAEMON_PIDFILE; then
p=$(<$DAEMON_STATE/$DAEMON_PIDFILE)
if test -n "$p" && grep -qsE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then
echo -n '(already running) '
else
rm -f $DAEMON_STATE/$DAEMON_PIDFILE
fi
fi
PID_FILE_ARG="$DAEMON_PIDFILE"
else
DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES"
PID_FILE_ARG="$DAEMON_STATE$DAEMON_PIDFILE"
fi
if [ -n "$DHCPD_RUN_AS" ]; then
DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)"
DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP"
chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \
"$DAEMON_STATE/${DAEMON_PIDFILE%/*}"
fi
## check syntax with -t (output to log file) and start only when the syntax is okay
rm -f $STARTPROC_LOGFILE # start log
error=0
if ! $DAEMON_BIN $DHCPv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $PID_FILE_ARG > $STARTPROC_LOGFILE 2>&1 ; then
error=1
else
## Start daemon. If this fails the return value is set appropriate.
## The init script should return 0, even if service is already running,
## to match the LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'"
$DAEMON_BIN $DHCPv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE
ret=$?
fi
if [ $error -gt 0 -o ${ret:-0} -gt 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details "
## set status to failed
rc_failed
else
ln -sf "$DAEMON_STATE$DAEMON_PIDFILE" "$DAEMON_PIDFILE"
[ "$DHCPD_RUN_CHROOTED" = "yes" ] && echo -n "[chroot]" || :
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON "
# Catch the case where daemon is running without chroot,
# but sysconfig/dhcp has been changed to use chroot (and
# another way around).
# In this case is there is no $chroot/$pidfile, but there
# should be a /pidfile that we use instead.
# We can not kill without pid file or dhcp4 kills dhcp6.
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
if test ! -s "$DAEMON_STATE$DAEMON_PIDFILE" -a \
-s "$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_PIDFILE"
fi
else
if test ! -s "$DAEMON_PIDFILE" -a \
-s "$DAEMON_STATE$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
fi
fi
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p "$PID_FILE" $DAEMON_BIN
ret=$?
# umount proc and remove libraries from the chroot jail,
# so they are not left over if the server is deinstalled
if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then
umount ${CHROOT_PREFIX}/proc 2>/dev/null
rm -f $CHROOT_PREFIX/lib*/*
fi
# Remember status and be verbose
rc_failed $ret
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 $DHCPv_OPT status
if test $? = 0; then
$0 $DHCPv_OPT restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Check syntax and when it is OK, stop the service
## and regardless of whether it was running or not,
## start it again.
if ! $0 $DHCPv_OPT check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 $DHCPv_OPT stop
sleep 3
$0 $DHCPv_OPT start
# Remember status and be quiet
rc_status
fi
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
elif ! $0 $DHCPv_OPT check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 $DHCPv_OPT stop && sleep 3 && $0 $DHCPv_OPT start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ]; then
# If it supports signalling:
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for $DAEMON: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_STATE/$DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
rc=0
for i in /etc/sysconfig/dhcpd $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES; do
test $i -nt $DAEMON_STATE/$DAEMON_PIDFILE && rc=1
done
test $rc = 1 && echo restart
;;
check-syntax|syntax-check)
echo -n "Checking syntax of $DAEMON_CONF: "
## this nice bit is from Edwin Groothuis:
## check syntax (quiet)
$DAEMON_BIN $DHCPv_OPT -q -t -cf $DAEMON_CONF
rc_status
if [ $? -ne 0 ]; then
echo ""
## check syntax (verbose)
$DAEMON_BIN $DHCPv_OPT -t -cf $DAEMON_CONF
echo -ne '\nConfig is NOT okay'
rc_failed
fi
rc_status -v
;;
check-lease|check-lease-file)
echo -n "Checking lease file $DAEMON_LEASES: "
if [ -s ${DAEMON_STATE}/db/$DAEMON_LEASES ] ; then
## check leases file (quiet)
$DAEMON_BIN $DHCPv_OPT -q -T -cf /dev/null -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
rc_status
if [ $? -ne 0 ]; then
echo ""
## check leases file (verbose)
$DAEMON_BIN $DHCPv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
echo -ne '\nLease file is NOT okay'
rc_failed
fi
else
rc_status -u
fi
rc_status -v
;;
*)
SCRIPT="${SCRIPT:-${0##*/} $DHCPv_OPT}"
echo "Usage: $SCRIPT {start|stop|status|try-restart|restart|force-reload|reload|probe|check-syntax} [-v]"
exit 1
esac
rc_exit

15
dhcpd.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=ISC DHCPv4 Server
Before=multi-user.target
After=remote-fs.target network.target nss-lookup.target time-sync.target ldap.service ndsd.service
[Service]
Type=forking
Restart=on-abort
ExecStart=/usr/lib/dhcp/dhcpd -4 start
ExecStop=/usr/lib/dhcp/dhcpd -4 stop
[Install]
WantedBy=multi-user.target
Alias=dhcp-server.service

15
dhcpd6.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=ISC DHCPv6 Server
Before=multi-user.target
After=remote-fs.target network.target nss-lookup.target time-sync.target ldap.service ndsd.service
[Service]
Type=forking
Restart=on-abort
ExecStart=/usr/lib/dhcp/dhcpd -6 start
ExecStop=/usr/lib/dhcp/dhcpd -6 stop
[Install]
WantedBy=multi-user.target
Alias=dhcp6-server.service

249
dhcrelay.script Normal file
View File

@ -0,0 +1,249 @@
#! /bin/sh
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
# Copyright (c) 2002 SuSE Linux AG
# Copyright (c) 2003-2014 SUSE LINUX Products GmbH
#
# Author: Peter Poeml <poeml@suse.de>, 2001
# Marius Tomaschewski <mt@suse.de>, 2010
#
# /usr/lib/dhcp/dhcrelay helper,
# fromer /etc/init.d/dhcrelay init script
#
###
DHCPv_OPT=$1 ; shift
case $DHCPv_OPT in
-4)
DAEMON="ISC DHCPv4 relay agent"
DAEMON_BIN=/usr/sbin/dhcrelay
DAEMON_CONF=/etc/sysconfig/dhcrelay
DAEMON_PIDFILE=/var/run/dhcrelay.pid
STARTPROC_LOGFILE=/var/log/rc.dhcrelay.log
SUPPORTS_HUP="no"
;;
-6)
DAEMON="ISC DHCPv6 relay agent"
DAEMON_BIN=/usr/sbin/dhcrelay6
DAEMON_CONF=/etc/sysconfig/dhcrelay
DAEMON_PIDFILE=/var/run/dhcrelay6.pid
STARTPROC_LOGFILE=/var/log/rc.dhcrelay6.log
;;
*)
echo >&2 "Usage: $0 <-4|-6> <action>"
exit 2
;;
esac
test -s "$DAEMON_CONF" && . "$DAEMON_CONF"
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting $DAEMON"
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN && {
echo -n "... already running"; rc_status -v; exit 0;
}
case $DHCPv_OPT in
-4)
## If interfaces or servers are not set, skip starting of dhcrelay
## and return with "program not configured"
if [ -z "$DHCRELAY_INTERFACES" -o -z "$DHCRELAY_SERVERS" ]; then
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
DHCRELAY_INTERFACES_ARGS=''
for i in $DHCRELAY_INTERFACES ; do
DHCRELAY_INTERFACES_ARGS="$DHCRELAY_INTERFACES_ARGS -i $i"
done
DHCRELAY_ARGS="$DHCRELAY_INTERFACES_ARGS $DHCRELAY_SERVERS"
;;
-6)
DHCRELAY6_LOWER_INTERFACES_ARGS=''
for l in $DHCRELAY6_LOWER_INTERFACES ; do
test "x$l" = x -o "x$l" = "x-l" && continue
DHCRELAY6_LOWER_INTERFACES_ARGS="$DHCRELAY6_LOWER_INTERFACES_ARGS -l $l"
done
DHCRELAY6_UPPER_INTERFACES_ARGS=''
for u in $DHCRELAY6_UPPER_INTERFACES ; do
test "x$u" = x -o "x$u" = "x-u" && continue
DHCRELAY6_UPPER_INTERFACES_ARGS="$DHCRELAY6_UPPER_INTERFACES_ARGS -u $u"
done
if [ "x$DHCRELAY6_LOWER_INTERFACES_ARGS" = x -o \
"x$DHCRELAY6_UPPER_INTERFACES_ARGS" = x ]; then
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
DHCRELAY_ARGS="$DHCRELAY6_LOWER_INTERFACES_ARGS $DHCRELAY6_UPPER_INTERFACES_ARGS"
;;
esac
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
# startproc should return 0, even if service is
# already running to match LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPv_OPT $DHCRELAY_OPTIONS $DHCRELAY_ARGS'"
startproc -q -l $STARTPROC_LOGFILE -p $DAEMON_PIDFILE $DAEMON_BIN $DHCPv_OPT $DHCRELAY_OPTIONS $DHCRELAY_ARGS &>/dev/null
rc=$?
if ! [ $rc -eq 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details "
## set status to failed
rc_failed
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p $DAEMON_PIDFILE $DAEMON_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
sleep 1
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
$0 stop && sleep 1 && $0 start
rc_status
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ] ; then
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
$0 stop && $0 start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
if [ "$SUPPORTS_HUP" = "yes" ] ; then
# If it supports signalling:
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for dhcp relay agent: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
if [ "$DAEMON_CONF" -nt "$DAEMON_PIDFILE" ]; then
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo reload
else
echo restart
fi
fi
;;
*)
SCRIPT="${SCRIPT:-${0##*/} $DHCPv_OPT}"
echo "Usage: $SCRIPT {start|stop|status|try-restart|restart|force-reload|reload|probe} [-v]"
exit 1
;;
esac
rc_exit

15
dhcrelay.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=ISC DHCPv4 Relay Agent
Before=multi-user.target
After=remote-fs.target network.target nss-lookup.target time-sync.target ldap.service ndsd.service
[Service]
Type=forking
Restart=on-abort
ExecStart=/usr/lib/dhcp/dhcrelay -4 start
ExecStop=/usr/lib/dhcp/dhcrelay -4 stop
[Install]
WantedBy=multi-user.target
Alias=dhcp-relay.service

15
dhcrelay6.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=ISC DHCPv6 Relay Agent
Before=multi-user.target
After=remote-fs.target network.target nss-lookup.target time-sync.target ldap.service ndsd.service
[Service]
Type=forking
Restart=on-abort
ExecStart=/usr/lib/dhcp/dhcrelay -6 start
ExecStop=/usr/lib/dhcp/dhcrelay -6 stop
[Install]
WantedBy=multi-user.target
Alias=dhcp6-relay.service

View File

@ -16,8 +16,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# Please send feedback via http://www.suse.de/feedback
#

434
rc.dhcpd
View File

@ -2,7 +2,7 @@
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
# Copyright (c) 2002, 2003 SuSE Linux AG
# Copyright (c) 2004-2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2004-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@ -41,429 +41,11 @@
# needs to rely on time synchronisation.)
### END INIT INFO
test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd
SUPPORTS_CHROOT="yes"
SUPPORTS_RUN_AS="yes"
SUPPORTS_HUP="no"
DHCPDv_OPT=-4
test "$SUPPORTS_CHROOT" = no && DHCPD_RUN_CHROOTED=no
test "$SUPPORTS_RUN_AS" = no && DHCPD_RUN_AS=""
test "$DHCPD_BINARY" = "/usr/sbin/dhcpd.lpf" -o \
"$DHCPD_BINARY" = "/usr/sbin/dhcpd.bsd" && \
DHCPD_BINARY=/usr/sbin/dhcpd
DHCPD_CONF_INCLUDE_FILES=${DHCPD_CONF_INCLUDE_FILES:-/etc/dhcpd.d}
DAEMON='ISC DHCPv4 4.x Server'
DAEMON_BIN=${DHCPD_BINARY:=/usr/sbin/dhcpd}
DAEMON_CONF=/etc/dhcpd.conf
DAEMON_STATE=/var/lib/dhcp
DAEMON_LEASES=dhcpd.leases
# note: $DAEMON_PIDFILE is a symlink to the
# $DAEMON_STATE$DAEMON_PIDFILE (also
# while DHCPD_RUN_CHROOTED=no) now,
# as DHCPD_RUN_AS is not allowed to
# create pid files in /var/run.
DAEMON_PIDFILE=/var/run/dhcpd.pid
STARTPROC_LOGFILE=/var/log/rc.dhcpd.log
LDAP_CONF=/etc/openldap/ldap.conf
test "$DHCPD_RUN_CHROOTED" = "yes" && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
if ! [ -r "$DAEMON_CONF" ] ; then
case $1 in
stop|status)
if test ! -s /etc/sysconfig/dhcpd ; then
test -e $DAEMON_STATE/$DAEMON_PIDFILE && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
fi
;;
*)
echo -n >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."
rc_failed 6
rc_status -v
rc_exit
;;
esac
fi
# remove empty pid files to avoid disturbing warnings by checkproc/killproc
# (these can occur if dhcpd does not start correctly)
test -e $DAEMON_PIDFILE && ! test -s $DAEMON_PIDFILE && rm $DAEMON_PIDFILE
test -e $DAEMON_STATE/$DAEMON_PIDFILE && ! test -s $DAEMON_STATE/$DAEMON_PIDFILE && rm $DAEMON_STATE/$DAEMON_PIDFILE
case "$1" in
start)
echo -n "Starting $DAEMON "
## If there is no conf file, skip starting of dhcpd
## and return with "program not configured"
if ! [ -f $DAEMON_CONF ]; then
echo -n "... no configuration file found";
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
## If the interfaces are not set, skip starting of dhcpd
## and return with "program not configured"
if [ -z "$DHCPD_INTERFACE" ]; then
var="DHCPD_INTERFACE"
case $DHCPDv_OPT in -6) var=DHCPD6_INTERFACE ;; esac
echo -n "... set $var in /etc/sysconfig/dhcpd"
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
if [ "$DHCPD_INTERFACE" = "ANY" ]; then
DHCPD_INTERFACE=""
fi
jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES
if ! [ -e $jail/db/$leases ]; then
# until 9.0, the lease file was in /var/lib/dhcp and part of the package
if test -e $jail/$leases -a '!' -L $jail/$leases; then
# this is the case where the %post script runs _before_ the old package is
# removed (i.e., dhcpd.leases has not renamed to .rpmsave yet)
mv $jail/$leases $jail/db/$leases && \
ln -s db/$leases $jail/
elif test -e $jail/$leases.rpmsave; then
# this is what's left when the package is already gone.
mv $jail/$leases.rpmsave $jail/db/$leases && \
ln -s db/$leases $jail/
else
# fresh installation:
# a lease file must be present. the server won't start without
touch $jail/db/$leases
fi
fi
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
## copy the conf file to the chroot jail (dhcpd has to be restarted anyway,
## when it has changed) and change path to leases file
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do
if test -d "${i}" ; then
test -d "$CHROOT_PREFIX/${i}" || \
mkdir -p "$CHROOT_PREFIX/${i}"
elif test -e "${i}" ; then
test -d "$CHROOT_PREFIX/${i%/*}" || \
mkdir -p "$CHROOT_PREFIX/${i%/*}"
fi
done
rm -f $CHROOT_PREFIX/dev/urandom
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc/{gai.conf,nsswitch.conf,resolv.conf,host.conf,hosts,localtime,bindresvport.blacklist} /dev/urandom; do
if ! test -e "$i"; then continue; fi # neither of them is absolutely necessary
cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
done
libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*))
if test -x /usr/bin/ldd ; then
get_ldd_deps()
{
ldd_wl="\/${libdir}\/lib"
ldd_bl="\/${libdir}\/libc\."
/usr/bin/ldd "$1" | \
while read -sr a b c d ; do
[ -n "$c" ] || continue
[[ $c =~ $ldd_wl ]] || continue
[[ $c =~ $ldd_bl ]] && continue
echo $c
done
}
else
get_ldd_deps() { :; }
fi
cplibs=`for i in /$libdir/{libresolv.so.*,libnss_*.so.*} \
/$libdir/{libpthread.so.0,libdl.so.2,libgcc_s.so.*} ;
do
if [ -s "$i" ] ; then
echo "$i"
get_ldd_deps "$i"
fi
done | sort -u`
for i in $cplibs ; do
if [ -s "$i" ]; then
cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
fi
done
# mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6}
mkdir -p ${CHROOT_PREFIX}/proc
mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null
DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES"
## If there is a pid file containing a pid, the machine might have crashed. pid files in
## /var/run are always cleaned up at boot time, but this is not the case for the pid file in
## the chroot jail. Therefore, and old pid file may exist. This is only a problem if it
## incidentally contains the pid of a running process. If this process is not a 'dhcpd',
## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.)
if test -s $DAEMON_STATE/$DAEMON_PIDFILE; then
p=$(<$DAEMON_STATE/$DAEMON_PIDFILE)
if test -n "$p" && grep -qsE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then
echo -n '(already running) '
else
rm -f $DAEMON_STATE/$DAEMON_PIDFILE
fi
fi
PID_FILE_ARG="$DAEMON_PIDFILE"
else
DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES"
PID_FILE_ARG="$DAEMON_STATE$DAEMON_PIDFILE"
fi
if [ -n "$DHCPD_RUN_AS" ]; then
DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)"
DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP"
chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \
"$DAEMON_STATE/${DAEMON_PIDFILE%/*}"
fi
## check syntax with -t (output to log file) and start only when the syntax is okay
rm -f $STARTPROC_LOGFILE # start log
error=0
if ! $DAEMON_BIN $DHCPDv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $PID_FILE_ARG > $STARTPROC_LOGFILE 2>&1 ; then
error=1
else
## Start daemon. If this fails the return value is set appropriate.
## The init script should return 0, even if service is already running,
## to match the LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'"
$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE
ret=$?
fi
if [ $error -gt 0 -o ${ret:-0} -gt 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details "
## set status to failed
rc_failed
else
ln -sf "$DAEMON_STATE$DAEMON_PIDFILE" "$DAEMON_PIDFILE"
[ "$DHCPD_RUN_CHROOTED" = "yes" ] && echo -n "[chroot]" || :
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON "
# Catch the case where daemon is running without chroot,
# but sysconfig/dhcp has been changed to use chroot (and
# another way around).
# In this case is there is no $chroot/$pidfile, but there
# should be a /pidfile that we use instead.
# We can not kill without pid file or dhcp4 kills dhcp6.
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
if test ! -s "$DAEMON_STATE$DAEMON_PIDFILE" -a \
-s "$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_PIDFILE"
fi
else
if test ! -s "$DAEMON_PIDFILE" -a \
-s "$DAEMON_STATE$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
fi
fi
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p "$PID_FILE" $DAEMON_BIN
ret=$?
# umount proc and remove libraries from the chroot jail,
# so they are not left over if the server is deinstalled
if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then
umount ${CHROOT_PREFIX}/proc 2>/dev/null
rm -f $CHROOT_PREFIX/lib*/*
fi
# Remember status and be verbose
rc_failed $ret
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Check syntax and when it is OK, stop the service
## and regardless of whether it was running or not,
## start it again.
if ! $0 check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 stop
sleep 3
$0 start
# Remember status and be quiet
rc_status
fi
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
elif ! $0 check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 stop && sleep 3 && $0 start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ]; then
# If it supports signalling:
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for $DAEMON: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_STATE/$DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
rc=0
for i in /etc/sysconfig/dhcpd $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES; do
test $i -nt $DAEMON_STATE/$DAEMON_PIDFILE && rc=1
done
test $rc = 1 && echo restart
;;
check-syntax|syntax-check)
echo -n "Checking syntax of $DAEMON_CONF: "
## this nice bit is from Edwin Groothuis:
## check syntax (quiet)
$DAEMON_BIN $DHCPDv_OPT -q -t -cf $DAEMON_CONF
rc_status
if [ $? -ne 0 ]; then
echo ""
## check syntax (verbose)
$DAEMON_BIN $DHCPDv_OPT -t -cf $DAEMON_CONF
echo -ne '\nConfig is NOT okay'
rc_failed
fi
rc_status -v
;;
check-lease|check-lease-file)
echo -n "Checking lease file $DAEMON_LEASES: "
if [ -s ${DAEMON_STATE}/db/$DAEMON_LEASES ] ; then
## check leases file (quiet)
$DAEMON_BIN $DHCPDv_OPT -q -T -cf /dev/null -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
rc_status
if [ $? -ne 0 ]; then
echo ""
## check leases file (verbose)
$DAEMON_BIN $DHCPDv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
echo -ne '\nLease file is NOT okay'
rc_failed
fi
else
rc_status -u
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|check-syntax} [-v]"
exit 1
test -x /usr/lib/dhcp/dhcpd || exit 5
case $1 in
start|stop|try-restart|restart|force-reload|reload|status|probe|*)
export SCRIPT=${0##*/}
exec /usr/lib/dhcp/dhcpd -4 "$@" || exit 1
;;
esac
rc_exit

435
rc.dhcpd6
View File

@ -41,432 +41,11 @@
# needs to rely on time synchronisation.)
### END INIT INFO
test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd
SUPPORTS_CHROOT="yes"
SUPPORTS_RUN_AS="yes"
SUPPORTS_HUP="no"
DHCPDv_OPT=-6
DHCPD_RUN_CHROOTED=$DHCPD6_RUN_CHROOTED
DHCPD_RUN_AS=$DHCPD6_RUN_AS
DHCPD_BINARY=$DHCPD6_BINARY
DHCPD_INTERFACE=$DHCPD6_INTERFACE
DHCPD_CONF_INCLUDE_FILES=${DHCPD6_CONF_INCLUDE_FILES:-/etc/dhcpd6.d}
DHCPD_OTHER_ARGS=$DHCPD6_OTHER_ARGS
test "$SUPPORTS_CHROOT" = no && DHCPD_RUN_CHROOTED=no
test "$SUPPORTS_RUN_AS" = no && DHCPD_RUN_AS=""
DAEMON='ISC DHCPv6 4.x Server'
DAEMON_BIN=${DHCPD_BINARY:=/usr/sbin/dhcpd6}
DAEMON_CONF=/etc/dhcpd6.conf
DAEMON_STATE=/var/lib/dhcp6
DAEMON_LEASES=dhcpd6.leases
# note: $DAEMON_PIDFILE is a symlink to the
# $DAEMON_STATE$DAEMON_PIDFILE (also
# while DHCPD_RUN_CHROOTED=no) now,
# as DHCPD_RUN_AS is not allowed to
# create pid files in /var/run.
DAEMON_PIDFILE=/var/run/dhcpd6.pid
STARTPROC_LOGFILE=/var/log/rc.dhcpd6.log
LDAP_CONF=
test "$DHCPD_RUN_CHROOTED" = "yes" && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
if ! [ -r "$DAEMON_CONF" ] ; then
case $1 in
stop|status)
if test ! -s /etc/sysconfig/dhcpd ; then
test -e $DAEMON_STATE/$DAEMON_PIDFILE && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
fi
;;
*)
echo -n >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."
rc_failed 6
rc_status -v
rc_exit
;;
esac
fi
# remove empty pid files to avoid disturbing warnings by checkproc/killproc
# (these can occur if dhcpd does not start correctly)
test -e $DAEMON_PIDFILE && ! test -s $DAEMON_PIDFILE && rm $DAEMON_PIDFILE
test -e $DAEMON_STATE/$DAEMON_PIDFILE && ! test -s $DAEMON_STATE/$DAEMON_PIDFILE && rm $DAEMON_STATE/$DAEMON_PIDFILE
case "$1" in
start)
echo -n "Starting $DAEMON "
## If there is no conf file, skip starting of dhcpd
## and return with "program not configured"
if ! [ -f $DAEMON_CONF ]; then
echo -n "... no configuration file found";
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
## If the interfaces are not set, skip starting of dhcpd
## and return with "program not configured"
if [ -z "$DHCPD_INTERFACE" ]; then
var="DHCPD_INTERFACE"
case $DHCPDv_OPT in -6) var=DHCPD6_INTERFACE ;; esac
echo -n "... set $var in /etc/sysconfig/dhcpd"
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
if [ "$DHCPD_INTERFACE" = "ANY" ]; then
DHCPD_INTERFACE=""
fi
jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES
if ! [ -e $jail/db/$leases ]; then
# until 9.0, the lease file was in /var/lib/dhcp and part of the package
if test -e $jail/$leases -a '!' -L $jail/$leases; then
# this is the case where the %post script runs _before_ the old package is
# removed (i.e., dhcpd.leases has not renamed to .rpmsave yet)
mv $jail/$leases $jail/db/$leases && \
ln -s db/$leases $jail/
elif test -e $jail/$leases.rpmsave; then
# this is what's left when the package is already gone.
mv $jail/$leases.rpmsave $jail/db/$leases && \
ln -s db/$leases $jail/
else
# fresh installation:
# a lease file must be present. the server won't start without
touch $jail/db/$leases
fi
fi
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
## copy the conf file to the chroot jail (dhcpd has to be restarted anyway,
## when it has changed) and change path to leases file
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do
if test -d "${i}" ; then
test -d "$CHROOT_PREFIX/${i}" || \
mkdir -p "$CHROOT_PREFIX/${i}"
elif test -e "${i}" ; then
test -d "$CHROOT_PREFIX/${i%/*}" || \
mkdir -p "$CHROOT_PREFIX/${i%/*}"
fi
done
rm -f $CHROOT_PREFIX/dev/urandom
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc/{gai.conf,nsswitch.conf,resolv.conf,host.conf,hosts,localtime,bindresvport.blacklist} /dev/urandom; do
if ! test -e "$i"; then continue; fi # neither of them is absolutely necessary
cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
done
libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*))
if test -x /usr/bin/ldd ; then
get_ldd_deps()
{
ldd_wl="\/${libdir}\/lib"
ldd_bl="\/${libdir}\/libc\."
/usr/bin/ldd "$1" | \
while read -sr a b c d ; do
[ -n "$c" ] || continue
[[ $c =~ $ldd_wl ]] || continue
[[ $c =~ $ldd_bl ]] && continue
echo $c
done
}
else
get_ldd_deps() { :; }
fi
cplibs=`for i in /$libdir/{libresolv.so.*,libnss_*.so.*} \
/$libdir/{libpthread.so.0,libdl.so.2,libgcc_s.so.*} ;
do
if [ -s "$i" ] ; then
echo "$i"
get_ldd_deps "$i"
fi
done | sort -u`
for i in $cplibs ; do
if [ -s "$i" ]; then
cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
fi
done
# mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6}
mkdir -p ${CHROOT_PREFIX}/proc
mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null
DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES"
## If there is a pid file containing a pid, the machine might have crashed. pid files in
## /var/run are always cleaned up at boot time, but this is not the case for the pid file in
## the chroot jail. Therefore, and old pid file may exist. This is only a problem if it
## incidentally contains the pid of a running process. If this process is not a 'dhcpd',
## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.)
if test -s $DAEMON_STATE/$DAEMON_PIDFILE; then
p=$(<$DAEMON_STATE/$DAEMON_PIDFILE)
if test -n "$p" && grep -qsE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then
echo -n '(already running) '
else
rm -f $DAEMON_STATE/$DAEMON_PIDFILE
fi
fi
PID_FILE_ARG="$DAEMON_PIDFILE"
else
DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES"
PID_FILE_ARG="$DAEMON_STATE$DAEMON_PIDFILE"
fi
if [ -n "$DHCPD_RUN_AS" ]; then
DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)"
DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP"
chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \
"$DAEMON_STATE/${DAEMON_PIDFILE%/*}"
fi
## check syntax with -t (output to log file) and start only when the syntax is okay
rm -f $STARTPROC_LOGFILE # start log
error=0
if ! $DAEMON_BIN $DHCPDv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $PID_FILE_ARG > $STARTPROC_LOGFILE 2>&1 ; then
error=1
else
## Start daemon. If this fails the return value is set appropriate.
## The init script should return 0, even if service is already running,
## to match the LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'"
$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $PID_FILE_ARG $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE
ret=$?
fi
if [ $error -gt 0 -o ${ret:-0} -gt 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details "
## set status to failed
rc_failed
else
ln -sf "$DAEMON_STATE$DAEMON_PIDFILE" "$DAEMON_PIDFILE"
[ "$DHCPD_RUN_CHROOTED" = "yes" ] && echo -n "[chroot]" || :
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON "
# Catch the case where daemon is running without chroot,
# but sysconfig/dhcp has been changed to use chroot (and
# another way around).
# In this case is there is no $chroot/$pidfile, but there
# should be a /pidfile that we use instead.
# We can not kill without pid file or dhcp4 kills dhcp6.
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
if test ! -s "$DAEMON_STATE$DAEMON_PIDFILE" -a \
-s "$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_PIDFILE"
fi
else
if test ! -s "$DAEMON_PIDFILE" -a \
-s "$DAEMON_STATE$DAEMON_PIDFILE" ; then
PID_FILE="$DAEMON_STATE$DAEMON_PIDFILE"
fi
fi
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p "$PID_FILE" $DAEMON_BIN
ret=$?
# umount proc and remove libraries from the chroot jail,
# so they are not left over if the server is deinstalled
if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then
umount ${CHROOT_PREFIX}/proc 2>/dev/null
rm -f $CHROOT_PREFIX/lib*/*
fi
# Remember status and be verbose
rc_failed $ret
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Check syntax and when it is OK, stop the service
## and regardless of whether it was running or not,
## start it again.
if ! $0 check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 stop
sleep 3
$0 start
# Remember status and be quiet
rc_status
fi
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
elif ! $0 check-syntax &>/dev/null ; then
echo -n "Syntax check reports errors, see log messages"
rc_failed
rc_status -v
else
$0 stop && sleep 3 && $0 start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ]; then
# If it supports signalling:
killproc -p $DAEMON_STATE/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_STATE/$DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for $DAEMON: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_STATE/$DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
rc=0
for i in /etc/sysconfig/dhcpd $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES; do
test $i -nt $DAEMON_STATE/$DAEMON_PIDFILE && rc=1
done
test $rc = 1 && echo restart
;;
check-syntax|syntax-check)
echo -n "Checking syntax of $DAEMON_CONF: "
## this nice bit is from Edwin Groothuis:
## check syntax (quiet)
$DAEMON_BIN $DHCPDv_OPT -q -t -cf $DAEMON_CONF
rc_status
if [ $? -ne 0 ]; then
echo ""
## check syntax (verbose)
$DAEMON_BIN $DHCPDv_OPT -t -cf $DAEMON_CONF
echo -ne '\nConfig is NOT okay'
rc_failed
fi
rc_status -v
;;
check-lease|check-lease-file)
echo -n "Checking lease file $DAEMON_LEASES: "
if [ -s ${DAEMON_STATE}/db/$DAEMON_LEASES ] ; then
## check leases file (quiet)
$DAEMON_BIN $DHCPDv_OPT -q -T -cf /dev/null -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
rc_status
if [ $? -ne 0 ]; then
echo ""
## check leases file (verbose)
$DAEMON_BIN $DHCPDv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
echo -ne '\nLease file is NOT okay'
rc_failed
fi
else
rc_status -u
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|check-syntax} [-v]"
exit 1
test -x /usr/lib/dhcp/dhcpd || exit 5
case $1 in
start|stop|try-restart|restart|force-reload|reload|status|probe|*)
export SCRIPT=${0##*/}
exec /usr/lib/dhcp/dhcpd -6 "$@" || exit 1
;;
esac
rc_exit

View File

@ -25,197 +25,11 @@
# physical network segment to another.
### END INIT INFO
DHCPv_OPT=-4
DAEMON="ISC DHCPv4 relay agent"
DAEMON_BIN=/usr/sbin/dhcrelay
DAEMON_CONF=/etc/sysconfig/dhcrelay
DAEMON_PIDFILE=/var/run/dhcrelay.pid
STARTPROC_LOGFILE=/var/log/rc.dhcrelay.log
SUPPORTS_HUP="no"
test -s "$DAEMON_CONF" && . "$DAEMON_CONF"
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting $DAEMON"
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN && {
echo -n "... already running"; rc_status -v; exit 0;
}
## If interfaces or servers are not set, skip starting of dhcrelay
## and return with "program not configured"
if [ -z "$DHCRELAY_INTERFACES" -o -z "$DHCRELAY_SERVERS" ]; then
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
DHCRELAY_INTERFACES_ARGS=''
for i in $DHCRELAY_INTERFACES ; do
DHCRELAY_INTERFACES_ARGS="$DHCRELAY_INTERFACES_ARGS -i $i"
done
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
# startproc should return 0, even if service is
# already running to match LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPv_OPT $DHCRELAY_OPTIONS $DHCRELAY_INTERFACES_ARGS $DHCRELAY_SERVERS'"
startproc -q -l $STARTPROC_LOGFILE -p $DAEMON_PIDFILE $DAEMON_BIN $DHCPv_OPT $DHCRELAY_OPTIONS $DHCRELAY_INTERFACES_ARGS $DHCRELAY_SERVERS &>/dev/null
rc=$?
if ! [ $rc -eq 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details "
## set status to failed
rc_failed
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p $DAEMON_PIDFILE $DAEMON_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
sleep 1
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
$0 stop && sleep 1 && $0 start
rc_status
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ] ; then
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
$0 stop && $0 start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
if [ "$SUPPORTS_HUP" = "yes" ] ; then
# If it supports signalling:
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for dhcp relay agent: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
if [ "$DAEMON_CONF" -nt "$DAEMON_PIDFILE" ]; then
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo reload
else
echo restart
fi
fi
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe} [-v]"
exit 1
;;
test -x /usr/lib/dhcp/dhcrelay || exit 5
case $1 in
start|stop|try-restart|restart|force-reload|reload|status|probe|*)
export SCRIPT=${0##*/}
exec /usr/lib/dhcp/dhcrelay -4 "$@" || exit 1
;;
esac
rc_exit

View File

@ -25,205 +25,11 @@
# physical network segment to another.
### END INIT INFO
DHCPv_OPT=-6
DAEMON="ISC DHCPv6 relay agent"
DAEMON_BIN=/usr/sbin/dhcrelay6
DAEMON_CONF=/etc/sysconfig/dhcrelay
DAEMON_PIDFILE=/var/run/dhcrelay6.pid
STARTPROC_LOGFILE=/var/log/rc.dhcrelay6.log
SUPPORTS_HUP="no"
test -s "$DAEMON_CONF" && . "$DAEMON_CONF"
if ! [ -x "$DAEMON_BIN" ]; then
case $1 in
stop) ;;
*) echo -n >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
case $1 in
status) rc_failed 4 ;;
*) rc_failed 5 ;;
esac
rc_status -v
;;
esac
rc_exit
fi
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting $DAEMON"
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN && {
echo -n "... already running"; rc_status -v; exit 0;
}
DHCRELAY6_LOWER_INTERFACES_ARGS=''
for l in $DHCRELAY6_LOWER_INTERFACES ; do
test "x$l" = x -o "x$l" = "x-l" && continue
DHCRELAY6_LOWER_INTERFACES_ARGS="$DHCRELAY6_LOWER_INTERFACES_ARGS -l $l"
done
DHCRELAY6_UPPER_INTERFACES_ARGS=''
for u in $DHCRELAY6_UPPER_INTERFACES ; do
test "x$u" = x -o "x$u" = "x-u" && continue
DHCRELAY6_UPPER_INTERFACES_ARGS="$DHCRELAY6_UPPER_INTERFACES_ARGS -u $u"
done
## If interfaces or servers are not set, skip starting of dhcrelay
## and return with "program not configured"
if [ "x$DHCRELAY6_LOWER_INTERFACES_ARGS" = x -o \
"x$DHCRELAY6_UPPER_INTERFACES_ARGS" = x ]; then
# Tell the user this has skipped
rc_status -s
# service is not configured
exit 6;
fi
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
# startproc should return 0, even if service is
# already running to match LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPv_OPT $DHCRELAY6_OPTIONS $DHCRELAY6_LOWER_INTERFACES_ARGS $DHCRELAY6_UPPER_INTERFACES_ARGS'"
startproc -q -l $STARTPROC_LOGFILE -p $DAEMON_PIDFILE $DAEMON_BIN $DHCPv_OPT $DHCRELAY6_OPTIONS $DHCRELAY6_LOWER_INTERFACES_ARGS $DHCRELAY6_UPPER_INTERFACES_ARGS &>/dev/null
rc=$?
if ! [ $rc -eq 0 ]; then
## be verbose
echo ""
echo -n " please see $STARTPROC_LOGFILE for details ";
## set status to failed
rc_failed
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down $DAEMON"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
killproc -p $DAEMON_PIDFILE $DAEMON_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
sleep 1
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
$0 stop && sleep 1 && $0 start
rc_status
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ] ; then
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
$0 stop && $0 start
rc_status
fi
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
if [ "$SUPPORTS_HUP" = "yes" ] ; then
# If it supports signalling:
echo -n "Reload service $DAEMON"
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
rc_failed 3
rc_status -v
fi
;;
status)
echo -n "Checking for dhcp relay agent: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc -p $DAEMON_PIDFILE $DAEMON_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
if [ "$DAEMON_CONF" -nt "$DAEMON_PIDFILE" ]; then
if [ "$SUPPORTS_HUP" = "yes" ]; then
echo reload
else
echo restart
fi
fi
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe} [-v]"
exit 1
;;
test -x /usr/lib/dhcp/dhcrelay || exit 5
case $1 in
start|stop|try-restart|restart|force-reload|reload|status|probe|*)
export SCRIPT=${0##*/}
exec /usr/lib/dhcp/dhcrelay -6 "$@" || exit 1
;;
esac
rc_exit

View File

@ -182,25 +182,3 @@ DHCPD_OTHER_ARGS=""
#
DHCPD6_OTHER_ARGS=""
## Type: string
## Default: ""
## ServiceRestart: dhcpd
#
# You may specify another dhcpd binary to be run.
# The full path needs to be specified.
#
# If empty, the default applies.
#
DHCPD_BINARY=""
## Type: string
## Default: ""
## ServiceRestart: dhcpd6
#
# You may specify another dhcpd binary to be run.
# The full path needs to be specified.
#
# If empty, the default applies.
#
DHCPD6_BINARY=""