[libvirt] [PATCH 02/10] Add VIR_SECRET_GET_VALUE_INTERNAL_CALL.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 src/driver.h           |   12 ++++++++++++
 src/libvirt.c          |    2 ++
 src/libvirt_internal.h |    3 +++
 src/remote_internal.c  |    3 ++-
 4 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index 042c4af..28d7848 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -12,6 +12,8 @@
 #include <libxml/uri.h>
 
 #include "internal.h"
+#include "libvirt_internal.h"
+
 /*
  * List of registered drivers numbers
  */
@@ -802,6 +804,16 @@ struct _virDeviceMonitor {
     virDrvNodeDeviceDestroy deviceDestroy;
 };
 
+enum {
+    /* This getValue call is inside libvirt, override the "private" flag.
+       This flag can not be set by outside callers. */
+    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 16
+};
+
+/* 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);
+
 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,
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]