summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2014-04-25 09:11:51 +0200
committerJan Synacek <jsynacek@redhat.com>2014-04-28 08:52:12 +0200
commit4354a7f31b6ed6a0b8cf58d2bd3cc10945385a4f (patch)
treebec4e4d9d64d318965bd4fb172619be1576672b3 /src
parentf97b815a2f8ab34e61a38af416d9f876f61b42bd (diff)
downloadopenlmi-providers-4354a7f31b6ed6a0b8cf58d2bd3cc10945385a4f.tar.gz
openlmi-providers-4354a7f31b6ed6a0b8cf58d2bd3cc10945385a4f.tar.xz
openlmi-providers-4354a7f31b6ed6a0b8cf58d2bd3cc10945385a4f.zip
logicalfile: respect configuration when creating/removing directories
Diffstat (limited to 'src')
-rw-r--r--src/logicalfile/LMI_UnixDirectoryProvider.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/logicalfile/LMI_UnixDirectoryProvider.c b/src/logicalfile/LMI_UnixDirectoryProvider.c
index 65a5430..0f19cbb 100644
--- a/src/logicalfile/LMI_UnixDirectoryProvider.c
+++ b/src/logicalfile/LMI_UnixDirectoryProvider.c
@@ -90,8 +90,9 @@ static CMPIStatus LMI_UnixDirectoryCreateInstance(
check_status(st);
const char *path = get_string_property_from_op(iop, "Name");
+ bool allow = lmi_read_config_boolean("LMI_UnixDirectory", "AllowMkdir");
- if (mkdir(path, 0777) < 0) {
+ if (allow && mkdir(path, 0777) < 0) {
char errmsg[BUFLEN];
char strerr[BUFLEN];
snprintf(errmsg, BUFLEN, "Can't mkdir: %s (%s)",
@@ -99,6 +100,10 @@ static CMPIStatus LMI_UnixDirectoryCreateInstance(
strerror_r(errno, strerr, BUFLEN));
CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
}
+ if (allow == false) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED,
+ "Can't mkdir: disabled by provider configuration");
+ }
return CMReturnObjectPath(cr, iop);
}
@@ -121,8 +126,9 @@ static CMPIStatus LMI_UnixDirectoryDeleteInstance(
const CMPIObjectPath* cop)
{
const char *path = get_string_property_from_op(cop, "Name");
+ bool allow = lmi_read_config_boolean("LMI_UnixDirectory", "AllowRmdir");
- if (rmdir(path) < 0) {
+ if (allow && rmdir(path) < 0) {
char errmsg[BUFLEN];
char strerr[BUFLEN];
snprintf(errmsg, BUFLEN, "Can't rmdir: %s (%s)",
@@ -130,6 +136,10 @@ static CMPIStatus LMI_UnixDirectoryDeleteInstance(
strerror_r(errno, strerr, BUFLEN));
CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
}
+ if (allow == false) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED,
+ "Can't rmdir: disabled by provider configuration");
+ }
CMReturn(CMPI_RC_OK);
}
@@ -186,4 +196,5 @@ KONKRET_REGISTRATION(
/* vi: set et: */
/* Local Variables: */
/* indent-tabs-mode: nil */
+/* c-basic-offset: 4 */
/* End: */