summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-03-04 10:57:01 +0100
committerUri Lublin <uril@redhat.com>2010-03-08 04:15:34 +0200
commit5baae1c7a08c5eb1f0076df05f41843b4532ee49 (patch)
tree3be61bff76877f9c18b6e32140e7d5a5551fe141
parent5ea2893e3cf6f99c7f2a8b62736871068def2b49 (diff)
downloadspice-5baae1c7a08c5eb1f0076df05f41843b4532ee49.tar.gz
spice-5baae1c7a08c5eb1f0076df05f41843b4532ee49.tar.xz
spice-5baae1c7a08c5eb1f0076df05f41843b4532ee49.zip
new libspice api: configure port + ticket
Add new functions to configure spice port and ticketing. Yes, this is incomplete, it includes just the most important bits to get something up'n'running. These functions are supposed to replace both spice_parse_args() and the monitor interaction via qterm interface. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--server/reds.c46
-rw-r--r--server/spice.h5
2 files changed, 51 insertions, 0 deletions
diff --git a/server/reds.c b/server/reds.c
index f6447cd0..35b1a164 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -5493,3 +5493,49 @@ void spice_server_destroy(SpiceServer *s)
ASSERT(reds == s);
reds_exit();
}
+
+int spice_server_set_port(SpiceServer *s, int port)
+{
+ ASSERT(reds == s);
+ if (port < 0 || port > 0xffff)
+ return -1;
+ spice_port = port;
+ return 0;
+}
+
+int spice_server_set_noauth(SpiceServer *s)
+{
+ ASSERT(reds == s);
+ memset(taTicket.password, 0, sizeof(taTicket.password));
+ ticketing_enabled = 0;
+ return 0;
+}
+
+int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
+ int fail_if_connected, int disconnect_if_connected)
+{
+ ASSERT(reds == s);
+
+ if (reds->peer) {
+ if (fail_if_connected)
+ return -1;
+ if (disconnect_if_connected)
+ reds_disconnect();
+ }
+
+ on_activating_ticketing();
+ ticketing_enabled = 1;
+ if (lifetime == 0) {
+ taTicket.expiration_time = INT_MAX;
+ } else {
+ time_t now = time(NULL);
+ taTicket.expiration_time = now + lifetime;
+ }
+ if (passwd != NULL) {
+ strncpy(taTicket.password, passwd, sizeof(taTicket.password));
+ } else {
+ memset(taTicket.password, 0, sizeof(taTicket.password));
+ taTicket.expiration_time = 0;
+ }
+ return 0;
+}
diff --git a/server/spice.h b/server/spice.h
index 49a52a8d..b8a476e1 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -32,4 +32,9 @@ SpiceServer *spice_server_new(void);
int spice_server_init(SpiceServer *s, CoreInterface *core);
void spice_server_destroy(SpiceServer *s);
+int spice_server_set_port(SpiceServer *s, int port);
+int spice_server_set_noauth(SpiceServer *s);
+int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
+ int fail_if_connected, int disconnect_if_connected);
+
#endif