Upload paths?? "The webserver does not have permissions to read that directory. "

MetalHellsAngel

Joined: 2005-04-21
Posts: 13
Posted: Thu, 2005-09-22 10:32


Gallery version: gallery-2.0
PHP version: Php 4.3.11
PHPInfo Link: PhpInfo found Here
Webserver: Apache2 for win32
Database: MySql 4.0.25
Activated toolkits: Image Magik, GD
Operating system :Windows Xp Pro
Browser: Maxthon 1.3.3 build 50 (An IE Shell Browser)

No Matter which path I put in I can't seem to make the file upload path work I keep recieving this error. I have no .htaccess files inside that directory, I double checked just in case.

Quote:
The webserver does not have permissions to read that directory

[img]http://MetalHell.ServeMp3.Com/g2/g2_error.gif[/img]

I did a search and found only 2 posts about this neither which appeared to have been followed up on with the correct information on how to fix it. How can I fix this error?

T.Y.I.A.
Angel

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 10:45

from your phpinfo:

Quote:
C:\WINDOWS\php.ini

you are on a windows server, the path must begin with a drive letter, e.g. c:\some\path\to\upload

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Thu, 2005-09-22 11:06

I'm fighting a similar issue on an OpenBSD box.

Gallery version = 2.0-rc-2 core 0.9.36
PHP version = 4.3.10 apache
Webserver = Apache/1.3.29 (Unix) PHP/4.3.10 mod_ssl/2.8.16 OpenSSL/0.9.7d
Database = mysql 4.0.23
Toolkits = ArchiveUpload, Exif, NetPBM
Operating system = OpenBSD 3.7 GENERIC#50 i386
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; SV1)

A link to my phpinfo:
http://www.lowtek.ca/gallery/phpinfo.php

I'm trying to set under the Admin Options / General section -> Local Server Upload Paths. When I type in /tmp I get the error message: "The webserver does not have permissions to read that directory." which is clearly not true.

drwxrwxrwt 2 root wheel 512 Sep 22 07:01 tmp

I realize I'm back a level on Gallery, but having looked at the php code, this has to be something stupid with my setup. I tried (and failed) to add some extra debug to the php script. If someone has hints on this I'll take another run.

In my situation I cannot even add /tmp to the upload path and the permissions on /tmp are fine
drwxrwxrwt 2 root wheel 512 Sep 22 07:01 tmp

The weird thing is that everything else seems to be working fine, I can even use the Import from Gallery1 and point it at a "random" path on my system that contains old Gallery data.

What will help me
1) someone pointing out the obvious I've overlooked
2) tips on how to add debug statements to the php code in modules/core/SimpleCallback.inc so I can figure out why the system thinks it can't read the /tmp directory

Thanks
Roo

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 11:15

please post a phpinfo link
see instructions in
FAQ: What information is required when I ask for help in the forums?

also, what does g2 say, no permissions?

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 00:04

Updated my original message with phpinfo link and some more details.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-23 00:10

well, g2 tells you what php is_readable('/tmp') is returning.
do you use SELinux?
http://codex.gallery2.org/index.php/Gallery2:KnownIssues

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 00:19

If you examine the information I posted more carefully, you'll see that I am using OpenBSD 3.7 - not SELinux.

I wrote a very simple php program

<?php
$filename = '/tmp';
if (is_readable($filename)) {
echo 'The file is readable';
} else {
echo 'The file is not readable';
}
?>

And tested it. The result was "The file is readable", as I would expect. So, clearly php can see /tmp -- but for some reason, I still have this issue.

Any other ideas? (and thanks for ultra-speedy responses)
Roo

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-23 00:26

i saw that it's openbsd. selinux isn't only a linux distribution, i thought maybe some of the selinux tools exist for the bsd families too.

line 136, file modules/core/AdminCore.inc

		} else if (!$platform->is_readable($realPath)) {
		    $error[] = 'form[error][uploadLocalServer][newDir][notReadable]';

if you find out what $realPath is (just var_dump($realPath); exit;), you're a step further.

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 02:49

I believe SELinux tooling and OpenBSD don't mix at all. However, OpenBSD does have some quirky security things, so you're guess may not be entirely off the mark. Let's put this aside and dig into the code.

I modified modules/core/AdminCore.inc to have:

  } else if (!$platform->is_readable($realPath)) {
   $error[] = 'form[error][uploadLocalServer][newDir][notReadable]';
   var_dump($realPath); exit;
  }

And this is the output I got: bool(false)

Which seems odd, so I moved the hack further up in the code to line 122 or so:

var_dump($path); exit;
  $realPath = GalleryCoreApi::convertFromUtf8($path);

And I get: string(4) "/tmp"

