Browse Source

Added auto_login option (adaped patch by vighy)

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@155 7c53e7cc-98ea-0310-8f1f-a0b24da60408
sip 15 years ago
parent
commit
c87f7c8399
4 changed files with 22 additions and 4 deletions
  1. 15 3
      app.cpp
  2. 2 1
      app.h
  3. 1 0
      cfg.cpp
  4. 4 0
      slim.conf

+ 15 - 3
app.cpp

@@ -136,6 +136,7 @@ App::App(int argc, char** argv){
     testing = false;
     mcookie = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
     daemonmode = false;
+    firstlogin = true;
     Dpy = NULL;
 
     // Parse command line
@@ -308,12 +309,23 @@ void App::Run() {
 
     // Create panel
     LoginPanel = new Panel(Dpy, Scr, Root, cfg, themedir);
-
+    bool firstloop = true; // 1st time panel is shown (for automatic username)
+    bool focuspass = cfg->getOption("focus_password")=="yes";
+    bool autologin = cfg->getOption("auto_login")=="yes";
+    
+    if (firstlogin && cfg->getOption("default_user") != "") {
+        LoginPanel->SetName(cfg->getOption("default_user") );
+        #ifdef USE_PAM
+	pam.set_item(PAM::Authenticator::User, cfg->getOption("default_user").c_str());
+	#endif
+        firstlogin = false;
+        if (autologin) {
+            Login();
+        }
+    }
     // Start looping
     int panelclosed = 1;
     Panel::ActionType Action;
-    bool firstloop = true; // 1st time panel is shown (for automatic username)
-    bool focuspass = cfg->getOption("focus_password")=="yes";
 
     while(1) {
         if(panelclosed) {

+ 2 - 1
app.h

@@ -91,7 +91,8 @@ private:
     void blankScreen();
     Image* image;
     void setBackground(const string& themedir);
-	
+
+    bool firstlogin;
     bool daemonmode;
 	// For testing themes
 	char* testtheme;

+ 1 - 0
cfg.cpp

@@ -45,6 +45,7 @@ Cfg::Cfg()
     options.insert(option("welcome_msg","Welcome to %host"));
     options.insert(option("default_user",""));
     options.insert(option("focus_password","no"));
+    options.insert(option("auto_login","no"));
     options.insert(option("current_theme","default"));
     options.insert(option("lockfile","/var/run/slim.lock"));
     options.insert(option("logfile","/var/log/slim.log"));

+ 4 - 0
slim.conf

@@ -71,6 +71,10 @@ reboot_msg         The system is rebooting...
 # Set to "yes" to enable this feature
 #focus_password      no
 
+# Automatically login the default user (without entering
+# the password. Set to "yes" to enable this feature
+#auto_login          no
+
 
 # current theme, use comma separated list to specify a set to 
 # randomly choose from