Recycle bin for samba home shares

I need to add network shares to user shares (homes).

However, when I edit the include.conf file, the changes are added to the [global] section of the smb.conf file.

I tried adding the following section to the include.conf file:

[homes]

but it still doesn’t load.

Any suggestions?

Usually it works to put sections like [global] to include.conf but the [homes] section is special as it dynamically adds existing users home directories.

Maybe you could add pseudo users, so home shares are created or add normal shares and let the users use them.

Could you please explain what you want to achieve in more detail? Maybe there are other options…

BTW, you could use testparm to check the config and if include.conf is applied correctly.

I would like each user’s shared personal folder to have its own network trash can, like shared folders.

I have already checked with testparm, but the [homes] section is not populated if I enter something like this in include.conf:

[homes]
     recycle:repository = .recycle/$U

From what I understand by looking at testparm, this is what activates the network trash can for the shared folder.

In fact, if I create a network folder with the trash can enabled (for example, share00), I find that line in the corresponding [share00] section, while the configuration of the other network trash can parameters is found in [global].

1 Like

Maybe it could be set using samba registry:

net conf setparm Homes recycle...

I’m going to test it later and report…not in front of pc right now.

EDIT:

@saitobenkei you’re right, it’s not possible by customizing the include.conf, another section seems not accepted.

I adapted the samba package and added an /etc/samba/include_homes.conf to be able to customize the homes section.

You can test it by updating an existing samba instance, in the following example it’s samba3. To be able to upgrade, the “force” option needs to be used. Please don’t use that for usual upgrades as it upgrades without checking the version.

api-cli run update-module --data '{"module_url":"ghcr.io/mrmarkuz/samba:addincludehomes","instances":["samba3"],"force":true}'

Now you can edit /etc/samba/include_homes.conf and add your settings for the recycle bin.

I use nano for editing, you can choose any editor:

runagent -m samba3
podman unshare nano $(podman volume inspect config --format={{.Mountpoint}})/include_homes.conf

I added following content, keeptree preserves directory structures and versions allows multiple versions of deleted files.

recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes

In the case of a home recycle bin the $U variable is not needed IMO as it’s not a “shared” recycle bin for more users like the usual shares.

After restarting the samba-dc service the homes recycle bin should work.

systemctl --user restart samba-dc
1 Like

Thanks, I’ll try later!

Will the Samba update be released in the standard package?

EDIT:

Yes! It works!

Thank you!

1 Like

Great news! You’re welcome.

It was just a nightly action to check if it can work.

I think a toggle in the UI like “Enable recycle bin for home shares” could also be nice.
Maybe both, so we also have a way to customize the homes section manually.
@davidep what do you think?

2 Likes

That would be very useful!

It was just a nightly action to check if it can work.

At night you sleep or do other things! You shouldn’t work! :smiley:

1 Like

It’s not just work, it’s also passion :smiley:

2 Likes

ns8-samba 3.2.0 was released and the homes section can be customized now. Instead of introducing a second file, it can be configured in include.conf

To setup a recycle bin for home shares, add the following to include.conf:

[homes]
recycle:repository = .recycle

Restart the service to apply the config:

systemctl --user restart samba-dc
2 Likes