[kredentials] Adding renewal timer option

Neil Horman nhorman at fedoraproject.org
Thu Jun 28 13:28:45 UTC 2012


commit bceb93e44c836282fc511081e20bab0ae05c1424
Author: Neil Horman <nhorman at tuxdriver.com>
Date:   Thu Jun 28 09:28:34 2012 -0400

    Adding renewal timer option

 kredentials-renew-option.patch |  120 ++++++++++++++++++++++++++++++++++++++++
 kredentials.spec               |    7 ++-
 2 files changed, 126 insertions(+), 1 deletions(-)
---
diff --git a/kredentials-renew-option.patch b/kredentials-renew-option.patch
new file mode 100644
index 0000000..d0d86aa
--- /dev/null
+++ b/kredentials-renew-option.patch
@@ -0,0 +1,120 @@
+diff -up kredentials-2.0-pre3/kredentials.1.orig kredentials-2.0-pre3/kredentials.1
+--- kredentials-2.0-pre3/kredentials.1.orig	2012-06-28 07:46:46.311834603 -0400
++++ kredentials-2.0-pre3/kredentials.1	2012-06-28 07:47:36.294228059 -0400
+@@ -40,6 +40,9 @@ Inform the user via a KDE "passive dialo
+ .TP
+ \-d|--disable-aklog
+ Don't run aklog to get new AFS tokens when renewing Kerberos creds.
++.TP
++\-r|--renew
++Set the renewal time in seconds.  Setting a time of 0 disables ticket renewal
+ .SH BUGS
+ There aren't really any major bugs, but the feature list can and should
+ be expanded.
+diff -up kredentials-2.0-pre3/src/kredentials.cpp.orig kredentials-2.0-pre3/src/kredentials.cpp
+--- kredentials-2.0-pre3/src/kredentials.cpp.orig	2012-01-29 14:48:32.000000000 -0500
++++ kredentials-2.0-pre3/src/kredentials.cpp	2012-06-28 07:46:35.245526093 -0400
+@@ -57,6 +57,12 @@
+ #define LOG kDebugDevNull()
+ #endif /*DEBUG*/
+ 
++/*
++ * Since our timer runs in ms, we can wait more than
++ * MAX_INT/1000 seconds
++ */
++#define MAX_RENEWAL_TIME (INT_MAX / 1000)
++
+ kredentials::kredentials(int notify)
+     : KSystemTrayIcon(),tixmgr(){
+     // set the shell's ui resource file
+@@ -100,7 +106,8 @@ kredentials::kredentials(int notify)
+ 	
+     timer = new QTimer(this);
+     connect(timer, SIGNAL(timeout()), this, SLOT(ticketTimerEvent()));
+-    timer->start(1000);
++    if (secondsToNextRenewal)
++       timer->start(secondsToNextRenewal * 1000);
+ 
+     LOG << "Using Kerberos KRB5CCNAME of" << cc.name().c_str();
+     LOG << "kredentials constructor returning";
+@@ -168,7 +175,8 @@ void kredentials::tryPassGetTickets(){
+ 	    if( !runAklog() ){
+ 		KMessageBox::sorry(0, i18n("Unable to run aklog"), 0, 0);
+ 	    }
+-	    timer->start(1000);
++            if (secondsToNextRenewal)
++	       timer->start(secondsToNextRenewal * 1000);
+ 	    //that's it
+ 	    break;
+ 	}
+@@ -245,8 +253,8 @@ void kredentials::tryRenewTickets()
+     // restart the timer here, regardless of whether we currently
+     // have tickets now or not.  The user may get tickets before
+     // the next timeout, and we need to be able to renew them
+-    secondsToNextRenewal = DEFAULT_RENEWAL_INTERVAL;
+-    timer->start(1000);
++    if(secondsToNextRenewal)
++       timer->start(secondsToNextRenewal * 1000);
+     if(authenticated > 0){
+ 	if( !runAklog() ){
+ 	    KMessageBox::sorry(0, "Unable to run aklog", 0, 0);
+@@ -287,11 +295,7 @@ void kredentials::ticketTimerEvent()
+     LOG << "ticketTimerEvent triggered, secondsToNextRenewal ==" 
+ 	<< secondsToNextRenewal;
+ 
+-    secondsToNextRenewal--;
+-    if(secondsToNextRenewal < 0)
+-    {
+-	tryRenewTickets();
+-    }
++    tryRenewTickets();
+     return;
+ }
+ 
+@@ -339,4 +343,14 @@ void kredentials::setDoNotify(int state)
+     doNotify = state;
+ }
+ 
++void kredentials::setRenewalTime(int seconds)
++{
++    QString msgString;
++    if (seconds > MAX_RENEWAL_TIME) {
++	KMessageBox::information(0, msgString, "Can't wait more than 2147483 seconds to renew", 0, 0);
++	seconds = MAX_RENEWAL_TIME;
++    }
++    secondsToNextRenewal = seconds;
++}
++
+ #include "kredentials.moc"
+diff -up kredentials-2.0-pre3/src/kredentials.h.orig kredentials-2.0-pre3/src/kredentials.h
+--- kredentials-2.0-pre3/src/kredentials.h.orig	2012-01-29 14:48:32.000000000 -0500
++++ kredentials-2.0-pre3/src/kredentials.h	2012-06-28 07:46:35.245526093 -0400
+@@ -62,7 +62,7 @@ public:
+      */
+     virtual ~kredentials();
+ 	void setDoNotify(int);
+-	
++	void setRenewalTime(int);
+ protected slots:
+ 	void tryRenewTickets();
+ 	void showTicketCache();
+diff -up kredentials-2.0-pre3/src/main.cpp.orig kredentials-2.0-pre3/src/main.cpp
+--- kredentials-2.0-pre3/src/main.cpp.orig	2011-12-26 03:37:31.000000000 -0500
++++ kredentials-2.0-pre3/src/main.cpp	2012-06-28 07:46:35.245526093 -0400
+@@ -47,6 +47,8 @@ int main(int argc, char **argv)
+ 			 ki18n("Inform the user when credentials are renewed"));
+     options.add("d").add("disable-aklog", 
+ 			 ki18n("Don't run aklog after renewing Kerberos tickets"));
++    options.add("r").add("renew <seconds>",
++			 ki18n("'Number of seconds to delay before renewal"), "3600");
+     KCmdLineArgs::addCmdLineOptions( options );
+     KUniqueApplication::addCmdLineOptions();
+ 
+@@ -71,6 +73,7 @@ int main(int argc, char **argv)
+ 	{
+ 		k_obj->setDoAklog(false);
+ 	}
++	k_obj->setRenewalTime(args->getOption("renew").toInt());
+ 
+ 	k_obj->show();
+ 
diff --git a/kredentials.spec b/kredentials.spec
index 9fd064d..739207d 100644
--- a/kredentials.spec
+++ b/kredentials.spec
@@ -1,6 +1,6 @@
 Name:	kredentials
 Version:	2.0
