Koozali.org: home of the SME Server

Cannot upload images to Ibay

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« on: March 24, 2005, 12:10:20 AM »
I cannot seem to upload any images to my ibay.
Is this another template fragment issue or something cause it works fine in my primary bay. Thanks

Ed
......

gavincowie

Cannot upload images to Ibay
« Reply #1 on: March 24, 2005, 12:39:37 AM »
"open_basedir" is in effect on ibays - you will need to specify a php upload location inside your ibay. Ordinarily by editing httpd.conf, tho in this case the templates make it a bit more tricky - I'm using a method that pulls in parameters from the e-smith accounts db - does anyone remember who wrote the code for the "httpdAdvanced" entry? Dan Brown, was it you?

Anyway it ends up like this : (all on one line)
php_admin_value upload_tmp_dir /home/e-smith/files/ibays/youribay/html/tmp_upload

You should be able to make the tmp_upload in the /files/ folder instead of html for more security.

G

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #2 on: March 24, 2005, 05:39:20 PM »
What I have is an ECommerce program that allows you to add products and browse for a picture and thumbnail to upload and associate with the product.

All is fine except that the image which should have been added to the database does not appear. I have tried several times and nothing seems to work.

I have a Mambo site running in my Primary that works on the same principal and I can do the same thing and browse for a file to upload and it works fine.

The Ibay site is the puzzler. Hope this makes my issue clearer. Thanks
......

gavincowie

Cannot upload images to Ibay
« Reply #3 on: March 24, 2005, 06:48:03 PM »
Quote
What I have is an ECommerce program that allows you to add products and browse for a picture and thumbnail to upload and associate with the product.

All is fine except that the image which should have been added to the database does not appear. I have tried several times and nothing seems to work.


Yeah, the uploading is the problem. By default, uploading via php will put it in /tmp - this is fine for the primary ibay, it doesn't have open_basedir restrictions on it. All other ibays do have the restriction, therefore they can't reach /tmp and the upload fails.

You'll need to tell apache to set that php_admin_value for the ibay so that the php uploading will go to a location that is "within" the openbasedir path restriction.

G

PS. when uploading with php, it doesn't matter where you tell (or where the script tells) the file to go to, be it in the filesystem or in a database. It will still first go to a temporary filesystem location as specified in the php.ini file as the upload is taking place.
[/quote]

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #4 on: March 24, 2005, 08:25:28 PM »
Quote
You'll need to tell apache to set that php_admin_value for the ibay so that the php uploading will go to a location that is "within" the openbasedir path restriction.


Thanks Gavin

Are you saying that I should create a template fragment in the /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf and add an entry that says what? (php_admin_value open_basedir /home/e-smith/files/ibays/store) is what it says right now in http.conf.
I'm confused by this open_basedir path restriction thing.

Thanks again
......

gavincowie

Cannot upload images to Ibay
« Reply #5 on: March 25, 2005, 08:04:56 AM »
You got it - the problem is creating template fragments for ibays is a particularly tricky case - a loop is used to set all the web parameters for the various ibays, so setting a particular param for a particular ibay requires a bit of lateral thinking. Fortunately, Dan Brown, one of the mental limbo champs around here has already done that thinking.

http://www.familybrown.org/howtos/advanced-ibay-howto.html

This is an old howto from 2001, but it's still applicable even if the line numbers have moved a bit.

Strange, I could only find this howto using yahoo(!) not google...

G

PS. Where Mr. Brown found the time to work on The Da Vinci code with all the SME hacking he's been up to over the past few years is beyond me.

Offline hardijs

  • ****
  • 77
  • +0/-0
gallery too?
« Reply #6 on: March 30, 2005, 02:21:27 PM »
may it be the same reason (or one of many) that breaks gallery (Knuddi install) too?

gavincowie

Big yeppers
« Reply #7 on: March 30, 2005, 06:29:47 PM »
Quote
may it be the same reason (or one of many) that breaks gallery (Knuddi install) too?
That's a big yes.

Using Dan Brown's referenced hack, I just made a tmp dir inside my ibay, did :

/sbin/e-smith/db accounts setprop myIbayName httpdAdvanced "php_admin_value upload_tmp_dir /home/e-smith/files/ibays/myIbayName/html/tmp"

all on one line, then:
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
and finally:
/etc/e-smith/events/actions/restart-httpd-graceful

