Re: [PHP] syntax woes

2009-04-03 Thread Michael A. Peters

Jan G.B. wrote:


you don't need the ugly .   . string . merging.


um, I guess most of my code is ugly ;)

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



Re: [PHP] syntax woes

2009-04-03 Thread Jan G.B.
2009/4/3  aurfal...@gmail.com:
 Hi all,

 For any one following this thread, here is how I worked around the
 apache/php/chown limitation.

 script snippet (and if any one has a more elegant style, please share as I
 am an amateur script kiddie).

 $path = /homes.$username;
 $chowncmd = /usr/bin/sudo /bin/chown ;
 mkdir($path);
 chmod($path, 0775);
 exec($chowncmd.$username.  .$path);




OK - you asked for style... ;)
I personally think it's elegant to build such strings with sprintf() like..

$path = sprintf(/homes/%s, $username);
or exec(sprintf(%s %s %s, $chowncmd, $username, $path));

That way you don't need added whitespace on vars like $chowncmd and
you don't need the ugly .   . string . merging.

btw. be sure that you always use
http://php.net/manual/en/function.escapeshellcmd.php as well as
http://php.net/manual/en/function.escapeshellarg.php when dealing with
user inputs and system calls.

byebye




 I modified /etc/sudoers;

 #Defaults requiretty   - I added the comment.
 apache ALL = NOPASSWD: /bin/chown  - added this line.

 - aurf
 On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote:

 Chris wrote:

 Shawn McKenzie wrote:

 Chris wrote:

 Wow, it does chown and chmod as well, thats friggen cool.

 chown will only work if the script is running as root which I doubt
 your
 drupal site will be.


 Or if the script is running as a user/group that has write permissions
 to the dir/file that your trying to chown.

 chmod may allow that, but not chown.

 I believe it depends upon the operating system and version of the
 operating system.

 --
 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



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



Re: [PHP] syntax woes

