0

I've installed the samba via brew and it appears to not start successfully on MacOS Monterey 12.5.

I would like to emphasis, this is question is about the smbd daemon from samba.org and therefore not the one from Apple.

Here is the command line that I ran:

sudo /usr/local/sbin/samba-dot-org-smbd -i; echo $?

The output:

smbd version 4.16.4 started.
Copyright Andrew Tridgell and the Samba Team 1992-2022

And the process immediately exit with return code 1.

No log file has been generated.

Do you have any clue why it does not run?

-/-

As documentation, hereby below all the preparation I made to use is as a service:

# install samba
brew install samba

# disable system netbios daemon
sudo launchctl stop com.apple.netbiosd
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.netbiosd.plist

# disable system smb daemon
sudo launchctl stop com.apple.smbd

# create org.samba.smbd.plist
cat << EOF | sudo tee /Library/LaunchDaemons/org.samba.smbd.plist >/dev/null
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.samba.smbd</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/sbin/samba-dot-org-smbd</string>
            <string>-F</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>samba</string>
    </dict>
</plist>
EOF

# create org.samba.nmbd.plist
cat << EOF | sudo tee /Library/LaunchDaemons/org.samba.nmbd.plist >/dev/null
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.samba.nmbd</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/sbin/nmbd</string>
            <string>-F</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>netbios</string>
    </dict>
</plist>
EOF

# create Scans directory in home folder
mkdir -m a+rwx ~/Scans

# create samba log directory
sudo mkdir /var/log/samba

# Create samba configuration
cat << EOF | sudo tee /usr/local/etc/smb.conf >/dev/null
[global]
   workgroup = WORKGROUP
   server string = %h server (Samba, MacOS)
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   server role = standalone server

[Scans]
   path = /Users/$USERNAME/Scans
   comment = Scans
   locking = no
   guest ok = yes
   read only = no
   writeable = yes
   browseable = yes
   printable = no
   create mask = 0666
   directory mask = 0777
   vfs objects = catia
   catia:mappings = 0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6
EOF

# launch samba daemon
sudo launchctl load -w /Library/LaunchDaemons/org.samba.smbd.plist

# launch netbios daemon
sudo launchctl load -w /Library/LaunchDaemons/org.samba.nmbd.plist

# check if daemons are started
sudo launchctl list | head -1 &&  sudo launchctl list | grep -E '(smbd|nmbd|netbios)'

# view your shares
smbutil view -g //$(hostname)

# stop
sudo launchctl stop org.samba.smbd
sudo launchctl stop org.samba.nmbd
0

1 Answer 1

1

The problem is that some of the permissions are not correct when installed through brew.

After brew install samba create a minimal smb.conf sudo nano /opt/homebrew/etc/smb.conf

After that, make sure you give full disk access to smbd and samba-dot-org-smbd in Privacy Settings of Mac OSX

You can start samba with sudo /opt/homebrew/sbin/samba-dot-org-smbd -i -d 4

You will see an error message complaining about directory permissions

These commands got me started with samba. Still working on some permission problems, but at least the server is up and running:

sudo chown root:wheel /opt/homebrew/var/lock/msg.lock

sudo chmod 755 /opt/homebrew/var/lock/msg.lock

mkdir /opt/homebrew/Cellar/samba/4.18.2/private

2
  • @Thinkr what extr information is needed?
    – mmmmmm
    May 1, 2023 at 11:14
  • Good question. I set up a password with "smbpasswd -a user" and now I always get access denied log messages. I tried to solve for a few hours but gave up for now. Getting samba to work on Mac is extremely hard somehow
    – mrchrister
    May 2, 2023 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .