Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
a974da19
Commit
a974da19
authored
Dec 21, 2020
by
Alessio Netti
Browse files
Fall back to /tmp/ dir if $HOME/.cache cannot be used for sensor cache
parent
1ba44cea
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/src/sensorconfig.cpp
View file @
a974da19
...
...
@@ -1951,23 +1951,30 @@ SCError SensorConfigImpl::findSensorCachePath(std::string &path) {
_clusterName
=
""
;
return
SC_UNKNOWNERROR
;
}
// Retrieving home dir
if
((
homeDir
=
getenv
(
"HOME"
))
==
""
)
{
return
SC_PATHERROR
;
}
path
=
homeDir
+
"/.cache/"
;
// Cache dir does not exist - we create it
if
(
access
(
path
.
c_str
(),
F_OK
)
!=
0
&&
mkdir
(
path
.
c_str
(),
0700
)
!=
0
)
{
path
=
""
;
return
SC_PATHERROR
;
}
try
{
// Retrieving home dir
if
((
homeDir
=
getenv
(
"HOME"
))
==
""
)
{
throw
std
::
domain_error
(
"Home directory is not defined!"
);
}
path
=
homeDir
+
"/.cache/"
;
// Cache dir does not exist - we create it
if
(
access
(
path
.
c_str
(),
F_OK
)
!=
0
&&
mkdir
(
path
.
c_str
(),
0700
)
!=
0
)
{
throw
std
::
domain_error
(
"Cache directory cannot be accessed!"
)
;
}
// Cache dir exists but it is not accessible
if
(
access
(
path
.
c_str
(),
W_OK
)
!=
0
)
{
path
=
""
;
return
SC_PATHERROR
;
// Cache dir exists but it is not writeable
if
(
access
(
path
.
c_str
(),
W_OK
)
!=
0
)
{
throw
std
::
runtime_error
(
"Cache directory is not writeable!"
);
}
}
catch
(
const
std
::
domain_error
&
e
)
{
path
=
"/tmp/"
;
// Tmp dir exists but it is not writeable
if
(
access
(
path
.
c_str
(),
W_OK
)
!=
0
)
{
path
=
""
;
return
SC_PATHERROR
;
}
}
path
+=
std
::
string
(
SENSOR_CACHE_FILENAME
)
+
_clusterName
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment