From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: Re: [PATCH 6/6] libxl: vncviewer: make autopass work properly Date: Thu, 3 Feb 2011 12:39:12 +0000 Message-ID: References: <1296584702-20138-1-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-2-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-3-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-4-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-5-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-6-git-send-email-ian.jackson@eu.citrix.com> <1296584702-20138-7-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-path: In-Reply-To: <1296584702-20138-7-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Tue, 1 Feb 2011, Ian Jackson wrote: > The file we write the vnc password to must be rewound back to the > beginning, or the vnc viewer will simply get EOF. good catch > > When the syscalls for communicating the password to the vnc client > fail, bomb out with an error messsage rather than blundering on (and > probably producing a spurious password prompt). > > Following this patch, xl vncviewer --autopass works, provided the qemu > patch for writing the password to xenstore has also been applied. > > Signed-off-by: Ian Jackson > --- > tools/libxl/libxl.c | 25 +++++++++++++++++-------- > 1 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index b386a2a..5c1b3ab 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -827,23 +827,32 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass) > if ( vnc_pass ) { > char tmpname[] = "/tmp/vncautopass.XXXXXX"; > autopass_fd = mkstemp(tmpname); > - if ( autopass_fd < 0 ) > - goto skip_autopass; > + if ( autopass_fd < 0 ) { > + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > + "mkstemp %s failed", tmpname); > + exit(-1); > + } I don't think we should call exit here, this is a library not an executable. However instead of just skipping autopass we should avoid exec'ing vncviewer completely and return and error. > > - if ( unlink(tmpname) ) > + if ( unlink(tmpname) ) { > /* should never happen */ > - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unlink %s failed", tmpname); > + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > + "unlink %s failed", tmpname); > + exit(-1); > + } > ditto > if ( libxl_write_exactly(ctx, autopass_fd, vnc_pass, strlen(vnc_pass), > - tmpname, "vnc password") ) { > - do { close(autopass_fd); } while(errno == EINTR); > - goto skip_autopass; > + tmpname, "vnc password") ) > + exit(-1); ditto > + > + if ( lseek(autopass_fd, SEEK_SET, 0) ) { > + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > + "rewind %s (autopass) failed", tmpname); > + exit(-1); ditto > } > > args[2] = "-autopass"; > } > > -skip_autopass: > libxl__exec(autopass_fd, -1, -1, args[0], args); > abort(); > } > -- > 1.5.6.5 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >