Incorrect samba password for mounted devices

Hi,

Since I updated my raspberry pi B to RC3 I cannot access my usb hard disk from windows using samba. I’m using default samba config files and I am mounting my hard disk using fstab as follows:

fstab:

/dev/mmcblk0p1 /boot vfat defaults,noatime 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime 0 0
UUID=810547cf-5199-44f5-a8bd-c44dec50f4a7 /mnt/RaspberryPi ext4 defaults,nofail 0 0

Every time I try to access this share it asks for password and osmc:osmc is not valid, any other share is working correctly.I installed samba with app store. The /mnt/RaspberryPi directory was made using “sudo mkdir /mnt/RaspberryPi” and then “sudo chown -R osmc:osmc /mnt/RaspberryPi”

Any ideas?

You can’t be using the default samba configuration as it doesn’t share anything under /mnt.

So either you’ve added something in smb.conf or have an smb-local.conf or smb-shares.conf or samba is actually sharing the drive mounted in /media.

Please paste a copy of your smb.conf and smb-local.conf and smb-shares.conf if you have them, also the output of:

ls -al /mnt /media

I was trying to add this drive using smb-shares.conf but after some tests I gave up and deleted smb-local.conf and the lines added to smb-shares.conf. There is nothing in /media. My drive is the share list, so I guess that it is being shared by default.

ls -la /mnt /media /etc/samba

/etc/samba:
total 36
drwxr-xr-x  3 root root 4096 May 20 00:55 .
drwxr-xr-x 75 root root 4096 May 22 19:50 ..
-rw-r--r--  1 root root    8 Mar  7 13:14 gdbcommands
-rw-r--r--  1 root root  329 May 20 00:55 smb-shares.conf
-rw-r--r--  1 root root 1657 May 14 23:32 smb.conf
-rw-r--r--  1 root root 9231 Apr 12 12:28 smb.conf.distributed
drwxr-xr-x  2 root root 4096 Mar 15 15:19 tls

/media:
total 12
drwxr-xr-x  2 root root 4096 May 19 16:12 .
drwxr-xr-x 23 root root 4096 May 15 11:05 ..
-rw-r--r--  1 root root  232 Mar  6 13:34 README

/mnt:
total 16
drwxr-xr-x  4 root root 4096 May 19 18:02 .
drwxr-xr-x 23 root root 4096 May 15 11:05 ..
drwxr-xr-x 16 osmc osmc 4096 May 20 01:01 RaspberryPi
drwxr-xr-x  2 osmc osmc 4096 May 19 18:02 WDTV

cat /etc/samba/smb.conf

[global]

# If you require a fully custom smb.conf create smb-local.conf instead of editing smb.conf so your
# configuration will not be overwritten by samba upgrades. You can use smb.conf as a template by
# copying it to smb-local.conf then removing the config file line below in the new file. If you only
# need to add some additional shares see smb-shares.conf below for a simpler way to do this.

    config file = /etc/samba/smb-local.conf

    workgroup = WORKGROUP
    security=user
    follow symlinks = yes
    wide links = no
    unix extensions = no
    lock directory = /var/cache/samba
    load printers = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes
    log level = 1
    map to guest = bad user
    usershare template share = automount template

    read raw = Yes
    write raw = Yes
    strict locking = no
    min receivefile size = 16384
    use sendfile = true
    aio read size = 2048
    aio write size = 2048
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072

[osmc]
    browsable = yes
    read only = no
    valid users = osmc
    path = /home/osmc
    comment = OSMC Home Directory

[automount template]
    browseable = yes
    -valid = no
    valid users = osmc
    path = %P
    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

# Add custom shares in smb-shares.conf instead of editing smb.conf so they will not be
# overwritten by samba updates. You can only add new shares to smb-shares.conf, not change
# the default shares or global options. If you need full control see smb-local.conf above.

include = /etc/samba/smb-shares.conf

cat /etc/samba/smb-shares.conf

Deprecated devices share. If you do not need this you can remove it.
[devices]
    browsable = yes
    read only = no
    valid users = osmc
    path = /media
    force user = root
    comment = Deprecated (Please use the Auto-mount Volume shares)
    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

I’m afraid I can’t see how your drive mounted in /mnt is being shared by samba at all.

The default samba config files will share /home/osmc as osmc, and if you have smb-shares.conf from a legacy install will also share /media as the devices share.

In addition udisks-glue.conf will share any automounted drive’s partitions as individual shares based on their partition labels. Nowhere is anything sharing drives mounted under /mnt.

What happens if you comment out your fstab line and reboot - does the drive automount in /media (it should) and get an automatically created share ? (it should)

The device is not automonted at boot unless I start kodi (I disabled it because I don’t want it to be started at boot), this happens since RC3 and that’s why I added the fstab line. But, If I comment the fstab line, reboot and start kodi, the device is automounted and it’s accessible from windows.

