php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44638 unlink() deletes full directories under Solaris when run as root
Submitted: 2008-04-04 13:02 UTC Modified: 2008-04-11 18:44 UTC
From: graham at wyenet dot net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.5 OS: Solaris 10
Private report: No CVE-ID: None
 [2008-04-04 13:02 UTC] graham at wyenet dot net
Description:
------------
unlink() function will erase full (or empty) directories, where permissions are ok.

This actually breaks test suite, test copy_variation4.phpt which creates null files. The unlink actually removes the ext/standard/tests/file directory and then of course the test suits crashes out.





Reproduce code:
---------------
<?php
  unlink("test");
?>


Expected result:
----------------
PHP 5.2.3 on Solaris gives the following error.

[function.unlink]: Not owner in test.php

Although it would make more sence to be

[function.unlink]: Is directory in test.php

Actual result:
--------------
directory test is erased without warning, even if there are files present in the directory. fsck will recover the files. It wont break ownership permissions, and it wont erase directories containing file which where ownership permissions come into place.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-04 18:11 UTC] jani@php.net
$ php -r 'unlink("ttt");'

Warning: unlink(ttt): Is a directory in Command line code on line 1

Perhaps Solaris unlink() actually allows unlinking directories?
PHP just wraps around the libc unlink() so..
 [2008-04-07 11:05 UTC] graham at wyenet dot net
It would appear its only really a problem when running php as the "Root" user. For lower privileged users Solaris10 appears to be giving the following result.

Warning: unlink(test): Not owner in Command line code on line 1.

The test suite failed because I compiled PHP using "Root". When I tried again using my normal user access it worked fine.

It does seem that on solaris 10, running the test suite as the root user may cause a failer during copy_variation4.phpt.
 [2008-04-11 18:44 UTC] johannes@php.net
According to unlink(2) manpage on Solaris:

      If the path argument is a directory and the filesystem  sup-
      ports  unlink() and unlinkat() on directories, the directory
      is unlinked from its parent with no cleanup being performed.
      In  UFS,  the  disconnected directory will be found the next
      time the filesystem is checked with fsck(1M). 

The issue does only exist with a Solaris box using UFS and when run as "root" user. That's Solaris' behaviour where PHP has no influence. Marking as bogus therefore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC