Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
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


Re: [PHP] read smb drive

2010-11-05 Thread Steve Staples
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


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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net 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.


hmm, yeah im not sure if theres a clean mounting interface between windows
and linux.  the nomenclature is different for one, and im not even sure how
to mount a network drive programmatically under windows.  maybe someone else
on the list does.

-nathan


Re: [PHP] read smb drive

2010-11-05 Thread Richard Quadling
On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:
 On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net 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.


 hmm, yeah im not sure if theres a clean mounting interface between windows
 and linux.  the nomenclature is different for one, and im not even sure how
 to mount a network drive programmatically under windows.  maybe someone else
 on the list does.

 -nathan


You don't need to mount the share. If the share is available, then
you can access using UNC ...

\\server\share\directory\file.ext is fine.
Or
\\xxx.xxx.xxx.xxx\share\directory\file.ext

But watch out ... in PHP, you'll need to either use / or \\ for each \
in the UNC path ...

server\\share\\directory\\file.ext is fine.
Or
//xxx.xxx.xxx.xxx/share/directory/file.ext


If you do really need to map it, then

net use x: \\server\share

and

net use x: /d

to drop the mapping.

But you don't need to mount the share if the server with

Is this not the same on unix?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] read smb drive

2010-11-05 Thread Richard Quadling
On 5 November 2010 16:43, Richard Quadling rquadl...@gmail.com wrote:
 On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:
 On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net 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.


 hmm, yeah im not sure if theres a clean mounting interface between windows
 and linux.  the nomenclature is different for one, and im not even sure how
 to mount a network drive programmatically under windows.  maybe someone else
 on the list does.

 -nathan


 You don't need to mount the share. If the share is available, then
 you can access using UNC ...

 \\server\share\directory\file.ext is fine.
 Or
 \\xxx.xxx.xxx.xxx\share\directory\file.ext

 But watch out ... in PHP, you'll need to either use / or \\ for each \
 in the UNC path ...

 server\\share\\directory\\file.ext is fine.
 Or
 //xxx.xxx.xxx.xxx/share/directory/file.ext


 If you do really need to map it, then

 net use x: \\server\share

 and

 net use x: /d

 to drop the mapping.

 But you don't need to mount the share if the server with

 Is this not the same on unix?


If you need to supply credentials to access the share, then mapping it
(I think) is the only way PHP could access it ...

net use x: \\server\share /user:domain\username password

If you don't supply the password, the user would need to enter it at
the command line. A bit difficult via the web.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[usern...@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


If the device and permissions are a fixed, then I'd use the /SAVECRED
option and ask the user to do the job once. Thereafter you can just
...

net use x: \\server\share

and no need to enter permissions as this will use the stored ones.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling rquadl...@gmail.comwrote:

 On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:
  On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net
 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.
 
 
  hmm, yeah im not sure if theres a clean mounting interface between
 windows
  and linux.  the nomenclature is different for one, and im not even sure
 how
  to mount a network drive programmatically under windows.  maybe someone
 else
  on the list does.
 
  -nathan
 

 You don't need to mount the share. If the share is available, then
 you can access using UNC ...

 But you don't need to mount the share

 Is this not the same on unix?


im not sure, ive got some linux machines mounting windows shares and it
seems ls is not happy using the smb url to the share.  there may be a way
though, for those willing to dig a little :D

-nathan


Re: [PHP] read smb drive

2010-11-05 Thread Alexandr

Nathan Nobbe пишет:

On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling rquadl...@gmail.comwrote:

  

On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:


On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net
  

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.


hmm, yeah im not sure if theres a clean mounting interface between
  

windows


and linux.  the nomenclature is different for one, and im not even sure
  

how


to mount a network drive programmatically under windows.  maybe someone
  

else


on the list does.

-nathan

  

You don't need to mount the share. If the share is available, then
you can access using UNC ...

But you don't need to mount the share

Is this not the same on unix?




im not sure, ive got some linux machines mounting windows shares and it
seems ls is not happy using the smb url to the share.  there may be a way
though, for those willing to dig a little :D

-nathan

  

You can use 'smbclient' for copy file from the machine running the
client (Linux) to the server (Windows). In PHP it is necessary to use
functions like system or shell_exec.


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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 11:01 AM, Alexandr verbitsky_alexa...@mail.bywrote:

 Nathan Nobbe пишет:

  On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling rquadl...@gmail.com
 wrote:



 On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:


 On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net


 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.


 hmm, yeah im not sure if theres a clean mounting interface between


 windows


 and linux.  the nomenclature is different for one, and im not even sure


 how


 to mount a network drive programmatically under windows.  maybe someone


 else


 on the list does.

 -nathan



 You don't need to mount the share. If the share is available, then
 you can access using UNC ...

 But you don't need to mount the share

 Is this not the same on unix?




 im not sure, ive got some linux machines mounting windows shares and it
 seems ls is not happy using the smb url to the share.  there may be a way
 though, for those willing to dig a little :D

 -nathan



 You can use 'smbclient' for copy file from the machine running the
 client (Linux) to the server (Windows). In PHP it is necessary to use
 functions like system or shell_exec.


ahh - good call.  iirc that's the underlying program used by mount actually
when mounting smb shares.  i know it's called by our automount scripts as
well.  never bothered to use it directly, however that sounds like the way
to go in this scenario.

-nathan


Re: [PHP] read smb drive

2010-11-05 Thread Steve Staples
On Fri, 2010-11-05 at 11:06 -0600, Nathan Nobbe wrote:
 On Fri, Nov 5, 2010 at 11:01 AM, Alexandr verbitsky_alexa...@mail.bywrote:
 
  Nathan Nobbe пишет:
 
   On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling rquadl...@gmail.com
  wrote:
 
 
 
  On 5 November 2010 16:30, Nathan Nobbe quickshif...@gmail.com wrote:
 
 
  On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples sstap...@mnsi.net
 
 
  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.
 
 
  hmm, yeah im not sure if theres a clean mounting interface between
 
 
  windows
 
 
  and linux.  the nomenclature is different for one, and im not even sure
 
 
  how
 
 
  to mount a network drive programmatically under windows.  maybe someone
 
 
  else
 
 
  on the list does.
 
  -nathan
 
 
 
  You don't need to mount the share. If the share is available, then
  you can access using UNC ...
 
  But you don't need to mount the share
 
  Is this not the same on unix?
 
 
 
 
  im not sure, ive got some linux machines mounting windows shares and it
  seems ls is not happy using the smb url to the share.  there may be a way
  though, for those willing to dig a little :D
 
  -nathan
 
 
 
  You can use 'smbclient' for copy file from the machine running the
  client (Linux) to the server (Windows). In PHP it is necessary to use
  functions like system or shell_exec.
 
 
 ahh - good call.  iirc that's the underlying program used by mount actually
 when mounting smb shares.  i know it's called by our automount scripts as
 well.  never bothered to use it directly, however that sounds like the way
 to go in this scenario.
 
 -nathan


looks like it is not as simple as i had hoped/thought...

i found a smb class on phpclasses.org, maybe tonight i will look at that
and see if it what i need it to be.




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



Re: [PHP] read smb drive

2010-11-05 Thread Alexander Holodny
Small and maybe useless note about privileges required to exec 'mount'
command via php's system():
root is not required if 'user' option exists in /etc/fstab.
It is true because mount cmd has always root privileges due to suexec
bit and it decides whether calling user is authorized to mount
something or not.

2010/11/5, Steve Staples sstap...@mnsi.net:
 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...

 Steve


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



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