Mailing List Archive

Save mode and File uploading
Hi,

When I installed Mediawiki, it warned me my ISP's php is in save mode.
So, I changed the /images directory to 777 as suggested and the
installation proceeded ok. But now when I tried to upload an image, it
failed with the error:

Could not copy file "/tmp/phpsBKyBW" to

"/home/wikiphoto_trial/htdocs/wiki/images/temp/0/0e/20041203005505!Printer_Test_file.jpg".

with the details shown at the top:

Warning: move_upload_file(): SAVE MODE Restriction in effect. The
script whose uid is 1090 is not allowed to access
/home/wikiphoto_trial/htdocs/wiki/images/temp owned by uid 1001 in
/home/wikiphoto_trial/htdocs/wiki/includes/SpecialUpload.php on line 334

I check the owner of my images/temp directory and it is not owned by me.
The owner is "Webadmin". it seems it was created by the Apache process
and php doesn't like it. What should I do now?

p.s. I'm sorry if this question has been asked and answered by others
before. I don't know how to search the mailing list archive.

Thanks
--
John
Re: Save mode and File uploading [ In reply to ]
On Dec 2, 2004, at 5:54 PM, John Yu wrote:
> Warning: move_upload_file(): SAVE MODE Restriction in effect. The
> script whose uid is 1090 is not allowed to access
> /home/wikiphoto_trial/htdocs/wiki/images/temp owned by uid 1001 in
> /home/wikiphoto_trial/htdocs/wiki/includes/SpecialUpload.php on line
> 334
>
> I check the owner of my images/temp directory and it is not owned by
> me. The owner is "Webadmin". it seems it was created by the Apache
> process and php doesn't like it. What should I do now?

Safe mode has some bogus, ugly, stupid restrictions that break the
upload system. You can however manually create the directories, and if
they're owned by the right user it might work.

images/0
images/0/00
images/0/01
...
images/0/0f
images/1/10
images/1/11
...
images/f/ff

images/archive/0/00
..
images/archive/f/ff

images/temp/0/00
...
images/temp/f/ff

Fun, isn't it! :P

> p.s. I'm sorry if this question has been asked and answered by others
> before. I don't know how to search the mailing list archive.

Go to google.com, and just put "site:mail.wikipedia.org" in with the
search query.

-- brion vibber (brion @ pobox.com)
Re: Save mode and File uploading [ In reply to ]
Thanks, Brion.

Hmm, the ellipses in your list... you mean I need to create all
directories 0/00 to f/ff? Including the subdirs under temp and archive,
that's 9000+ directories to create! Is that right?

What about images/thumb directory? Do I need to create 0/00-f/ff
subdirectories under it as well?
--
John

Brion Vibber wrote:

> On Dec 2, 2004, at 5:54 PM, John Yu wrote:
>
>> Warning: move_upload_file(): SAVE MODE Restriction in effect. The
>> script whose uid is 1090 is not allowed to access
>> /home/wikiphoto_trial/htdocs/wiki/images/temp owned by uid 1001 in
>> /home/wikiphoto_trial/htdocs/wiki/includes/SpecialUpload.php on line 334
>>
>> I check the owner of my images/temp directory and it is not owned by
>> me. The owner is "Webadmin". it seems it was created by the Apache
>> process and php doesn't like it. What should I do now?
>
>
> Safe mode has some bogus, ugly, stupid restrictions that break the
> upload system. You can however manually create the directories, and if
> they're owned by the right user it might work.
>
> images/0
> images/0/00
> images/0/01
> ...
> images/0/0f
> images/1/10
> images/1/11
> ...
> images/f/ff
>
> images/archive/0/00
> ..
> images/archive/f/ff
>
> images/temp/0/00
> ...
> images/temp/f/ff
>
> Fun, isn't it! :P
>
>> p.s. I'm sorry if this question has been asked and answered by others
>> before. I don't know how to search the mailing list archive.
>
>
> Go to google.com, and just put "site:mail.wikipedia.org" in with the
> search query.
>
> -- brion vibber (brion @ pobox.com)
Re: Save mode and File uploading [ In reply to ]
On Dec 2, 2004, at 7:35 PM, John Yu wrote:
> Thanks, Brion.
>
> Hmm, the ellipses in your list... you mean I need to create all
> directories 0/00 to f/ff? Including the subdirs under temp and
> archive, that's 9000+ directories to create! Is that right?

256*3 + 16*3 + 2 = 818

The first digit of the two-digit subdirs is always the parent dir's
digit.

> What about images/thumb directory? Do I need to create 0/00-f/ff
> subdirectories under it as well?

Oh yeah, make that:
256*4 + 16*4 + 3 = 1091

