aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjrb <jrb@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2004-08-16 19:07:30 +0000
committerjrb <jrb@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2004-08-16 19:07:30 +0000
commit1ad5ec46227854fa4685834dfb9b7ff3b8464d4c (patch)
tree3b9c734de2e42cf7d715241f3e205347343fc67c
parent61737a3fa4e41fb86b8f01f102494c69e3c0142a (diff)
Initial revision
git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@2 517b70f8-ed25-0410-8bf6-f5db08f7b76e
-rw-r--r--AUTHORS0
-rw-r--r--ChangeLog0
-rw-r--r--Makefile.am1
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh21
-rw-r--r--configure.ac44
-rw-r--r--po/ChangeLog11
-rw-r--r--po/Makefile.in.in254
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/krb5-auth-dialog.pot37
-rw-r--r--src/Makefile.am17
-rw-r--r--src/krb5-auth-dialog.c282
-rw-r--r--src/krb5-auth-dialog.glade253
14 files changed, 921 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..dd6709f
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src po
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..78d50ea
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+PKG_NAME=krb5-auth-dialog
+
+(test -f $srcdir/configure.ac \
+ && test -f $srcdir/src/krb5-auth-dialog.c) || {
+ echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+ echo " top-level $PKG_NAME directory"
+ exit 1
+}
+
+
+which gnome-autogen.sh || {
+ echo "You need to install gnome-common from the GNOME CVS"
+ exit 1
+}
+USE_GNOME2_MACROS=1 . gnome-autogen.sh
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..f274406
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,44 @@
+AC_INIT(src/krb5-auth-dialog.c)
+
+AM_INIT_AUTOMAKE(krb5-auth-dialog, 0.1)
+AM_CONFIG_HEADER(config.h)
+
+AM_MAINTAINER_MODE
+
+GETTEXT_PACKAGE=krb5-auth-dialog
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
+
+
+AC_PROG_CC
+AC_ISC_POSIX
+AC_HEADER_STDC
+AM_PROG_LIBTOOL
+AC_PROG_INTLTOOL
+
+ALL_LINGUAS=""
+AM_GLIB_GNU_GETTEXT
+
+PKG_CHECK_MODULES(GNOME,
+[
+ gtk+-2.0 >= 2.4.0
+ libglade-2.0 >= 2.4.0
+])
+
+AC_PATH_PROG([KRB5_CONFIG], krb5-config, none, $PATH:/usr/kerberos/bin)
+if test "x$KRB5_CONFIG" != "xnone"; then
+ KRB5_LIBS="`${KRB5_CONFIG} --libs krb5`"
+ KRB5_CFLAGS="`${KRB5_CONFIG} --cflags krb5`"
+ AC_SUBST(KRB5_CFLAGS)
+ AC_SUBST(KRB5_LIBS)
+fi
+
+
+CFLAGS="$GNOME_CFLAGS $KRB5_CFLAGS $CFLAGS"
+
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+po/Makefile.in
+])
diff --git a/po/ChangeLog b/po/ChangeLog
new file mode 100644
index 0000000..e352a9c
--- /dev/null
+++ b/po/ChangeLog
@@ -0,0 +1,11 @@
+2004-08-16 gettextize <bug-gnu-gettext@gnu.org>
+
+ * Makefile.in.in: New file, from gettext-0.14.1.
+ * boldquot.sed: New file, from gettext-0.14.1.
+ * en@boldquot.header: New file, from gettext-0.14.1.
+ * en@quot.header: New file, from gettext-0.14.1.
+ * insert-header.sin: New file, from gettext-0.14.1.
+ * quot.sed: New file, from gettext-0.14.1.
+ * remove-potcdate.sin: New file, from gettext-0.14.1.
+ * Rules-quot: New file, from gettext-0.14.1.
+
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
new file mode 100644
index 0000000..6d2cd50
--- /dev/null
+++ b/po/Makefile.in.in
@@ -0,0 +1,254 @@
+# Makefile for program source directory in GNU NLS utilities package.
+# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+#
+# - Modified by Owen Taylor <otaylor@redhat.com> to use GETTEXT_PACKAGE
+# instead of PACKAGE and to look for po2tbl in ./ not in intl/
+#
+# - Modified by jacob berkman <jacob@ximian.com> to install
+# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
+
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ..
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+datadir = @datadir@
+libdir = @libdir@
+localedir = $(libdir)/locale
+gnulocaledir = $(datadir)/locale
+gettextsrcdir = $(datadir)/glib-2.0/gettext/po
+subdir = po
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
+
+CC = @CC@
+GENCAT = @GENCAT@
+GMSGFMT = @GMSGFMT@
+MSGFMT = @MSGFMT@
+XGETTEXT = @XGETTEXT@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
+GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
+
+DEFS = @DEFS@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+
+INCLUDES = -I.. -I$(top_srcdir)/intl
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
+
+SOURCES =
+POFILES = @POFILES@
+GMOFILES = @GMOFILES@
+DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
+$(POFILES) $(GMOFILES) $(SOURCES)
+
+POTFILES = \
+
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+INSTOBJEXT = @INSTOBJEXT@
+
+.SUFFIXES:
+.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
+
+.c.o:
+ $(COMPILE) $<
+
+.po.pox:
+ $(MAKE) $(GETTEXT_PACKAGE).pot
+ $(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*pox
+
+.po.mo:
+ $(MSGFMT) -o $@ $<
+
+.po.gmo:
+ file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
+ && rm -f $$file && $(GMSGFMT) -o $$file $<
+
+.po.cat:
+ sed -f ../intl/po2msg.sed < $< > $*.msg \
+ && rm -f $@ && $(GENCAT) $@ $*.msg
+
+
+all: all-@USE_NLS@
+
+all-yes: $(CATALOGS)
+all-no:
+
+$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
+ $(GENPOT)
+
+install: install-exec install-data
+install-exec:
+install-data: install-data-@USE_NLS@
+install-data-no: all
+install-data-yes: all
+ if test -r "$(MKINSTALLDIRS)"; then \
+ $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
+ else \
+ $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
+ fi
+ @catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ case "$$cat" in \
+ *.gmo) destdir=$(gnulocaledir);; \
+ *) destdir=$(localedir);; \
+ esac; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
+ if test -r "$(MKINSTALLDIRS)"; then \
+ $(MKINSTALLDIRS) $$dir; \
+ else \
+ $(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
+ fi; \
+ if test -r $$cat; then \
+ $(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+ echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
+ else \
+ $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
+ fi; \
+ if test -r $$cat.m; then \
+ $(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ if test -r $(srcdir)/$$cat.m ; then \
+ $(INSTALL_DATA) $(srcdir)/$$cat.m \
+ $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ true; \
+ fi; \
+ fi; \
+ done
+ if test "$(PACKAGE)" = "glib"; then \
+ if test -r "$(MKINSTALLDIRS)"; then \
+ $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
+ else \
+ $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
+ fi; \
+ $(INSTALL_DATA) $(srcdir)/Makefile.in.in \
+ $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
+ else \
+ : ; \
+ fi
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall:
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+ rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+ rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+ rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+ done
+ if test "$(PACKAGE)" = "glib"; then \
+ rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
+ fi
+
+check: all
+
+dvi info tags TAGS ID:
+
+mostlyclean:
+ rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
+ rm -fr *.o
+ rm -f .intltool-merge-cache
+
+clean: mostlyclean
+
+distclean: clean
+ rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+ rm -f $(GMOFILES)
+
+distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: update-po $(DISTFILES)
+ dists="$(DISTFILES)"; \
+ for file in $$dists; do \
+ ln $(srcdir)/$$file $(distdir) 2> /dev/null \
+ || cp -p $(srcdir)/$$file $(distdir); \
+ done
+
+update-po: Makefile
+ $(MAKE) $(GETTEXT_PACKAGE).pot
+ tmpdir=`pwd`; \
+ cd $(srcdir); \
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ echo "$$lang:"; \
+ if $$tmpdir/$(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist -o $$tmpdir/$$lang.new.po $$lang; then \
+ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+ rm -f $$tmpdir/$$lang.new.po; \
+ else \
+ if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+ :; \
+ else \
+ echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+ rm -f $$tmpdir/$$lang.new.po; \
+ exit 1; \
+ fi; \
+ fi; \
+ else \
+ echo "msgmerge for $$cat failed!"; \
+ rm -f $$tmpdir/$$lang.new.po; \
+ fi; \
+ done
+
+# POTFILES is created from POTFILES.in by stripping comments, empty lines
+# and Intltool tags (enclosed in square brackets), and appending a full
+# relative path to them
+POTFILES: POTFILES.in
+ ( if test 'x$(srcdir)' != 'x.'; then \
+ posrcprefix='$(top_srcdir)/'; \
+ else \
+ posrcprefix="../"; \
+ fi; \
+ rm -f $@-t $@ \
+ && (sed -e '/^#/d' \
+ -e "s/^\[.*\] +//" \
+ -e '/^[ ]*$$/d' \
+ -e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
+ | sed -e '$$s/\\$$//') > $@-t \
+ && chmod a-w $@-t \
+ && mv $@-t $@ )
+
+Makefile: Makefile.in.in ../config.status POTFILES
+ cd .. \
+ && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
+ $(SHELL) ./config.status
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..59b6252
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1 @@
+src/krb5-auth-dialog.glade
diff --git a/po/krb5-auth-dialog.pot b/po/krb5-auth-dialog.pot
new file mode 100644
index 0000000..e5a000e
--- /dev/null
+++ b/po/krb5-auth-dialog.pot
@@ -0,0 +1,37 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2004-08-16 14:53-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/krb5-auth-dialog.glade.h:1
+msgid "*"
+msgstr ""
+
+#: src/krb5-auth-dialog.glade.h:2
+msgid "<span size=\"smaller\"> </span>"
+msgstr ""
+
+#: src/krb5-auth-dialog.glade.h:3
+msgid "Network Authentication"
+msgstr ""
+
+#: src/krb5-auth-dialog.glade.h:4
+msgid "_Password:"
+msgstr ""
+
+#: src/krb5-auth-dialog.glade.h:5
+msgid "_Renew Ticket"
+msgstr ""
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..abe9677
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = \
+ -DGLADEDIR=\""$(datadir)/krb5-auth-dialog/"\"
+
+bin_PROGRAMS = krb5-auth-dialog
+
+krb5_auth_dialog_SOURCES = \
+ krb5-auth-dialog.c
+
+krb5_auth_dialog_LDADD = @KRB5_LIBS@ @GNOME_LIBS@
+
+gladedir = $(datadir)/krb5-auth-dialog
+glade_DATA = \
+ krb5-auth-dialog.glade
+
+EXTRA_DIST = \
+ $(glade_DATA)
+
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c
new file mode 100644
index 0000000..42674d7
--- /dev/null
+++ b/src/krb5-auth-dialog.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2004 Red Hat, Inc.
+ * Authored by Christopher Aillon <caillon@redhat.com>
+ *
+ * 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, 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.
+ *
+ */
+
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <stdlib.h>
+#include <time.h>
+#include <krb5.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pwd.h>
+#include "config.h"
+
+#define CREDENTIAL_CHECK_INTERVAL 30000 /* milliseconds */
+#define SECONDS_BEFORE_PROMPTING 1800
+
+static GladeXML *xml = NULL;
+static krb5_context kcontext;
+static krb5_principal kprincipal;
+static char* defname = NULL;
+
+static int renew_credentials ();
+
+static int
+whoami (const char **username)
+{
+ struct passwd *p;
+ uid_t uid;
+
+ uid = geteuid();
+ if (!(p = getpwuid(uid))) {
+ return -1;
+ }
+
+ *username = p->pw_name;
+
+ return 0;
+}
+
+static void
+setup_dialog(GladeXML *xml, GtkWidget *dialog, gchar *prompt)
+{
+ GtkWidget *entry;
+ GtkWidget *label;
+
+ /* Clear the password entry field */
+ entry = glade_xml_get_widget(xml, "krb5_entry");
+ gtk_entry_set_text (GTK_ENTRY(entry), "");
+
+ /* Use the prompt label that krb5 provides us */
+ label = glade_xml_get_widget(xml, "krb5_message_label");
+ gtk_label_set_text(GTK_LABEL (label), prompt);
+
+ /* Only hide, and not destroy the dialog, so we can re-use it later. */
+ g_signal_connect(dialog, "response",
+ G_CALLBACK (gtk_widget_hide),
+ dialog);
+}
+
+static krb5_error_code
+KRB5_CALLCONV
+krb5_gtk_prompter(krb5_context ctx,
+ void *data,
+ const char *name,
+ const char *banner,
+ int num_prompts,
+ krb5_prompt prompts[])
+{
+ GtkWidget *dialog;
+ krb5_error_code errcode;
+ int i;
+
+ errcode = KRB5_LIBOS_CANTREADPWD;
+
+ dialog = glade_xml_get_widget(xml, "krb5_dialog");
+
+ for (i = 0; i < num_prompts; i++) {
+ const gchar *password = NULL;
+ int password_len = 0;
+ int response;
+
+ GtkWidget *entry;
+
+ errcode = KRB5_LIBOS_CANTREADPWD;
+
+ entry = glade_xml_get_widget(xml, "krb5_entry");
+ setup_dialog(xml, dialog, (gchar *)prompts[i].prompt);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ password = gtk_entry_get_text (GTK_ENTRY (entry));
+ password_len = strlen (password);
+ errcode = 0;
+ break;
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ prompts[i].reply->data = (char *)password;
+ prompts[i].reply->length = password_len;
+ }
+
+ return errcode;
+}
+
+static gboolean
+credentials_expiring_real (void)
+{
+ krb5_ccache cache = NULL;
+ krb5_cc_cursor cur;
+ krb5_creds my_creds;
+ krb5_principal princ;
+ krb5_flags flags;
+ krb5_error_code code;
+ int exit_status = 0;
+
+ gboolean retval = FALSE;
+
+ memset(&my_creds, 0, sizeof(my_creds));
+
+ code = krb5_init_context(&kcontext);
+ if (code) {
+ return FALSE;
+ }
+
+ if ((code = krb5_cc_default(kcontext, &cache))) {
+ return FALSE;
+ }
+
+ flags = 0; /* turns off OPENCLOSE mode */
+ if ((code = krb5_cc_set_flags(kcontext, cache, flags))) {
+ if (code == KRB5_FCC_NOFILE) {
+#ifdef KRB5_KRB4_COMPAT
+ if (name == NULL)
+ do_v4_ccache(0);
+#endif
+ }
+ exit(1);
+ }
+
+ if ((code = krb5_cc_get_principal(kcontext, cache, &princ))) {
+ exit(1);
+ }
+ if ((code = krb5_unparse_name(kcontext, princ, &defname))) {
+ exit(1);
+ }
+ if ((code = krb5_cc_start_seq_get(kcontext, cache, &cur))) {
+ exit(1);
+ }
+ while (!(code = krb5_cc_next_cred(kcontext, cache, &cur, &my_creds))) {
+ if (my_creds.times.endtime - time(0) < SECONDS_BEFORE_PROMPTING)
+ retval = TRUE;
+ krb5_free_cred_contents(kcontext, &my_creds);
+ }
+ if (code == KRB5_CC_END) {
+ if ((code = krb5_cc_end_seq_get(kcontext, cache, &cur))) {
+ exit(1);
+ }
+ flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode, from klist.c */
+ if ((code = krb5_cc_set_flags(kcontext, cache, flags))) {
+ exit(1);
+ }
+#ifdef KRB5_KRB4_COMPAT
+ if (name == NULL && !status_only)
+ do_v4_ccache(0);
+#endif
+ if (exit_status) exit(exit_status);
+ } else {
+ exit(1);
+ }
+
+ return retval;
+}
+
+static gboolean
+credentials_expiring (gpointer *data)
+{
+ if (credentials_expiring_real()) {
+ renew_credentials();
+ }
+ return TRUE;
+}
+
+static int
+renew_credentials (void)
+{
+ krb5_error_code retval;
+ krb5_get_init_creds_opt options;
+ krb5_creds my_creds;
+ krb5_ccache ccache;
+ const char *username;
+
+ memset(&my_creds, 0, sizeof(my_creds));
+ krb5_get_init_creds_opt_init(&options);
+
+ retval = krb5_init_context(&kcontext);
+ if (retval) {
+ return retval;
+ }
+
+ retval = whoami(&username);
+ if (retval) {
+ return retval;
+ }
+
+ retval = krb5_parse_name(kcontext, username, &kprincipal);
+ if (retval) {
+ return retval;
+ }
+
+ retval = krb5_get_init_creds_password(kcontext, &my_creds, kprincipal,
+ NULL, krb5_gtk_prompter, 0,
+ 0,
+ NULL,
+ &options);
+ if (retval) {
+ if (retval == KRB5KRB_AP_ERR_BAD_INTEGRITY) {
+ /* Invalid password, try again. */
+ return renew_credentials();
+ }
+ return retval;
+ }
+
+ retval = krb5_cc_default(kcontext, &ccache);
+ if (retval) {
+ return retval;
+ }
+
+ retval = krb5_cc_initialize(kcontext, ccache, kprincipal);
+ if (retval) {
+ return retval;
+ }
+
+ retval = krb5_cc_store_cred(kcontext, ccache, &my_creds);
+ if (retval) {
+ return retval;
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *dialog;
+
+ gtk_init(&argc, &argv);
+
+ xml = glade_xml_new(GLADEDIR "krb5-auth-dialog.glade", NULL, NULL);
+ dialog = glade_xml_get_widget(xml, "krb5_dialog");
+
+ g_timeout_add (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, NULL);
+ credentials_expiring (NULL);
+ gtk_main();
+
+ return 0;
+}
diff --git a/src/krb5-auth-dialog.glade b/src/krb5-auth-dialog.glade
new file mode 100644
index 0000000..72bc593
--- /dev/null
+++ b/src/krb5-auth-dialog.glade
@@ -0,0 +1,253 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkDialog" id="krb5_dialog">
+ <property name="border_width">6</property>
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Network Authentication</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="krb5_renew_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Renew Ticket</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-dialog-authentication</property>
+ <property name="icon_size">6</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">10</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="krb5_message_label">
+ <property name="width_request">333</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">3</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox5">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">3</property>
+
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Password:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">krb5_entry</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="krb5_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">False</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char" translatable="yes">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="krb5_wrong_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;span size=&quot;smaller&quot;&gt; &lt;/span&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>