Forum archive 2000-2006

Lars Jensen - Problem display errors - ww 2.2

Lars Jensen - Problem display errors - ww 2.2

by Arnold Pizer -
Number of replies: 0
inactiveTopicProblem display errors - ww 2.2 topic started 5/23/2006; 12:17:06 PM
last post 5/25/2006; 7:17:39 AM
userLars Jensen - Problem display errors - ww 2.2  blueArrow
5/23/2006; 12:17:06 PM (reads: 832, responses: 16)
Hi,

There seems to be some difficulties with displaying problems in ww 2.2. The issue does not seem to be related to the particular display mode used. The error message I see again and again is included below. Some problems where I see this error are:

File name: asuLibrary/set119LinearSystems/p15.pg

File name: asuLibrary/set119LinearSystems/p16.pg

File name: asuLibrary/set119LinearSystems/p17.pg

Almost all of unionLibrary/setAlgebraAbsoluteValue

Almost all of unionLibrary/setAlgebraInequalities

Most problems in the dartmouthLibrary/Marsden-Tromba-Weinstein library

etc.

Any ideas what the error means?

Thanks, Lars.

------------------------------------------------------

Warning messages

Error messages

sourceFilePath is unsafe! at /opt/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 462.

Call stack

The information below can help locate the source of the problem.

* in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 155 of /opt/webwork2/lib/WeBWorK/ContentGenerator.pm

* in WeBWorK::ContentGenerator::go called at line 299 of /opt/webwork2/lib/WeBWorK.pm

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/23/2006; 2:45:06 PM (reads: 879, responses: 1)
Hi Lars,

This comes from a change in which we insisted that all problems be in subdirectories of the templates directory (or linked to from that directory). This fixes a significant security hole which allowed any readable file on the computer to be retrieved by hacking the URL.

(See bug #970 http://bugs.webwork.rochester.edu/show_bug.cgi?id=970 for gory details.)

The fix, or at least a partial one, restricts the directories in which problems can be replaced to the templates directory (and subdirectories) and directories linked to from there.

I handle this by placing the problem libraries under a webwork directory:

webwork
|
-----------------------------------------------------------



| | | | |
webwork2 pg courses rochester_problib union_problib

etc. and in the modelCourse/templates directory I place links to each of these problem libraries. When new courses are created using the modelCourse as a template the problem libraries are properly linked in.

For existing courses you will need to create the links by hand (if there are few of them) or you can write a script that will place the links there if you have a great many.

I'm pretty sure that you will find that you have set the addresses for the problem libraries which are causing trouble to be some directory not under the templates directory.

Hope this helps.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/23/2006; 2:59:54 PM (reads: 940, responses: 0)
Hi Mike,

Thanks for the answer. How does this explain that the vast majority of problems work? Our rochester_problib problems all seem to show fine. So does most others. The one I listed above are exceptions.

Out directory structure is:

/opt/webwork2/

/opt/pg/

/opt/wwlib

And all the problem libraries are under wwlib. For example,

/opt/wwlib/rochester_problib

/opt/wwlib/asu_problib

Thanks, Lars.

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/23/2006; 3:24:33 PM (reads: 881, responses: 1)
Hi Lars,

Look at the templates directory for one of the courses where the problem occurs. You might see links such as:

rochesterLibrary --> /opt/wwlib/rochester_problib

but no link for

unionLibrary --> /opt/wwlib/rochester_problib

and similarly for asuLibrary

you might also see local copies of some of the union library problems which don't cause any problems.

Check the url that the problem is trying to reach (particularly the value of sourceFilePath ) and see if it is under the templates directory for that course.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/23/2006; 5:55:06 PM (reads: 939, responses: 0)
Hi Mike,

Thanks for the suggestion - however, all the symbolic links are in the templates directory. When I say above that "Almost all of unionLibrary/setAlgebraAbsoluteValue" I mean that almost all of the problems in the set produces the error, but *some do not!* Some of the problems in the same set display fine and the rest produce the error listed above...

Any other ideas?

Thanks, Lars.

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/23/2006; 7:09:02 PM (reads: 851, responses: 2)
Hi, OK. I'm getting a bit puzzled. I can't reproduce this error here. The error message

sourceFilePath is unsafe! at /opt/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 462.

is pretty explicit it happens when the variable &sourceFilePath= .....&

is set to something which is not a subset of the templates directory for the course. (this variable will appear in the url, after the ? mark and probably waaaay off to the right in the url that's in the url box when the error is reported. Knowing what sourceFilePath is set too would give us some clue.

The other thing is to look at the union setAlgebraAbsoluteValue from the homework editor and look at each of the paths to the problem source files to see if any look very different from the others.

I would expect this to fail on a problem by problem basis (the error is in Problem.pm) since the path to each problem is individual, so the fact that some problems in a set work and some don't is not necessarily surprising. Are you looking at these problems from a set that has been built? or from the library browser?

Hope this helps.

Take care,

Mike

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 11:42:02 AM (reads: 913, responses: 1)
Hi Mike,

There's more to this problem than I first reported. My first comments was on displaying the problems only: Some problems in the set display fine in the library browser, while others in the *same* set don't. But when I click "Try it" (in the library browser) all problems produce the error message above, no matter how they display. This is also the case for *all* other problems in *all* other libraries, including the rochester library...

All symbolic links pointing to the libraries in /opt/wwlib are present in the templates directories of our courses.

What could be going on here?

Lars.

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 1:37:27 PM (reads: 977, responses: 0)
Hi,

This problem is definitely not related to symbolic links because I downloaded the problem library directly into the templates directory of the course, and I still get the same error message....

The &sourceFilePath part of the URL is this:

&sourceFilePath=union_problib/setAlgebraAbsoluteValue/p1-abs-a.pg

Any ideas?

Lars.

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 2:53:57 PM (reads: 851, responses: 0)
OK, plan C. It may be that there is a bug in your version of the Problem.pm file (your path for sourceFilePath looks correct by the way, so I don't think that is a problem).

Bug #994 addressed a problem with Problem Library:

SetMaker uses a relative path for sourceFilePath, which is nice, but which path_is_subdir didn't account for. Added thrid argument, $allow_relative, to that utility which causes $dir to be prepended to $path. Modified Problem.pm to trigger this behavior. Fixed in HEAD: Utils.pm 1.74 Problem.pm 1.198 rel-2-2-dev: Utils.pm 1.71.2.3 Problem.pm 1.191.2.7

can you check your version numbers against those? You can get the latest versions of the files from the CVS.

If you are already connected to the CVS (i.e. there CVS directories in among your source files) then

cvs update -r 1.71.2.3 Utils.pm

will get you the version of Utils.pm connected with rel-2-2-dev.

You can also check around line 461 in Problem.pm -- see if you have:

die "sourceFilePath is unsafe!" unless path_is_subdir($sourceFilePath, $ce->{courseDirs}->{templates}, 1); # 1==path can be relative to dir

If the 1 is not there, then you need to update Problem.pm and also the Utils.pm file.

Hopefully this will solve the problem. (Why this problem would cause troubles with some problem paths but not others is a complete mystery to me however.)

Good luck.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 4:53:02 PM (reads: 830, responses: 0)
Hi Mike,

Above instructions - replacing Utils.pm and Problem.pm - definitely helped. Now most of the problems display in the library browser, and "Try it" works for those that do display correctly. Several problems still don't display, but the error message about &sourceFilePath has been replaced by errors like the one below. (The &sourcefilepath error seems to have gone away.)

Thanks,

Lars.

---------------------------------------------------


 

WeBWorK Error

WeBWorK has encountered a software error while attempting to process this problem. It is likely that there is an error in the problem itself. If you are a student, report this error message to your professor to have it corrected. If you are a professor, please consult the error output below for more information. Error messages

expected an answer hash at line 2502 of (eval 209) Died within main::trim_whitespace called at line 297 of [PG]/macros/listAnswer.pl from within main::std_list_cmp called at line 33 of [PG]/macros/unionAnswer.pl from within main::num_union_cmp called at line 37 of [TMPL]/unionLibrary/setAlgebraAbsoluteValue/p1-abs-b.pg Error details

Problem1 ERROR caught by Translator while processing problem file:unionLibrary/setAlgebraAbsoluteValue/p1-abs-b.pg * expected an answer hash at line 2502 of (eval 209) Died within main::trim_whitespace called at line 297 of [PG]/macros/listAnswer.pl from within main::std_list_cmp called at line 33 of [PG]/macros/unionAnswer.pl from within main::num_union_cmp called at line 37 of [TMPL]/unionLibrary/setAlgebraAbsoluteValue/p1-abs-b.pg

*

------Input Read 1 ##DESCRIPTION 2 ## Inequality 3 ##ENDDESCRIPTION 4 ## K. Lesh, Union College, 9/9/03 5 6 DOCUMENT(); # This should be the first executable line in the problem. 7 8 loadMacros( 9 PG.pl, 10 PGbasicmacros.pl, 11 PGchoicemacros.pl, 12 PGanswermacros.pl, 13 PGauxiliaryFunctions.pl, 14 "PGunion.pl", # Union College utilities 15 "unionAnswer.pl", # Load answer-checker appropriate to the problem 16 "PGcourse.pl", # Customization file for the course 17 ); 18 19 TEXT(beginproblem()); 20 21 BEGIN_PROBLEM(); 22 23 $a = random(1,8,1); 24 $b = random(2,10,1); 25 $c = random(3,15,1); 26 $min=-$a-$b*$c; 27 $max=$b*$c-$a; 28 29 BEGIN_TEXT 30 Solve the following inequality. Enter the answer in interval notation. 31 [ left|frac{x+$a}{$b}right| leq $c ] 32 $BR 33 Answer: {ans_rule(35)} 34 $PAR 35 $INFINITY_UNION_MESSAGE 36 END_TEXT 37 38 $showPartialCorrectAnswers = 0; 39 ANS(num_union_cmp("[$min,$max]")); 40 41 END_PROBLEM(); 42 ENDDOCUMENT(); # This should be the last executable line in the problem.;

-----

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 5:52:45 PM (reads: 847, responses: 0)
Hi Lars,

well that's progress at least. I can reproduce this problem our production server, but not on hosted or on our development server. I haven't yet been able to figure out exactly where this bug was fixed. I'll keep at it.

-- MIke

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 6:33:06 PM (reads: 841, responses: 0)
Lars,

Try updating the union_problib from the CVS -- that solved some of the problema here. Unless there are multiple bugs at your end it will probably work for you as well.

-- Mike

<| Post or View Comments |>


userMichael Gage - Re: Problem display errors - ww 2.2  blueArrow
5/24/2006; 7:51:07 PM (reads: 839, responses: 0)
I solved the remaining bugs here once I removed some old local copies of the macros files which were overriding the new macro files I got from the CVS. I don't think you have local copies of the macro files so once you've updated the union_problib you should be ready to go. Let us know how it turns out.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/25/2006; 1:58:36 AM (reads: 839, responses: 3)
Hi Mike,

My union_problib was freshly updated already. However, I figured out that one issue is that some Union problems refer to PGauxiliaryfunctions.pl instead of PGauxiliaryFunctions.pl - this obviously produces an error.

Another common error is this:

Error messages

expected an answer hash at line 2502 of (eval 374) Died within main::trim_whitespace called at line 297 of [PG]/macros/listAnswer.pl from within main::std_list_cmp called at line 33 of [PG]/macros/unionAnswer.pl from within main::num_union_cmp called at line 60 of [TMPL]/unionLibrary/setAlgebraInequalities/an_appA_1.pg Error details

Problem1

ERROR caught by Translator while processing problem file:unionLibrary/setAlgebraInequalities/an_appA_1.pg

*

expected an answer hash at line 2502 of (eval 374)

Died within main::trim_whitespace called at line 297 of [PG]/macros/listAnswer.pl

from within main::std_list_cmp called at line 33 of [PG]/macros/unionAnswer.pl

from within main::num_union_cmp called at line 60 of [TMPL]/unionLibrary/setAlgebraInequalities/an_appA_1.pg

Lars.

<| Post or View Comments |>


userDavide P. Cervone - Re: Problem display errors - ww 2.2  blueArrow
5/25/2006; 6:51:45 AM (reads: 897, responses: 1)
Lars:

Make sure you update the MACROS that are from the Union library, not just the problem files. Note that the error message indicates that you are getting listAnswer.pl from the pg/macros directory, so unless you have update the copies in pg/macros by hand, you will be getting the old copies. There was a change to the trim_whitespace command last fall that required changes to the code that calls it, and listAnswer.pl was one such place.

Now that WeBWorK has a more flexible macro library path variable (which can be set in global.conf), you might want to remove the Union macros from pg/macros and simply have the macrosPath variable include the directory where they can be found (/opt/wwlib/union_problib/macros) so that you don't have to worry about making updates by hand in the future.

I'll look for the PGauxiliaryfunctions.pl problem (we're running on a system that does not distinguish upper- and lower-case file names, so that type of error slips by very easily).

Davide

<| Post or View Comments |>


userDavide P. Cervone - Re: Problem display errors - ww 2.2  blueArrow
5/25/2006; 7:17:39 AM (reads: 908, responses: 0)
There were two files in setAnalGeomLines that had the wrong capitalization for PGauxiliaryFunction.pl. I have fixed these in the CVS repository.

Thanks for the error report.

Davide

<| Post or View Comments |>


userLars Jensen - Re: Problem display errors - ww 2.2  blueArrow
5/26/2006; 1:45:43 AM (reads: 969, responses: 0)
Hi Davide,

Thanks for the info. Editing the macro path in global.conf does help fix the problems.

Lars.

<| Post or View Comments |>