
On Mon, Sep 07, 2009 at 04:12:37PM +0200, Miloslav Trmač wrote:
Add a VIR_SECRET_GET_VALUE_INTERNAL_CALL flag value, replacing the originally separate libvirt_internal_call parameter. The flag is used to differentiate external virSecretGetValue() calls from internal calls by libvirt drivers that need to use the secret even if it is private.
* src/libvirt_internal.h (VIR_SECRET_GET_VALUE_FLAGS_MASK): New definition. * src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): New definition. * src/libvirt.c (virSecretGetValue): Don't allow the user to specify internal flags. * src/remote_internal.c (remoteSecretGetValue): Don't allow send internal flags over RPC.
Sounds fine,
+/* Make sure ... INTERNAL_CALL can not be set by the caller */ +verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL & + VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
??? what's that ? an assert at compile time ? I don't know that construct I would rather avoid it if it's not portable.
typedef virSecretPtr (*virDrvSecretLookupByUUIDString) (virConnectPtr conn, const char *uuid); diff --git a/src/libvirt.c b/src/libvirt.c index 45619e2..96d204c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -9066,6 +9066,8 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags) goto error; }
+ flags &= VIR_SECRET_GET_VALUE_FLAGS_MASK; + if (conn->secretDriver != NULL && conn->secretDriver->getValue != NULL) { unsigned char *ret;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 6976f34..60564d2 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,6 +27,9 @@ /* bits 16 and above of virDomainXMLFlags are for internal use */ #define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
+/* Bits 16 and above of virSecretGetValue flags are for internal use */ +#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0xffff + #ifdef WITH_LIBVIRTD int virStateInitialize(int privileged); int virStateCleanup(void); diff --git a/src/remote_internal.c b/src/remote_internal.c index 3dd4609..745b128 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -76,6 +76,7 @@ # define AI_ADDRCONFIG 0 #endif
+#include "libvirt_internal.h" #include "virterror_internal.h" #include "logging.h" #include "datatypes.h" @@ -6595,7 +6596,7 @@ remoteSecretGetValue (virSecretPtr secret, size_t *value_size, remoteDriverLock (priv);
make_nonnull_secret (&args.secret, secret); - args.flags = flags; + args.flags = flags & VIR_SECRET_GET_VALUE_FLAGS_MASK;
memset (&ret, 0, sizeof (ret)); if (call (secret->conn, priv, 0, REMOTE_PROC_SECRET_GET_VALUE,
Except that verify() surprise, patch looks fine to me. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/