mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-10 04:58:12 -05:00
conf: Add new secret type "passphrase"
Add a new secret type known as "passphrase" - it will handle adding the
secret objects that need a passphrase without a specific username.
The format is:
<secret ...>
<uuid>...</uuid>
...
<usage type='passphrase'>
<name>mumblyfratz</name>
</usage>
</secret>
Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
@@ -338,6 +338,19 @@ virAccessDriverPolkitCheckSecret(virAccessManagerPtr manager,
|
||||
virAccessPermSecretTypeToString(perm),
|
||||
attrs);
|
||||
} break;
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE: {
|
||||
const char *attrs[] = {
|
||||
"connect_driver", driverName,
|
||||
"secret_uuid", uuidstr,
|
||||
"secret_usage_name", secret->usage.name,
|
||||
NULL,
|
||||
};
|
||||
|
||||
return virAccessDriverPolkitCheck(manager,
|
||||
"secret",
|
||||
virAccessPermSecretTypeToString(perm),
|
||||
attrs);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-1
@@ -29,6 +29,7 @@
|
||||
#include "viralloc.h"
|
||||
#include "secret_conf.h"
|
||||
#include "virsecretobj.h"
|
||||
#include "virstring.h"
|
||||
#include "virerror.h"
|
||||
#include "virxml.h"
|
||||
#include "viruuid.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
VIR_LOG_INIT("conf.secret_conf");
|
||||
|
||||
VIR_ENUM_IMPL(virSecretUsage, VIR_SECRET_USAGE_TYPE_LAST,
|
||||
"none", "volume", "ceph", "iscsi")
|
||||
"none", "volume", "ceph", "iscsi", "passphrase")
|
||||
|
||||
const char *
|
||||
virSecretUsageIDForDef(virSecretDefPtr def)
|
||||
@@ -56,6 +57,9 @@ virSecretUsageIDForDef(virSecretDefPtr def)
|
||||
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||
return def->usage.target;
|
||||
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE:
|
||||
return def->usage.name;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -85,6 +89,10 @@ virSecretDefFree(virSecretDefPtr def)
|
||||
VIR_FREE(def->usage.target);
|
||||
break;
|
||||
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE:
|
||||
VIR_FREE(def->usage.name);
|
||||
break;
|
||||
|
||||
default:
|
||||
VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
|
||||
break;
|
||||
@@ -145,6 +153,14 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE:
|
||||
if (!(def->usage.name = virXPathString("string(./usage/name)", ctxt))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("passphrase usage specified, but name is missing"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected secret usage type %d"),
|
||||
@@ -297,6 +313,10 @@ virSecretDefFormatUsage(virBufferPtr buf,
|
||||
virBufferEscapeString(buf, "<target>%s</target>\n", def->usage.target);
|
||||
break;
|
||||
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE:
|
||||
virBufferEscapeString(buf, "<name>%s</name>\n", def->usage.name);
|
||||
break;
|
||||
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected secret usage type %d"),
|
||||
|
||||
@@ -40,6 +40,7 @@ struct _virSecretDef {
|
||||
char *volume; /* May be NULL */
|
||||
char *ceph;
|
||||
char *target;
|
||||
char *name;
|
||||
} usage;
|
||||
};
|
||||
|
||||
|
||||
@@ -237,6 +237,11 @@ virSecretObjSearchName(const void *payload,
|
||||
if (STREQ(secret->def->usage.target, data->usageID))
|
||||
found = 1;
|
||||
break;
|
||||
|
||||
case VIR_SECRET_USAGE_TYPE_PASSPHRASE:
|
||||
if (STREQ(secret->def->usage.name, data->usageID))
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
Reference in New Issue
Block a user