I wonder if putting the tmp dir in files would have worked too...

G

Skydiver

SME 7.0 Alpha 3
« Reply #8 on: March 31, 2005, 02:34:14 AM »
Will this work with the SME ver i am using

i want to have followSymLinks . Will this allow access to the /tmp foulder within my system foulders rather then in the ibay itself.

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #9 on: March 31, 2005, 03:00:22 AM »
Gavin

What version of SME are you running?

I emailed Dan and he said that the instuctions were for version 4.1.2 and didn't think that the advanced properties would be necessary to allow uploading images (depending on how the store front system handled that).

Were the commands in your last message the only necessary steps or what part of Dan's instructions did you use? In version 6.0.1 that I am running the 90e-smithAccess40ibays file lines are nothing like the ones in version 4.1.2 so there is no way of knowing where to add them.
Thanks

Ed
......

Skydiver

SME 7.0 Alpha 3
« Reply #10 on: March 31, 2005, 03:03:48 AM »
i am using SME 7.0 Alpha 3

gavincowie

Cannot upload images to Ibay
« Reply #11 on: March 31, 2005, 03:22:18 AM »
Quote
i want to have followSymLinks . Will this allow access to the /tmp foulder within my system foulders rather then in the ibay itself.

To allow access to the /tmp folder you will have to disable the open_basedir restriction.

G

gavincowie

Cannot upload images to Ibay
« Reply #12 on: March 31, 2005, 03:35:37 AM »
edb,
Quote
I emailed Dan and he said that the instuctions were for version 4.1.2 and didn't think that the advanced properties would be necessary to allow uploading images (depending on how the store front system handled that).
yep, the instructions were for 4.1.2 - I used them on 5.1.2 and again on 5.6 with a bit of tweaking. I wouldn't have expected uploading to "just work" since php by default does want to put uploaded files into /tmp - and if the open_basedir restrictions are in effect...

Maybe we can get Dan in here... I'm out of touch :)

G[/quote]

Offline hardijs

  • ****
  • 77
  • +0/-0
Re: gallery
« Reply #13 on: March 31, 2005, 09:19:36 AM »
Quote from: "gavincowie"
Quote
may it be the same reason (or one of many) that breaks gallery (Knuddi install) too?
That's a big yes.



did the thing
did the complete ibay content delete and install a new - now works.

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #14 on: March 31, 2005, 04:03:58 PM »
What exactly did you do?

Where did you put this part of the code: line 130?

if ($properties{'httpdAdvanced'})
            {
                $result .= "# Advanced Properties\n";
                $result .= $properties{'httpdAdvanced'};
                $result .= "\n";
            }
The code preceeding this line looks nothing like the code in my file so I don't know where to add it.
......

Offline hardijs

  • ****
  • 77
  • +0/-0
gallery
« Reply #15 on: March 31, 2005, 04:22:21 PM »
Quote from: "edb"
What exactly did you do?

Code: [Select]

/sbin/e-smith/db accounts setprop gallery httpdAdvanced "php_admin_value upload_tmp_dir /home/e-smith/files/ibays/gallery/html/temp"

 
then
Quote

/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
and finally:
/etc/e-smith/events/actions/restart-httpd-graceful

then deleted everything in the gallery ibay (I know - quite an overkill)

the run the Knuddi install script again
so after a fresh configure I am doing my gallery uploads again

I know that I got an easy way as there are almost none gallery users and I did not need to import/copy them - so starting from scratch (or almost that) did work.

gavincowie

Cannot upload images to Ibay
« Reply #16 on: March 31, 2005, 11:34:33 PM »
Quote

edb wrote:
Quote
What exactly did you do?


You need to look for the references to the if statement that deals with "AuthName" in the template - if you add in the "if httpdAdvanced" lines after that if statement closed, that should get the advanced stuff to appear in the right place for the ibay declarations.

G[/quote]

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #17 on: April 01, 2005, 04:21:27 PM »
Quote
You need to look for the references to the if statement that deals with "AuthName" in the template


Here is my file, there are lots of places where it says "AuthName". Could you indicate in bold where I should add the line. Thanks

#------------------------------------------------------------
# Information bay directories
#------------------------------------------------------------

