コンピュータや音楽の事書いてます

webDAVとsambaを同じディレクトリに適用する

windows, mac, android, iPhone 全てで、なるべくPC操作が苦手な人にも操作出来るアップローダの構築。windowsからはsamba。それ以外はwebDAVで行ける。ダウンロードだけなら通常のブラウザから。

webDAV(apache)設定

パスワード認証無し
DavLockDB "/etc/httpd/var/DavLock"

Alias /public "/home/public"
<Directory "/home/public">
    Dav On
    Options None Indexes
    IndexOptions NameWidth=* Charset=UTF-8

    Order Allow,Deny
    Allow from all
</Directory>
Basic認証
Alias /private "/home/private"
<Directory "/home/private">
    Header add MS-Author-Via "DAV" 
    Dav On

    SSLRequireSSL
    Options None Indexes
    IndexOptions NameWidth=* Charset=UTF-8
    AuthType Basic
    AuthName "shareuser"
    AuthUserFile "/etc/httpd/user.passwd"
    Require valid-user
    Order Allow,Deny
    Allow from all
</Directory>

/home/private, /home/public の権限を755に変更
ユーザ作成

htpasswd -c /etc/httpd/user.passwd ユーザ名 #2人目からは -c は要らない

SSL鍵作成

cd /etc/httpd/conf
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

/etc/httpd/conf/extra/httpd-ssl.conf

SSLCertificateFile "/etc/httpd/conf/server.crt"
SSLCertificateKeyFile "/etc/httpd/conf/server.key"

samba3設定

デフォルトでは smbpasswdではなく、passdb backend = tdbsam が有効になっている。

pdbedit -a -u ユーザ名
workgroup = WORKGROUP
netbios name = share
unix charset = UTF-8
dos charset = CP932
security = user
guest account = nobody
map to guest = Bad User

#パスワード無し
[public]
    path = /home/public
    browseable = yes
    writable = yes
    create mask = 0666
    directory mask = 0755
    guest only = Yes

#パスワード有り 全てのユーザが同じディレクトリを使う
[private]
    path = /home/private
    browseable = yes
    writable = yes
    create mask = 0666
    directory mask = 0755