2

A share on the server is defined as follows

[share]
path = ...
read only = no
create mask = 0777
directory mask = 0777
force create mode = 0777
force directory mode = 0777
valid users = dobiasd

It is mounted via the fstab on the client:

//server/share /home/dobiasd/share/ cifs file_mode=0777,dir_mode=0777,iocharset=utf8,username=dobiasd,password=dummy 0 0

The client can create files and directories. A newly created directory can also be deleted again, but it is not possible to create new files or directories inside this new directory. To allow this I first have to do a chmod -R 777 . on the server, so the "drwxrwxr-x" of the directory becomes a "drwxrwxrwx".

How can I get samba to create the new directory immediately in a way so that subfolders can be created in it?

1 Answer 1

4

So, this is a Samba share, mounted on a Linux box (clients using Windows don't have the issue)? If I understand well, it could be only a umask issue. If you type umask on your client, you will probably get 0002 which means that when you create a new directory, its ACLs are rwxrwxr-x (rw-rw-r-- for files).

So, if you want all your newly created folders and files to be world writeable, you can set umask 0000 (in your .bash_profile for instance). Of course, this may be a bad idea...

If I were you, I would ensure all your trusted users are members of a same group, say friends and set these rights on your parent share directory:

chmod g+rwxs /path/to/share

Here, the role of the sgid bit (the s above), is to ensure that all the directories and files which will be created under this directory will be owned by the group owner of the parent directory.

Example to be more clear (here, apaul is member of users (primary) and friends groups):

$ mkdir /tmp/share
$ mkdir /tmp/share/dir1
$ ls -l /tmp/share
drwxrwxr-x 2 apaul users  4096  7 april 21:48 dir1

$ chgrp friends /tmp/share
$ chmod g+rwxs /tmp/share
$ ls -ld /tmp/share
drwxrwsr-x 4 apaul friends 4096  7 april 21:49 share/

$ mkdir /tmp/share/dir2
$ ls -l /tmp/share
drwxrwxr-x 2 apaul users   4096  7 april 21:48 dir1
drwxrwsr-x 2 apaul friends 4096  7 april 21:49 dir2

Then, all members of the friends group can create sub-directories (or file) under the share, but this one is not world writeable.

1
  • Wow, thank you very much. That did the trick. I did not know at all about the sgid bit before. Additionally now I use force user = serverlocaluser. Commented Apr 8, 2015 at 5:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.