{
    use esmith::AccountsDB;
    my $adb = esmith::AccountsDB->open_ro();
    $OUT = "";
    foreach my $ibay ($adb->ibays)
    {
   my %properties = $ibay->props;
   my $key = $ibay->key;
   #------------------------------------------------------------
   # Figure out which combination of parameters to use. If
   # PublicAccess parameter is present, this is e-smith 4.0.
   # Otherwise, it's e-smith 3.0.
   #------------------------------------------------------------

   my $allow;
   my $pass;
   my $satisfy;
   
   if ($properties{'PublicAccess'})
   {
       if ($properties{'PublicAccess'} eq 'none')
       {
      next;
       }
       elsif ($properties{'PublicAccess'} eq 'local')
       {
      $allow   = $localAccess;
      $pass    = 0;
      $satisfy = 'all';
       }
       elsif ($properties{'PublicAccess'} eq 'local-pw')
       {
      $allow   = $localAccess;
      $pass    = 1;
      $satisfy = 'all';
       }
       elsif ($properties{'PublicAccess'} eq 'global')
       {
      $allow   = 'all';
      $pass    = 0;
      $satisfy = 'all';
       }
       elsif ($properties{'PublicAccess'} eq 'global-pw')
       {
      $allow   = 'all';
      $pass    = 1;
      $satisfy = 'all';
       }
       elsif ($properties{'PublicAccess'} eq 'global-pw-remote')
       {
      $allow   = $localAccess;
      $pass    = 1;
      $satisfy = 'any';
       }
   }
   elsif ($properties {'ReadAccess'} eq 'global')
   {
       if ($properties {'UsePassword'} eq 'yes')
       {
      $allow   = 'all';
      $pass    = 1;
      $satisfy = 'all';
       }
       else
       {
      $allow   = 'all';
      $pass    = 0;
      $satisfy = 'all';
       }
   }
   else
   {
       if ($properties {'UsePassword'} eq 'yes')
       {
      $allow   = $localAccess;
      $pass    = 1;
      $satisfy = 'all';
       }
       else
       {
      $allow   = $localAccess;
      $pass    = 0;
      $satisfy = 'all';
       }
   }


   my $dynamicContent = $properties{'CgiBin'} || "disabled";
   $OUT .= "\n";
   $OUT .= "#------------------------------------------------------------\n";
   $OUT .= "# $key ibay directories ($properties{'Name'})\n";
   $OUT .= "#------------------------------------------------------------\n";

   $OUT .= "\n";
   $OUT .= "<Directory /home/e-smith/files/ibays/$key/html>\n";
   $OUT .= "    Options Indexes\n";
   if ($dynamicContent eq 'enabled')
   {
       $OUT .= "    Options +Includes\n";
   }
   else
   {
       $OUT .= "    <FilesMatch \"\\.(php|php3|phtml)\$\">\n";
       $OUT .= "        order deny,allow\n";
       $OUT .= "        Deny from all\n";
       $OUT .= "    </FilesMatch>\n";
       $OUT .= "    Options +IncludesNOEXEC\n";
   }
   $OUT .= "    AllowOverride None\n";
   $OUT .= "    order deny,allow\n";
   $OUT .= "    deny from all\n";
   $OUT .= "    allow from $allow\n";
   if ($pass)
   {
       $OUT .= "    AuthName \"$properties{'Name'}\"\n";
       $OUT .= "    AuthType Basic\n";
       $OUT .= "    AuthExternal pwauth\n";
       $OUT .= "    require user $key\n";
       $OUT .= "    Satisfy $satisfy\n";
   }
   $OUT .= "</Directory>\n";

   $OUT .= "\n";
   $OUT .= "<Directory /home/e-smith/files/ibays/$key/cgi-bin>\n";
   if ($dynamicContent eq 'enabled')
   {
       $OUT .= "    Options ExecCGI\n";
   }
   $OUT .= "    AllowOverride None\n";
   $OUT .= "    order deny,allow\n";
   $OUT .= "    deny from all\n";
   $OUT .= "    allow from $allow\n";
   if ($pass)
   {
       $OUT .= "    AuthName \"$properties{'Name'}\"\n";
       $OUT .= "    AuthType Basic\n";
       $OUT .= "    AuthExternal pwauth\n";
       $OUT .= "    require user $key\n";
       $OUT .= "    Satisfy $satisfy\n";
   }
   $OUT .= "</Directory>\n";

   $OUT .= "\n";
   $OUT .= "<Directory /home/e-smith/files/ibays/$key/files>\n";
   $OUT .= "    AllowOverride None\n";
   $OUT .= "    order deny,allow\n";
   $OUT .= "    deny from all\n";
   $OUT .= "    allow from $allow\n";
   if ($pass)
   {
       $OUT .= "    AuthName \"$properties{'Name'}\"\n";
       $OUT .= "    AuthType Basic\n";
       $OUT .= "    AuthExternal pwauth\n";
       $OUT .= "    require user $key\n";
       $OUT .= "    Satisfy $satisfy\n";
   }
   $OUT .= "</Directory>\n";
    }
}
......

gavincowie

Cannot upload images to Ibay
« Reply #18 on: April 01, 2005, 07:29:48 PM »
$OUT .= " AllowOverride None\n";
$OUT .= " order deny,allow\n";
$OUT .= " deny from all\n";
$OUT .= " allow from $allow\n";
if ($pass)
{
$OUT .= " AuthName \"$properties{'Name'}\"\n";
$OUT .= " AuthType Basic\n";
$OUT .= " AuthExternal pwauth\n";
$OUT .= " require user $key\n";
$OUT .= " Satisfy $satisfy\n";
}
--- PUT IT IN HERE ---
$OUT .= "</Directory>\n";

$OUT .= "\n";
$OUT .= "<Directory /home/e-smith/files/ibays/$key/cgi-bin>\n";

But, change it from using "$result" to using "$OUT" - as $OUT is the string you are adding to and it is the one that is used to make the template.

G

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #19 on: April 04, 2005, 06:41:14 AM »
Thanks again Gavin.

That makes it crystal clear but unfortunately it still didn't work for my purposes. I have not however tried to do as Hardijs suggested and delete everything in the Ibay.

Ed
......

gavincowie

Cannot upload images to Ibay
« Reply #20 on: April 04, 2005, 06:30:57 PM »
Quote
That makes it crystal clear but unfortunately it still didn't work for my purposes.

Bugger! So what happened? did it even make the appropriate php configuration lines appear in /etc/httpd/conf/httpd.conf when you did the expand template?

G

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #21 on: April 04, 2005, 09:22:22 PM »
Quote
Bugger! So what happened? did it even make the appropriate php configuration lines appear in /etc/httpd/conf/httpd.conf when you did the expand template?


Here is the section of the file that was appended:

<Directory /home/e-smith/files/ibays/store/cgi-bin>
    Options ExecCGI
    AllowOverride None
    order deny,allow
    deny from all
    allow from all
#   Advanced Properties
Options Indexes Includes FollowSymLinks
</Directory>

I did not put in the # sign next to Advanced Properties, this was done automatically.
If I try to remove the coment and restart httpd I get an error
[root@mail root]# service httpd restart
Stopping httpd:                                            [   OK   ]
Starting httpd: Syntax error on line 1374 of /etc/httpd/conf/httpd.conf:
Invalid command 'Advanced', perhaps mis-spelled or defined by a module not included in the server configuration
                                                           [ FAILED ]

Appears to be something wrong with the syntax.
......

gavincowie

Cannot upload images to Ibay
« Reply #22 on: April 04, 2005, 09:48:15 PM »
Quote
<Directory /home/e-smith/files/ibays/store/cgi-bin>
Options ExecCGI
AllowOverride None
order deny,allow
deny from all
allow from all
# Advanced Properties
Options Indexes Includes FollowSymLinks
</Directory>


First, the # Advanced Properties line is just a comment so you can know what the line below is for. you can leave it there without issue.

Second, it appears you pasted in the wrong place? you added the httpdadvanced code inside the "cgi-bin Directory" declaration:
$OUT .= "<Directory /home/e-smith/files/ibays/$key/cgi-bin>\n";

instead of inside the "html Directory" declaration:
$OUT .= "<Directory /home/e-smith/files/ibays/$key/html>\n";

So unless you *meant* to apply these options to the cgi-bin instead of the html directory i would refer back to my posting about exactly where to insert the httpdAdvanced fragment and change the location of the paste.

Also, if you are wanting to specify *additional* apache Options directives, you will have to add '+' signs to them, e.g.:
Options +FollowSymLinks

Finally, judging by the full template code you originally pasted, the "Indexes" and "Includes" directives are already there - you should get away with just setting the httpdAdvanced value to the example line above.

Fun eh?

G

Offline edb

  • *
  • 548
  • +0/-0
