Commit 53842e8a authored by Nikola Hardi's avatar Nikola Hardi
Browse files

Use the correct tmpdir when autoloading the jclient file

parent 631f4edf
Pipeline #1226841 passed with stage
in 6 minutes and 4 seconds
......@@ -14,7 +14,7 @@ struct TJClientFile : public TObject {
TJClientFile(const char *filepath = NULL);
bool loadFile(const char *filepath = NULL);
TString getDefaultPath();
void setTmpdir();
TString getTmpdir();
TString sUsercert;
TString sUserkey;
......
......@@ -7,6 +7,8 @@
using std::ifstream;
TJClientFile::TJClientFile(const char *filepath) {
tmpdir = getTmpdir();
if(filepath != NULL) {
this->isValid = loadFile(filepath);
} else {
......@@ -19,7 +21,7 @@ TString TJClientFile::getDefaultPath() {
sprintf(cUserId, "%d", getuid());
char* jclientFileLocation = new char[100];
sprintf(jclientFileLocation, "%s%s%s", P_tmpdir, "/jclient_token_", cUserId);
sprintf(jclientFileLocation, "%s/jclient_token_%s", tmpdir.Data(), cUserId);
defaultJClientPath = TString(jclientFileLocation);
delete[] cUserId;
......@@ -28,7 +30,9 @@ TString TJClientFile::getDefaultPath() {
return defaultJClientPath;
}
void TJClientFile::setTmpdir() {
TString TJClientFile::getTmpdir() {
TString tmpdir;
if (getenv("TMPDIR") != NULL)
tmpdir = getenv("TMPDIR");
else if (getenv("TMP") != NULL)
......@@ -37,6 +41,8 @@ void TJClientFile::setTmpdir() {
tmpdir = getenv("TEMP");
else
tmpdir = P_tmpdir;
return tmpdir;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment