Installation

PGlateximage on Oracle install

PGlateximage on Oracle install

by Alex Jordan -
Number of replies: 8

I'm installing fresh on an Oracle setup for a new development server.  I'm nearly done and then I'll do it again, but streamlined with what I've learned the first time, and I'll add a guide to the wiki.

I'm not able to get PGlateximage to work. I've tried using each of the test problems in `t/latex_image_test/`but I get the same error:

1. ERROR caught by Translator while processing problem file:local/pie.pg
****************
ERRORS from evaluating PG file: 
Failed to create directory [WW]/tmp/tikz.gJCzocJw: Permission denied at [PG]/lib/WeBWorK/PG/ImageGenerator.pm line 84 Died within WeBWorK::PG::ImageGenerator::makeTempDirectory called at line 178 of [PG]/lib/LaTeXImage.pm from within LaTeXImage::draw called at line 716 of [PG]/lib/PGcore.pm from within PGcore::insertGraph called at line 650 of [PG]/macros/PG.pl from within main::insertGraph called at line 28 of (eval 1063)


That looks like a permissions issue, but just to experiment,
I set /opt/webwork/webwork2/tmp to 777, and nothing changes.
I added a warn statement in ImageGenerator, at line 79, after
`$success = mkdir $fullPath;`:
(https://github.com/openwebwork/pg/blob/main/lib/WeBWorK/PG/ImageGenerator.pm#L79)

I added:
warn($fullPath." ".$success);

This shows me that `$fullPath` is being constructed as expected:
/opt/webwork/webwork2/tmp/tikz.1877xhsN 0 at [PG]/lib/WeBWorK/PG/ImageGenerator.pm line 80

But $success is not happening. It's not successfully executing that mkdir and I don't know why.

This is a shot in the dark but is it possible it is trying to execute like:
mkdir [WW]/tmp/tikz.1877xhsN
with that shorthand in place for /opt/webwork/webwork2?

In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Glenn Rice -

It seems your shot in the dark missed before it was fired.  If your warn statement right after the "mkdir" system call output the full path, then that is also what the system call had.  Also, knowing how the code works, I know that the path shortening only occurs on warnings after the fact.

Have you also checked ownership of the tmp directory?  It should be owned by the server user (not sure what that is on Oracle).  Although if you set permissions of the directory to 777, that should work even if the directory is not owned by the server user.

What does the command "ls -l" show when executed in the /opt/webwork/webwork2 directory for the permissions, owner, and group of the tmp directory?  It should be something like "drwxrwsr-x" for permissions, and "www-data" for the user and group (where www-data will instead be the Oracle server user).

Also check that there isn't something inside the tmp directory that is in the way.  Perhaps delete everything in it except the README file.

In reply to Glenn Rice

Re: PGlateximage on Oracle install

by Alex Jordan -
Yeah, I traced the `[WW]` down to the error message handling. It doesn't apply when there is no space before the path, which explains why I say the full path in my warn statements.

I've changed ownership (and group) for the `tmp` folder in every combination that I think is remotely reasonable. And in exasperation I set that folder to 777, and nothing changes. I restart apache each time, although I'm not sure that should matter.

The server user is `apache`, like with RHEL. And there is nothing in the [WW]/tmp folder except README. I can manually add a folder from the command line and that works as expected as long as the permissions are right with whatever user I am acting as. I'm unable to actually switch user to `apache` though, the message I get when I try is "This account is currently not available." I've removed the one folder I manually added. Here is the current `ls -la` output:

alex.jordan@vmwebworkdevw02:/opt/webwork/webwork2/tmp $ ls -la .
total 12
drwxrwsr-x. 2 apache apache 4096 Sep 8 14:53 .
drwxrwxr-x. 17 wwadmin wwadmin 4096 Sep 7 15:03 ..
-rwxrwxr-x. 1 apache apache 156 Jul 19 21:39 README

As I said above, I've played with changing the owners and groups, but it seems like they are supposed to be apache here.

It turns out I only get the error message about being unable to create the temp folder while running the problem through the editor. When I put the problem in an exercise set and visit it there, I get no error message. But I also get no image file to see. And no files appear in [WW]/tmp (although maybe they would naturally be cleaned up before I coudl see them). Meanwhile in [WW]/htdocs/tmp/testing/images, there are "svg" images, except they are empty files. Suggesting nothing was built over in [WW]/tmp and an empty svg was created. There are nonempty png and gif files in [WW]/htdocs/tmp that I think come from when I was browsing the OPL earlier in the installation.

Still at a loss.
In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Alex Jordan -
OK, I found this:
https://stackoverflow.com/questions/5165183/apache-permissions-php-file-create-mkdir-fail#answer-16446586

And it has gotten me to the next level. On Oracle, it seems the apache user is not allowed to use mkdir unless explicitly granted permission to do that. I ran the command at the `chcon` answer and now I have a different issue with PGlateximage, but I'll keep tinkering. I'm past the mkdir issue.

Do you have an idea for where else this might matter? What are all the places where the server user needs to to use mkdir that I haven't run up against yet?
In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Alex Jordan -
I applied the same to five root folders that the server user needs access to, as listed in some of the installation guides. The -R option is for recursion, so this should make it equivalent to other systems.

I'm hitting many quirks with this installation that appear to be specific to Oracle/SELinux. Or so I assume since some of them are not mentioned in Andrew's RHEL instructions for 2.16. This business with `chcon` is just the latest.
In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Glenn Rice -
Yeah, I suspected that SELinux might be involved.

The server will need to be able to run mkdir in any of the temporary locations. I am not sure what all that will include. Clearly /opt/webwork/webwork2/tmp, /opt/webwork/webwork2/htdocs/tmp (unless you use another location for your html tmp directory), /opt/webwork/webwork2/DATA, and of course /opt/webwork/courses. The server needs write access to /opt/webwork/webwork2/logs, but I don't think subdirectories are ever created in that directory.
In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Danny Glin -

I'm no expert on SELinux, but it seems like the commands in the first section of https://webwork.maa.org/wiki/Installation_Manual_for_2.16_on_RHEL8#Configure_SELinux are doing the same thing as the chcon command that you reference.  Did you have to do the chcon stuff even after the semanage stuff?

In reply to Danny Glin

Re: PGlateximage on Oracle install

by Alex Jordan -

Hmm, that may be. My IT contact handled the first steps following the 2.16 RHEL guide without me, and had gotten past that point. However, later after the chcon stuff, I learned about semanage to ensure that the chcon changes persist. And that's when I discovered semanage was not installed. I installed it, and ran that, and these steps will be in my forthcoming write-up.

In reply to Alex Jordan

Re: PGlateximage on Oracle install

by Glenn Rice -
Looking at the instructions it seems that the /opt/webwork/webwork2/tmp directory is not there. That should be added.