On 8/2/07 10:57 AM, Daniel Brown wrote: > On 8/2/07, Ben Ramsey <ramsey@xxxxxxx> wrote: >> PHP (doesn't work): >> chmod('/path/to/dir', 02775); >> >> We've tested the PHP code on files, and it works, but it doesn't work on >> directories. > > Drop the preceding 0 from the chmod() function parameters. The > four-digit octal value is preferred, and the 0 is the first bit to > show that there's no user- or group-specific execution (su-exec'ing, > basically) or "stickiness" to the file/directory. However, > three-digit values will work. In either case, five digits will not > work. > > Right: > chmod 0755 file.php > chmod 1777 file.php > chmod('file.php',0755); > chmod('file.php',1777); What about on directories? That's our problem. The following works on files (even though you say it shouldn't). I'll clarify: 02775 sets permissions based on how we expect 2775 to work using chmod from the command prompt. The problem is that 2775 with PHP's chmod() doesn't set the permissions in the same way that it does from the command prompt. This works on files: chmod('/path/to/file.php', 02775); But it doesn't work on directories. Here's what we're doing: <?php chmod('./test1', 2775); ?> Here's what we get: $ ls -l d-ws-w-rwt 2 user user 4096 Aug 2 15:33 test1 Here's what we expect: $ chmod 2775 test1 drwxrwsr-x 2 user user 4096 Aug 2 15:34 test1 So, what are we doing wrong with chmod() that is causing us to get the wrong results? Keep in mind that we are running the PHP script as the same user who owns the directory. -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php