This is more sensible. A double check that the $realPath is bogus..

  $realPath = GalleryCoreApi::convertFromUtf8($path);
var_dump($realPath); exit;

Results in:bool(false) -- confirming that I'm not on crack.

So clearly I need to dig into the convertFromUtf8() function. The var_dump();exit(); trick is super handy for tracking this down, thanks for the php debug tip. I'll dig around a bit more and see if I can solve this myself.

Roo

 
akatheone

Joined: 2005-09-22
Posts: 8
Posted: Fri, 2005-09-23 05:59

Im having a similar issue.

Frankly, I have no clue what andrew is talking about.

Why cant there be some instructions for Simpletons.... You know, something like, "hey dude, just type in /xyz and it should find the path."

Instead... well I dont even know what to say about this.

1. I dont want users to be able to upload anything - that is, outside of me.
2. Is this thing telling me to specify what directory, "I" am going to upload files to?
3. If so, why when I type in /members/gallery2 do I get the Initial Error Message - The webserver does not have permissions to read that directory -

See I was hoping to read some kinda simple instructions like, Maybe I just need to change the permissions on that directory or something "simple' like that. Please forgive me and my ignorance but Im sure there are plenty simpletons like me who would love to use this awesome tool, if only we could figure out just what the heck is going on.

No offense to Andrew or anything, but I'm certainly not following that train of thought at all - I think I have more in common with Angel right now where

Quote:
I did a search and found only 2 posts about this neither which appeared to have been followed up on with the correct information on how to fix it. How can I fix this error?

T.Y.I.A.
Angel

thanks in advance to anyone with a "simple" solution.

=D

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 06:51
Quote:
Frankly, I have no clue what andrew is talking about.

:) My hope is that at one point along the way, the real problem will be uncovered and a simple solution will be available to everyone.

Your note does indicate some confusion about this feature. The upload directory is used to configure one of the ways that you can bring in data to Gallery. Any users who can create/modify albums are going to be able to upload stuff (be it via a web browser or other means).

This upload directory is to allow users who have the ability to place files on the webserver's disk to point at an archive (or tree) of pictures and suck them in to gallery. I suspect if you have users who can't modify albums, but who can put files on your server -- you've got bigger problems :)

If you're using XP, many people are falling into the trap of using the wrong type of paths it seems. I fully agree that the error message needs to be a bit more descriptive. If you really need help, you need to post the information asked for in the FAQ http://codex.gallery2.org/index.php/Gallery2:FAQ#What_information_is_required_when_I_ask_for_help_in_the_forums.3F

Ok, without further delay -- onto some more confusing goop.

I've done more digging into my problem. I believe I'm getting closer.

line 158 in modules/core/classes/helpers/GalleryCharsetHelper_simple.class

    function convertFromUtf8($string, $targetEncoding=null) {
        global $gallery;
        $phpVm = $gallery->getPhpVm();

        if (empty($targetEncoding)) {
            $targetEncoding = GalleryCharsetHelper_simple::detectSystemCharset();
var_dump($targetEncoding);var_dump($string);exit();
        }

Is giving me output that looks like: "%a %b %d %H:%M:%S %Y" string(4) "/tmp"

Now, this looks a lot like the date time format string that was processed previously, I'm unclear why it is what I'm getting back from detectSystemCharset();

I also know that in my situation, the path I'm taking is to recode the string.

        } else if ($phpVm->function_exists('recode_string')) {
            return $phpVm->recode_string('UTF-8..' . $targetEncoding, $string);

I suspect trying to recode the string as 'UTF-8..%a %b %d %H:%M:%S %Y' isn't terribly meaningful.

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 07:21

Getting closer here. A trivial php script.

<?php
echo nl_langinfo (CODESET);
?>

Results in output: %a %b %d %H:%M:%S %Y

This seems to me that my operating system is busted, as the CODESET should be "a string with the name of the character encoding" but I appear to be getting back a date time format.

Can someone else who is having this problem try the above php script?

The Gallery code that is triggering this problem for me is in file modules/core/classes/helpers/GalleryCharsetHelper_simple.class at around line 41

        /* Determine character set of current locale */
        if (empty($sourceEncoding) && $phpVm->function_exists('nl_langinfo')) {
            /* @suppress windows warning: "nl_langinfo() is not supported in this PHP build" */
            $sourceEncoding = @$phpVm->nl_langinfo(CODESET);
        }

Hacking out the above snippet of code, seems to make Gallery happy about accepting /tmp as an upload directory (I haven't tested the actual import from local directory yet - but I suspect it will work..3am here, so time to get some sleep).

Sigh, more digging on the web turns up that OpenBSD is most likely broken in this way: http://archives.postgresql.org/pgsql-hackers/2004-07/msg01372.php So here is my request to the kind folk doing Gallery development - any chance you can code around this limitation of OpenBSD?

<?php
echo nl_langinfo (CODESET);
echo nl_langinfo (D_T_FMT);
?>

This php script outputs the same string for both queries. So my suggestion for working around this OpenBSD defect is to compare the string from both queries, if they are the same - then assume that CODESET is broken and set $sourceEncoding back to NULL.

Roo

 
MetalHellsAngel

Joined: 2005-04-21
Posts: 13
Posted: Fri, 2005-09-23 10:33
valiant wrote:
from your phpinfo:

Quote:
C:\WINDOWS\php.ini

you are on a windows server, the path must begin with a drive letter, e.g. c:\some\path\to\upload

Thanks very much valiant this fixed things with no problem. :):):)

 
peter_k

