New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmp file fixed to test.txt causes writing permission problem on a multi-user server #48

Closed
dawnmy opened this Issue Nov 6, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@dawnmy
Copy link

dawnmy commented Nov 6, 2014

tmp file fixed to test.txt causes writing permission problem on a multi-user server.

WARNING: no write permissions in directory /vol/tmp: Permission denied will try /tmp/.
ERROR: could not open /vol/tmp//tmp/sortmerna_keys_43918.txt file for writing

I think this problem involves the following source code in indexdb.cpp

strcat(try_str,"test.txt");
FILE *tmp = fopen(try_str, "w+");

@dawnmy dawnmy changed the title tmp file for creating index tmp file fixed to test.txt causes writing permission problem on a multi-user server Nov 6, 2014

@ekopylova

This comment has been minimized.

Copy link
Contributor

ekopylova commented Nov 6, 2014

While I look into this, have you tried using setting the "--tmpdir" parameter in indexdb_rna? This allows you to choose the directory where the temporary file will be written to.

@dawnmy

This comment has been minimized.

Copy link
Author

dawnmy commented Nov 7, 2014

Yes, it works with "--tmpdir" option. But, why don't you use a tmp file name with randomly generated characters?

@ekopylova

This comment has been minimized.

Copy link
Contributor

ekopylova commented Nov 11, 2014

There is one temporary file that indexdb_rna needs to write (CMPH keys) during index construction. If a --tmpdir directory is not passed, indexdb_rna will try $TMPDIR, followed by /tmp/, followed by current directory by opening a test file for writing in each of those (the code you've shown above). In your case, it looks like writing to the /tmp/ directory succeeded but the path was incorrectly constructed (should be /tmp/sortmerna_keys_43918.txt rather than /vol/tmp//tmp/sortmerna_keys_43918.txt). Looking at the code I see where the issue is & I'll fix it in the upcoming days. Thanks for reporting the bug!

@dawnmy

This comment has been minimized.

Copy link
Author

dawnmy commented Nov 12, 2014

Thank you for the response! I actually have the write permissions in directory /vol/tmp, but since other users on the same server indexed the SORTMERNA database using "indexdb" and hence a "test.txt" generated in /vol/tmp, and I have no permission to override it. Below is the running process:

First try $TMPDIR

char keys_str[2000] = "";
strcat(keys_str,tmpdir_env);

Here, tmpdir_env is /vol/tmp,

strcat(try_str,"test.txt");
FILE *tmp = fopen(try_str, "w+");

But /vol/tmp/test.txt have already been created by other users since it's a fixed file name. And of course I have no permission to override it. Therefore "indexdb" thought I have no write permission or this directory does not exist and try to switch to /tmp, but here keys_str == "/vol/tmp/"

strcat(keys_str,"/tmp/");

Then indexdb got a nonexistent directory /vol/tmp//tmp/

if ( keys == NULL )
{
    fprintf(stderr," %sERROR%s: could not open %s file for writing\n",
    "\033[0;31m","\033[0m",keys_str);
    exit(EXIT_FAILURE);
}
@ekopylova

This comment has been minimized.

Copy link
Contributor

ekopylova commented Nov 12, 2014

your insight looks correct to me! I'll have some time near the end of the week to fix this.

@ekopylova ekopylova added the bug label Jan 9, 2015

@ekopylova ekopylova referenced this issue Jan 12, 2015

Merged

Fixes 48 #61

@ekopylova

This comment has been minimized.

Copy link
Contributor

ekopylova commented Jan 12, 2015

Resolved in PR #61.

Now the temporary 'test.txt' file is 'test_PID.txt' and should not cause issues on a multi-user server. Also, the temporary file is deleted if successfully written to the temporary directory.

@ekopylova ekopylova closed this Jan 12, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment