Hello community,
here is the log from the commit of package dhcdbd
checked in at Sun May 7 15:52:20 CEST 2006.
--------
--- dhcdbd/dhcdbd.changes 2006-03-28 16:58:55.000000000 +0200
+++ STABLE/dhcdbd/dhcdbd.changes 2006-05-04 23:03:59.000000000 +0200
@@ -1,0 +2,7 @@
+Thu May 4 23:02:48 CEST 2006 - rml@suse.de
+
+- Ask dhclient to set the hostname as required by the sysconfig
+ option DHCLIENT_HOSTNAME_OPTION (Novell major bug #139532)
+- Fix possible memory corruption
+
+-------------------------------------------------------------------
New:
----
dhcdbd-1.14-bug-fixes.patch
dhcdbd-set-hostname.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ dhcdbd.spec ++++++
--- /var/tmp/diff_new_pack.ezj9Le/_old 2006-05-07 15:51:24.000000000 +0200
+++ /var/tmp/diff_new_pack.ezj9Le/_new 2006-05-07 15:51:24.000000000 +0200
@@ -14,7 +14,7 @@
BuildRequires: dbus-1-devel
Summary: DHCP D-BUS Daemon
Version: 1.12
-Release: 10
+Release: 17
License: GPL
Group: Productivity/Networking/Boot/Utilities
URL: http://people.redhat.com/~jvdias/dhcdbd
@@ -24,6 +24,8 @@
Patch2: dhcdbd-no-nr_open-rml.patch
Patch3: dhcdbd-dbus-reconnect-thoenig-02.patch
Patch4: dhcdbd-less-verbose-logging-rml.patch
+Patch5: dhcdbd-set-hostname.patch
+Patch6: dhcdbd-1.14-bug-fixes.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: dhcp-client >= 3.0.3 dbus-1 >= 0.60
@@ -44,6 +46,8 @@
%patch2 -p1
%patch3 -p0
%patch4 -p1
+%patch5 -p1
+%patch6 -p1
%build
make CFLAGS="-Wall $RPM_OPT_FLAGS" CC='gcc' LIBDIR=%_lib
@@ -67,6 +71,10 @@
%dir /var/lib/named
%changelog -n dhcdbd
+* Thu May 04 2006 - rml@suse.de
+- Ask dhclient to set the hostname as required by the sysconfig
+ option DHCLIENT_HOSTNAME_OPTION (Novell major bug #139532)
+- Fix possible memory corruption
* Tue Mar 28 2006 - rml@suse.de
- Log debugging spew less readily (Novell bug #161138)
* Tue Mar 21 2006 - rml@suse.de
++++++ dhcdbd-1.14-bug-fixes.patch ++++++
CHANGES | 11 +++++++++++
dhcp_options.c | 4 ++--
dhcp_options.h | 8 ++++----
diff -urN dhcdbd-1.12/CHANGES dhcdbd-1.14/CHANGES
--- dhcdbd-1.12/CHANGES 2006-01-17 16:23:51.000000000 -0500
+++ dhcdbd-1.14/CHANGES 2006-04-20 15:43:43.000000000 -0400
@@ -1,6 +1,17 @@
dhcdbd Change Log
~~~~~~~~~~~~~~~~~
+* Thu Apr 20 2006 Jason Vas Dias - 1.14-1.FC5
+- fix bug 189529: prevent potential memory corruption on hex string
+options with single-byte non-ascii values
+- modify dhcp option types to be in line with latest ISC dhcp
+
+* Fri Feb 10 2006 Jesse Keating - 1.12-1.FC5.2
+- bump again for double-long bug on ppc(64)
+
+* Tue Feb 07 2006 Jesse Keating - 1.12-1.FC5.1
+- rebuilt for new gcc4.1 snapshot and glibc changes
+
* Tue Jan 17 2006 Jason Vas Dias 1.12-1
- Cleanup un-exercised code in dbus_service.c, lines 381 & 391
(pointed out by David Binderman)
diff -urN dhcdbd-1.12/dhcp_options.c dhcdbd-1.14/dhcp_options.c
--- dhcdbd-1.12/dhcp_options.c 2006-01-17 16:23:51.000000000 -0500
+++ dhcdbd-1.14/dhcp_options.c 2006-04-20 14:39:57.000000000 -0400
@@ -1267,7 +1267,7 @@
}
return octs;
}
- for(p = (uint8_t*)input; p < (endp-1); p++)
+ for(p = (uint8_t*)input; p < endp; p++)
{
if( (*p < 32) || (*p > 127) )
{
@@ -1555,7 +1555,7 @@
if( vlen <= 0 )
return 0;
for( p = *value, endp = (*value) + vlen;
- p < (endp-1);
+ p < endp;
p++
)
if( (*p < 32) || (*p > 127) )
diff -urN dhcdbd-1.12/dhcp_options.h dhcdbd-1.14/dhcp_options.h
--- dhcdbd-1.12/dhcp_options.h 2006-01-17 16:23:51.000000000 -0500
+++ dhcdbd-1.14/dhcp_options.h 2006-04-20 15:27:24.000000000 -0400
@@ -449,7 +449,7 @@
{ "lpr-servers", "IA", DHC_O_Universe, 9, 0 },
{ "impress-servers", "IA", DHC_O_Universe, 10, 0 },
{ "resource-location-servers", "IA", DHC_O_Universe, 11, 0 },
- { "host-name", "X", DHC_O_Universe, 12, 0 },
+ { "host-name", "t", DHC_O_Universe, 12, 0 },
{ "boot-size", "S", DHC_O_Universe, 13, 0 },
{ "merit-dump", "t", DHC_O_Universe, 14, 0 },
{ "domain-name", "t", DHC_O_Universe, 15, 0 },
@@ -499,7 +499,7 @@
{ "dhcp-rebinding-time", "L", DHC_O_Universe, 59, 0 },
{ "vendor-class-identifier", "X", DHC_O_Universe, 60, 0 },
{ "dhcp-client-identifier", "X", DHC_O_Universe, 61, 0 },
- { "nwip-domain", "X", DHC_O_Universe, 62, 0 },
+ { "nwip-domain", "t", DHC_O_Universe, 62, 0 },
{ "nwip-suboptions", "Enwip.", DHC_O_Universe, 63, 0 },
{ "nisplus-domain", "t", DHC_O_Universe, 64, 0 },
{ "nisplus-servers", "IA", DHC_O_Universe, 65, 0 },
@@ -523,7 +523,7 @@
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
{ "nds-servers", "IA", DHC_O_Universe, 85, 0 },
- { "nds-tree-name", "X", DHC_O_Universe, 86, 0 },
+ { "nds-tree-name", "t", DHC_O_Universe, 86, 0 },
{ "nds-context", "X", DHC_O_Universe, 87, 0 },
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
@@ -555,7 +555,7 @@
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
- { "subnet-selection", "X", DHC_O_Universe, 118, 0 },
+ { "subnet-selection", "I", DHC_O_Universe, 118, 0 },
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
{ 0L, 0L, 0, 0, 0 },
++++++ dhcdbd-set-hostname.patch ++++++
Makefile | 19 +++--
dhcdbd.c | 47 +++++++++++++-
shvar.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
shvar.h | 74 +++++++++++++++++++++++
4 files changed, 328 insertions(+), 12 deletions(-)
diff -urN dhcdbd-1.12/dhcdbd.c dhcdbd/dhcdbd.c
--- dhcdbd-1.12/dhcdbd.c 2006-01-17 16:23:51.000000000 -0500
+++ dhcdbd/dhcdbd.c 2006-05-04 16:07:10.000000000 -0400
@@ -20,9 +20,7 @@
#include "dbus_service.h"
#include "dhcdbd.h"
#include "dhcp_options.h"
-
-#define TRUE 1
-#define FALSE 0
+#include "shvar.h"
typedef
enum dhc_ifs_e
@@ -729,9 +727,10 @@
int dhcdbd_run_dhclient( DHC_IF *d_if )
{
char **dhc_args, **dhc_envp, *xtra_arg=0L;
- uint8_t n_args=12, arg;
+ uint8_t n_args=14, arg;
DHC_IF *rel_if=0L;
int i;
+ shvarFile *file;
sigset_t ss;
pid_t kill_pid=0;
char dhc_if_conf_file[1024];
@@ -911,6 +910,46 @@
return -1;
strcpy(dhc_args[arg], "-q");
+ file = svNewFile ("/etc/sysconfig/network/dhcp");
+ if (file) {
+ char hostname[HOST_NAME_MAX+1];
+ char *buf;
+
+ buf = svGetValue (file, "DHCLIENT_HOSTNAME_OPTION");
+ if (buf && buf[0] != '\0' && buf[0] != '"') {
+ if (!strcmp (buf, "AUTO")) {
+ FILE *f;
+
+ f = fopen ("/etc/HOSTNAME", "r");
+ if (f > 0) {
+ if (fgets (hostname, HOST_NAME_MAX, f)) {
+ size_t len;
+
+ len = strlen (hostname);
+ if (hostname[len-1] == '\n')
+ hostname[len-1] = '\0';
+ } else {
+ fclose (f);
+ goto out;
+ }
+ fclose (f);
+ }
+ } else
+ strncpy (hostname, buf, HOST_NAME_MAX);
+
+ if((dhc_args[++arg] = (char*)malloc( 3 )) == 0L)
+ return -1;
+ strcpy(dhc_args[arg], "-H");
+ if((dhc_args[++arg] = (char*)malloc( strlen (hostname) + 1 )) == 0L)
+ return -1;
+ strcpy(dhc_args[arg], hostname);
+
+out:
+ free (buf);
+ }
+ svCloseFile (file);
+ }
+
if((dhc_args[++arg] = (char*)malloc( 3 )) == 0L)
return -1;
strcpy(dhc_args[arg], "-e");
diff -urN dhcdbd-1.12/Makefile dhcdbd/Makefile
--- dhcdbd-1.12/Makefile 2006-01-17 16:23:51.000000000 -0500
+++ dhcdbd/Makefile 2006-05-04 16:04:17.000000000 -0400
@@ -7,28 +7,31 @@
LDFLAGS ?= -g
DESTDIR ?= /
LIBDIR ?= lib
-DBUS_INCLUDES ?= -I/usr/$(LIBDIR)/dbus-1.0/include -I/usr/include/dbus-1.0
-DBUS_LIBS ?= -ldbus-1
-OBJS = dbus_service.o dhcdbd.o dhcp_options.o main.o
-SRCS = dbus_service.c dhcdbd.c dhcp_options.c main.c
-INCS = dbus_service.h dhcdbd.h dhcp_options.h includes.h
+INCLUDES ?= -I/usr/$(LIBDIR)/dbus-1.0/include -I/usr/include/dbus-1.0 -I/opt/gnome/include/glib-2.0 -I/opt/gnome/lib/glib-2.0/include
+LIBS ?= -ldbus-1 -L/opt/gnome/lib -lglib-2.0
+OBJS = dbus_service.o dhcdbd.o dhcp_options.o main.o shvar.o
+SRCS = dbus_service.c dhcdbd.c dhcp_options.c main.c shvar.c
+INCS = dbus_service.h dhcdbd.h dhcp_options.h includes.h shvar.h
all: dhcdbd tests CHANGES
.c.o:
- ${CC} ${CFLAGS} -c $<
+ ${CC} ${INCLUDES} ${CFLAGS} -c $<
.SUFFIXES: .c .o
dbus_service.o: dbus_service.c dbus_service.h
- $(CC) $(CFLAGS) $(DBUS_INCLUDES) -c dbus_service.c
+ $(CC) $(CFLAGS) $(INCLUDES) -c dbus_service.c
+
+shvar.o: shvar.c shvar.h
+ $(CC) $(CFLAGS) $(INCLUDES) -c shvar.c
dhcdbd.o: $(INCS) dhcdbd.c
dhcp_options.o: dhcp_options.c dhcp_options.h
dhcdbd: $(OBJS) $(SRCS) $(INCS)
- $(LD) $(LDFLAGS) -o $@ $(OBJS) $(DBUS_LIBS)
+ $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
tests: dhcdbd
(cd tests; make)
diff -urN dhcdbd-1.12/shvar.c dhcdbd/shvar.c
--- dhcdbd-1.12/shvar.c 1969-12-31 19:00:00.000000000 -0500
+++ dhcdbd/shvar.c 2006-05-04 16:03:59.000000000 -0400
@@ -0,0 +1,200 @@
+/*
+ * shvar.c
+ *
+ * Implementation of non-destructively reading/writing files containing
+ * only shell variable declarations and full-line comments.
+ *
+ * Includes explicit inheritance mechanism intended for use with
+ * Red Hat Linux ifcfg-* files. There is no protection against
+ * inheritance loops; they will generally cause stack overflows.
+ * Furthermore, they are only intended for one level of inheritance;
+ * the value setting algorithm assumes this.
+ *
+ * Copyright 1999,2000 Red Hat, Inc.
+ *
+ * This 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "shvar.h"
+
+/* Open the file <name>, returning a shvarFile on success and NULL on failure.
+ Add a wrinkle to let the caller specify whether or not to create the file
+ (actually, return a structure anyway) if it doesn't exist. */
+static shvarFile *
+svOpenFile(const char *name, gboolean create)
+{
+ shvarFile *s = NULL;
+ int closefd = 0;
+
+ s = g_malloc0(sizeof(shvarFile));
+
+#if 1 /* NetworkManager local change */
+ s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
+ if (s->fd != -1) closefd = 1;
+#else
+ s->fd = open(name, O_RDWR); /* NOT O_CREAT */
+ if (s->fd == -1) {
+ /* try read-only */
+ s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
+ if (s->fd != -1) closefd = 1;
+ }
+#endif
+ s->fileName = g_strdup(name);
+
+ if (s->fd != -1) {
+ struct stat buf;
+ char *p, *q;
+
+ if (fstat(s->fd, &buf) < 0) goto bail;
+ s->arena = g_malloc0(buf.st_size + 1);
+
+ if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
+
+ /* we'd use g_strsplit() here, but we want a list, not an array */
+ for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
+ s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
+ }
+
+ /* closefd is set if we opened the file read-only, so go ahead and
+ close it, because we can't write to it anyway */
+ if (closefd) {
+ close(s->fd);
+ s->fd = -1;
+ }
+
+ return s;
+ }
+
+ if (create) {
+ return s;
+ }
+
+bail:
+ if (s->fd != -1) close(s->fd);
+ if (s->arena) g_free (s->arena);
+ if (s->fileName) g_free (s->fileName);
+ g_free (s);
+ return NULL;
+}
+
+/* Open the file <name>, return shvarFile on success, NULL on failure */
+shvarFile *
+svNewFile(const char *name)
+{
+ return svOpenFile(name, FALSE);
+}
+
+/* Create a new file structure, returning actual data if the file exists,
+ * and a suitable starting point if it doesn't. */
+shvarFile *
+svCreateFile(const char *name)
+{
+ return svOpenFile(name, TRUE);
+}
+
+/* remove escaped characters in place */
+static void
+unescape(char *s) {
+ int len, i;
+
+ len = strlen(s);
+ if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) {
+ i = len - 2;
+ memmove(s, s+1, i);
+ s[i+1] = '\0';
+ len = i;
+ }
+ for (i = 0; i < len; i++) {
+ if (s[i] == '\\') {
+ memmove(s+i, s+i+1, len-(i+1));
+ len--;
+ }
+ s[len] = '\0';
+ }
+}
+
+
+/* Get the value associated with the key, and leave the current pointer
+ * pointing at the line containing the value. The char* returned MUST
+ * be freed by the caller.
+ */
+char *
+svGetValue(shvarFile *s, const char *key)
+{
+ char *value = NULL;
+ char *line;
+ char *keyString;
+ int len;
+
+ g_assert(s);
+ g_assert(key);
+
+ keyString = g_malloc0(strlen(key) + 2);
+ strcpy(keyString, key);
+ keyString[strlen(key)] = '=';
+ len = strlen(keyString);
+
+ for (s->current = s->lineList; s->current; s->current = s->current->next) {
+ line = s->current->data;
+ if (!strncmp(keyString, line, len)) {
+ value = g_strdup(line + len);
+ unescape(value);
+ break;
+ }
+ }
+ g_free(keyString);
+
+ if (value) {
+ if (value[0]) {
+ return value;
+ } else {
+ g_free(value);
+ return NULL;
+ }
+ }
+ if (s->parent) value = svGetValue(s->parent, key);
+ return value;
+}
+
+/* Close the file descriptor (if open) and delete the shvarFile.
+ * Returns -1 on error and 0 on success.
+ */
+int
+svCloseFile(shvarFile *s)
+{
+
+ g_assert(s);
+
+ if (s->fd != -1) close(s->fd);
+
+ g_free(s->arena);
+ for (s->current = s->freeList; s->current; s->current = s->current->next) {
+ g_free(s->current->data);
+ }
+ g_free(s->fileName);
+ g_list_free(s->freeList);
+ g_list_free(s->lineList); /* implicitly frees s->current */
+ g_free(s);
+ return 0;
+}
diff -urN dhcdbd-1.12/shvar.h dhcdbd/shvar.h
--- dhcdbd-1.12/shvar.h 1969-12-31 19:00:00.000000000 -0500
+++ dhcdbd/shvar.h 2006-05-04 16:02:53.000000000 -0400
@@ -0,0 +1,74 @@
+/*
+ * shvar.h
+ *
+ * Interface for non-destructively reading/writing files containing
+ * only shell variable declarations and full-line comments.
+ *
+ * Includes explicit inheritance mechanism intended for use with
+ * Red Hat Linux ifcfg-* files. There is no protection against
+ * inheritance loops; they will generally cause stack overflows.
+ * Furthermore, they are only intended for one level of inheritance;
+ * the value setting algorithm assumes this.
+ *
+ * Copyright 1999 Red Hat, Inc.
+ *
+ * This 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef _SHVAR_H
+#define _SHVAR_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _shvarFile shvarFile;
+struct _shvarFile {
+ char *fileName; /* read-only */
+ int fd; /* read-only */
+ char *arena; /* ignore */
+ GList *lineList; /* read-only */
+ GList *freeList; /* ignore */
+ GList *current; /* set implicitly or explicitly,
+ points to element of lineList */
+ shvarFile *parent; /* set explicitly */
+ int modified; /* ignore */
+};
+
+
+/* Open the file <name>, return shvarFile on success, NULL on failure */
+shvarFile *
+svNewFile(const char *name);
+
+/* Get the value associated with the key, and leave the current pointer
+ * pointing at the line containing the value. The char* returned MUST
+ * be freed by the caller.
+ */
+char *
+svGetValue(shvarFile *s, const char *key);
+
+/* Close the file descriptor (if open) and delete the shvarFile.
+ * Returns -1 on error and 0 on success.
+ */
+int
+svCloseFile(shvarFile *s);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ! _SHVAR_H */
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...