-- brion vibber (brion @ pobox.com)
Re: Save mode and File uploading [ In reply to ]
On Fri, 03 Dec 2004 14:35:42 +1100, John Yu <jyu@objectmastery.com> wrote:
> Hmm, the ellipses in your list... you mean I need to create all
> directories 0/00 to f/ff? Including the subdirs under temp and archive,
> that's 9000+ directories to create! Is that right?

Uploads are filed based on md5sums; so, yeah, the maximum layout's
gonna be pretty humongous. Easily done though, if you can get at a
shell and Perl:

$ cd /path/to/your/wiki/images
$ mkdir archive temp
$ perl -e '@hex=("0".."9", "a".."f"); for $pre ("", "archive/",
"temp/") { for $w (@hex) { mkdir("$pre$w"); for $x (@hex) {for $y
(@hex) { mkdir("$pre$w/$x$y") } } } }'

And then adjust the ownership of everything recursively if need be.
If you *don't* have shell access, it's not so easy; either you could
get Perl to issue FTP commands from your home PC (I bet there are
plenty of modules on CPAN that make *that* easy); or, you could just
edit MediaWiki so that it stores uploads in one flat directory.

> What about images/thumb directory? Do I need to create 0/00-f/ff
> subdirectories under it as well?

Oh, well, if you do, add thumb to the mkdir line, and "thumb\" to the
same list as "archive/" and "temp/"

;)

--
Rowan Collins BSc
[IMSoP]
Re: Save mode and File uploading [ In reply to ]
On Fri, 03 Dec 2004 14:35:42 +1100, John Yu <jyu@objectmastery.com> wrote:
> Hmm, the ellipses in your list... you mean I need to create all
> directories 0/00 to f/ff? Including the subdirs under temp and archive,
> that's 9000+ directories to create! Is that right?

Uploads are filed based on md5sums; so, yeah, the maximum layout's
gonna be pretty humongous. Easily done though, if you can get at a
shell and Perl:

$ cd /path/to/your/wiki/images
$ mkdir archive temp
$ perl -e '@hex=("0".."9", "a".."f"); for $pre ("", "archive/",
"temp/") { for $w (@hex) { mkdir("$pre$w"); for $x (@hex) {for $y
(@hex) { mkdir("$pre$w/$x$y") } } } }'

And then adjust the ownership of everything recursively if need be.
If you *don't* have shell access, it's not so easy; either you could
get Perl to issue FTP commands from your home PC (I bet there are
plenty of modules on CPAN that make *that* easy); or, you could just
edit MediaWiki so that it stores uploads in one flat directory.

> What about images/thumb directory? Do I need to create 0/00-f/ff
> subdirectories under it as well?

Oh, well, if you do, add thumb to the mkdir line, and "thumb\" to the
same list as "archive/" and "temp/"

;)

--
Rowan Collins BSc
[IMSoP]
Re: Save mode and File uploading [ In reply to ]
On Thu, 2 Dec 2004 20:22:07 -0800, Brion Vibber <brion@pobox.com> wrote:
> The first digit of the two-digit subdirs is always the parent dir's
> digit.
>
> > What about images/thumb directory? Do I need to create 0/00-f/ff
> > subdirectories under it as well?
>
> Oh yeah, make that:
> 256*4 + 16*4 + 3 = 1091

D'oh! In that case:
$ cd /path/to/your/wiki/images
$ mkdir archive temp thumb
$ perl -e '@hex=("0".."9", "a".."f"); for $pre ("", "archive/",
"temp/", "thumb/") { for $w (@hex) { mkdir("$pre$w"); for $x (@hex) {
mkdir("$pre$w/$w$x") } } }'

I know it's probably useless to you anyway, but I'm a bit of a perfectionist. :/

--
Rowan Collins BSc
[IMSoP]
Re: Save mode and File uploading [ In reply to ]
Oh, I see. Thanks Brion.

Now, where's my shell script manual... :-)
--
John


Brion Vibber wrote:

> On Dec 2, 2004, at 7:35 PM, John Yu wrote:
>
>> Thanks, Brion.
>>
>> Hmm, the ellipses in your list... you mean I need to create all
>> directories 0/00 to f/ff? Including the subdirs under temp and
>> archive, that's 9000+ directories to create! Is that right?
>
>
> 256*3 + 16*3 + 2 = 818
>
> The first digit of the two-digit subdirs is always the parent dir's
> digit.
>
>> What about images/thumb directory? Do I need to create 0/00-f/ff
>> subdirectories under it as well?
>
>
> Oh yeah, make that:
> 256*4 + 16*4 + 3 = 1091
>
> -- brion vibber (brion @ pobox.com)
>
>------------------------------------------------------------------------
>
>_______________________________________________
>MediaWiki-l mailing list
>MediaWiki-l@Wikimedia.org
>http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
>
Re: Save mode and File uploading [ In reply to ]
Many thanks, Rowan!


Rowan Collins wrote:

>On Thu, 2 Dec 2004 20:22:07 -0800, Brion Vibber <brion@pobox.com> wrote:
>
>
>>The first digit of the two-digit subdirs is always the parent dir's
>>digit.
>>
>>
>>
>>>What about images/thumb directory? Do I need to create 0/00-f/ff
>>>subdirectories under it as well?
>>>
>>>
>>Oh yeah, make that:
>>256*4 + 16*4 + 3 = 1091
>>
>>
>
>D'oh! In that case:
>$ cd /path/to/your/wiki/images
>$ mkdir archive temp thumb
>$ perl -e '@hex=("0".."9", "a".."f"); for $pre ("", "archive/",
>"temp/", "thumb/") { for $w (@hex) { mkdir("$pre$w"); for $x (@hex) {
>mkdir("$pre$w/$w$x") } } }'
>
>I know it's probably useless to you anyway, but I'm a bit of a perfectionist. :/
>
>
>
AW: Save mode and File uploading [ In reply to ]
it makes completely sense to store files in 9999 subdirs thinking of the
myriade files that Wikipedia one day will have to host,

on the other hand for small wiki-sites, that maybe will have to deal with
maybe 50 Pictures and 10 Files this might provide extra burden.

What speaks against letting that behaviour be switched on (default) and OFF
in Localsettings.php, if OFF the files are simply stored and searched in the
upload-dir without further subdirs?

Maybe I am wrong when I guess that for Bryan or some of the real good
Wiki-Hackers that is a 5-10 min. task to add that adequat
variable-questioning in the 2 positions (upload/retrieval) in the code.


xxx

HeliR




> -----Ursprungliche Nachricht-----
> Von: mediawiki-l-bounces@Wikimedia.org
> [mailto:mediawiki-l-bounces@Wikimedia.org]Im Auftrag von Rowan Collins
> Gesendet: Freitag, 03. Dezember 2004 05:58
> An: MediaWiki announcements and site admin list
> Betreff: Re: [Mediawiki-l] Save mode and File uploading
>
>
> On Fri, 03 Dec 2004 14:35:42 +1100, John Yu <jyu@objectmastery.com> wrote:
> > Hmm, the ellipses in your list... you mean I need to create all
> > directories 0/00 to f/ff? Including the subdirs under temp and archive,
> > that's 9000+ directories to create! Is that right?
>
> Uploads are filed based on md5sums; so, yeah, the maximum layout's
> gonna be pretty humongous. Easily done though, if you can get at a
> shell and Perl:
>
> $ cd /path/to/your/wiki/images
> $ mkdir archive temp
> $ perl -e '@hex=("0".."9", "a".."f"); for $pre ("", "archive/",
> "temp/") { for $w (@hex) { mkdir("$pre$w"); for $x (@hex) {for $y
> (@hex) { mkdir("$pre$w/$x$y") } } } }'
>
> And then adjust the ownership of everything recursively if need be.
> If you *don't* have shell access, it's not so easy; either you could
> get Perl to issue FTP commands from your home PC (I bet there are
> plenty of modules on CPAN that make *that* easy); or, you could just
> edit MediaWiki so that it stores uploads in one flat directory.
>
> > What about images/thumb directory? Do I need to create 0/00-f/ff
> > subdirectories under it as well?
>
> Oh, well, if you do, add thumb to the mkdir line, and "thumb\" to the
> same list as "archive/" and "temp/"
>
> ;)
>
> --
> Rowan Collins BSc
> [IMSoP]
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l@Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
Re: AW: Save mode and File uploading [ In reply to ]
On Dec 4, 2004, at 2:26 AM, Heli Retzek wrote:
> What speaks against letting that behaviour be switched on (default)
> and OFF in Localsettings.php, if OFF the files are simply stored and
> searched in the upload-dir without further subdirs?

Sounds like you want $wgHashedUploadDirectory = false;

(This option is new in 1.4.)

-- brion vibber (brion @ pobox.com)
Re: Save mode and File uploading [ In reply to ]
On Thu, 2 Dec 2004 18:31:25 -0800, Brion Vibber <brion@pobox.com> wrote:
> Go to google.com, and just put "site:mail.wikipedia.org" in with the
> search query.

Can you make sure that that bit makes it on the website somewhere?

-- Jamie
-------------------------------------------------------------------
http://endeavour.zapto.org/astro73/
Thank you to JosephM for inviting me to Gmail!