On 05/11/2010 16:18, Steve Staples wrote:
> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
>>> Hey guys (and gals)
>>> I am writing something that needs to connect to a SMB server... can this
>>> be done easliy?
>>> I copied a sample code from php.net that used the system() command and
>>> mounted the SMB to a /mnt/tmp partion, and technically, it works.... the
>>> problem is, is that mount has to be run as root...
>>> is there a way to put the "mount/unmount" commands into an allowed
>>> command?   i supposed, the other problem is, is waht if this is on a
>>> windows machine?
>>> i dont really want to mess with permissions too much, since this will
>>> have to be portable from linux to windows...   any help would be
>>> appreciated...
>> is there any reason the php application code has to be responsible for
>> mounting the network drive?
>> typically this is an os-level responsibility.
>> -nathan
> this is true, but i am looking at mounting it, reading the contents,
> maybe moving a file to it, or renaming a file... and then closing the
> smb share.
> i have thought abotu making it a requirement on the users end to have
> the directory ready for the application... but thought also about maybe
> giving them the option to connect to it and do what it has to do, then
> close it... 
> i've been doing it the second way, but was wondering if the first was a
> viable option or not.
> Steve

To do this without giving your web site root permissions you will have
to split out the required actions.

You could have a php daemon running as root which periodically checks if
the share needs mounting. The trigger could be many things, like the
existence of a file or database record.

You can then have the web site create the file or database record when
it needs the share mounting and then wait for the mount to appear.

I have used the Pear module System_Daemon[1] to do this in the past,
very easy to use.

[1] http://pear.php.net/package/System_Daemon



PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to