aboutsummaryrefslogtreecommitdiffstats
path: root/vnc-client.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2011-11-29 11:38:36 +0100
committerGerd Hoffmann <kraxel@redhat.com>2011-11-29 11:38:36 +0100
commit990c8197f467b12992ce77bfb275d93dd45924f9 (patch)
treecbce65ec06bb797cfd13a8e3f30a330a970f6ef9 /vnc-client.c
parent41a813cdbd22de82c2cdf57132170b10f5234034 (diff)
downloadxenwatch-990c8197f467b12992ce77bfb275d93dd45924f9.tar.gz
vnc-client: allow passing in username+password from the command line
Diffstat (limited to 'vnc-client.c')
-rw-r--r--vnc-client.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/vnc-client.c b/vnc-client.c
index d6db233..a4c833e 100644
--- a/vnc-client.c
+++ b/vnc-client.c
@@ -24,11 +24,13 @@ static void usage(FILE *fp)
"\n"
"usage: %s [options] display\n"
"options:\n"
- " -h Print this text.\n"
- " -d Enable debug output.\n"
- " -p Show mouse pointer.\n"
- " -f Start in fullscreen mode.\n"
- " -c Close on disconnect.\n"
+ " -h Print this text.\n"
+ " -d Enable debug output.\n"
+ " -p Show mouse pointer.\n"
+ " -f Start in fullscreen mode.\n"
+ " -c Close on disconnect.\n"
+ " -u <user> Set username.\n"
+ " -s <pass> Set password.\n"
"\n"
"-- \n"
"(c) 2006 Gerd Hoffmann <kraxel@redhat.com>\n",
@@ -39,7 +41,7 @@ int
main(int argc, char *argv[])
{
unsigned long vnc_flags = VNC_FLAG_STANDALONE;
- char hostname[65];
+ char hostname[65], *username = NULL, *password = NULL;
int port;
int debug = 0;
int c;
@@ -51,7 +53,7 @@ main(int argc, char *argv[])
++progname;
gtk_init(&argc, &argv);
- while ((c = getopt(argc, argv, "hdpfc")) != -1) {
+ while ((c = getopt(argc, argv, "hdpfcu:s:")) != -1) {
switch (c) {
case 'd':
debug++;
@@ -65,6 +67,12 @@ main(int argc, char *argv[])
case 'c':
vnc_flags |= VNC_FLAG_DISCONNECT_CLOSE;
break;
+ case 'u':
+ username = optarg;
+ break;
+ case 's':
+ password = optarg;
+ break;
case 'h':
usage(stdout);
exit(0);
@@ -108,8 +116,13 @@ main(int argc, char *argv[])
printf("Connecting to host '%s' port %d\n", hostname, port);
if (NULL == vnc_open(strlen(hostname) ? hostname : NULL,
- port, vnc_flags, debug))
+ port, vnc_flags, debug, username, password))
exit(1);
+ if (password) {
+ while (*password) {
+ *(password++) = '*';
+ }
+ }
gtk_main();
fprintf(stderr,"bye...\n");