自从我们升级到 OSX El Capitan 以来,我们的 SMB 服务器遇到了一些奇怪的文件权限错误。
我们有一台 ubuntu 服务器,通过 SMB 共享文件夹将我们的工作文件托管到每个 Mac 工作站。我们使用通过 SMB 进行 Git和源树建立我们的网站(方便共享相同的数据库和文件),自从我们升级到OS X El Capitan以来,文件权限就不一样了,并且Git标记每个文件的更改,因为它们的权限从0664切换到0775(或0644切换到0755)。
例如,以下是ls -la
在我们的开发服务器上使用 SSH 的输出
➜ CashierTheme git:(develop) ls -la
total 72
drwxrwsr-x 9 nestorwww nestorwww 4096 oct. 12 23:42 .
drwxrwsr-x 6 nestorwww nestorwww 4096 avril 14 17:33 ..
-rw-rw-r-- 1 nestorwww nestorwww 12261 oct. 12 23:42 CashierThemeApp.php
-rw-rw-r-- 1 nestorwww nestorwww 56 oct. 12 23:42 composer.json
-rw-rw-r-- 1 nestorwww nestorwww 352 oct. 12 23:42 config.yml
drwxrwsr-x 2 nestorwww nestorwww 4096 oct. 12 23:42 Controllers
-rw-rw-r-- 1 nestorwww nestorwww 170 oct. 12 23:42 .editorconfig
drwxrwsr-x 2 nestorwww nestorwww 4096 oct. 12 23:42 Entities
drwxrwsr-x 4 nestorwww nestorwww 4096 oct. 12 23:42 Forms
drwxrwsr-x 8 nestorwww nestorwww 4096 oct. 12 23:42 .git
-rw-rw-r-- 1 nestorwww nestorwww 35 oct. 12 23:42 .gitignore
-rw-rw-r-- 1 nestorwww nestorwww 1060 oct. 12 23:42 LICENSE.md
-rw-rw-r-- 1 nestorwww nestorwww 1819 oct. 12 23:42 README.md
drwxr-sr-x 2 nestorwww nestorwww 4096 oct. 12 23:42 Repositories
drwxrwsr-x 6 nestorwww nestorwww 4096 oct. 12 23:42 Resources
drwxrwsr-x 10 nestorwww nestorwww 4096 oct. 12 23:42 static
文件权限没问题。然后,以下是ls -la
来自我们的 SMB 共享文件夹(来自我的 Mac):
➜ CashierTheme git:(develop) ✗ ls -la
total 328
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 .
drwx------ 1 ambroisemaupate staff 16384 14 avr 17:33 ..
-rwx------ 1 ambroisemaupate staff 170 12 oct 23:42 .editorconfig
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:43 .git
-rwx------ 1 ambroisemaupate staff 35 12 oct 23:42 .gitignore
-rwx------ 1 ambroisemaupate staff 12261 12 oct 23:42 CashierThemeApp.php
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 Controllers
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 Entities
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 Forms
-rwx------ 1 ambroisemaupate staff 1060 12 oct 23:42 LICENSE.md
-rwx------ 1 ambroisemaupate staff 1819 12 oct 23:42 README.md
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 Repositories
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 Resources
-rwx------ 1 ambroisemaupate staff 56 12 oct 23:42 composer.json
-rwx------ 1 ambroisemaupate staff 352 12 oct 23:42 config.yml
drwx------ 1 ambroisemaupate staff 16384 12 oct 23:42 static
因此,当我git status
在开发服务器上输入命令时,一切正常:
➜ CashierTheme git:(develop) git status
Sur la branche develop
Votre branche est à jour avec 'origin/develop'.
rien à valider, la copie de travail est propre
以下是git status
SMB 共享的输出:
➜ CashierTheme git:(develop) ✗ git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .editorconfig
modified: .gitignore
modified: CashierThemeApp.php
modified: Controllers/ContactController.php
modified: Controllers/InvoiceController.php
modified: Controllers/PaymentController.php
modified: Controllers/PostingController.php
modified: Controllers/QuoteController.php
modified: Entities/BankOperationTrait.php
modified: Entities/Contact.php
modified: Entities/Invoice.php
modified: Entities/Letter.php
modified: Entities/PayableInterface.php
modified: Entities/Payment.php
modified: Entities/Posting.php
modified: Entities/PostingObject.php
modified: Entities/Quote.php
modified: Forms/ContactSelectorType.php
modified: Forms/ContactType.php
modified: Forms/DataTransformer/ContactToNumberTransformer.php
modified: Forms/Filters/ContactFilterType.php
modified: Forms/Filters/PostingFilterType.php
modified: Forms/Filters/QuoteFilterType.php
modified: Forms/InvoiceStatusType.php
modified: Forms/InvoiceType.php
modified: Forms/PaymentType.php
modified: Forms/PostingObjectType.php
modified: Forms/PostingObjectUnitType.php
modified: Forms/PostingType.php
modified: Forms/QuoteStatusType.php
modified: Forms/QuoteType.php
modified: LICENSE.md
modified: README.md
modified: Repositories/PostingRepository.php
modified: Resources/config/.gitignore
modified: Resources/config/fonts.default.xml
modified: Resources/config/pdf_stylesheet.default.xml
modified: Resources/firewalled-routes.yml
modified: Resources/imports/roles.rzt
modified: Resources/imports/settings.rzt
modified: Resources/routes.yml
modified: Resources/translations/messages.en.xlf
modified: Resources/translations/messages.fr.xlf
modified: Resources/views/404.html.twig
modified: Resources/views/admin/test.html.twig
modified: Resources/views/base.html.twig
modified: Resources/views/baseAnonymous.html.twig
modified: Resources/views/blocks/filters.html.twig
modified: Resources/views/blocks/paidtotals.html.twig
modified: Resources/views/blocks/totals.html.twig
modified: Resources/views/blocks/totals.xml.twig
modified: Resources/views/blocks/waitingtotals.html.twig
modified: Resources/views/contacts/edit.html.twig
modified: Resources/views/contacts/list.html.twig
modified: Resources/views/dashboard/list.html.twig
modified: Resources/views/forms.html.twig
modified: Resources/views/invoices/edit.html.twig
modified: Resources/views/invoices/list.html.twig
modified: Resources/views/invoices/view.xml.twig
modified: Resources/views/modules/navigation-elements.html.twig
modified: Resources/views/modules/navigation.html.twig
modified: Resources/views/payments/edit.html.twig
modified: Resources/views/payments/list.html.twig
modified: Resources/views/pdfbase.xml.twig
modified: Resources/views/quotes/edit.html.twig
modified: Resources/views/quotes/list.html.twig
modified: Resources/views/quotes/view.xml.twig
modified: Resources/views/tabledforms.html.twig
modified: composer.json
modified: config.yml
modified: static/Gruntfile.js
modified: static/bower.json
modified: static/css/main.less
modified: static/css/normalize.less
modified: static/css/postings/commons.less
modified: static/css/style.less
modified: static/css/style.min.css
modified: static/css/vars.less
modified: static/css/vendor.less
modified: static/css/vendor.min.css
typechange: static/css/widgets/debugpanel.less
modified: static/css/widgets/nav.less
modified: static/fonts/fontawesome-webfont.woff2
modified: static/js/main.js
modified: static/js/vendor/jquery-2.1.3.min.js
modified: static/js/vendor/uikit.min.js
modified: static/package.json
modified: static/public/cashier-theme.08d1e458.min.js
modified: static/public/config/assets.config.php
modified: static/public/style.7474e8a1.css
modified: static/public/vendor-cashier-theme.1a8458ff.min.js
modified: static/public/vendor.03b81695.css
no changes added to commit (use "git add" and/or "git commit -a")
使用git diff
:
diff --git a/.editorconfig b/.editorconfig
old mode 100644
new mode 100755
diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/CashierThemeApp.php b/CashierThemeApp.php
old mode 100644
new mode 100755
diff --git a/Controllers/ContactController.php b/Controllers/ContactController.php
old mode 100644
new mode 100755
等等
最后一段代码,这是我的 SMB 共享配置,其中我明确告诉对文件使用 0644,对目录使用 0755。
[DevWebServer]
path = /var/www
force group = myuser
force user = myuser
browsable = yes
writeable = yes
create mask = 0644
directory mask = 0755
force create mode = 0644
force directory mode = 0755
hide dot files = no
guest ok = no
public = no
veto files = /._*/.DS_Store/.AppleDouble
delete veto files = yes
我们在使用 OS X Yosemite 之前没有遇到过任何问题。
- 自从升级到 OS 10.11 以来,是否有人遇到过这个问题?
- 是否有人知道如何使服务器和 SMB 共享的权限保持一致?
- 我是否忘记了 SMB 共享配置中的某些内容?
如果有人想知道我们为什么使用 Git 而不是 SMB,那是因为我们同时与许多人合作建立网站。在我们的工作站上为每个站点都保留一份副本对于同步数据库和文档文件来说是一件很麻烦的事。
感谢您的阅读和时间。
答案1
这对我有用
[Shared]
comment = Folder Shared
path = /path
unix extensions = no
force group = root
force user = root
browsable = yes
writeable = yes
create mask = 0644
directory mask = 0755
force create mode = 0644
force directory mode = 0755
hide dot files = no
guest ok = no
public = no
valid users = @users
答案2
您还可以尝试使用支持 SMB2 的最新版本(4.2 或更高版本)的 Samba,并启用vfs_水果在共享上。这将增加对 Apple 的 SMB2 AAPL 扩展的支持,该扩展应该比 SMB1/CIFS 的 Unix 扩展工作得更好。
答案3
升级到 OS X 10.11.1 后,此问题仍然存在。
作为部分解决方法,您可以使用 SSHFS 而不是 SMB 共享文件。SSHFS 保留权限,但它有几个缺点:
- 当多个用户写入相同的文件时出现问题。
- 不支持本机扩展属性、ACL 等。
- 比 SMB 慢。
另请参阅 Apple 支持社区的讨论:https://discussions.apple.com/message/29104711
答案4
尝试在 Ubuntusmb.conf
文件中使用以下语句禁用 unix 扩展:
unix extensions = no
然后重新启动 Samba 并查看问题是否仍然存在。