Sophie

Sophie

distrib > Fedora > 16 > x86_64 > media > updates-src > by-pkgid > ad5c5b64f1d6024bf8b95a6a3a9812f6 > files > 5

kredentials-2.0-0.3.pre3.fc16.src.rpm

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();