Some Bits: Nelson's log

A Sonos v1 SMB server

Summary: do you need a SMB server to serve your local library of music files to your v1 Sonos? Barry de Graaff has a solution, sonossmb. It’s a small Node implementation of SMB that works with Sonos. It works! It does take a bit of hacking to install though.

About sonossmb

I used Samba for years to serve music to the Sonos. The problem is the v1 systems are unsupported and have an ancient insecure SMBv1 client baked into them. And starting with Ubuntu 22 (which has Samba 4.17) it no longer works with Sonos, even with the special v1 config directives. No idea what’s wrong. That got me speculating that a simple stripped down anonymous-only SMBv1 server for Sonos might be a nice product. Which is what de Graaff created!

His server is based on Adobe’s Node SMB server, a project I never heard of and looks abandoned. He tells me it mostly works with Sonos just fine. He just made one tiny change to upcase the share’s name. The packaging and installation is a little trickier. He’s got some good docs and a script but it’s still something you might need to understand Linux pretty well to get running. More on that in a bit.

One problem I ran into; Ubuntu 22 ships Node 18. And that gives an error related to SSL ciphers I think because Node dropped support for old insecure SSL clients. The workaround of export NODE_OPTIONS=--openssl-legacy-provider worked for me.

Note that the share has a name like \\192.168.0.2\PUBLIC and you must log in with the username “guest”, no password. Empty username doesn’t work.

It’d be nice if Samba could be fixed. That SSL thing makes me wonder if that’s what broke on Ubuntu 22, that they too dropped some old SSL stuff that the Sonos ancient client needs. There’s some discussion on the Samba list. One happy thing is one of the Samba developers himself has a Sonos so someone in the know may work on the problem.

Packaging, Snap.

Barry’s server works but I can’t quite use it as-is on my LAN. I really need a full Samba server too. But I only have a single Linux box. And SMB doesn’t work well other than on a single port, 445. Some clients do work on other ports but I haven’t tested it with Sonos and am pessimistic. Maybe I need to just add a second IP address to my server and bind the special Sonos server there, but yuck.

All the drama of getting the thing installed makes me think a Snap container / image is the perfect way to run this server. There’s a snap for the web server Caddy so a daemon that accesses local files and serves them on the network is possible in Snap. But I’ve never built a Snap and have no idea how hard it’d be. I guess Docker would work too but Snap seems to be the choice for consumers on Ubuntu systems so I think starting there makes sense. I may give a go at building a Snap, we’ll see.

adobe/node-smb-server patch

Here’s the patch Barry sent me to upcase filenames:

diff -Naur node-smb-server-master/lib/smb/cmd/tree_connect_andx.js sonos-smb/lib/smb/cmd/tree_connect_andx.js
--- node-smb-server-master/lib/smb/cmd/tree_connect_andx.js	2021-06-22 17:20:12.000000000 +0200
+++ sonos-smb/lib/smb/cmd/tree_connect_andx.js	2022-12-09 08:21:10.674527000 +0100
@@ -10,6 +10,10 @@
  *  governing permissions and limitations under the License.
  */
 
+/* As required by original License I hereby notify you that I have made changes to this file.
+ * Copyright (C) 2022 Barry de Graaff
+ * */
+
 'use strict';
 
 var put = require('put');
@@ -76,7 +80,7 @@
 
   logger.debug('[%s] flags: %s, password: %s, service: %s, path: %s', SMB.COMMAND_TO_STRING[commandId].toUpperCase(), msg.flags.toString(2), msg.password.toString('hex'), msg.service, msg.path);
 
-  var shareName = msg.path.substring(msg.path.lastIndexOf('\\') + 1);
+  var shareName = msg.path.substring(msg.path.lastIndexOf('\\') + 1).toUpperCase();
   var shareLevelPassword = utils.bufferEquals(msg.password, Buffer.from([ 0x00 ])) ? null : msg.password;
   if (_.indexOf(server.getShareNames(), shareName) === -1) {
     result = {

Comments

Barry de Graaff 

Thanks for blogging, it inspired me to come up with this solution.