From patchwork Tue Nov 30 13:22:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 73816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C312DB7080 for ; Thu, 2 Dec 2010 00:18:42 +1100 (EST) Received: from localhost ([127.0.0.1]:45248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNmZu-0006Mz-OG for incoming@patchwork.ozlabs.org; Wed, 01 Dec 2010 08:18:34 -0500 Received: from [140.186.70.92] (port=53328 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNegi-0001Ou-Sh for qemu-devel@nongnu.org; Tue, 30 Nov 2010 23:53:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNQAi-0004IJ-Cx for qemu-devel@nongnu.org; Tue, 30 Nov 2010 08:23:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43340) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNQAi-0004Ed-2r for qemu-devel@nongnu.org; Tue, 30 Nov 2010 08:23:04 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAUDN2ag006961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Nov 2010 08:23:02 -0500 Received: from rincewind.home.kraxel.org (vpn1-7-174.ams2.redhat.com [10.36.7.174]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAUDN0CF017910; Tue, 30 Nov 2010 08:23:01 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 839A7453E0; Tue, 30 Nov 2010 14:22:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 30 Nov 2010 14:22:58 +0100 Message-Id: <1291123379-3101-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1291123379-3101-1-git-send-email-kraxel@redhat.com> References: <1291123379-3101-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 2/3] vnc: support password expire X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds support for expiring passwords to vnc. It adds a new vnc_display_pw_expire() function which specifies the time when the password will expire. Signed-off-by: Gerd Hoffmann --- console.h | 1 + qemu-common.h | 3 +++ ui/vnc.c | 14 ++++++++++++++ ui/vnc.h | 1 + 4 files changed, 19 insertions(+), 0 deletions(-) diff --git a/console.h b/console.h index aafb031..b2fc908 100644 --- a/console.h +++ b/console.h @@ -369,6 +369,7 @@ void vnc_display_init(DisplayState *ds); void vnc_display_close(DisplayState *ds); int vnc_display_open(DisplayState *ds, const char *display); int vnc_display_password(DisplayState *ds, const char *password); +int vnc_display_pw_expire(DisplayState *ds, time_t expires); void do_info_vnc_print(Monitor *mon, const QObject *data); void do_info_vnc(Monitor *mon, QObject **ret_data); char *vnc_display_local_addr(DisplayState *ds); diff --git a/qemu-common.h b/qemu-common.h index b3957f1..d0ab116 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -50,6 +50,9 @@ typedef struct DeviceState DeviceState; #if !defined(ENOTSUP) #define ENOTSUP 4096 #endif +#ifndef TIME_MAX +#define TIME_MAX LONG_MAX +#endif #ifndef CONFIG_IOVEC #define CONFIG_IOVEC diff --git a/ui/vnc.c b/ui/vnc.c index da70757..495d6d6 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2082,11 +2082,16 @@ static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len) unsigned char response[VNC_AUTH_CHALLENGE_SIZE]; int i, j, pwlen; unsigned char key[8]; + time_t now = time(NULL); if (!vs->vd->password || !vs->vd->password[0]) { VNC_DEBUG("No password configured on server"); goto reject; } + if (vs->vd->expires < now) { + VNC_DEBUG("Password is expired"); + goto reject; + } memcpy(response, vs->challenge, VNC_AUTH_CHALLENGE_SIZE); @@ -2432,6 +2437,7 @@ void vnc_display_init(DisplayState *ds) vs->ds = ds; QTAILQ_INIT(&vs->clients); + vs->expires = TIME_MAX; if (keyboard_layout) vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout); @@ -2503,6 +2509,14 @@ int vnc_display_password(DisplayState *ds, const char *password) return 0; } +int vnc_display_pw_expire(DisplayState *ds, time_t expires) +{ + VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; + + vs->expires = expires; + return 0; +} + char *vnc_display_local_addr(DisplayState *ds) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; diff --git a/ui/vnc.h b/ui/vnc.h index 9619b24..4f895be 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -120,6 +120,7 @@ struct VncDisplay char *display; char *password; + time_t expires; int auth; bool lossy; #ifdef CONFIG_VNC_TLS