-Release:	0.2.pre3%{?dist}
+Release:	0.3.pre3%{?dist}
 Summary:	KDE system tray kerberos ticket monitor
 
 Group:		System Environment/Daemons
@@ -19,6 +19,7 @@ BuildRequires:	desktop-file-utils
 Requires:	kdebase	
 
 Patch0: kredentials-build.patch
+Patch1: kredentials-renew-option.patch
 
 %description
 Kredentials is a system tray applet that monitors and renews kerberos tickets
@@ -27,6 +28,7 @@ for a user
 %prep
 %setup -q -n %{name}-%{version}-pre3
 %patch0 -p1
+%patch1 -p1
 
 %build
 %{__mkdir} build
@@ -66,6 +68,9 @@ desktop-file-install --dir=$RPM_BUILD_ROOT/%{_datadir}/applications %{SOURCE1}
 %{_datadir}/icons/hicolor/64x64/apps/kredentials.png
 
 %changelog
+* Thu Jun 28 2012 Neil Horman <nhorman at tuxdriver.com> - 2.0-0.3.pre3
+- Add renewal timer option
+
 * Fri Jun 08 2012 Neil Horman <nhorman at tuxdriver.com> - 2.0-0.2.pre3
 - Update to latest version
 


More information about the scm-commits mailing list