Joined: 2005-09-15
Posts: 134
Posted: Fri, 2005-09-23 10:44

Gallery version = 2.0 noyau 1.0.0
PHP version = 4.3.10 apache
Serveur Web = Apache/1.3.20 Sun Cobalt (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6 PHP/4.3.10 FrontPage/5.0.2.2510 mod_perl/1.26
Base de données = mysql 4.0.16-standard
Boîtes à outils = ArchiveUpload, Exif, Gd, SquareThumb
Système d'exploitation = Linux raq22.amenworld.com 2.4.19C13_V #1 Fri Feb 20 01:55:03 PST 2004 i686
Navigateur Web = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
[url]htttp://www.mir-w-art.org/phpversion.php[/url]

Exactly the same issue here. The "from local server" upload method worked perfectly on my local machine (XP, Apache, PHP, MySql), but didn't work on the remote server (info above). BTW, the zip-upload module didn't work either. Same problem with accessing the directory on the server.

For others with the same problem, I used the following work-around:
1- put (ftp) images that you want to upload in a /temp/ directory somewhere in or below the root of your web directory (as I understand it, this is key difference with the other method, where you should be able to put the pictures in any directory on your server)
2- use the third upload method ("From Web Page") to select the images from your temp directory e.g. //www.yoursite.net/temp/
3- don't forget to uncheck the 2 or 3 gif images that are often present on the page (you can see these when you copy the url in a browser; the gifs are e.g. the horizontal line, arrow icon to go up one level, the folder icon)
4- add URL's

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-23 11:14

MetalHellsAngel: cool

Andrew_Low: good research :) Could you please file a g2 bug on http://sf.net/projects/gallery/ , a bug title like "[G2] nl_langinfo(CODESET) returns date format on OpenBSD" seems appropriate.
your detection for a broken nl_langinfo(CODESET) seems to be ok. So chances are good this will be soon in G2. we'll have to check if this might be a problem for other OS and write a small unit test, that's it. thanks :)

akatheone: Andrew_Low already explained it. i guess it would make sense to add another G2 permission for the "add from local server" method. not every user that is allowed to add items should be allowed to add files from the local server upload path. maybe, we even need a permission per path.
right now, you should make sure you delete everything in your local upload path once you're finished adding, if you have other users in g2 with add item permission.

 
peter_k

Joined: 2005-09-15
Posts: 134
Posted: Fri, 2005-09-23 11:23

Reading another post, I found the answer to my problem (but not sure it's the same problem as Andrew's...)

The "Local Server Upload Paths" that you define must be the full path on the server. The mistake I made was that I set it to: /web/temp/ . I though that G2 would start looking in the root of my "territory" of the shared host (I ignorantly took the highest level I can get to in FileZilla FTP as the start of the path (/))

However, G2 needs the *full* path on the server, which you can find in the phpinfo - apache environment (or other) - document root.
In my case, the document root looked like /home/.sites/142/site692/web (directory where I put the phpinfo.php file), hence in my example the "Local Server Upload Path" to define in G2 is /home/.sites/142/site692/web/temp/

[edit] for users who are not aware of phpinfo, check out this post for another way of finding the full path: http://gallery.menalto.com/node/39088#comment-145085

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 11:59
peter_k wrote:
I found the answer to my problem (but not sure it's the same problem as Andrew's...)

My problem was very specific to OpenBSD as it turns out.

If you want to see if your having the same problem (peter_k I doubt you were as you resolved it another way). Run this php script:

<?php
echo nl_langinfo (CODESET);
echo nl_langinfo (D_T_FMT);
?>

If you get output that looks something like:
%a %b %d %H:%M:%S %Y%a %b %d %H:%M:%S %Y
(ie: the date/time format string twice in a row) then you're probably running OpenBSD or another OS with exactly the same problem.