After a fresh install everything is working fine, I don’t know what was the problem. Although devices are not automounted unless I start kodi, the fstab option is ok for me. Thank you for your help and your hard work!

Thanks for this, I was sceptical at first but it seems you are right - only FAT32 and NTFS partitions are auto-mounting without Kodi running. This is most unusual and we will look into why this is happening.

This should be fixed now. Please run updates to install an update that I’ve just pushed out, and temporarily comment out your fstab mount for your external drive then reboot.

You should find that your external drive partitions are automounted in /media and shared via samba properly without Kodi launching on startup - please confirm that this is the case.

Thanks for noticing that problem - as I don’t usually test with Kodi disabled I missed it…

Nice, now the disk is automounted at boot as always and it’s accessible via samba. Is there any reason to use the automatic way instead of the line I use in fstab? Glad to help

Use whichever you’re happy with - our intention is to make things as easy as possible by automatically mounting external drives by name when connected, and automatically sharing them with samba if you have samba installed. There were a couple of bugs that were causing this not to work under all circumstances, but I think I have those fixed now.

I’m trying to make this share not to ask for password but it’s impossible so far, Am I doing something wrong?

cat /etc/samba/smb-local.conf

[global]
    workgroup = WORKGROUP
    security = user
    follow symlinks = yes
    wide links = no
    unix extensions = no
    lock directory = /var/cache/samba
    load printers = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes
    log level = 1
    map to guest = bad user
    usershare template share = automount template

    read raw = Yes
    write raw = Yes
    strict locking = no
    min receivefile size = 16384
    use sendfile = true
    aio read size = 2048
    aio write size = 2048
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072

    mangled names = no

[osmc]
    browsable = no
    read only = no
    valid users = osmc
    path = /home/osmc
    comment = OSMC Home Directory

[automount template]
    browseable = yes
    -valid = no
    valid users = osmc
    path = %P
    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

# Add custom shares in smb-shares.conf instead of editing smb.conf so they will not be
# overwritten by samba updates. You can only add new shares to smb-shares.conf, not change
# the default shares or global options. If you need full control see smb-local.conf above.

include = /etc/samba/smb-shares.conf

cat /etc/samba/smb-shares.conf

[RaspberryPi]
    browsable = yes
    read only = no
    path = /mnt/RaspberryPi
    guest ok = yes
    force user = osmc
    force group = osmc
    create mask = 755
    directory mask = 755
    force create mode = 755
    force directory mode = 755

At least I can access it using osmc:osmc

1 Like

Try at the end of the general section of smb-local.conf

map to guest = Bad Password
guest account = root

and this in your smb-shares.conf

[RaspberryPi]
browsable = yes
read only = no
path = /mnt/RaspberryPi
guest ok = yes

I would not recommend this.

I would suggest under the [RaspberryPi] section to only add this line to your existing lines:

map to guest = bad user

Shouldn’t need anything else. Guest account = root is a bad idea.

It’s not working at the moment because windows uses the guest account for unauthenticated shares, but the guest account doesn’t exist on OSMC by default. map to guest = bad user means any unrecognised username will map to the guest account, then the guest ok = yes and force user and force group will work.

See map to guest here:

https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html

Edit:

This option may need to be added to the Global section, thus require a custom smb-local.conf

But using that configuration every file I create via samba will be owned by root, right? Before the update to RC3 everything was working fine with a configuration pretty similar to the configuration I’ve posted before. I want every file to be owned by osmc:osmc with that permissions (755), anyway I’ll give it a shot in a while and will post the result

which he’s already got from my reading of his post

Any particular reason? BTW I have no idea about linux generally I just try and find things that work :smile:

You suggested map to guest = bad password, I suggested map to guest = bad user - check the smb.conf man page for why map to guest = bad password is not ideal.

Two reasons - one is allowing any unauthenticated user (which is what map to guest does) to be able to write files as root is just a really bad idea from a security point of view.

The other reason is I’ve gone to some lengths in RC3 to set up the samba shares and the automounter so that files on all different partition types (fat32, exfat, ext4, ntfs) can be written as the osmc user - this means that kodi and the ftp server are both able to delete and rename files written by samba.

If you map to root (as was default in the devices share in RC2 and earlier) then files written by samba cannot be deleted or renamed by either kodi, an ftp client logged in as osmc, or any programs running as osmc.

1 Like

Yes but he already has map to guest = bad user in his smb-local.conf which wasn’t working

Ah cheers - I had noticed that devices were mounted as root RC2 so couldn’t see any difference - I didnt realise that you had changed this in RC3.

Personally not really worried about the security issues :smile:

Thanks for the explanation

Not a good reason to advise others (who may not know any better) to compromise theirs… :wink:

most people who dont want to bother with passwords(OP) aren’t worried about internal security, must stop my cats from hacking the network :laughing: