0

i have a folder called Public inside my home folder. I need to share this folder (write only) via samba. However if i chmod 772 Public it doesn't work since my home folder is 750. Is there a way to solve this without chmod 777 my home folder?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Matteo
  • 570

2 Answers2

2

To access a directory, the directory itself, as well as all the intermediate directories from the root down, has to have the x permission for the given user, their group or all. This would allow reading files in the directory if one knew their pathnames (listing the contents of the directory would not be allowed unless r was also in effect).

For a world-write-only directory ("write" meaning "permitting the creation and deletion of files and subdirectories, and updating their metadata"), the permissions on the directory itself should be wx, and all parent directories should have at least x.

If you are creating a "drop box" in your home directory, therefore:

cd
mkdir directory
chmod o=wx,g=wx directory
chmod a+x "$HOME"

Note that I'm also giving the group wx access to the directory here (rather than using g=). A member of the group who owns the directory (probably your primary group) would otherwise be explicitly denied access to the directory even though o=wx was in effect.

Assuming you as the owner has rwx permissions to the directory, this is equivalent to the octal permissions 0733 on the "drop box" directory.

Kusalananda
  • 333,661
0

You could use the force user directive on the SAMBA share definition to ensure all network access is made as your user account. The missing "other" permissions on the parent directory then become irrelevant.

Without knowing the details of your requirement there's little point suggesting more complex alternatives.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • Hmm... This would mean that all new files were owned by the account, not by the users creating the files. It would also mean that access permissions on individual files and subdirectories would become (more or less) ineffective. – Kusalananda Dec 20 '18 at 09:11
  • @Kusalananda without details of what the OP wants it's as good a suggestion as any. UNIX style permissions and SAMBA permissions often don't cleanly intersect (well, not intuitively). – Chris Davies Dec 20 '18 at 11:46