LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-27-2023, 02:21 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,561

Rep: Reputation: 177Reputation: 177
Prevent directory moving and renaming on samba share


I have a Samba shared network drive. It's smb.conf attributes are:
Code:
readonly = no
locking = yes
public = yes
printable = no
create mask = 0660
force user = user
force group = group
force create mode = 0660
directory mask = 2771
This important bit here is that the user.group is forced to (obfuscated) user.group. The Windows clients access this mapped drive as that user and group.

All that works fine in that all Windows users can read/update any files and folders on this share.

However, I now want some of the directories to have unchangeable names since certain paths get stored in the database. For example I need:
Code:
drwxrwx--x 14 user   group    4096 2022-12-22 10:12 Accts\ Payable\ -\ ofc/
to never allow users to change its name. Other solutions, such as changing the owner to root.root won't work because the entire volume is shared as owner user.group.

Can this be done?

Last edited by mfoley; 11-27-2023 at 02:23 PM.
 
Old 11-28-2023, 05:40 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,640

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
The ONLY way I know to get that behavior is to allow only READ ONLY access on those files and folders, and in some cases even THAT does not suffice.

At a previous work location I advised to allow access using SAMBA only to a select group, and make the rest operate clients over network using only the application protocol or SFTP protocol. Where they did not take my advice remediation for accidental file or folder moves was routine.

(( I am not always right, but when I am I remember FOREVER! ;-) ))
 
Old 11-28-2023, 06:02 PM   #3
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,454
Blog Entries: 7

Rep: Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559
Quote:
Originally Posted by mfoley View Post
However, I now want some of the directories to have unchangeable names since certain paths get stored in the database. For example I need:
Code:
drwxrwx--x 14 user   group    4096 2022-12-22 10:12 Accts\ Payable\ -\ ofc/
to never allow users to change its name. Other solutions, such as changing the owner to root.root won't work because the entire volume is shared as owner user.group.

Can this be done?
In short: No.

As noted by wpeckham, accidental file or folder moves are a 'feature' of Windows/SMB file shares. You can't disable drag & drop in Windows, so any Windows user who has permissions to write to that share can cause havoc. If you do a search, you will find many, many forum posts by exasperated admins about this very big problem.

What I've done at the office on the client machines is something like this: https://www.top-password.com/blog/di...in-windows-10/ It doesn't disable drag and drop, just decreases its sensitivity. Users will complain about their computer being slow to respond, but it does go some way to preventing accidental moves. If you're running an AD server, you might be able to set this as group policy, but I don't know because I haven't tried.
 
Old 11-28-2023, 10:39 PM   #4
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,561

Original Poster
Rep: Reputation: 177Reputation: 177
hmm, that sucks. So I can't even use Access Control Lists for this?
 
Old 11-29-2023, 12:51 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314Reputation: 7314
is it an ext4 filesystem (that you want to access from windows)? Or?
 
Old 11-29-2023, 05:46 PM   #6
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,454
Blog Entries: 7

Rep: Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559
Quote:
Originally Posted by mfoley View Post
hmm, that sucks. So I can't even use Access Control Lists for this?
You probably could, if you only have one or even just a few directories to protect... but it'd be on a per-directory basis, and a PITA to administer if you have to change something... Not something you'd want to do if you had tens or hundreds of directories.

There is another solution: https://github.com/broken-e/DragDropConfirm. This causes a confirmation dialog box to pop-up every time someone tries to move or rename a file or directory. You'd need to install it at the client end... and trust that your users aren't stupid enough to click OK instead of Cancel.
 
  


Reply

Tags
permissions, rename, samba



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a was to prevent moving/deleting a directory within a Samba share? mfoley Linux - Server 2 04-24-2021 01:53 PM
vSphere / ESXi - Renaming Directory Names in Data-Store and Moving things around in Data-Store devUnix Linux - Virtualization and Cloud 1 04-27-2017 08:13 AM
AWK script: moving, copying and renaming files uprjamaja Programming 10 12-05-2006 01:06 PM
renaming and moving filenames nightjar Linux - General 10 03-01-2003 09:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration