s3-smbd: use fruit:model string for mDNS registration
authorGünther Deschner <gd@samba.org>
Tue, 15 Jan 2019 13:26:17 +0000 (14:26 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 15 Jan 2019 20:27:20 +0000 (21:27 +0100)
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 <Rouven_Weiler@gmx.net>

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Tue Jan 15 21:27:20 CET 2019 on sn-devel-144

source3/smbd/avahi_register.c

index 6c87669ba36aececec7aac161d49b3281d5de0af..883c862c37465613f06e006883dfb40eaaa7d6a4 100644 (file)
@@ -111,8 +111,10 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
                size_t 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",