From 990c8197f467b12992ce77bfb275d93dd45924f9 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 29 Nov 2011 11:38:36 +0100 Subject: vnc-client: allow passing in username+password from the command line --- vnc-client.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'vnc-client.c') 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 Set username.\n" + " -s Set password.\n" "\n" "-- \n" "(c) 2006 Gerd Hoffmann \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"); -- cgit