mode problems in System::mkDir();
| From: | Alex Hayes | Date: | Sun, 18 Jan 2004 22:40:52 +0000 |
| Subject: | mode problems in System::mkDir(); | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-25139@lists.php.net to get a copy of this message | ||
Hi,
Perhaps I am using this package with the incorrect syntax, so il start by
just supplying you with my call to the method.. Ive checked what values are
getting set in the actual mkDir method and they all seemed correct...
however see my solution below...
<?php
require_once("System.php");
$result = System::mkDir("-p -m 0700 ./newdir");
var_dump($result);
?>
output is of course bool(true)
However, say for example you do an ls -la on that directory..
=========8<========
$ ls -la
drwxrwxrwx 7 nobody nobody 4096 Jan 19 09:09 .
drwxr-xr-x 7 ahayes Domain U 4096 Jan 7 17:01 ..
d-w-r-xr-T 2 nobody nobody 4096 Jan 19 09:09 asdff
=========>8========
As you can see, not really what its supposed to be... ;)
i also tried supplying just an int by leaving the 0 off the 700 but still
get the same problems (and also when i do alot of other permissions octal
numbers...)
Ive also tested it on a couple of different systems, however all are red hat
(two are 7.3 with php 4.1.2, one is 9 with php 4.2.2) still the same
problems..
So.. assuming its not something wrong with what im doing ;) i have been
trying to work out why its not working and I believe i may have found out
where its not working.
I believe the problem is within the call to System::mkDir(); as we are
supplying it with a string of options. Say for instance we do a
var_dump(0700); we get int(511), however if we do a var_dump($mode); within
our System::mkDir method we get a string("0770");
So i started playing around with converting the $mode, which is a string, to
a integer by using octdec($mode) and it appears to work.
Could the package maintainers please have a look at this, and if it does
appear to be a problem, please make this change... I believe all that needs
to happen is as follows...
foreach($opts[0] as $opt) {
if ($opt[0] == 'p') {
$create_parents = true;
} elseif($opt[0] == 'm') {
$mode = octdec($opt[1]);
}
}
thanks
alex