mbentley / docker-timemachine

Docker image to run Samba (compatible Time Machine for macOS)
Apache License 2.0
527 stars 65 forks source link

Unable to add multiple users #161

Closed listinfm closed 6 months ago

listinfm commented 6 months ago

Describe the Bug

I'm trying to setup the timemachine (smb) so that 2 users have their own access/credentials. I have setup the macvlan since avahi was interfering with the host, and below is the docker compose. When I try to log into the Timemachine from my mac, I keep being denied. Looking at the log I believe the individual user I have set up (alex) are not being successfully created, the log show it fails to add the usergroup, user, find the user.

I'm not too sure what I'm doing incorrectly or how I can go about troubleshooting this further. Any help is welcomed!

Expected Behavior

Successful creation of user credentials and ability to log into the timemachine using the credentials

Steps to Reproduce

  1. Run the docker compose
  2. Attempt to log into timemachine

How You're Launching the Container

here is the docker compose, created a macvlan separately.

services:
  timemachine:
    container_name: timemachine
    image: mbentley/timemachine:smb
    environment:
      - MIMIC_MODEL=TimeCapsule8,119
      - TM_USERNAME=timemachine
      - TM_GROUPNAME=timemachine
      - PASSWORD=timemachine
      - TM_UID=1000
      - TM_GID=1000
      - SET_PERMISSIONS=false
      - SMB_VFS_OBJECTS=fruit streams_xattr
      - VOLUME_SIZE_LIMIT=500 G
      - SHARE_NAME=TimeMachine
      - EXTERNAL_CONF=/users
      - SMB_INHERIT_PERMISSIONS=no
      - HIDE_SHARES=no
      - SMB_PORT=445
    restart: always
    ports:
      - "137:137/udp"
      - "138:138/udp"
      - "139:139"
      - "445:445"
    volumes:
      - ${HomeLocation}/config/timemachine/backup:/opt
      - ${HomeLocation}/config/timemachine/users:/users
    tmpfs:
      - /run/samba
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    networks:
      timemachinevlan:
        ipv4_address: 192.168.1.109

networks:
  timemachinevlan:
    external: true

Container Logs

INFO: CUSTOM_SMB_CONF=false; generating [global] section of /etc/samba/smb.conf...
INFO: Creating /var/log/samba/cores
INFO: Avahi - generating base configuration in /etc/avahi/services/smbd.service...
INFO: Loading values from /users/alex.conf
INFO: Avahi - adding the 'dk0', 'alextimemachine
' share txt-record to /etc/avahi/services/smbd.service...
INFO: Group timemachine
 doesn't exist; creating...
addgroup: illegal character with code 13 at position 11
INFO: User alex
 doesn't exist; creating...
adduser: illegal character with code 13 at position 4
INFO: Setting password from environment variable
chpasswd: unknown user alex
INFO: INFO: CUSTOM_SMB_CONF=false; generating [alextimemachine
] section of /etc/samba/smb.conf...
Failed to add entry for user alex
.
Failed to find user alex
 in passdb backend.
INFO: Samba - Created INFO: Samba - INFO: Samba - setting password
Failed to find entry for user alex
.
INFO: SET_PERMISSIONS=false; not setting ownership and permissions for /opt/alex
INFO: Avahi - completing the configuration in /etc/avahi/services/smbd.service...
INFO: running test for xattr support on your time machine persistent storage location...
touch: /opt/alex/xattr-test: No such file or directory
WARN: unable to write test file (is your persistent storage location read only or an invalid path?)
WARN: xattr test failure - unable to set xattrs on your persistent data store. Time machine backups may fail!
INFO: Detected filesystem for /opt/alex
 is ext4
INFO: Detected filesystem for /opt/kimberly
 is ext4
INFO: entrypoint complete; executing 's6-svscan /etc/s6'
dbus socket not yet available; sleeping...
nmbd version 4.18.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2023
smbd version 4.18.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2023
INFO: Profiling support unavailable in this build.
Found user 'avahi' (UID 86) and group 'avahi' (GID 86).
Successfully dropped root privileges.
avahi-daemon 0.8 starting up.
WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
Loading service file /etc/avahi/services/smbd.service.
Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.1.109.
New relevant interface eth0.IPv4 for mDNS.
Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
New relevant interface lo.IPv4 for mDNS.
Network interface enumeration completed.
Registering new address record for 192.168.1.109 on eth0.IPv4.
Registering new address record for 127.0.0.1 on lo.IPv4.
Server startup complete. Host name is 5c59938b16dd.local. Local service cookie is 781646607.
Service "5c59938b16dd" (/etc/avahi/services/smbd.service) successfully established.
*****
Samba name server 5C59938B16DD is now a local master browser for workgroup WORKGROUP on subnet 192.168.1.109
*****

Time Machine client Logs

No response

Additional Context

No response

mbentley commented 6 months ago

Please post your EXTERNAL_CONF files without the passwords. Something isn't right.

listinfm commented 6 months ago

Here is my file:

TM_USERNAME=alex
TM_GROUPNAME=timemachine
PASSWORD=
SHARE_NAME=alextimemachine
VOLUME_SIZE_LIMIT="300 G"
TM_UID=1009
TM_GID=1000
mbentley commented 6 months ago

It isn't showing up in what your copied above but It looks like you have some odd carriage returns/end of lines in your user config file. In your logs, it looks like after every reference to the variables in the config file, it's including some sort of new line character.

Here is the startup of when I created the user config plus me making one up for kimberly.conf:

# alex.conf
TM_USERNAME=alex
TM_GROUPNAME=timemachine
PASSWORD=foobarbaz
SHARE_NAME=alextimemachine
VOLUME_SIZE_LIMIT="300 G"
TM_UID=1009
TM_GID=1000
#  kimberly.conf
TM_USERNAME=kimberly
TM_GROUPNAME=timemachine
PASSWORD=foobarbaz
SHARE_NAME=kimberlytimemachine
VOLUME_SIZE_LIMIT="300 G"
TM_UID=1010
TM_GID=1000
$ docker compose up
[+] Running 1/0
 ✔ Container timemachine  Created                                                                                0.0s
Attaching to timemachine
timemachine  | INFO: CUSTOM_SMB_CONF=false; generating [global] section of /etc/samba/smb.conf...
timemachine  | INFO: Avahi - generating base configuration in /etc/avahi/services/smbd.service...
timemachine  | INFO: Loading values from /users/alex.conf
timemachine  | INFO: Avahi - adding the 'dk0', 'alextimemachine' share txt-record to /etc/avahi/services/smbd.service...
timemachine  | INFO: Group timemachine exists; skipping creation
timemachine  | INFO: User alex exists; skipping creation
timemachine  | INFO: CUSTOM_SMB_CONF=false; generating [alextimemachine] section of /etc/samba/smb.conf...
timemachine  | INFO: Samba - Created User alex password set to none.
timemachine  | INFO: Samba - Enabled user alex.
timemachine  | INFO: Samba - setting password
timemachine  | INFO: SET_PERMISSIONS=false; not setting ownership and permissions for /opt/alex
timemachine  | INFO: Loading values from /users/kimberly.conf
timemachine  | INFO: Avahi - adding the 'dk1', 'kimberlytimemachine' share txt-record to /etc/avahi/services/smbd.service...
timemachine  | INFO: Group timemachine exists; skipping creation
timemachine  | INFO: User kimberly doesn't exist; creating...
timemachine  | INFO: Setting password from environment variable
timemachine  | chpasswd: password for 'kimberly' changed
timemachine  | INFO: INFO: CUSTOM_SMB_CONF=false; generating [kimberlytimemachine] section of /etc/samba/smb.conf...
timemachine  | INFO: Samba - Created Added user kimberly.
timemachine  | INFO: Samba - Enabled user kimberly.
timemachine  | INFO: Samba - setting password
timemachine  | INFO: SET_PERMISSIONS=false; not setting ownership and permissions for /opt/kimberly
timemachine  | INFO: Avahi - completing the configuration in /etc/avahi/services/smbd.service...
timemachine  | INFO: dbus PID exists; removing...
timemachine  | removed '/run/dbus/dbus.pid'
timemachine  | INFO: running test for xattr support on your time machine persistent storage location...
timemachine  | INFO: xattr test successful - your persistent data store supports xattrs
timemachine  | INFO: Detected filesystem for /opt/alex is fakeowner
timemachine  | INFO: Detected filesystem for /opt/kimberly is fakeowner
timemachine  | INFO: entrypoint complete; executing 's6-svscan /etc/s6'
timemachine  | Found user 'avahi' (UID 86) and group 'avahi' (GID 86).
timemachine  | Successfully dropped root privileges.

I am guessing that the conf files that you have created a DOS file formatted text file. This can be verified using the file command. Here I have the files converted to DOS format:

$ file *
alex.conf:     ASCII text, with CRLF line terminators
kimberly.conf: ASCII text, with CRLF line terminators

You can use dos2unix, which you may need to install, to convert the files to not have the CRLF line ends.

$ dos2unix *
dos2unix: converting file alex.conf to Unix format...
dos2unix: converting file kimberly.conf to Unix format...

You'll want to see that they're just a plain ASCII text file:

$ file *
alex.conf:     ASCII text
kimberly.conf: ASCII text

Or you can do all of this from inside the container:

Exec into the container:

docker exec -it timemachine sh

Install file and dos2unix:

apk add file dos2unix

Check and convert the files and re-check them:

cd /users
file *
dos2unix *
file *

Then restart your time machine container.

listinfm commented 6 months ago

@mbentley That certainly fixed it - thank you for the quick replies! Amazing support :). I was truly going in circles trying to understand what characters it wasn't liking. I do not think I would have figured this out without your help! Thank you so much, this has resolved the issue. :)