Running mount from PHP

This is a discussion on Running mount from PHP within the PHP General forums, part of the PHP Programming Forums category; Hi, I'm trying to run /bin/mount and /sbin/mount.cifs from a PHP page. So, I´ve added ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-09-2008
Mário Gamito
 
Posts: n/a
Default Running mount from PHP

Hi,

I'm trying to run /bin/mount and /sbin/mount.cifs from a PHP page.

So, I´ve added this to /etc/sudoers:

-------------------------------------------------------------------------
Cmnd_Alias CMD_MOUNT = /bin/mount
Cmnd_Alias CMD_CIFS ) = /sbin/mount.cifs

nobody ALL = NOPASSWD: CMD_MOUNT
nobody ALL = NOPASSWD: CMD_CIFS
-------------------------------------------------------------------------

Problem is that I need to run it from PHP and in this way, it doesn't mount..

I'm using PHP's exec function:
exec(sudo mount -t cifs ...)

I have the ownership and permissions of the mount point set correctly.

As it is a dynamic application, the mount point always changes
(/mnt/user1, /mnt/user2, etc.), so, /etc/fstab is not an option :(

Any ideas ?

Warm Regards,
Mário Gamito
Reply With Quote
  #2 (permalink)  
Old 07-09-2008
Per Jessen
 
Posts: n/a
Default Re: [PHP] Running mount from PHP

Mário Gamito wrote:

> Hi,
>
> I'm trying to run /bin/mount and /sbin/mount.cifs from a PHP page.
>
> So, I´ve added this to /etc/sudoers:
>
> -------------------------------------------------------------------------
> Cmnd_Alias CMD_MOUNT = /bin/mount
> Cmnd_Alias CMD_CIFS ) = /sbin/mount.cifs
>
> nobody ALL = NOPASSWD: CMD_MOUNT
> nobody ALL = NOPASSWD: CMD_CIFS
> -------------------------------------------------------------------------
>
> Problem is that I need to run it from PHP and in this way, it doesn't
> mount.
>
> I'm using PHP's exec function:
> exec(sudo mount -t cifs ...)
>
> I have the ownership and permissions of the mount point set correctly..
>
> As it is a dynamic application, the mount point always changes
> (/mnt/user1, /mnt/user2, etc.), so, /etc/fstab is not an option :(
>
> Any ideas ?


Which user are you running your script with? wwwrun?


/Per Jessen, Zürich

Reply With Quote
  #3 (permalink)  
Old 07-09-2008
Maxim Antonov
 
Posts: n/a
Default Re: [PHP] Running mount from PHP

Try to do folowing
write shell script
#!/bin/sh
mount /dev/hdb /home/mountpoint

then write C code

int main(){
system ("mount.sh");
return 0;
}

then compile C code
gcc main.c -o wrapper

then chmod :

# chmod a+s wrapper

and do from php:

system ('wrapper');




Per Jessen пишет:
> Mário Gamito wrote:
>
>> Hi,
>>
>> I'm trying to run /bin/mount and /sbin/mount.cifs from a PHP page.
>>
>> So, I´ve added this to /etc/sudoers:
>>
>> -------------------------------------------------------------------------
>> Cmnd_Alias CMD_MOUNT = /bin/mount
>> Cmnd_Alias CMD_CIFS ) = /sbin/mount.cifs
>>
>> nobody ALL = NOPASSWD: CMD_MOUNT
>> nobody ALL = NOPASSWD: CMD_CIFS
>> -------------------------------------------------------------------------
>>
>> Problem is that I need to run it from PHP and in this way, it doesn't
>> mount.
>>
>> I'm using PHP's exec function:
>> exec(sudo mount -t cifs ...)
>>
>> I have the ownership and permissions of the mount point set correctly.
>>
>> As it is a dynamic application, the mount point always changes
>> (/mnt/user1, /mnt/user2, etc.), so, /etc/fstab is not an option :(
>>
>> Any ideas ?

>
> Which user are you running your script with? wwwrun?
>
>
> /Per Jessen, Zürich
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:15 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0