ia64/xen-unstable

changeset 16868:05e36e506c09

ioemu: handle empty vnc passwd
Have xenstore_read_vncpasswd return -1 when it is unable to read the
passwd from XenStore (and store an empty password). However, don't
exit in such case since it may just mean that the use didn't set a
passwd. If he really did, xend would have given the passwd flag in the
-vnc option, and the empty passwd would make the vnc authentication
reject any password anyway.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 23 18:12:37 2008 +0000 (2008-01-23)
parents ed540d61339e
children db620f1c9d30
files tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/xenstore.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Wed Jan 23 18:05:27 2008 +0000
     1.2 +++ b/tools/ioemu/vl.c	Wed Jan 23 18:12:37 2008 +0000
     1.3 @@ -7756,8 +7756,7 @@ int main(int argc, char **argv)
     1.4  	int vnc_display_port;
     1.5  	char password[20];
     1.6  	vnc_display_init(ds);
     1.7 -	if (xenstore_read_vncpasswd(domid, password, sizeof(password)) < 0)
     1.8 -	    exit(0);
     1.9 +	xenstore_read_vncpasswd(domid, password, sizeof(password));
    1.10  	vnc_display_password(ds, password);
    1.11  	if ((vnc_display_port = vnc_display_open(ds, vnc_display, vncunused)) < 0) 
    1.12  	    exit (0);
     2.1 --- a/tools/ioemu/vl.h	Wed Jan 23 18:05:27 2008 +0000
     2.2 +++ b/tools/ioemu/vl.h	Wed Jan 23 18:12:37 2008 +0000
     2.3 @@ -1463,7 +1463,7 @@ void xenstore_process_event(void *opaque
     2.4  void xenstore_record_dm_state(char *state);
     2.5  void xenstore_check_new_media_present(int timeout);
     2.6  void xenstore_write_vncport(int vnc_display);
     2.7 -int xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen);
     2.8 +void xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen);
     2.9  
    2.10  int xenstore_domain_has_devtype(struct xs_handle *handle,
    2.11                                  const char *devtype);
     3.1 --- a/tools/ioemu/xenstore.c	Wed Jan 23 18:05:27 2008 +0000
     3.2 +++ b/tools/ioemu/xenstore.c	Wed Jan 23 18:12:37 2008 +0000
     3.3 @@ -489,19 +489,20 @@ void xenstore_write_vncport(int display)
     3.4      free(buf);
     3.5  }
     3.6  
     3.7 -int xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen)
     3.8 +void xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen)
     3.9  {
    3.10      char *buf = NULL, *path, *uuid = NULL, *passwd = NULL;
    3.11      unsigned int i, len, rc = 0;
    3.12  
    3.13 -    if (xsh == NULL) {
    3.14 -        return -1;
    3.15 -    }
    3.16 +    pwbuf[0] = '\0';
    3.17 +
    3.18 +    if (xsh == NULL)
    3.19 +        return;
    3.20  
    3.21      path = xs_get_domain_path(xsh, domid);
    3.22      if (path == NULL) {
    3.23          fprintf(logfile, "xs_get_domain_path() error. domid %d.\n", domid);
    3.24 -        return -1;
    3.25 +        return;
    3.26      }
    3.27  
    3.28      pasprintf(&buf, "%s/vm", path);
    3.29 @@ -509,35 +510,29 @@ int xenstore_read_vncpasswd(int domid, c
    3.30      if (uuid == NULL) {
    3.31          fprintf(logfile, "xs_read(): uuid get error. %s.\n", buf);
    3.32          free(path);
    3.33 -        return -1;
    3.34 +        return;
    3.35      }
    3.36  
    3.37      pasprintf(&buf, "%s/vncpasswd", uuid);
    3.38      passwd = xs_read(xsh, XBT_NULL, buf, &len);
    3.39      if (passwd == NULL) {
    3.40          fprintf(logfile, "xs_read(): vncpasswd get error. %s.\n", buf);
    3.41 -        pwbuf[0] = '\0';
    3.42          free(uuid);
    3.43          free(path);
    3.44 -        return rc;
    3.45 +        return;
    3.46      }
    3.47  
    3.48 -    for (i=0; i<len && i<pwbuflen; i++) {
    3.49 +    for (i=0; i<len && i<pwbuflen; i++)
    3.50          pwbuf[i] = passwd[i];
    3.51 -    }
    3.52      pwbuf[len < (pwbuflen-1) ? len : (pwbuflen-1)] = '\0';
    3.53      passwd[0] = '\0';
    3.54      pasprintf(&buf, "%s/vncpasswd", uuid);
    3.55 -    if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) {
    3.56 +    if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0)
    3.57          fprintf(logfile, "xs_write() vncpasswd failed.\n");
    3.58 -        rc = -1;
    3.59 -    }
    3.60  
    3.61      free(passwd);
    3.62      free(uuid);
    3.63      free(path);
    3.64 -
    3.65 -    return rc;
    3.66  }
    3.67  
    3.68