# samba-configer

WARNING: this was `vibe-coded`, expect bugs!

WARNING: this has not yet been audited by human eyes, use at your own risk!

`samba-configer` is a small interactive terminal program for reading an existing Samba configuration, listing shares, and guiding add/edit/delete operations.

Download the prebuilt executable: `curl -L https://git.dcreason.net/dakota/samba-configer/raw/branch/main/samba-configer -o samba-configer && chmod +x samba-configer`

It is implemented in Go with only the standard library so it builds into a single executable easily.

## Build

```bash
go build -o samba-configer .
```

## Run

```bash
./samba-configer -config /etc/samba/smb.conf
```

The program:

- Reads the Samba config and parses non-`[global]` sections as shares.
- Detects a missing Samba installation when the config file does not exist yet.
- Offers to install the Samba server package with a detected package manager such as `apt`, `dnf`, `yum`, `pacman`, `zypper`, or `apk`.
- Prompts to add, edit, or delete a share.
- Includes a user-management menu to verify all share accounts exist and to remove obviously unused share-style accounts.
- Includes a user-management menu to change a Samba user's password.
- Includes a client-mount workflow for connecting this computer to a share on another server with `cifs-utils`.
- Checks `valid users` entries against local accounts.
- Offers to create missing local accounts with `useradd -M -s /usr/sbin/nologin <user>`.
- If user creation fails because admin rights are needed, explains the issue and offers to retry with `sudo`.
- After creating a user, offers to launch `smbpasswd -a <user>` immediately so the Samba password can be set right away.
- Before saving, checks whether each share folder exists and offers to create missing directories.
- Before saving, offers to adjust share-folder ownership and permissions so connected users can actually read and write files.
- If saving the Samba config or its backup needs admin rights, explains the issue and offers to retry with `sudo`.
- Writes a timestamped backup before saving changes.
- Can append a CIFS mount entry to `/etc/fstab`, including an inline username and password if that is the setup you want.
- If it updates `/etc/fstab` on a systemd system, it reloads systemd before attempting the mount.

If you create a local account for a Samba-authenticated share, you may still need to add the Samba password separately:

```bash
smbpasswd -a <username>
```
