All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leandro Dardini <ldardini@tiscali.it>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Let user set vnc password from command line or file
Date: Sun, 06 Jan 2008 11:45:58 +0100	[thread overview]
Message-ID: <4780B166.6010701@tiscali.it> (raw)

Here is a little patch to let the user specify the vnc server password 
in the command line (yes, it is visible with the ps command) or via an 
external file (better choice). This adds two new arguments, 
-vnc-password and -vnc-password-file. The file containing the vnc 
password is in clear.

Please let me know if there is any writing rule I was not following, 
I'll be glad to modify the patch accordingly. I was doubtful whether to 
use a straight fopen or the QEMU_fopen. Let me know the difference.

Thank you

Leandro

diff -u -p vl.c.orig vl.c
--- vl.c.orig   2008-01-05 01:17:53.000000000 +0100
+++ vl.c        2008-01-06 12:17:11.000000000 +0100
@@ -7606,6 +7606,8 @@ static void help(int exitcode)
            "-no-reboot      exit instead of rebooting\n"
            "-loadvm file    start right away with a saved state (loadvm 
in monitor)\n"
           "-vnc display    start a VNC server on display\n"
+          "-vnc-password password    set VNC server password\n"
+          "-vnc-password-file file   set VNC server password (in clear) 
from file\n"
 #ifndef _WIN32
           "-daemonize      daemonize QEMU after initializing\n"
 #endif
@@ -7717,6 +7719,8 @@ enum {
     QEMU_OPTION_old_param,
     QEMU_OPTION_clock,
     QEMU_OPTION_startdate,
+    QEMU_OPTION_vnc_password,
+    QEMU_OPTION_vnc_password_file,
 };

 typedef struct QEMUOption {
@@ -7803,6 +7807,8 @@ const QEMUOption qemu_options[] = {
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
+    { "vnc-password", HAS_ARG, QEMU_OPTION_vnc_password },
+    { "vnc-password-file", HAS_ARG, QEMU_OPTION_vnc_password_file },

     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -8085,6 +8091,9 @@ int main(int argc, char **argv)
     int fds[2];
     const char *pid_file = NULL;
     VLANState *vlan;
+    char vnc_password[9];
+    FILE *fd_vnc_password_file;
+    const char *vnc_password_file = NULL;

     LIST_INIT (&vm_change_state_head);
 #ifndef _WIN32
@@ -8580,6 +8589,13 @@ int main(int argc, char **argv)
            case QEMU_OPTION_vnc:
                vnc_display = optarg;
                break;
+           case QEMU_OPTION_vnc_password:
+               strncpy(vnc_password,optarg,8);
+               vnc_password[8] = '\0';
+                break;
+           case QEMU_OPTION_vnc_password_file:
+               vnc_password_file = optarg;
+               break;
             case QEMU_OPTION_no_acpi:
                 acpi_enabled = 0;
                 break;
@@ -8849,8 +8865,21 @@ int main(int argc, char **argv)
         dumb_display_init(ds);
     } else if (vnc_display != NULL) {
         vnc_display_init(ds);
+       if (vnc_password_file != NULL) {
+         fd_vnc_password_file = fopen(vnc_password_file, "r");
+         if (!fd_vnc_password_file) {
+           fprintf(stderr, "qemu: could not open vnc server password 
file '%s'\n", vnc_password_file);
+           exit(1);
+         }
+         fgets(vnc_password,9,fd_vnc_password_file);
+         if (vnc_password[strlen(vnc_password) - 1] == '\n')
+           vnc_password[strlen(vnc_password) - 1] = '\0';
+         fclose(fd_vnc_password_file);
+       }
+       if (vnc_password && vnc_password[0])
+         vnc_display_password(NULL,vnc_password);
         if (vnc_display_open(ds, vnc_display) < 0)
-            exit(1);
+         exit(1);
     } else {
 #if defined(CONFIG_SDL)
         sdl_display_init(ds, full_screen, no_frame);

             reply	other threads:[~2008-01-06 10:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-06 10:45 Leandro Dardini [this message]
2008-01-06 16:44 ` [Qemu-devel] [PATCH] Let user set vnc password from command line or file Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4780B166.6010701@tiscali.it \
    --to=ldardini@tiscali.it \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.