Recycle Bin Samba NS8

how do you enable network recycle bin in samba? And how do change the install domain in NS8?

To add a recycle bin to all shares, we need to edit /home/samba1/.local/share/containers/storage/volumes/config/_data/include.conf and add the following content:

vfs objects = recycle
recycle: exclude_dir = /tmp,/temp,/cache
recycle: repository = Recycle Bin
recycle: versions = True
recycle: keeptree = True
recycle: touch = True
recycle: directory_mode = 0770
recycle: exclude = *.tmp,*.temp,*.o,*.obj,~$*

Restart the service to apply the new config:

runagent -m samba1 systemctl --user restart samba-dc
4 Likes

Good morning Markus!

It isn’t written in the docs, but it’s worth noting that the code uses also the samba registry as per-share config backend. Changes to the registry are picked up from the next share connection, and don’t require service restarts.

See for example the API that set the share description: ns8-samba/imageroot/actions/alter-share/50alter_share at main · NethServer/ns8-samba · GitHub

Refer also to net conf setparm manpage.

2 Likes

That’s nice and it works: (in this example testfolder gets a recycle bin)

Enter the container:

runagent -m samba1 podman exec -ti samba-dc bash

Execute following commands:

net conf setparm testfolder "vfs objects" recycle
net conf setparm testfolder recycle:exclude_dir /tmp,/temp,/cache
net conf setparm testfolder recycle:repository "Recycle Bin"
net conf setparm testfolder recycle:versions True
net conf setparm testfolder recycle:keeptree True
net conf setparm testfolder recycle:touch True
net conf setparm testfolder recycle:directory_mode 0770
net conf setparm testfolder recycle:exclude *.tmp,*.temp,*.o,*.obj,~$

The service needs to be restarted to apply the config.

runagent -m samba1 systemctl --user restart samba-dc

3 Likes

Hello,

I set these parameters but it doesn’t work. Also when I access cluster-admin it gives me an error when it searches for the list of shared folders.

Hi @gio.pelli

and welcome to NethServer Community.

Did you setup the include.conf file or did you run the net conf setparm command or both?
Maybe you could share the file or the commands you used.

Could you please share the error message.

I’m going to retry the recycle bin setup later today.

EDIT:

It seems both methods aren’t working anymore but the net conf commands create an error in the cluster-admin Shared folders page.

To get back to a working page in cluster admin just remove the params from the testfolder section with following commands:

net conf delparm testfolder "vfs objects"
net conf delparm testfolder recycle:exclude_dir
net conf delparm testfolder recycle:repository
net conf delparm testfolder recycle:versions
net conf delparm testfolder recycle:keeptree
net conf delparm testfolder recycle:touch
net conf delparm testfolder recycle:directory_mode
net conf delparm testfolder recycle:exclude

Now cluster-admin should work again.
I need to check why it isn’t working anymore…

This is the error:

option 'recycle' in section 'testfolder' already exists

Yes but there are different subparams which should be allowed. @davidep do you have an idea why the samba registry entries aren’t working anymore?

This is the error trace:

Traceback (most recent call last):
  File "/home/samba1/.config/actions/list-shares/50list_shares", line 75, in <module>
    ocfg.read_file(hconf.stdout, 'samba-registry-conf')
  File "/usr/lib64/python3.11/configparser.py", line 734, in read_file
    self._read(f, source)
  File "/usr/lib64/python3.11/configparser.py", line 1112, in _read
    raise DuplicateOptionError(sectname, optname,
configparser.DuplicateOptionError: While reading from 'samba-registry-conf' [line  7]: option 'recycle' in section 'testfolder' already exists

Thanks mrmarkuz,

it’s the same situation and I also had deleted the parameters to restore cluster-amin.

Did you also remove the lines from include.conf and restart the service?

I wrote it wrong, I also had deleted the parameters and now cluster-admin is ok.

Thanks

1 Like

The instructions for adding a recycle bin to all shares should work now. The vfs objects param was missing.
I also adapted the instructions for adding a recycle bin to just one share…

EDIT:

…but this is not working as the cluster-admin has errors on the shared folders page, see also Recycle Bin Samba NS8 - #6 by mrmarkuz
I think it’s a bug, there seem problems with processing more than one config field including a “:”. It throws an error because they’re seen as duplicate.
I’m going to investigate…

4 Likes

Hello @mrmarkuz . I tried to modify the include.conf file and it works perfectly. But this doesn’t seem to apply to users home directories. Is that possible as well? :thinking:

1 Like

It should apply to user home shares too as it’s a global definition. Here it works.

Sometimes you need to refresh the file manager to show the Recycle bin.

Which system/file manager are you using to browse the home shares?

Hi @mrmarkuz

On quite a lot of Windows systems, the Trashcan will only be visible AFTER you erase a file!

My 2 cents
Andy

AFAIK the “Recycle Bin” folder is created on file deletion on the samba side if it doesn’t exist already and the deleted file is moved into the that folder so exceptionally it’s not a Windows issue.

Not specifically, but is mostly seen from a Windows box… :slight_smile:

But essentially, your statement is 100% correct. Samba creates that folder on first file deletion, wheras on Windows systems, the Trashcan is visble even if no file has been deleted.

1 Like

Oh sorry, my bad, it does work. I was looking under the wrong home folder :smile:

EDIT:
After the change, I couldn’t set a shared folders ACLs using Windows anymore. I reverted the change and it seems to work, but this popup box doesnt show anything anymore.

EDITv2:
I removed special permissions for all shares with setfacl -b -R.
Then resetted ACLs using NS8 interface.
And now it looks like it works again.

Dunno about the Recycle Bin, afraid to turn it on again :smiley:

2 Likes

Thanks for the info.
Maybe setting the vfs objects needs to be done another way.
I’m going to investigate and report back.

No problem. :+1: Hope the change didn’t mess up sysvol or netlogon folders, they also had the extended permissions (but maybe thats normal).
After reverting permissions and removing the config everything seems to work normal including logging in, GPOs, shares.

If you find a way to properly turn on the Recycle Bin, it would be very useful :+1:

EDIT: I modified the “Recycle Bin” name to “Atkritne” which is the same in Latvian. But in theory that shouldn’t matter.

1 Like

Thanks for the report. I’ll try to reproduce it.

project card NethServer · GitHub

1 Like