Skip to content

feat: make /var/lib/samba and /var/cache/samba volume ready #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 20, 2025

Conversation

dr3st
Copy link
Contributor

@dr3st dr3st commented Apr 20, 2025

Related to: #45

I would like to use persistent data for /var/lib/samba, to keep passwords in samba's database.
So samba users should not be created again (with password reset) and admins can get rid of plaintext passwords in users.conf (after creation).

To be honest, I got the idea from: https://github.com/crazy-max/docker-samba/blob/510903d53db39e0490d1e9ee3f1aaf6d762b96e8/rootfs/etc/cont-init.d/01-config.sh#L24

I tested it locally and I don't think this would break anything, even if users are not using a volume for /data.

Thanks in advance for your time to check :)

@kroese
Copy link
Contributor

kroese commented Apr 20, 2025

What is the advantage compared to just doing:

volumes:
  - /data/lib:/var/lib/samba
  - /data/cache:/var/cache/samba

Because that would require no changes and seems a bit more clear?

@dr3st
Copy link
Contributor Author

dr3st commented Apr 20, 2025

The problem here is, that you must know the structure of /var/lib/samba. The cache folder folder can be mounted, you are right.
I started a blank container:

podman run --name test --rm -ti --entrypoint  /bin/sh ghcr.io/dockur/samba:4.21.4
ls -hlA /var/lib/samba/
total 12K    
drwxrwx---    2 root     root        4.0K Mar 28 01:41 bind-dns
drwx------    2 root     root        4.0K Mar 28 01:41 private
drwxr-xr-x    2 root     root        4.0K Mar 28 01:41 sysvol

If you mount the folder, it will be empty and samba won't start (I tested yesterday). For sure, you can create the folders before starting the container, but not everbody will know how to find out, which folders have to be created.
As long samba does not need more subfolders under /var/lib/samba the once copy at the beginning would be okay...

Maybe it would be better, to find -type d instead of creating folders inside mount if nonexisting.

If you "accept" the issue, I would optimize it a little bit to be future proof.

@kroese
Copy link
Contributor

kroese commented Apr 20, 2025

I expected that Samba would create the folders automaticly. In that case I prefer that the script just creates /var/lib/samba/bind-dns, /var/lib/samba/private and /var/lib/samba/sysvol if they don't exist.

@kroese
Copy link
Contributor

kroese commented Apr 20, 2025

Can you test if it works with the change I made?

@dr3st
Copy link
Contributor Author

dr3st commented Apr 20, 2025

I moved the folder creation, because the creation of users can only be done, if the folder structure is given

Apr 20 11:37:08 server samba-app[3697873]: tdbsam_open: Failed to open/create TDB passwd [/var/lib/samba/private/passdb.tdb]
Apr 20 11:37:08 server samba-app[3697873]: tdbsam_getsampwnam: failed to open /var/lib/samba/private/passdb.tdb!
Apr 20 11:37:08 server samba-app[3697873]: User Search failed!
Apr 20 11:37:08 server samba-app[3697873]: Failed to open /var/lib/samba/private/secrets.tdb

Now it will works :)

@kroese kroese merged commit 6613c4e into dockur:master Apr 20, 2025
1 check passed
@dr3st dr3st deleted the mount-var-lib-samba branch April 20, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants