Module Name:    src
Committed By:   jmcneill
Date:           Sun May 15 16:38:26 UTC 2022

Modified Files:
        src/usr.sbin/sysinst: configmenu.c msg.mi.en

Log Message:
sysinst: Enable mDNS lookups via NSS when enabling mdnsd.

Add/remove "multicast_dns" to the hosts: line in /etc/nsswitch.conf when
toggling the mdnsd rcvar. Change the label from "Enable mdnsd" to "Enable
multicast DNS support" to better describe what's going on here.

Now when you enable multicast DNS support in the installer, the host will
both advertise itself on the network and resolve .local network names.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/configmenu.c
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/sysinst/msg.mi.en

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/configmenu.c
diff -u src/usr.sbin/sysinst/configmenu.c:1.15 src/usr.sbin/sysinst/configmenu.c:1.16
--- src/usr.sbin/sysinst/configmenu.c:1.15	Thu Apr 21 17:30:15 2022
+++ src/usr.sbin/sysinst/configmenu.c	Sun May 15 16:38:25 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.15 2022/04/21 17:30:15 martin Exp $ */
+/* $NetBSD: configmenu.c,v 1.16 2022/05/15 16:38:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -53,6 +53,7 @@ static int set_pkgsrc(struct menudesc *,
 static void config_list_init(void);
 static void get_rootsh(void);
 static int toggle_rcvar(struct menudesc *, void *);
+static int toggle_mdnsd(struct menudesc *, void *);
 static void configmenu_hdr(struct menudesc *, void *);
 static int check_root_password(void);
 
@@ -100,7 +101,7 @@ configinfo config_list[] = {
 	{MSG_enable_sshd, CONFIGOPT_SSHD, "sshd", toggle_rcvar, NULL},
 	{MSG_enable_ntpd, CONFIGOPT_NTPD, "ntpd", toggle_rcvar, NULL},
 	{MSG_run_ntpdate, CONFIGOPT_NTPDATE, "ntpdate", toggle_rcvar, NULL},
-	{MSG_enable_mdnsd, CONFIGOPT_MDNSD, "mdnsd", toggle_rcvar, NULL},
+	{MSG_enable_mdnsd, CONFIGOPT_MDNSD, "mdnsd", toggle_mdnsd, NULL},
 	{MSG_enable_xdm, CONFIGOPT_XDM, "xdm", toggle_rcvar, NULL},
 	{MSG_enable_cgd, CONFIGOPT_CGD, "cgd", toggle_rcvar, NULL},
 	{MSG_enable_lvm, CONFIGOPT_LVM, "lvm", toggle_rcvar, NULL},
@@ -455,6 +456,37 @@ toggle_rcvar(struct menudesc *menu, void
 	return 0;
 }
 
+static int
+toggle_mdnsd(struct menudesc *menu, void *arg)
+{
+	configinfo **confp = arg;
+	int s;
+	const char *setting, *varname;
+
+	varname = confp[menu->cursel]->rcvar;
+
+	s = check_rcvar(varname);
+
+	/* we're toggling, so invert the sense */
+	if (s) {
+		confp[menu->cursel]->setting = MSG_NO;
+		setting = "files dns";
+	} else {
+		confp[menu->cursel]->setting = MSG_YES;
+		setting = "files multicast_dns dns";
+	}
+
+	if (logfp) {
+		fprintf(logfp, "setting hosts: %s\n", setting);
+		fflush(logfp);
+	}
+	replace("/etc/nsswitch.conf", "s/^hosts:.*/hosts:\t\t%s/", setting);
+
+	toggle_rcvar(menu, arg);
+
+	return 0;
+}
+
 static void
 configmenu_hdr(struct menudesc *menu, void *arg)
 {

Index: src/usr.sbin/sysinst/msg.mi.en
diff -u src/usr.sbin/sysinst/msg.mi.en:1.38 src/usr.sbin/sysinst/msg.mi.en:1.39
--- src/usr.sbin/sysinst/msg.mi.en:1.38	Thu Apr 21 17:30:15 2022
+++ src/usr.sbin/sysinst/msg.mi.en	Sun May 15 16:38:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.en,v 1.38 2022/04/21 17:30:15 martin Exp $	*/
+/*	$NetBSD: msg.mi.en,v 1.39 2022/05/15 16:38:25 jmcneill Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1158,7 +1158,7 @@ message enable_binpkg {Enable installati
 message enable_sshd {Enable sshd}
 message enable_ntpd {Enable ntpd}
 message run_ntpdate {Run ntpdate at boot}
-message enable_mdnsd {Enable mdnsd}
+message enable_mdnsd {Enable multicast DNS support}
 message enable_xdm {Enable xdm}
 message enable_cgd {Enable cgd}
 message enable_lvm {Enable lvm}

Reply via email to