Cannot upload images to Ibay
« Reply #23 on: April 04, 2005, 10:45:01 PM »
Thanks for pointing that out Gavin.

That was pretty stupid of me to overlook that.

Ok I added the /sbin/e-smith/db accounts setprop store httpdAdvanced "Options Indexes Includes FollowSymLinks" command without realizing that it was just an example in Dan's instructions. So how do I reverse the command now that it is added to the httpd.conf file?

Also, I tried to upload an image again after editing the file as you pointed out but still no go. I'll have to touch base with the programmer of the ecommerce package to see if there maybe something else but they told me that they don't support my SME server config (due to all the templating stuff).
......

gavincowie

Cannot upload images to Ibay
« Reply #24 on: April 04, 2005, 10:55:41 PM »
Quote
Ok I added the /sbin/e-smith/db accounts setprop store httpdAdvanced "Options Indexes Includes FollowSymLinks" command without realizing that it was just an example in Dan's instructions. So how do I reverse the command now that it is added to the httpd.conf file?


The beauty of the e-smith db + templates system - just do it again, but with the value you want. e.g.

/sbin/e-smith/db accounts setprop store httpdAdvanced "Options +FollowSymLinks"

then perform the expand template again :
/sbin/e-esmith/expand-template /etc/httpd/conf/httpd.conf

the do the restarting of apache command.

G

Offline edb

  • *
  • 548
  • +0/-0
Uploading I mages to IBay - Issue Resolved
« Reply #25 on: April 10, 2005, 07:48:23 PM »
Ok, I found the answer to my uploading images issue.

It involves two commands at the server:

# /sbin/e-smith/db accounts setprop store PHPBaseDir /home/e-smith/files/ibays/youribayname/:/tmp

# /sbin/e-smith/signal-event ibay-modify youribayname

These two commands solved my issue.

I can now browse for the images, link them with my products and have the images actually appear on the site.  ;-) :pint:

Here is the link that I viewed to find the answer:
http://forums.contribs.org/index.php?topic=21553.msg96897#msg96897

Hope this will help someone else that is having the same issue.

Thanks to all for your replies to this thread.

BTW Gavin you were right on with your initial posts except that the path to /tmp may not have been exactly correct and I didn't need the advanced stuff.

Ed
......

Offline arne

  • *****
  • 1,116
  • +0/-4
Cannot upload images to Ibay
« Reply #26 on: April 10, 2005, 10:58:38 PM »
"Can not upload" .. this is a rather well known issue about the SME server. The SME has for years used a PHP chroot that have made it imposible to transfer files from the temporary upload area to the webserver file area. Reason: Security.

One easy solution: To unlock the PHP croot, wich will reduce the overall security of your system.

Have not actually tried this on newer versions than 6.0.1, but guess it still wil work.

Don't have my notes for "how to unlock the php chroot", but I have answered it out some times before.

After opening the PHP croot, it does not use to be any problem about making uploads etc. The disadvantage is that php scripts also might have the freedom to reach areas of your computer where it could make some damage. It will be less secure.

Another idea is to make some minor changes to the templates for the php.ini file, so it will accept bigger size of the uploadable objects, etc.
......

actronzs

Re: Cannot upload images to Ibay
« Reply #27 on: January 31, 2006, 10:06:04 PM »
Quote from: "edb"
I cannot seem to upload any images to my ibay.
Is this another template fragment issue or something cause it works fine in my primary bay. Thanks

Ed


Hi Ed,

on my SME ReleaseVersion=6.0.1-01 i use this:

/sbin/e-smith/db accounts getprop Primary PHPBaseDir (just for information)
/sbin/e-smith/db accounts setprop Primary PHPBaseDir /tmp:/home/e-smith/files/ibays/Primary (the ibay in which your Cerberus resides)
/sbin/e-smith/signal-event ibay-modify Primary
service httpd restart

Do:
ls /etc/e-smith/templates-custom/etc/php.ini (to make sure it exists)

Do:
cp /etc/e-smith/templates/etc/php.ini/50PathsDirectories /etc/e-smith/templates-custom/etc/php.ini

Run:
pico /etc/e-smith/templates-custom/etc/php.ini/50PathsDirectories

Add this value to the file:
upload_tmp_dir = /tmp

Save the file

Run:
/sbin/e-smith/expand-template /etc/php.ini

Run:
service httpd restart

zoran