Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.maint.boot > #72369 > unrolled thread
| Started by | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| First post | 2024-04-26 17:50 +0200 |
| Last post | 2025-07-03 14:20 +0200 |
| Articles | 5 — 1 participant |
Back to article view | Back to linux.debian.maint.boot
Bug#1069897: Netcfg to get search domain Frédéric Guyot <guyot.frederic26@gmail.com> - 2024-04-26 17:50 +0200
Bug#1069897: Netcfg to get search domain Frédéric Guyot <guyot.frederic26@gmail.com> - 2024-05-01 12:40 +0200
Bug#1069897: Netcfg to get search domain Frédéric Guyot <guyot.frederic26@gmail.com> - 2024-05-03 12:10 +0200
Bug#1069897: Netcfg to get search domain Frédéric Guyot <guyot.frederic26@gmail.com> - 2025-07-03 12:40 +0200
Bug#1069897: Netcfg to get search domain Frédéric Guyot <guyot.frederic26@gmail.com> - 2025-07-03 14:20 +0200
| From | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| Date | 2024-04-26 17:50 +0200 |
| Subject | Bug#1069897: Netcfg to get search domain |
| Message-ID | <IxvZL-98wP-5@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
Package: netcfg
Version: 1.187
As explained in this thread:
https://lists.debian.org/debian-boot/2024/04/msg00061.html , netcfg
doesn't read the search domain property sent by dhcp to make it
available to udhcpc and fill /etc/resolv.conf + lease file properly.
This setup doesn't work in an environment where you have multiple
search domains and it's getting even more complicated if your network
mirror is on one of those search domains that is different from
$domain.
A commit as already been made for the udhcpc script here:
https://salsa.debian.org/installer-team/busybox/-/commit/bd0d90574a4e39b39d38b664ad15ac0c2ca1bbad
We now just need to update netcfg package to make $search available to udhcpc.
A proposed solution would be to update this line
(https://salsa.debian.org/installer-team/netcfg/-/blob/master/dhcp.c#L38)
as follow:
const char* dhclient_request_options_udhcpc[] = { "subnet",
"broadcast", "router", "domain", "hostname", "dns", "search",
"ntpsrv", /* extra */ NULL };
Thanks
[toc] | [next] | [standalone]
| From | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| Date | 2024-05-01 12:40 +0200 |
| Message-ID | <Izfxv-afU0-7@gated-at.bofh.it> |
| In reply to | #72369 |
[Multipart message — attachments visible in raw view] — view raw
Here is a proposed patch:
diff -Naur netcfg-master/dhcp.c netcfg-master-updated/dhcp.c
--- netcfg-master/dhcp.c 2024-05-01 11:14:26.209026580 +0100
+++ netcfg-master-updated/dhcp.c 2024-05-01 11:15:11.888387848 +0100
@@ -41,6 +41,7 @@
"domain",
"hostname",
"dns",
+ "search",
"ntpsrv", /* extra */
NULL };
[toc] | [prev] | [next] | [standalone]
| From | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| Date | 2024-05-03 12:10 +0200 |
| Message-ID | <IzY1A-aMbG-9@gated-at.bofh.it> |
| In reply to | #72369 |
[Multipart message — attachments visible in raw view] — view raw
This will require a bit more work than anticipated. The patch posted above will only do half of the job. netcfg will call udhcp with the "-O search" option added which will update /etc/resolv.conf with the correct search domain values assuming that the patch for /etc/udhcpc/default.script is also applied along this one. Now the problem is that netcfg is calling the "netcfg_write_resolv" function from static.c that will overwrite any changes made by udhcpc on resolv.conf and will only keep the domain and nameservers. https://salsa.debian.org/installer-team/netcfg/-/blob/master/dhcp.c#L513 https://salsa.debian.org/installer-team/netcfg/-/blob/master/dhcp.c#L616 https://salsa.debian.org/installer-team/netcfg/-/blob/master/static.c?ref_type=heads#L261
[toc] | [prev] | [next] | [standalone]
| From | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| Date | 2025-07-03 12:40 +0200 |
| Message-ID | <L4pwd-eVD3-3@gated-at.bofh.it> |
| In reply to | #72369 |
[Multipart message — attachments visible in raw view] — view raw
Here is an updated patch for this issue:
--- dhcp.c
+++ dhcp.c
@@ -41,6 +41,7 @@
"domain",
"hostname",
"dns",
+ "search",
"ntpsrv", /* extra */
NULL };
@@ -510,7 +511,7 @@
* nameservers now so we can do rDNS lookups later to possibly
* find out the domain.
*/
- netcfg_write_resolv(NULL, interface);
+ netcfg_write_resolv(NULL, NULL, interface);
state = HOSTNAME;
break;
@@ -613,7 +614,7 @@
netcfg_write_common("", hostname, domain);
netcfg_write_loopback();
netcfg_write_interface(interface);
- netcfg_write_resolv(domain, interface);
+ netcfg_write_resolv(domain, search, interface);
#if !defined(__FreeBSD_kernel__)
kill_dhcp_client();
#endif
--- static.c
+++ static.c
@@ -258,14 +258,16 @@
return 1;
}
-int netcfg_write_resolv (const char *domain, const struct
netcfg_interface *interface)
+int netcfg_write_resolv (const char *domain , const char *search,
const struct netcfg_interface *interface)
{
FILE* fp = NULL;
if ((fp = file_open(RESOLV_FILE, "w"))) {
unsigned int i = 0;
+ if (search && !empty_str(search))
+ fprintf(fp, "search %s\n", search);
if (domain && !empty_str(domain))
- fprintf(fp, "search %s\n", domain);
+ fprintf(fp, "domain %s\n", domain);
for (i = 0; i < NETCFG_NAMESERVERS_MAX; i++)
if (!empty_str(interface->nameservers[i]))
This should do the trick.
If someone comes across this issue and this patch hasn't been merged
we found an ugly workaround using a preseed file:
d-i preseed/early_command string \
sed -i '/^case /i domain="$search"' /etc/udhcpc/default.script; \
mv /sbin/udhcpc /sbin/udhcpc.real; \
echo '#!/bin/sh' > /sbin/udhcpc; \
echo 'exec /bin/busybox udhcpc -O search "$@"' >> /sbin/udhcpc; \
chmod +x /sbin/udhcpc
It will make a wrapper for udhcpc that will force netcfg to query
search domains, patch the default.script callback script from udhcpc
to make domain="$seach".
regards
[toc] | [prev] | [next] | [standalone]
| From | Frédéric Guyot <guyot.frederic26@gmail.com> |
|---|---|
| Date | 2025-07-03 14:20 +0200 |
| Message-ID | <L4r4Z-eWGF-3@gated-at.bofh.it> |
| In reply to | #75804 |
[Multipart message — attachments visible in raw view] — view raw
Right so I was wrong, netcfg reads the domain from here: /tmp/domain_name
which is filled by udhcpc default.script
The patch above won't work alone as we would need udhcpc to write the
search domain to a file and make a read function in netcfg to get the info
(or something along those lines)
Here is an updated version of the hack:
d-i preseed/early_command string \
sed -i 's|printf "\$domain" > /tmp/domain_name|printf "$search" >
/tmp/domain_name|' /etc/udhcpc/default.script; \
mv /sbin/udhcpc /sbin/udhcpc.real; \
echo '#!/bin/sh' > /sbin/udhcpc; \
echo 'exec /bin/busybox udhcpc -O search "$@"' >> /sbin/udhcpc; \
chmod +x /sbin/udhcpc
On Thu, Jul 3, 2025 at 12:30 PM Frédéric Guyot <guyot.frederic26@gmail.com>
wrote:
> Here is an updated patch for this issue:
>
> --- dhcp.c
> +++ dhcp.c
> @@ -41,6 +41,7 @@
> "domain",
> "hostname",
> "dns",
> + "search",
> "ntpsrv", /* extra */
> NULL };
>
> @@ -510,7 +511,7 @@
> * nameservers now so we can do rDNS lookups later to possibly
> * find out the domain.
> */
> - netcfg_write_resolv(NULL, interface);
> + netcfg_write_resolv(NULL, NULL, interface);
> state = HOSTNAME;
> break;
>
> @@ -613,7 +614,7 @@
> netcfg_write_common("", hostname, domain);
> netcfg_write_loopback();
> netcfg_write_interface(interface);
> - netcfg_write_resolv(domain, interface);
> + netcfg_write_resolv(domain, search, interface);
> #if !defined(__FreeBSD_kernel__)
> kill_dhcp_client();
> #endif
>
> --- static.c
> +++ static.c
> @@ -258,14 +258,16 @@
> return 1;
> }
>
> -int netcfg_write_resolv (const char *domain, const struct netcfg_interface *interface)
> +int netcfg_write_resolv (const char *domain , const char *search, const struct netcfg_interface *interface)
> {
> FILE* fp = NULL;
>
> if ((fp = file_open(RESOLV_FILE, "w"))) {
> unsigned int i = 0;
> + if (search && !empty_str(search))
> + fprintf(fp, "search %s\n", search);
> if (domain && !empty_str(domain))
> - fprintf(fp, "search %s\n", domain);
> + fprintf(fp, "domain %s\n", domain);
>
> for (i = 0; i < NETCFG_NAMESERVERS_MAX; i++)
> if (!empty_str(interface->nameservers[i]))
>
> This should do the trick.
>
> If someone comes across this issue and this patch hasn't been merged we found an ugly workaround using a preseed file:
>
> d-i preseed/early_command string \
> sed -i '/^case /i domain="$search"' /etc/udhcpc/default.script; \
> mv /sbin/udhcpc /sbin/udhcpc.real; \
> echo '#!/bin/sh' > /sbin/udhcpc; \
> echo 'exec /bin/busybox udhcpc -O search "$@"' >> /sbin/udhcpc; \
> chmod +x /sbin/udhcpc
>
> It will make a wrapper for udhcpc that will force netcfg to query search domains, patch the default.script callback script from udhcpc to make domain="$seach".
>
> regards
>
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.maint.boot
csiph-web