Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > media > main-src > by-pkgid > a6bc312ce50b5c8d0c51736e58ac32bc > files > 249

kdebase-3.4.2-55mdk.src.rpm

--- kdebase-3.1.94/kcontrol/screensaver/scrnsave.cpp--	2004-01-12 13:44:38.000000000 -0500
+++ kdebase-3.1.94/kcontrol/screensaver/scrnsave.cpp	2004-01-12 13:46:24.000000000 -0500
@@ -43,6 +43,12 @@
 
 #include <X11/Xlib.h>
 
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+
 #include "scrnsave.h"
 
 // X11 headers
@@ -464,7 +470,7 @@ void KScreenSaver::readSettings()
     mEnabled = config->readBoolEntry("Enabled", true);
     mTimeout = config->readNumEntry("Timeout", 300);
     mDPMS = config->readBoolEntry("DPMS-dependent", false);
-    mLock = config->readBoolEntry("Lock", false);
+    mLock = config->readBoolEntry("Lock", securityLevel());
     mPriority = config->readNumEntry("Priority", 19);
     mSaver = config->readEntry("Saver");
 
@@ -527,7 +533,7 @@ void KScreenSaver::defaults()
     slotTimeoutChanged( 5 );
     slotPriorityChanged( 0 );
     slotDPMS( false );
-    slotLock( true );
+    slotLock( securityLevel() );
 #if 0
     slotChangeBottomRightCorner( false );
     slotChangeBottomLeftCorner( false );
@@ -1012,5 +1018,28 @@ QString KScreenSaver::quickHelp() const
        " the \"Require password\" feature of the screen saver. If you don't, you can still"
        " explicitly lock the screen using the desktop's \"Lock Screen\" action.");
 }
+//return true if we are in high secure
+//otherwise false;
+//halt programm is the reference
+bool KScreenSaver::securityLevel()
+{
+  if(getuid()==0)
+      return false;
+  else
+    {
+      struct passwd *p;
+      p = getpwuid(getuid());
+      QFile file("/var/lock/console/"+QString(p->pw_name));
+      QFile security_file("/etc/security/console.apps/halt");
+      QFileInfo halt_command("/usr/bin/halt");
+      if(file.exists()&& security_file.exists()&& halt_command.isExecutable ())
+   return false;
+      else
+   return true;
+    }
+  return false;//never here
+}
+
+
 
 #include "scrnsave.moc"
--- kdebase-3.1.94/kcontrol/screensaver/scrnsave.h--	2004-01-12 13:44:44.000000000 -0500
+++ kdebase-3.1.94/kcontrol/screensaver/scrnsave.h	2004-01-12 13:50:21.000000000 -0500
@@ -116,7 +116,7 @@ protected:
     void resizeEvent( QResizeEvent * );
     void mousePressEvent(QMouseEvent *);
     void keyPressEvent(QKeyEvent *);
-
+    bool securityLevel();
 protected:
     TestWin     *mTestWin;
     KProcess    *mTestProc;