how OSX tells what type of device a samba host is

Harald Sitter sitter at kde.org
Fri Jan 31 14:40:12 GMT 2020


The past week I've been poking around various smb things and also
investigated how OS X knows what device type a remote host is.

After all, Kai has been fond of their lovely CRT screens for the
longest time. But we never quite knew how they actually which server
should have a CRT.

https://i.imgur.com/ASDBCCG.jpg
https://i.imgur.com/DjGw8iT.jpg

Long story short:

- Services discovered over dns-sd are considered "macish" and get
macish icons (e.g. SMITH in screenshot 1)

- Services that further have a _device-info._tcp service get more
specific icons (e.g. me's iMac in screenshot 1 is an iMac so it gets
an iMac icon)

- If that device info contains useless information a question mark
icon is used (e.g. ME-STANDARD in screenshot 2)

- Services discovered via other technology (smb1, wsdiscovery) are PCs
and get CRT icons

So, it simply leverage dns-sd. Albeit in a bit of a special way
because OSX itself does not actually expose _device-info._tcp as a
service but simply sends the information along with the mDNS response.
Furthermore device-info actually has no specified format [1].
It's a bit awkward from an avahi POV because that data doesn't show up
in the regular service listing. To not bore you with avahi details
though, here's what the underlying mDNS response would contain:

        me\342\200\231s iMac._device-info._tcp.local: type TXT, class IN
            Name: me\342\200\231s iMac._device-info._tcp.local
            Type: TXT (Text strings) (16)
            .000 0000 0000 0001 = Class: IN (0x0001)
            0... .... .... .... = Cache flush: False
            Time to live: 4500
            Data length: 26
            TXT Length: 14
            TXT: model=iMac10,1
            TXT Length: 10
            TXT: osxvers=18

In essence, the device-info service needs to contain model data and
OSX will make use of it. For example you could retrofit any Linux with
this information by publishing a suitable service

e.g. `avahi-publish -s AJAX _device-info._tcp 0 model=MacBook`

would show the host using a MacBook icon. Other options are listed here [2].

Great!
But what happens when you set arbitrary models?

That is actually what we see in screenshot 2 for the me-STANDARD host.
It uses a newer samba which smartly exports device-info by default.
Not so smartly it does that using the type 'MacSamba' to which OS X
says "?". Also, I'm a bit on the fence about smbd claiming a general
purpose service name like that... Anyway, the question mark icon is
kind of a step back, but fortunately you can actually configure this
[3]

[global]
fruit:model = iMac

in your smb.conf and your PC is an iMac! Macgic!

This more or less concludes what I know on the subject. As a
consequence, since our smb slave supports dns-sd, we could allow icon
themes to have device-adjusted 'network-server-$model' icons. On linux
we of course have the problem that the default MacSamba isn't all that
useful for anything though :(

[1] http://www.dns-sd.org/ServiceTypes.html
[2] https://www.tumfatig.net/20170607/let-mac-os-auto-discover-your-smb-shares/
[3] https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html


More information about the Plasma-devel mailing list