2009-04-03 Thread Shawn McKenzie
Chris wrote:
 Shawn McKenzie wrote:
 Chris wrote:
 Wow, it does chown and chmod as well, thats friggen cool.
 chown will only work if the script is running as root which I doubt your
 drupal site will be.


 Or if the script is running as a user/group that has write permissions
 to the dir/file that your trying to chown.
 
 chmod may allow that, but not chown.
 
 server:~# groupadd test
 server:~# useradd a -g test
 server:~# useradd b -g test
 server:~# mkdir /test
 server:~# chown a.test /test
 server:~# su - a
 No directory, logging in with HOME=/
 a...@server:/$ cd test
 a...@server:/test$ chmod 775 .
 a...@server:/test$ touch a
 a...@server:/test$ chmod 664 a
 a...@server:/test$ chown b.test a
 chown: changing ownership of `a': Operation not permitted
 a...@server:/test$
 
 
Yeah, my bad.  chmod it is...

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] syntax woes

2009-04-02 Thread aurfalien

Hi all,

I'm unsure how to describe this but I'll try.

The following code works fine in its own PHP script;

$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);

But when placed in a larger PHP script being part of the  
ldap_provisioning module in Drupal, the Drupal GUI is blank until I do;


$mkdircmd = '/bin/mkdir /homes/'.$uid;

... were I surrounded the variable with , which causes it to not work.

I'm totally unsure how to approach this and am hoping syntax  
adjustments will fix it.


- aurf

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



Re: [PHP] syntax woes

2009-04-02 Thread Chris

aurfal...@gmail.com wrote:

Hi all,

I'm unsure how to describe this but I'll try.

The following code works fine in its own PHP script;

$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);

But when placed in a larger PHP script being part of the 
ldap_provisioning module in Drupal, the Drupal GUI is blank until I do;


$mkdircmd = '/bin/mkdir /homes/'.$uid;

... were I surrounded the variable with , which causes it to not work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/ 
folder (normally the web server would not be able to create such a path 
because of permission issues).


Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for that one.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the  
ldap_provisioning module in Drupal, the Drupal GUI is blank until I  
do;

$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to not  
work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/  
folder (normally the web server would not be able to create such a  
path because of permission issues).


Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for  
that one.


--
Postgresql  php tutorials
http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too  
vague because I don't really understand what I'm doing.


- aurf



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



Re: [PHP] syntax woes

2009-04-02 Thread Ashley Sheridan
On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:
  aurfal...@gmail.com wrote:
  Hi all,
  I'm unsure how to describe this but I'll try.
  The following code works fine in its own PHP script;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  exec($mkdircmd);
  But when placed in a larger PHP script being part of the  
  ldap_provisioning module in Drupal, the Drupal GUI is blank until I  
  do;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  ... were I surrounded the variable with , which causes it to not  
  work.
 
  $mkdircmd = /bin/mkdir /homes/$uid;
  or
  $mkdircmd = /bin/mkdir /homes/${uid};
 
  Should fix the syntax.
 
  I guess you've already solved the permissions problem on the /homes/  
  folder (normally the web server would not be able to create such a  
  path because of permission issues).
 
  Blank GUI - no idea. Anything in the error logs (php or apache) ?
 
  Maybe asking on a drupal specific list would be a better idea for  
  that one.
 
  -- 
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 Thanks Chris.
 
 I appreciate the response.  I was hoping my description wasn't too  
 vague because I don't really understand what I'm doing.
 
 - aurf
 
 
 
This might sound stupid because I've not played with Drupal, but what's
wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the
ldap_provisioning module in Drupal, the Drupal GUI is blank until I
do;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to not
work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/
folder (normally the web server would not be able to create such a
path because of permission issues).

Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for
that one.

--  
Postgresql  php tutorials

http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too
vague because I don't really understand what I'm doing.

- aurf



This might sound stupid because I've not played with Drupal, but  
what's

wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk



Hi Ash,

I didn't know there was one.

Lemme study it up, thanks for the suggestion.

- aurf

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



Re: [PHP] syntax woes

2009-04-02 Thread Ashley Sheridan
On Thu, 2009-04-02 at 15:58 -0700, aurfal...@gmail.com wrote:
  On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:
  aurfal...@gmail.com wrote:
  Hi all,
  I'm unsure how to describe this but I'll try.
  The following code works fine in its own PHP script;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  exec($mkdircmd);
  But when placed in a larger PHP script being part of the
  ldap_provisioning module in Drupal, the Drupal GUI is blank until I
  do;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  ... were I surrounded the variable with , which causes it to not
  work.
 
  $mkdircmd = /bin/mkdir /homes/$uid;
  or
  $mkdircmd = /bin/mkdir /homes/${uid};
 
  Should fix the syntax.
 
  I guess you've already solved the permissions problem on the /homes/
  folder (normally the web server would not be able to create such a
  path because of permission issues).
 
  Blank GUI - no idea. Anything in the error logs (php or apache) ?
 
  Maybe asking on a drupal specific list would be a better idea for
  that one.
 
  --  
  Postgresql  php tutorials
  http://www.designmagick.com/
 
  Thanks Chris.
 
  I appreciate the response.  I was hoping my description wasn't too
  vague because I don't really understand what I'm doing.
 
  - aurf
 
 
 
  This might sound stupid because I've not played with Drupal, but  
  what's
  wrong with using the mkdir command in PHP instead of the exec call?
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 Hi Ash,
 
 I didn't know there was one.
 
 Lemme study it up, thanks for the suggestion.
 
 - aurf
 
PHP can do everything ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

On Thu, 2009-04-02 at 15:58 -0700, aurfal...@gmail.com wrote:

On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the
ldap_provisioning module in Drupal, the Drupal GUI is blank  
until I

do;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to  
not

work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the / 
homes/

folder (normally the web server would not be able to create such a
path because of permission issues).

Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for
that one.

--  
Postgresql  php tutorials

http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too
vague because I don't really understand what I'm doing.

- aurf




This might sound stupid because I've not played with Drupal, but
what's
wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk



Hi Ash,

I didn't know there was one.

Lemme study it up, thanks for the suggestion.

- aurf


PHP can do everything ;)


Ash
www.ashleysheridan.co.uk




Wow, it does chown and chmod as well, thats friggen cool.

Ok, then, I'm sold, PHP can do everything...

... but save us from ourselves.  Sorry, I had to kik that in.  Tech  
will be the death of us all, wahahahahaha :)


- aurf




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



Re: [PHP] syntax woes

2009-04-02 Thread Chris



Wow, it does chown and chmod as well, thats friggen cool.


chown will only work if the script is running as root which I doubt your 
drupal site will be.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax woes

2009-04-02 Thread Shawn McKenzie
Chris wrote:
 
 Wow, it does chown and chmod as well, thats friggen cool.
 
 chown will only work if the script is running as root which I doubt your
 drupal site will be.
 

Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] syntax woes

2009-04-02 Thread Chris

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.

chown will only work if the script is running as root which I doubt your
drupal site will be.



Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.


chmod may allow that, but not chown.

server:~# groupadd test
server:~# useradd a -g test
server:~# useradd b -g test
server:~# mkdir /test
server:~# chown a.test /test
server:~# su - a
No directory, logging in with HOME=/
a...@server:/$ cd test
a...@server:/test$ chmod 775 .
a...@server:/test$ touch a
a...@server:/test$ chmod 664 a
a...@server:/test$ chown b.test a
chown: changing ownership of `a': Operation not permitted
a...@server:/test$


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax woes

2009-04-02 Thread Michael A. Peters

Chris wrote:

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.

chown will only work if the script is running as root which I doubt your
drupal site will be.



Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.


chmod may allow that, but not chown.




I believe it depends upon the operating system and version of the 
operating system.


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

Hi all,

For any one following this thread, here is how I worked around the  
apache/php/chown limitation.


script snippet (and if any one has a more elegant style, please share  
as I am an amateur script kiddie).


$path = /homes.$username;
$chowncmd = /usr/bin/sudo /bin/chown ;
mkdir($path);
chmod($path, 0775);
exec($chowncmd.$username.  .$path);


I modified /etc/sudoers;

#Defaults requiretty   - I added the comment.
apache ALL = NOPASSWD: /bin/chown  - added this line.

- aurf
On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote:


Chris wrote:

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.
chown will only work if the script is running as root which I  
doubt your

drupal site will be.



Or if the script is running as a user/group that has write  
permissions

to the dir/file that your trying to chown.

chmod may allow that, but not chown.


I believe it depends upon the operating system and version of the  
operating system.


--
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