简体   繁体   English

Snow Leopard挂载目录偶尔更改权限

[英]Snow Leopard mounted directory changes permissions sporadically

I have a smb mounted directory: /Volumes/myshare 我有一个smb安装目录:/ Volumes / myshare

This was mounted via Finder "Connect to Server..." with smb://myservername/myshare 这是通过smb:// myservername / myshare通过Finder“连接到服务器...”安装的

Everything good so far. 到目前为止一切都很好。

However, when I try to access the directory via PHP (running under Apache), it fails with permission denied about 10% of the time. 但是,当我尝试通过PHP(在Apache下运行)访问目录时,该目录失败,并且权限被拒绝的时间约为10%。 By this I mean that repeated accesses to my page sometimes result in a failure. 我的意思是,重复访问我的页面有时会导致失败。 My PHP page looks like: 我的PHP页面如下所示:


<?php
  $cmd = "ls -la /Volumes/ 2>&1";
  exec($cmd, $execOut, $exitCode);
  echo "<PRE>EXIT CODE = $exitCode<BR/>";
  foreach($execOut as $line) {
    echo "$line <BR/>";
  }
  echo "</PRE>";
?>

When it succeeds it looks like: 成功时,它看起来像:


EXIT CODE = 0
total 40 
drwxrwxrwt@  4 root   admin    136 Jun 14 12:34 . 
drwxrwxr-t  30 root   admin   1088 Jun  4 13:09 .. 
drwx------   1 galen  staff  16384 Jun 14 09:28 myshare 
lrwxr-xr-x   1 root   admin      1 Jun 11 16:05 galenhd -> / 

When it fails it looks like: 当失败时,它看起来像:


EXIT CODE = 1
ls: myshare: Permission denied 
total 8 
drwxrwxrwt@  4 root  admin   136 Jun 14 12:34 . 
drwxrwxr-t  30 root  admin  1088 Jun  4 13:09 .. 
lrwxr-xr-x   1 root  admin     1 Jun 11 16:05 galenhd -> / 

OTHER INFO: 其他信息:

I'm working with the PHP (5.3.1), and Apache server that comes out of the box with Snow Leopard. 我正在使用PHP(5.3.1)和Snow Leopard开箱即用的Apache服务器。

Also, if I write a PHP script that loops and retries the "ls -la.." from the command-line, it doesn't seem to fail. 另外,如果我编写了一个PHP脚本来循环并从命令行重试“ ls -la ..”,那么它似乎不会失败。

Nothing is changing about the code and/or filesystem between succeeds and fails, so this appears to be a truly intermittent failure. 成功与失败之间的代码和/或文件系统没有任何变化,因此这似乎是真正的间歇性失败。

This is driving me crazy. 这真让我抓狂。 Anyone have any idea what might be going on? 任何人都知道会发生什么事吗?

Thanks, Galen 谢谢,盖伦

My feeling is that it's probably not related to the SMB server, as I can't reproduce when running manually from the command-line. 我的感觉是,它可能与SMB服务器无关,因为从命令行手动运行时无法复制。 In other words it seems to only fail when run through the web (ie when hitting the apache page). 换句话说,它似乎仅在通过网络运行时(即,在访问apache页面时)失败。

So it looks to me like it's somehow an apache or "PHP under apache" bug... 所以在我看来,这就像是某种apache或“ PHP under apache”错误一样...

Now I'm seeing the page getting stuck in the "permission denied" state. 现在,我看到页面陷入了“拒绝权限”状态。 In other words it keeps failing after it fails for the first time. 换句话说,它在第一次失败后一直失败。 I have also found a series of steps to reproduce, and get out of "permission denied" state: 我还发现了一系列重现步骤,并摆脱了“权限被拒绝”状态:

1) Repeatedly hit the PHP page until it fails (it will stay "failed" after it fails) 1)反复打PHP页面,直到失败为止(失败后它将保持“失败”状态)

2) Once it's failed, performing an ls /Volumes on the command-line will fail. 2)一旦失败,在命令行上执行ls /Volumes将失败。

3) Doing a sudo ls /Volumes does work (ie root can see directory). 3)做一个sudo ls /Volumes确实可行(即root可以看到目录)。 Trying the ls as the normal user still fails though... 尽管以普通用户身份尝试ls仍然失败...

4) However ( this is the interesting part ) doing a sudo ls -l /Volumes on the actually repairs the mount. 4)但是( 这是很有趣的部分 )在实际修复挂载上执行sudo ls -l /Volumes In other words, after this command both PHP and command-line as the normal user starts working again. 换句话说,在执行此命令后,普通用户将再次以PHP和命令行身份开始工作。

CONCLUSION? 结论?

