[PATCH] use fruit:model string in avahi mDNS registration

Günther Deschner gd at samba.org
Tue Jan 15 13:44:59 UTC 2019


Hi,

please review and push.

Thanks,
Guenther
-- 
Günther Deschner                    GPG-ID: 8EE11688
Red Hat                         gdeschner at redhat.com
Samba Team                              gd at samba.org
-------------- next part --------------
From b4ea0d8fe4b501021afb39f5f50a6fb7746453c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Tue, 15 Jan 2019 14:26:17 +0100
Subject: [PATCH] s3-smbd: use fruit:model string for mDNS registration

With this change we now allow to modify the icon to represent Samba in
Finder. Possible values are at least:

fruit:model = iMac
fruit:model = MacBook
fruit:model = MacPro
fruit:model = Xserve
fruit:model = RackMac

Prior to this change we only displayed the correct icon when nmbd and
not avahi mDNS was used.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13746

Guenther

Signed-off-by: Guenther Deschner <gd at samba.org>
---
 source3/smbd/avahi_register.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c
index 6c87669ba36..0f1417ee94f 100644
--- a/source3/smbd/avahi_register.c
+++ b/source3/smbd/avahi_register.c
@@ -113,6 +113,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
 		AvahiStringList *adisk2 = NULL;
 		const char *hostname = NULL;
 		enum mdns_name_values mdns_name = lp_mdns_name();
+		const char *model;
 
 		DBG_DEBUG("AVAHI_CLIENT_S_RUNNING\n");
 
@@ -194,6 +195,32 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
 				state->entry_group = NULL;
 				break;
 			}
+
+		}
+
+		model = talloc_asprintf(state, "model=%s",
+					lp_parm_const_string(-1,
+							     "fruit",
+							     "model",
+							     "MacSamba"));
+		if (model == NULL) {
+			DBG_DEBUG("out of memory\n");
+			avahi_entry_group_free(state->entry_group);
+			state->entry_group = NULL;
+			break;
+		}
+
+		error = avahi_entry_group_add_service(
+			    state->entry_group, AVAHI_IF_UNSPEC,
+			    AVAHI_PROTO_UNSPEC, 0, hostname,
+			    "_device-info._tcp", NULL, NULL, 0,
+			    model, NULL);
+		if (error != AVAHI_OK) {
+			DBG_DEBUG("avahi_entry_group_add_service failed: %s\n",
+				  avahi_strerror(error));
+			avahi_entry_group_free(state->entry_group);
+			state->entry_group = NULL;
+			break;
 		}
 
 		error = avahi_entry_group_commit(state->entry_group);
-- 
2.20.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20190115/09d553f4/signature.sig>


More information about the samba-technical mailing list