I would suggest that the FAQ might be improved to cover this topic. It seems that a lot of WindowsXP users are hitting the "you need to use the drive letter in your full path" problem.

Peter_k hit a variant of this problem with the webserver having visibility into a subtree root (not sure the right words to explain this).. or so it seems to me. Again, possibly a FAQ item.

Quote:
...right now, you should make sure you delete everything in your local upload path once you're finished adding, if you have other users in g2 with add item permission.

I'd agree a permission setting on local upload is a good idea. Another suggestion would be just add the path, do your upload, and remove the path - if there are no paths - local upload is disabled. That way only admins can do a local upload.

I personally see the local upload as a good way to bulk upload and get things started. You probably won't do this frequently.

Valiant: I'll log a bug later today, thanks for the help (and the pat on the back) - I'm just happy that I can upload from local dirs now :) [tested it, it works fine with my hack]

Roo

 
peter_k

Joined: 2005-09-15
Posts: 134
Posted: Fri, 2005-09-23 12:13

Andrew, you're right, my problem had nothing to do with OpenBSD. I tried to run the php script anyway, and the output was just a blank screen...

And I think my issue was not even a variant or a problem at all. It just wasn't obvious for me how to define the "Local Server Upload Path" in G2 (being on a shared host). Maybe I should put it in the FAQ.

[edit]Done. I updated the FAQ.

 
Andrew_Low

Joined: 2005-08-30
Posts: 13
Posted: Fri, 2005-09-23 15:57

I've created a bug https://sourceforge.net/tracker/index.php?func=detail&aid=1301421&group_id=7130&atid=107130 to track the OpenBSD problem with Gallery2.

Roo

 
niqdanger

Joined: 2005-11-25
Posts: 1
Posted: Fri, 2005-11-25 23:51

For the record, the bug also tracks to OpenBSD 3.8. Not that there would be any reason it wouldnt, since all the other variables are exactly the same :-) I spent a few hours thinking it was some weird chroot thing, making /tmp directories all over the place until I did some web searching and found this. Your fix worked for me as well. Perhaps the PHP as compiled with OpenBSD does not have some of the charset options or languages?

-Nick

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2006-03-02 01:18

G2 now should now catch this case on OpenBSD.. fix in CVS now, will also be in 2.1-RC-2.

 
nuukie

Joined: 2006-08-25
Posts: 1
Posted: Fri, 2006-08-25 09:30

I'm running OpenBSD 3.9 and after installing the lastest stable release of G2 (2.1.2) I am running into the same issue as Andrew "The webserver does not have permissions to read that directory" when trying to add a local server upload path. I followed his instructions in prior posts and saw the OpenBSD statement so I'm baffled as to were to go from here. I ensured all paths I've tried have complete access (777) and still no luck. Any and all help on this issue would be greatly appreciated.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-08-25 19:39

what do you get for <?php var_dump(nl_langinfo(CODESET)); ?>

 
B@MB@M

Joined: 2005-03-28
Posts: 1
Posted: Sat, 2006-08-26 09:08
Quote:
<?php var_dump(nl_langinfo(CODESET)); ?>

output: string(3) "646"

My php info:
http://gallery2.bamweb.nl/info.php

Note: my apache is chrooted but I have worked it out since 3.6. I'm now running 3.9 with the problem of not accessing the directory I specify.

Quote:
<?php
echo nl_langinfo (CODESET);
echo nl_langinfo (D_T_FMT);
?>

output: 646%a %b %d %H:%M:%S %Y

--------------
update:

I now removed the following code:
in the following file:
modules/core/classes/helpers/GalleryCharsetHelper_simple.class

/* Determine character set of current locale */
if (empty($sourceEncoding) && $phpVm->function_exists('nl_langinfo')
&& defined('CODESET')) {
/* @suppress windows warning: "nl_langinfo() is not supported in this PHP build" */
$sourceEncoding = @$phpVm->nl_langinfo(CODESET);

/* OpenBSD may improperly return D_T_FMT value */
if (isset($sourceEncoding) && strpos($sourceEncoding, '%') !== false && defined('D_T_FMT') && $sourceEncoding == $phpVm->nl_langinfo(D_T_FMT)) {
$sourceEncoding = null;
}
}

This will make it work for now...
Hope it will be fixed in a newer version of OpenBSD or PHP or Gallery2 or a combination of them.
:)

 
jerseyclassic

Joined: 2009-03-11
Posts: 1
Posted: Tue, 2009-03-31 20:54

Help
I am very new to working on a website. Please can help me with questions below

1)How can i link my website to gallery

2) on set up page on gallery, they are asking, i donot understand let a lone answer.

Can any one help

Thanks Guys & Girls

all the best Doug