summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-03-09 14:18:20 +0100
committerAlexander Larsson <alexl@redhat.com>2010-03-09 14:18:20 +0100
commit4e014aa13f93c96c37765b73e18fff5da8637847 (patch)
treec7a746b614217836b7d8b8de9a4a5d19a496cac5 /server
parent232dbd8710dc75328c9991d84b323e0cac601562 (diff)
downloadspice-4e014aa13f93c96c37765b73e18fff5da8637847.tar.gz
spice-4e014aa13f93c96c37765b73e18fff5da8637847.tar.xz
spice-4e014aa13f93c96c37765b73e18fff5da8637847.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.
Diffstat (limited to 'server')
-rw-r--r--server/reds.c49
-rw-r--r--server/spice.h5
2 files changed, 54 insertions, 0 deletions
diff --git a/server/reds.c b/server/reds.c
index 8e5f935d..0ff21d40 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -5504,3 +5504,52 @@ 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