Page 1 of 2

warning message concerning smarty

Posted: Sat Apr 30, 2005 12:51 am
by BitchBird
alright guys, i installed the blog on my machine, with a local DB and an apache-server. great.

installed it on my webserver, oh lord, nothing works.

Code: Select all

Warning: Smarty error: unable to read resource: "./templates/default/index.tpl" in ./bundled-libs/Smarty/libs/Smarty.class.php on line 1088
by url, i can go to the login mask. i can login in. works fine. i can change nearly EVERYTHING. but i cannot watch the blog, this message keeps poppin' up. i played around with chmod, checked the paths, it's all as it's supposed to be. what the heck is wrong??

thanks for any help.

Posted: Sat Apr 30, 2005 11:13 am
by BitchBird
:evil:

Re: warning message concerning smarty

Posted: Sat Apr 30, 2005 12:58 pm
by garvinhicking
It seems your serendipity path settings are wrong, or maybe you did not extract the s9y tarball correctly? See if a templates/default/index.tpl file exists?

Make sure your serendipityHTTPPath and serendipityPath settings are properly configured.

Regards,
Garvin

Posted: Sat Apr 30, 2005 1:17 pm
by BitchBird
:shock:

Posted: Sat Apr 30, 2005 3:18 pm
by garvinhicking
Okay,if your patience is that limited, we should in fact stop this.

Posted: Sun May 01, 2005 8:00 am
by Guest
did you figure out what you are getting this error? I tried upgrading to 8.0 from 7.1 and I got the same thing. Then I tried a fresh install of 8.0 and I still get the same error. I checked and the file the page is complaining about ("./templates/default/index.tpl") exists:

-rw-r--r-- 1 shayan users 1938 Jan 11 07:53 index.tpl

and should be readable. any ideas?

Posted: Sun May 01, 2005 2:19 pm
by garvinhicking
Guest, what are your Serendipity Path Configuration options? If you go to the admin panel and configuration, the paths that are shown there.

I suppose that one of those may be wrong, especially the HTTP Path or the full server path.

Did you check if the "templates_c" folder exists on your install and is writable?

Regards,
Garvin

Posted: Sun May 01, 2005 9:28 pm
by shayan
You were right. My configuration options were messed up (I installed under a directory other than serendipity).

Now that I have fixed them at least the configuration pages are rendered nicly (before it was a raw html page; text only; old lynx format :)). However, I still get a very similar error for the front page:

Warning: Smarty error: (secure mode) accessing "/home/shayan/www/ideas/templates/default/index.tpl" is not allowed in ./bundled-libs/Smarty/libs/Smarty.class.php on line 1088

From configuration:

Full path: /home/shayan/www/ideas/
Upload path: uploads/
Relative path: /~shayan/ideas/
Relative template path: templates/
Relative upload path: uploads/

Also, templates_c exists and is writable by the world!

drwxrwxrwt 2 shayan users 512 Apr 15 16:30 templates_c/

Thanks for the quick reply,
Shayan

Posted: Sun May 01, 2005 10:11 pm
by garvinhicking
Shayan - this error can happen if the ownership of the file index.tpl (or one of the subdirectories) are owned by a different user than the Smarty-Library files. Can you check if that applies?

Regards,
Garvin

Posted: Sun May 01, 2005 11:05 pm
by shayan
I don't think that is the problem

shayan@leary(~/www/ideas/bundled-libs/Smarty/libs)$ ls -l
total 352
-rw-r--r-- 1 shayan users 12717 Apr 1 03:38 Config_File.class.php
-rw-r--r-- 1 shayan users 62932 Apr 1 03:38 Smarty.class.php
-rw-r--r-- 1 shayan users 90750 Apr 1 03:38 Smarty_Compiler.class.php
-rw-r--r-- 1 shayan users 5066 Mar 29 05:25 debug.tpl
drwxr-xr-x 2 shayan users 1024 Apr 15 16:29 internals
drwxr-xr-x 2 shayan users 2048 Apr 15 16:29 plugins

shayan@leary(~/www/ideas/templates)$ ls -ld .
drwxr-xr-x 21 shayan users 512 Apr 15 16:30 .

shayan@leary(~/www/ideas/templates/default)$ ls -ld .
drwxr-xr-x 4 shayan users 512 Apr 15 16:30 .

shayan@leary(~/www/ideas/templates/default)$ ls -l index.tpl
-rw-r--r-- 1 shayan users 1938 Jan 11 07:53 index.tpl

They are all owner by the same user.

Posted: Mon May 02, 2005 10:36 am
by garvinhicking
Shayan - you are using the 0.8 final release build, right?

I checked the Smarty file; it seems there is some trouble because your directories may be virtually linked?

Please edit your bundled-libs/Smarty/libs/internals/core.is_secure.php file.

This file only contains one function, please replace it temporarily with this code:

Code: Select all

<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * determines if a resource is secure or not.
 *
 * @param string $resource_type
 * @param string $resource_name
 * @return boolean
 */

//  $resource_type, $resource_name

function smarty_core_is_secure($params, &$smarty)
{
    if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
        return true;
    }

    if ($params['resource_type'] == 'file') {
        $_rp = realpath($params['resource_name']);
        echo "Realpath is : $_rp<br />\n";
        if (isset($params['resource_base_path'])) {
            foreach ((array)$params['resource_base_path'] as $curr_dir) {
                echo "Matching against $curr_dir == " . realpath($curr_dir) . "<br />\n";
                if ( ($_cd = realpath($curr_dir)) !== false &&
                     strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
                     $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
                    return true;
                }
                echo "No match.<br />\n";
            }
            echo "No matches.<br />\n";
        }
        if (!empty($smarty->secure_dir)) {
            foreach ((array)$smarty->secure_dir as $curr_dir) {
                echo "Matching against secure dir $curr_dir == " . realpath($curr_dir) . "<br />\n";
                if ( ($_cd = realpath($curr_dir)) !== false &&
                     strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
                     $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
                    return true;
                }    
                echo "No match.<br />\n";        
            }
            echo "No matches.<br />\n";
        }
    } else {
        echo "Non local file.<br />\n";
        // resource is not on local file system
        return call_user_func_array(
            $smarty->_plugins['resource'][$params['resource_type']][0][2],
            array($params['resource_name'], &$smarty));
    }
    echo "Access denied.<br />\n";

    return false;
}

/* vim: set expandtab: */

?>
With this debug output we should be able to track it down.

Best regards,
Garvin

Posted: Wed May 04, 2005 9:16 pm
by shayan
Sorry about the late reply.

Here is what I get when I change the file:

Realpath is :
Matching against /home/shayan/www/ideas/templates/idea ==
No match.
No matches.
Matching against secure dir /home/shayan/www/ideas/templates/ ==
No match.
No matches.
Access denied.

Warning: Smarty error: (secure mode) accessing "/home/shayan/www/ideas/templates/default/index.tpl" is not allowed in ./bundled-libs/Smarty/libs/Smarty.class.php on line 1088

any ideas?

Thanks,
Shayan

Posted: Wed May 04, 2005 9:47 pm
by garvinhicking
Your debugging output shows that either your PHP or your Filesystem has a bug.

As you cansee (hopefully ;) any call to realpath() on your system returns an empty value. Instead it should return the full absolute path to the parameter. (see http://www.php.net/realpath)


This can only happen if the directory "/home/shayan/www/ideas/templates/idea" does not exist, or if your PHP extension is buggy.

Please check again with "la -lad /$home/shayan/www/ideas/templates/idea" if this really returns contents. If yes it means you'll need to contact your server administrator and tell him that your PHP has a bug. Which Version/ServerOS Do you have? Which Apache version?

Regards,
Garvin

Posted: Wed May 04, 2005 10:42 pm
by shayan
Garvin,

The directory exists and contains files

shayan@leary(~/www/ideas/templates/idea)$ pwd
/home/shayan/www/ideas/templates/idea
shayan@leary(~/www/ideas/templates/idea)$ ls -lad .
drwxr-xr-x 3 shayan users 512 Apr 15 16:30 .
shayan@leary(~/www/ideas/templates/idea)$

I am running on OpenBSD 3.6, PHP Version 4.3.11, and Apache/1.3.33 (Unix) mod_fastcgi/2.4.2.

What is the best way to communicate the issue i am having to my admin? (I don't know anything about PHP!)

Thanks,
Shayan

Posted: Thu May 05, 2005 1:09 pm
by garvinhicking
Hi shayan!

Write a simple PHP script:

Code: Select all

<?php
echo realpath('/home/shayan/www/ideas/templates/idea');
?>
Execute that file - you should get an empty string, whereas the output "/home/shayan/www/ideas/templates/idea" is expected. Mail that script to your admin with a pointer to www.php.net/realpath/. Maybe this is a problem of OpenBSD, I don't know...

But the Smarty Engine relies on this command...

Regards,
Garvin