From: Günther Deschner Date: Tue, 15 Jan 2019 13:26:17 +0000 (+0100) Subject: s3-smbd: use fruit:model string for mDNS registration X-Git-Tag: ldb-1.3.8~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e0514d273e3fe5e85a48ee4b1c3e3f066f1b6c3;p=thirdparty%2Fsamba.git 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 a mac client negotiated the apple create context over SMB. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13746 Based on proposed patch from Rouven WEILER Guenther Signed-off-by: Guenther Deschner Reviewed-by: Ralph Boehme Autobuild-User(master): Günther Deschner Autobuild-Date(master): Tue Jan 15 21:27:20 CET 2019 on sn-devel-144 (cherry picked from commit 538ce72f1b2fa78450e3b711e58bd0e238faf466) --- diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c index 50462b5c610..99c16e7a641 100644 --- a/source3/smbd/avahi_register.c +++ b/source3/smbd/avahi_register.c @@ -111,8 +111,10 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status, int dk = 0; AvahiStringList *adisk = NULL; AvahiStringList *adisk2 = NULL; + AvahiStringList *dinfo = NULL; const char *hostname = NULL; enum mdns_name_values mdns_name = lp_mdns_name(); + const char *model = NULL; DBG_DEBUG("AVAHI_CLIENT_S_RUNNING\n"); @@ -196,6 +198,31 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status, } } + model = lp_parm_const_string(-1, "fruit", "model", "MacSamba"); + + dinfo = avahi_string_list_add_printf(NULL, "model=%s", model); + if (dinfo == NULL) { + DBG_DEBUG("avahi_string_list_add_printf" + "failed: returned NULL\n"); + avahi_entry_group_free(state->entry_group); + state->entry_group = NULL; + break; + } + + error = avahi_entry_group_add_service_strlst( + state->entry_group, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, 0, hostname, + "_device-info._tcp", NULL, NULL, 0, + dinfo); + avahi_string_list_free(dinfo); + 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); if (error != AVAHI_OK) { DBG_DEBUG("avahi_entry_group_commit failed: %s\n",