[Samba] issue with fruit:model not using avahi correctly?

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


Hi Rouven,

you're correct, our avahi callback did not use fruit:model at all. Can
you try the attached patch? It should make it work.

Thanks,
Guenther

On 15/01/2019 09:27, Rouven WEILER via samba wrote:
> hey folks,
>  
> I am trying to change the fruit:model value for changing the icon in the mac os finder.
> After digging a little bit in the source code I saw that "source3/smbd/avahi_register.c" does not contain a line where info like
> <service>
> <type>_device-info._tcp</type>
> <port>0</port>
> <txt-record>model=RackMac</txt-record>
> is added to avahi.
> In "source3/modules/vfs_fruit.c" I see that the paramater fruit:model is processed, but it does not seem to be used by avahi_register nor does it seem to be propagted.
>  
> These lines should be responsible for making smb show up correctly in the Finder sidebar with a correct icon.
>  
> Is this a bug/not available feature or did I misunderstand something?
>  
> I am not thinking my config os corrupted since my time machine share is propageted correctly (based on the avahi infos).
>  
> Some link that helped me:
> https://jonathanmumm.com/tech-it/mdns-bonjour-bible-common-service-strings-for-various-vendors/
> https://simonwheatley.co.uk/2008/04/avahi-finder-icons/
>  
> Thanks for your help.
> 


-- 
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/attachments/20190115/1bd5ae3e/signature.sig>


More information about the samba mailing list