OntoWiki icon indicating copy to clipboard operation
OntoWiki copied to clipboard

Virtuoso ini file access controll error reporting

Open white-gecko opened this issue 9 years ago • 18 comments

According to https://groups.google.com/forum/#!topic/ontowiki-user/ggWiE_wuEU4 we seem to have an issue of empty or wrong error reporting to the OntoWiki front-end, if the php temporary folder was not granted access in the virtuoso configuration ini file.

Even though for running OntoWiki it is necessary that the user grants access to the PHP temporary folder in the virtuoso configuration, we should correctly report the error in the OntoWiki user interface.

e.g.

The model could not be imported because your virtuoso backend is not able to import it from '/private/var/tmp/phpsON4Vs'.
Please add '/private/var/tmp/' to 'DirsAllowed' in your virtuoso configuration (aka. 'virtuoso.ini').

For this message we also have to make sure, that we always find the temporary folder used by OntoWiki resp. PHP.

white-gecko avatar Apr 27 '16 14:04 white-gecko

We should also try if we can reproduce the empty error message reported in https://groups.google.com/forum/#!topic/ontowiki-user/ggWiE_wuEU4

screen shot 2016-04-26 at 12 36 24

white-gecko avatar Apr 27 '16 14:04 white-gecko

It was me who reported the empty error message in https://groups.google.com/forum/#!topic/ontowiki-user/ggWiE_wuEU4. Please get in touch if you want help reproducing this. As i said in that report, the empty error message was an intermittent problem, but for me happened more than 50% of the time.

matt-wallis avatar Apr 27 '16 15:04 matt-wallis

@matt-wallis could you tell if this mainly happens for certain serialization formats, e.g. RDF/XML but not Turtle?

white-gecko avatar Jun 10 '16 11:06 white-gecko

I am presented with following erro while importing the AKSW model:

Could not import given model: Error importing statements: SQL Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]FA112: Can't stat file '/tmp/phpEAR6bq', error (2) : No such file or directory () in query: CALL DB.DBA.RDF_LOAD_RDFXML(FILE_TO_STRING_OUTPUT('/tmp/phpEAR6bq'), 'http://localhost/OntoWiki/index.php/AKSW/', 'http://localhost/OntoWiki/index.php/AKSW/')

I tried to do the following: '/private/var/tmp/' to the list behind 'DirsAllowed' unfortunately did not worked out in my case..

Any clue whats going wrong ?

ghost avatar Jul 14 '17 12:07 ghost

Is the /tmp directory listed in the DirsAllowed-line in your virtuoso.ini? Is the /tmp directory also writable for your php process and readable for your virtuoso user?

white-gecko avatar Jul 17 '17 10:07 white-gecko

the tmp directory is not listed in my DirsAllowed line it is as following: ., usr/share/virtuoso-opensource-6.1/vad

by running the following block:

// Create a temporary file in the temporary // files directory using sys_get_temp_dir() $temp_file = tempnam(sys_get_temp_dir(), 'Tux');

echo $temp_file;

I know the tmp directories path is : /tmp

ghost avatar Jul 17 '17 10:07 ghost

Ok, so you should add /tmp to your DirsAllowed variable.

DirsAllowed			= ., /usr/share/virtuoso-6.1/vad, /tmp

This is also described in http://docs.ontowiki.net/VirtuosoBackend.html#configuring-virtuoso

white-gecko avatar Jul 17 '17 12:07 white-gecko

Thanks, it was skipped though but now even after adding and restarting server the error persists:

Could not import given model: Error importing statements: SQL Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]FA112: Can't stat file '/tmp/php3bF2TR', error (2) : No such file or directory () in query: CALL DB.DBA.RDF_LOAD_RDFXML(FILE_TO_STRING_OUTPUT('/tmp/php3bF2TR'), 'http://localhost/OntoWiki/index.php/ALGO/', 'http://localhost/OntoWiki/index.php/ALGO/')

ghost avatar Jul 17 '17 13:07 ghost

Can you somehow verify if the file is actually created in /tmp or not?

white-gecko avatar Jul 18 '17 14:07 white-gecko

I did a watch and I observed there isn't any file being created in temp !

ghost avatar Jul 19 '17 16:07 ghost

can you verify, that you can write to /tmp with some other php script?

white-gecko avatar Jul 20 '17 13:07 white-gecko

If you add the following file to your server directory, next to the ontowiki or temporarily instead of the ontowiki you could verify, that your php process can write to tmp:

<?php
$filename = tempnam(sys_get_temp_dir(), 'Tux');

echo $filename;

// FROM http://php.net/manual/en/function.fwrite.php
// changed fopen mode from 'a' to 'w'
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if (!$handle = fopen($filename, 'w')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($somecontent) to file ($filename)";

    fclose($handle);

} else {
    echo "The file $filename is not writable";
}

white-gecko avatar Jul 20 '17 13:07 white-gecko

If you add the following file to your server directory, next to the ontowiki or temporarily instead of the ontowiki you could verify, that your php process can write to tmp:

<?php
$filename = tempnam(sys_get_temp_dir(), 'Tux');

echo $filename;

// FROM http://php.net/manual/en/function.fwrite.php
// changed fopen mode from 'a' to 'w'
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if (!$handle = fopen($filename, 'w')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($somecontent) to file ($filename)";

    fclose($handle);

} else {
    echo "The file $filename is not writable";
}

white-gecko avatar Jul 21 '17 09:07 white-gecko

It does write to temp: /tmp/TuxnlsOGhSuccess, wrote (Add this to the file ) to file (/tmp/TuxnlsOGh)

but the problem persists as following:

Could not import given model: Error importing statements: SQL Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]FA112: Can't stat file '/tmp/phpsLmioW', error (2) : No such file or directory () in query: CALL DB.DBA.RDF_LOAD_RDFXML(FILE_TO_STRING_OUTPUT('/tmp/phpsLmioW'), 'http://localhost/OntoWiki/index.php/data/', 'http://localhost/OntoWiki/index.php/data/')

ghost avatar Jul 28 '17 11:07 ghost

+1 year. I see the same import errors when attempting to import while running the OntoWiki.compose docker images. I expected that these would come pre-configured to allow access to the storage of each image.

Now going off to RTM for docker-compose to determine if I need to provide a volume, specify some access to local drives, or run as root, etc.

lonniev avatar May 20 '18 02:05 lonniev

I am also having this issue.... has anyone been able to solve this issue? Could not import given model: Error importing statements: SQL Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]FA112: Can't stat file '/tmp/phpLOQQ5c', error (2) : No such file or directory () in query: CALL DB.DBA.RDF_LOAD_RDFXML(FILE_TO_STRING_OUTPUT('/tmp/phpLOQQ5c'), .....

monkeybots avatar Feb 07 '19 20:02 monkeybots

Is this project still alive btw, or should I move on to an alternative?

monkeybots avatar Feb 08 '19 12:02 monkeybots

Actually I was not able to reproduce the error. Can you give me some hint on how to produce it? Last time I tried it everything was working fine.

white-gecko avatar Feb 08 '19 13:02 white-gecko