So it seems as it accessing the mount point via PHP/apache (see code above) breaks the mount, changing the permissions, which locks user out. 因此,似乎通过PHP / apache访问安装点(请参见上面的代码)会中断安装,更改权限,从而将用户锁定。 Then root can restore the permissions by issuing a sudo ls -l /Volumes !!! 然后root可以通过发出sudo ls -l /Volumes来恢复权限

What is going on here. 这里发生了什么。 This is pretty basic code. 这是非常基本的代码。 Surely someone has seen this before... 肯定有人见过...



Perhaps this is related? 也许这是相关的? https://superuser.com/questions/100746/osx-10-6-give-apache2-readwrite-access-to-mounted-windows-share/152473#152473 https://superuser.com/questions/100746/osx-10-6-give-apache2-readwrite-access-to-mount-windows-share/152473#152473


UPDATE: 2010-06-15: Updated my machine to 10.6.4, which claimed to help with SMB mount issues. 更新:2010-06-15:我的机器更新到10.6.4,声称可以解决SMB挂载问题。 However, this did not fix the problem I'm seeing. 但是,这不能解决我遇到的问题。 Looking more and more like an apache issue... 看起来越来越像一个Apache问题...


UPDATE: 2010-06-16 : If the code is changed to: 更新:2010-06-16 :如果代码更改为:
$cmd = "ls -a /Volumes/ 2>&1";
(removed -l option) it doesn't fail. (已删除-l选项)它不会失败。 In other words the"-l" flag is causing the failures to occur... 换句话说,“-l”标志导致失败发生。


UPDATE2: 2010-06-16 : Since it's looking like an Apache (on mac?) problem, I've posted to the Apache forum: http://forums.digitalpoint.com/showthread.php?t=1839935 UPDATE2:2010-06-16 :由于它看起来像Apache(在Mac上?)问题,因此我已发布到Apache论坛: http : //forums.digitalpoint.com/showthread.php?t=1839935

Can you check logs of this SMB server? 您可以检查该SMB服务器的日志吗? It appears as a SMB error, not yours. 它显示为SMB错误,而不是您的错误。

I concur with my IT guy, and I'm almost positive it's not an SMB issue. 我同意我的IT部门的意见,我几乎肯定这不是SMB问题。 I know this because when I run tcpdump, there is no network communication during failures. 我知道这一点是因为当我运行tcpdump时,在故障期间没有网络通信。 In other words, what is happening is: 换句话说,正在发生的是:

1) Apache changes permissions on filesystem in a bad way (ie changes permissions of mount dir). 1)Apache以一种不好的方式更改了文件系统的权限(即更改了mount dir的权限)。

2) Future attempts to access mount fail at OS/File-System level, even before SMB is accessed. 2)即使在访问SMB之前,将来尝试访问安装的尝试也会在OS /文件系统级别失败。

3) Filesystem permissions can be restored via the sudo ls -la /Volumes trick. 3)可以通过sudo ls -la /Volumes技巧恢复文件系统权限。

Perhaps not an answer, but some more data. 也许不是答案,而是更多数据。 I reached this page when researching a similar issue. 在研究类似问题时,我到达了此页面。 My Mac runs an Automator script when I log in as User to mount a NAS volume (FileShare) on /Volumes. 当我以用户身份登录以在/ Volumes上挂载NAS卷(FileShare)时,我的Mac运行Automator脚本。 I tried to symlink FileShare into /Library/WebServer/Documents and after enabling WebSharing was unable to browse it due to permissions (403 error). 我尝试将FileShare符号链接到/ Library / WebServer / Documents,并且启用WebSharing后由于权限而无法浏览它(403错误)。 The permissions looked fine (755). 权限看起来很好(755)。

Did some research and found out that the httpd process was running as the _www user (ps -ef from Terminal). 做了一些研究,发现httpd进程正在以_www用户身份运行(来自Terminal的ps -ef)。 Attempting to ls my symlinked director as _www (sudo -i -u _www ls FileShare) showed that the _www user received Permission denied. 尝试将我的链接链接导演称为_www(sudo -i -u _www ls FileShare),表明_www用户收到的权限被拒绝。

I ended up not fixing the permissions (nothing seemed to work), but rather went to /etc/apache2 and modified httpd.conf to have the httpd server run as user(staff) instead of _www(_www) (Under User/Group settings). 我最终没有解决权限问题(似乎没有任何效果),而是去了/ etc / apache2并修改了httpd.conf以使httpd服务器以user(staff)而不是_www(_www)的身份运行(在User / Group设置下) )。

Stopping and restarting the web server made it now run as User instead of _www -- and now it was able to navigate to the symlinked directory... 停止并重新启动Web服务器使它现在以User而不是_www的身份运行-现在它能够导航到符号链接目录...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM