Actually, the op did give you enough information, although I think he
also made a common mistake about regexp. However, I'll try to fill in
the gaps.

When setting up Drupal for multiple sites on one server, you are advised
to not use the default site installed which becomes the "template" for
all others. That means you wind up making entries in
/etc/drupal/6/sites/mydomain.com

There are two files of interest in there: settings.php and (if you
create it) baseurl.php. The baseurl is used to give the particular site
its base domain name (like http://mydomain.com).

The script in question is cron.sh: /usr/share/drupal6/scripts/cron.sh.
It attempts to use curl to load http://{yoursite}/cron.php.

If it can find the basename, that's good. If it can't find the basename
it uses http://localhost which in a multi-site set up is probably not
present and therefore you get a "cron failure" e-mail. Even if it is
present, I am not sure running cron.sh for one installation in a multi-
site install is sufficient (might be, but I doubt it).

Now, why is this a problem? Well it turns out it isn't exactly, although
it could be improved. You would THINK that since $ is a regexp meta
character (match end of line) that if you use it somewhere in a regexp
it should be escaped. I would just because it makes sense. However, at
least the version of grep shipped with the system understands that a $
followed by other characters must just be a dollar sign. So the script
is "correct" but easy to confuse that it is not correct.

HOWEVER, there is a common case where the script will fail. It assumes
that the base_url file (or settings.php) will use single quotes around
the URL. This isn't necessary as you could use double quotes and get
this sort of failure. You also get the failure anywhere you might have
otherwise harmless whitespace

So you could write a big nice regexp to handle it. Something like:

^[ \t]*\$base_url[ \t]*=[ \t*][\'\"]

Or even:

^[ \t]*\$base_url

Would probably be sufficient. However, if you do anything "fancy" that
still could break (e.g., look up a site name in a database). Somewhat
less efficient, but you could in fact run a php script (would require
php-cli though which is currently not a dependency, I think) and have it
include the other files and then echo $base_url. That would be the gold
standard.

So to summarize:
1) OP's bug is not really a bug because the $ metacharacter seems to be 
position sensitive and is treated as a normal character if not at the end of 
string.

2) However, the regexp is bugged because it requires you to adhere to a
single format for the base_url entry in either configuration file it
checks.

3) Suggest either fix the regexp as outlined or switch to using php to
interpret the variables.

-- 
Regular Expression error in cron.sh
https://bugs.launchpad.net/bugs/314815
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to