From 059ff58dcf85d703ef938c8203658b923f86e77f Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Wed, 3 Dec 2008 18:19:28 -1000 Subject: Send unique vendor class identifier unless user specifies one. Restores functionality we had before the NM changeover. This was originally requested by gurulabs.com. Instead of sending just 'anaconda' as the vendor class identifier, send something like: anaconda-Linux 2.6.27.5-117.fc10.i686 i686 Of course, if we fail to collect that information, fall back on 'anaconda'. Guru Labs wanted this functionality for PXE booting as it allowed them to more easily control per-client/per-release settings from the DHCP server. My fault for not adding this back when the NM changeover happened. --- loader/net.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'loader/net.c') diff --git a/loader/net.c b/loader/net.c index 62dc236c1..9c6c2f59f 100644 --- a/loader/net.c +++ b/loader/net.c @@ -1156,6 +1156,7 @@ int writeEnabledNetInfo(iface_t *iface) { char buf[INET6_ADDRSTRLEN+1]; char *ofile = NULL; char *nfile = NULL; + struct utsname kv; memset(&buf, '\0', sizeof(buf)); @@ -1163,29 +1164,38 @@ int writeEnabledNetInfo(iface_t *iface) { return 16; } - /* write vendor class if we have that */ - if (iface->vendorclass != NULL) { - if (asprintf(&ofile, "/etc/dhclient-%s.conf", iface->device) == -1) { - return 17; + /* write vendor class */ + if (iface->vendorclass == NULL) { + if (uname(&kv) == -1) { + iface->vendorclass = "anaconda"; + } else { + if (asprintf(&iface->vendorclass, "anaconda-%s %s %s", + kv.sysname, kv.release, kv.machine)) { + return 20; + } } + } - if ((fp = fopen(ofile, "w")) == NULL) { - free(ofile); - return 18; - } + if (asprintf(&ofile, "/etc/dhclient-%s.conf", iface->device) == -1) { + return 17; + } - fprintf(fp, "send vendor-class-identifier \"%s\";\n", - iface->vendorclass); + if ((fp = fopen(ofile, "w")) == NULL) { + free(ofile); + return 18; + } - if (fclose(fp) == EOF) { - free(ofile); - return 19; - } + fprintf(fp, "send vendor-class-identifier \"%s\";\n", + iface->vendorclass); - if (ofile) { - free(ofile); - ofile = NULL; - } + if (fclose(fp) == EOF) { + free(ofile); + return 19; + } + + if (ofile) { + free(ofile); + ofile = NULL; } /* write out new ifcfg-DEVICE file */ -- cgit