8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Sambaで下位ディレクトリに書き込めない

Posted at

Sambaをマウントしてファイルサーバとして使っていたのですが、マウントしたディレクトリには書き込めるのに、その下位ディレクトリに書き込めず、少しハマりました。
解決策としては単純なのですが、いつか忘れそうなので書いておきます。

環境

  • デスクトップ
  • Mac OS X 10.9.5
  • ファイルサーバ(FS)
  • FreeBSD 9.2-RELEASE-p4
  • Samba
  • 4.1.6

状況

Sambaを使ってファイルサーバをマウントできるようにしました。

smb4.conf(FS)
[public]
    path = /mnt/public
    writeable = yes
(中略)                                                                                                                     
    inherit owner = no                                                                                                                  
    inherit permissions = no                                                                                                           
    hide dot files = yes                                                                                                                
    guest ok = yes                                                                                                                      

このようにwritable = yesなので書き込みOKで、guest ok = yesなので認証なしでもいける!ようにしたつもりです。
ということでMacでマウントすると、/Volumes/publicというディレクトリができています。
なので、ここにディレクトリを作成してみます。

Mac
$ pwd
/Volumes/public
$ mkdir parent
$ ls
parent

作成できているようです。
では次に作成したparentディレクトリの下にディレクトリを作成してみます。

Mac
$ cd parent
$ mkdir child
mkdir: cannot create directory ‘child’: Permission denied

ここでなぜか怒られます。
Macで見た時のパーミッション的には問題無いので、なぜ書き込めないのか少し悩みました。
考えた結果、Sambaの方のパーミッションがおかしいのではないのかということで、再度smb4.confを確認します。

smb4.conf(FS)
[public]
    path = /mnt/public
    writeable = yes
(中略)                                                                                                                     
    inherit owner = no                                                                                                                  
    inherit permissions = no                                                                                                           
    hide dot files = yes                                                                                                                
    guest ok = yes                                                                                                                      

やはりwritable = yesになっているしなーと思って眺めていると、inherit permissionsという項目があることに気づきます。
inheritという言葉が今の状況に非常に合っているような気がして、inherit permissions = yesにしてSambaを再起動してみます。

FS
# /usr/local/etc/rc.d/samba_server restart
Performing sanity check on Samba configuration: OK
Waiting for PIDS: 3256.
Stopping smbd.
Waiting for PIDS: 3253.
Stopping nmbd.
Waiting for PIDS: 3250.
Performing sanity check on Samba configuration: OK
Starting nmbd.
Starting smbd.
Starting winbindd.

この状態で再度parentを作りなおして、childを作成してみます。

Mac
$ mkdir parent
$ cd parent
$ mkdir child
$ ls
child

ということでできるようになりました。
inherit aclinherit persmissionsの違いなどは
http://damedame.monyo.com/?date=20100901
などがわかりやすかったです。

8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?