vino r867 - in trunk: . po tools
- From: jwendell svn gnome org
- To: svn-commits-list gnome org
- Subject: vino r867 - in trunk: . po tools
- Date: Thu, 17 Jul 2008 18:32:03 +0000 (UTC)
Author: jwendell
Date: Thu Jul 17 18:32:02 2008
New Revision: 867
URL: http://svn.gnome.org/viewvc/vino?rev=867&view=rev
Log:
2008-07-06 Jorge Pereira <jorge jorgepereira com br>
* Makefile.am:
* configure.in:
* tools/Makefile.am:
* tools/vino-passwd.c:
* po/POTFILES.in:
* configure.in:
Added a tool to change Vino password, similar to Unix passwd command.
Closes #540853.
Added:
trunk/tools/ (props changed)
trunk/tools/Makefile.am
trunk/tools/vino-passwd.c
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
trunk/po/POTFILES.in
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Thu Jul 17 18:32:02 2008
@@ -1,4 +1,4 @@
-SUBDIRS = server capplet session docs po
+SUBDIRS = server capplet session tools docs po
EXTRA_DIST = \
MAINTAINERS \
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Jul 17 18:32:02 2008
@@ -47,6 +47,8 @@
PKG_CHECK_MODULES(VINO_CAPPLET, glib-2.0 >= 2.12.0 gtk+-2.0 >= 2.10.0 gconf-2.0 libglade-2.0 libgnomeui-2.0 dbus-glib-1)
+PKG_CHECK_MODULES(VINO_TOOLS, glib-2.0 >= 2.12.0 gconf-2.0)
+
dnl --enable-libnotify=(yes|no|auto)
LIBNOTIFY_VERSION=0.4.4
@@ -270,7 +272,7 @@
AC_SUBST(LIBZ)
AC_SUBST(LIBJPEG)
-AC_CHECK_HEADERS([netinet/in.h sys/time.h fcntl.h unistd.h sys/socket.h])
+AC_CHECK_HEADERS([netinet/in.h sys/time.h fcntl.h unistd.h sys/socket.h signal.h])
AC_CHECK_FUNCS([gettimeofday])
dnl
@@ -336,6 +338,7 @@
server/libvncserver/rfb/Makefile
capplet/Makefile
session/Makefile
+tools/Makefile
docs/Makefile
po/Makefile.in
])
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Thu Jul 17 18:32:02 2008
@@ -14,3 +14,4 @@
server/vino-status-icon.c
server/vino-util.c
session/vino-session.c
+tools/vino-passwd.c
Added: trunk/tools/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/tools/Makefile.am Thu Jul 17 18:32:02 2008
@@ -0,0 +1,18 @@
+NULL =
+
+INCLUDES = \
+ -DVINO_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ $(VINO_TOOLS_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(NULL)
+
+bin_PROGRAMS = vino-passwd
+
+vino_passwd_SOURCES = \
+ vino-passwd.c \
+ $(NULL)
+
+vino_passwd_LDADD = \
+ $(VINO_TOOLS_LIBS) \
+ $(NULL)
+
Added: trunk/tools/vino-passwd.c
==============================================================================
--- (empty file)
+++ trunk/tools/vino-passwd.c Thu Jul 17 18:32:02 2008
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2008 Jorge Pereira <jorge jorgepereira com br>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Jorge Pereira <jorge jorgepereira com br>
+ */
+
+#include <config.h>
+
+#define _GNU_SOURCE 1
+
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libintl.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+
+#ifdef VINO_ENABLE_KEYRING
+#include <gnome-keyring.h>
+#endif
+
+#define VINO_PREFS_DIR "/desktop/gnome/remote_access"
+#define VINO_PREFS_VNC_PASSWORD VINO_PREFS_DIR "/vnc_password"
+#define VINO_PASSWORD_MAXLEN 8
+
+static gboolean
+vino_passwd_set_password_in_keyring (const char *password)
+{
+#ifdef VINO_ENABLE_KEYRING
+ GnomeKeyringResult result;
+ guint32 item_id;
+
+ result = gnome_keyring_set_network_password_sync (
+ NULL, /* default keyring */
+ NULL, /* user */
+ NULL, /* domain */
+ "vino.local", /* server */
+ NULL, /* object */
+ "rfb", /* protocol */
+ "vnc-password", /* authtype */
+ 5900, /* port */
+ password, /* password */
+ &item_id);
+
+ return result == GNOME_KEYRING_RESULT_OK;
+#else
+ return FALSE;
+#endif
+}
+
+static void
+vino_passwd_set_password (GConfClient *conf,
+ const char *password)
+{
+ gchar *password_b64;
+
+ if (vino_passwd_set_password_in_keyring (password))
+ return;
+
+ password_b64 = g_base64_encode ((guchar *) password, strlen (password));
+ gconf_client_set_string (conf, VINO_PREFS_VNC_PASSWORD, password_b64, NULL);
+ g_free (password_b64);
+}
+
+static void
+vino_passwd_read (char *buff,
+ const size_t len,
+ const char *prompt_msg)
+{
+ struct termios told, tnew;
+ size_t pos = 0;
+ gboolean again = FALSE;
+
+ tcgetattr (STDIN_FILENO, &told);
+ tnew = told;
+ tnew.c_lflag &= ~(ICANON | ECHO | ISIG);
+ tnew.c_iflag &= ~(IXON | IXOFF);
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &tnew);
+
+ g_print (prompt_msg);
+
+ do
+ {
+ char key;
+
+ read (STDIN_FILENO, &key, 1);
+
+ if (key == 0x03) /* Ctrl + C */
+ kill (0, SIGQUIT);
+ else if (again && key == '\n')
+ {
+ g_printerr ("\n");
+ g_printerr (_("ERROR: Maximum length of password is %d characters. Please, re-enter the password.\n"), VINO_PASSWORD_MAXLEN);
+ g_print (prompt_msg);
+
+ pos = 0;
+ again = FALSE;
+ }
+ else if (pos > 0 && key == '\n')
+ break;
+ else if (pos > 0 && key == 0x7f) /* 0x7f - <BACKSPACE> */
+ pos--;
+ else if (key == '\n' || key == 0x7f)
+ continue;
+ else if (pos >= len -1)
+ again = TRUE;
+ else
+ buff[pos++] = key;
+ }
+ while (TRUE);
+ buff[pos] = '\0';
+
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &told);
+ fflush (stdout);
+}
+
+static void
+vino_passwd_change (GConfClient *conf)
+{
+ gchar password1[VINO_PASSWORD_MAXLEN + 1];
+ gchar password2[VINO_PASSWORD_MAXLEN + 1];
+
+ g_print (_("Changing Vino password.\n"));
+
+ vino_passwd_read (password1, sizeof(password1), _("Enter new Vino password: "));
+ g_print ("\n");
+
+ vino_passwd_read (password2, sizeof(password2), _("Retype new Vino password: "));
+ g_print ("\n");
+
+ if (!g_strcasecmp (password1, password2))
+ {
+ vino_passwd_set_password (conf, password1);
+ g_print (_("vino-passwd: password updated successfully.\n"));
+ }
+ else
+ {
+ g_printerr (_("Sorry, passwords do not match.\n"));
+ g_printerr (_("vino-passwd: password unchanged.\n"));
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ gboolean opt_version = FALSE;
+ GError *error = NULL;
+ GConfClient *conf = NULL;
+ GOptionContext *context = NULL;
+
+ const GOptionEntry entries[] =
+ {
+ {
+ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, _("Show Vino version"), NULL
+ },
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, VINO_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ context = g_option_context_new (_("- Updates Vino password"));
+ g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_set_help_enabled (context, TRUE);
+ g_option_context_parse (context, &argc, &argv, &error);
+ g_option_context_free (context);
+
+ if (error)
+ {
+ g_print ("%s\n%s\n",
+ error->message,
+ _("Run 'vino-passwd --help' to see a full list of available command line options"));
+ g_error_free (error);
+ return 1;
+ }
+
+ if (opt_version)
+ {
+ g_print (_("VINO Version %s\n"), VERSION);
+ return 0;
+ }
+
+ conf = gconf_client_get_default ();
+
+ if (gconf_client_key_is_writable (conf, VINO_PREFS_VNC_PASSWORD, NULL))
+ vino_passwd_change (conf);
+ else
+ g_printerr (_("ERROR: You do not have enough permissions to change Vino password.\n"));
+
+ g_object_unref (conf);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]