提交 6fcbdf73 编写于 作者: J John Ferlan

secret: Generate configDir during driver initialization

Rather than waiting for the first save to fail, let's generate the
directory with the correct privs during initialization.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 24d33d18
......@@ -96,17 +96,6 @@ secretObjFromSecret(virSecretPtr secret)
}
static int
secretEnsureDirectory(void)
{
if (mkdir(driver->configDir, S_IRWXU) < 0 && errno != EEXIST) {
virReportSystemError(errno, _("cannot create '%s'"),
driver->configDir);
return -1;
}
return 0;
}
/* Driver functions */
static int
......@@ -237,9 +226,6 @@ secretDefineXML(virConnectPtr conn,
goto cleanup;
if (!def->isephemeral) {
if (secretEnsureDirectory() < 0)
goto cleanup;
if (backup && backup->isephemeral) {
if (virSecretObjSaveData(obj) < 0)
goto restore_backup;
......@@ -338,9 +324,6 @@ secretSetValue(virSecretPtr secret,
if (virSecretSetValueEnsureACL(secret->conn, def) < 0)
goto cleanup;
if (secretEnsureDirectory() < 0)
goto cleanup;
if (virSecretObjSetValue(obj, value, value_size) < 0)
goto cleanup;
......@@ -481,6 +464,12 @@ secretStateInitialize(bool privileged,
goto error;
VIR_FREE(base);
if (virFileMakePathWithMode(driver->configDir, S_IRWXU) < 0) {
virReportSystemError(errno, _("cannot create config directory '%s'"),
driver->configDir);
goto error;
}
if (!(driver->secrets = virSecretObjListNew()))
goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册