AKSW / OntoWiki

Semantic data wiki as well as Linked Data publishing engine
https://ontowiki.net
205 stars 51 forks source link

Virtuoso ini file access controll error reporting #346

Open white-gecko opened 8 years ago

white-gecko commented 8 years ago

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 commented 8 years ago

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

matt-wallis commented 8 years ago

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.

white-gecko commented 8 years ago

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

ghost commented 7 years ago

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 ?

white-gecko commented 7 years ago

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?

ghost commented 7 years ago

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

white-gecko commented 7 years ago

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

ghost commented 7 years ago

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/')

white-gecko commented 7 years ago

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

ghost commented 7 years ago

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

white-gecko commented 7 years ago

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

white-gecko commented 7 years ago

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 commented 7 years ago

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";
}
ghost commented 7 years ago

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/')

lonniev commented 6 years ago

+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.

monkeybots commented 5 years ago

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 commented 5 years ago

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

white-gecko commented 5 years ago

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.