Reputation: 5961
This is strange, sometimes works, sometimes it doesnt.
I've put var_dumps of the link()'s arguments.
string(35) "/printbox/web/repo/docusearch/5.pdf"
string(82) "/printbox/web/repo/hardlink/Oleaginosa Moreno Hnos. S.A._20130715_000532989552.pdf"
__
A PHP Error was encountered
Severity: Warning
Message: link(): Operation not permitted
Filename: controllers/ct_form_procesar_escaneos.php
Line Number: 178
__
string(35) "/printbox/web/repo/docusearch/6.pdf"
string(77) "/printbox/web/repo/hardlink/MOLINOS RIO DE LA PLATA_20130715_000533396947.pdf" //THIS WORKED !!!
__ ABOVE WORKED (No error here and in fact hard link was created)
string(35) "/printbox/web/repo/docusearch/7.pdf"
string(77) "/printbox/web/repo/hardlink/RENOVA TIMBUES VICENTIN_20130715_000533520657.pdf"
__
A PHP Error was encountered
Severity: Warning
Message: link(): Operation not permitted
Filename: controllers/ct_form_procesar_escaneos.php
Line Number: 178
I really can't find any pattern.... and when I make a script to manually test one of the previous, also fails:
<?php
echo "Hi";
link( '/printbox/web/repo/docusearch/7.pdf', '/printbox/web/repo/hardlink/RENOVA TIMBUES VICENTIN_20130715_000533520657.pdf');
?>
Apache's log:
[Mon Jul 15 13:41:57 2013] [error] [client 192.168.100.204] PHP Warning: link(): Operation not permitted in /printbox/web/repo/a.php on line 3
Striping spaces for _ in the destination name didn't help.
Thanks!
Upvotes: 1
Views: 2296
Reputation: 111
For my situation, I found the following additional steps were required because I regularly update particular tarballs for download by other people, and I create individual hard links in PHP to those tarballs for each HTTP client so that the URL is randomized. In other words, I dynamically create a different hard link in PHP for each visitor to the web site. This failed when I moved from an old OS to a newer OS (OpenSuSE 13.1). Here is my method.
The advantage of this method is that the files can be owned by an ordinary user, but the "www" group can modify the files, and the HTTP server is able to make the hard links because they are group writeable. The user uploading the files to the server does not need to be in the HTTP server's group because of the "BSD semantics" of the group ownership inheritance. (See man 2 stat.)
Upvotes: 0
Reputation: 5961
Well, seems that the problem is that it needs write permissions on the first file (the one that exists), I don't know why.
Upvotes: 2