From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Like VNC, allow to set credentials for RDP.
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
Reviewed-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_conf.c | 13 +++++++++++++
src/conf/domain_conf.h | 2 ++
src/conf/schemas/domaincommon.rng | 10 ++++++++++
3 files changed, 25 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dedcf76511..7e7b007b9d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1994,6 +1994,7 @@ virDomainGraphicsAuthDefClear(virDomainGraphicsAuthDef *def)
if (!def)
return;
+ VIR_FREE(def->username);
VIR_FREE(def->passwd);
/* Don't free def */
@@ -11319,6 +11320,8 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node,
if (!def->passwd)
return 0;
+ def->username = virXMLPropString(node, "username");
+
validTo = virXMLPropString(node, "passwdValidTo");
if (validTo) {
g_autoptr(GDateTime) then = NULL;
@@ -11708,6 +11711,10 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDef *def,
if (STREQ_NULLABLE(multiUser, "yes"))
def->data.rdp.multiUser = true;
+ if (virDomainGraphicsAuthDefParseXML(node, &def->data.rdp.auth,
+ def->type) < 0)
+ return -1;
+
return 0;
}
@@ -26306,6 +26313,10 @@ virDomainGraphicsAuthDefFormatAttr(virBuffer *buf,
if (!def->passwd)
return;
+ if (def->username)
+ virBufferEscapeString(buf, " username='%s'",
+ def->username);
+
if (flags & VIR_DOMAIN_DEF_FORMAT_SECURE)
virBufferEscapeString(buf, " passwd='%s'",
def->passwd);
@@ -26580,6 +26591,8 @@ virDomainGraphicsDefFormatRDP(virBuffer *attrBuf,
virDomainGraphicsListenDefFormatAddr(attrBuf, glisten, flags);
+ virDomainGraphicsAuthDefFormatAttr(attrBuf, &def->data.rdp.auth, flags);
+
virDomainGraphicsDefFormatListnes(childBuf, def, flags);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3a97fd866c..dd49cfd144 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1903,6 +1903,7 @@ typedef enum {
} virDomainGraphicsAuthConnectedType;
struct _virDomainGraphicsAuthDef {
+ char *username;
char *passwd;
bool expires; /* Whether there is an expiry time set */
time_t validTo; /* seconds since epoch */
@@ -2027,6 +2028,7 @@ struct _virDomainGraphicsDef {
bool autoport;
bool replaceUser;
bool multiUser;
+ virDomainGraphicsAuthDef auth;
} rdp;
struct {
char *display;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 3276569325..7ef45a1731 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -4540,6 +4540,16 @@
<ref name="addrIPorName"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="username">
+ <text/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="passwd">
+ <text/>
+ </attribute>
+ </optional>
<ref name="listenElements"/>
</group>
<group>
--
2.47.0