Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > ac356884f4883da727404eba8d7c5a16 > files > 1

lxdm-0.2.0-4.fc13.src.rpm

From 3c6502affe326777d6ce481f9bb04ce7f3223ea6 Mon Sep 17 00:00:00 2001
From: dgod <dgod.osa@gmail.com>
Date: Mon, 17 May 2010 21:59:31 +0800
Subject: [PATCH 12/12] add debug option

---
 configure.ac |    9 +++++++++
 src/lxdm.c   |   39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7a7bea4..88b08ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,15 @@ else
  AC_CHECK_LIB([Xau],[XauWriteAuth])
 fi
 
+AC_ARG_ENABLE(debug,
+    AC_HELP_STRING([--enable-debug],[enable detailed debug]),
+    [enable_debug=$enablevar],
+    [enable_debug=yes]
+)
+if test "x$enable_debug" = "x$yes" ; then
+	CFLAGS="$CFLAGS -DLXDM_DEBUG"
+fi
+
 GETTEXT_PACKAGE=lxdm
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
diff --git a/src/lxdm.c b/src/lxdm.c
index e34b20b..a6dbb40 100644
--- a/src/lxdm.c
+++ b/src/lxdm.c
@@ -34,6 +34,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <ctype.h>
 #include <unistd.h>
 #include <stdarg.h>
@@ -239,6 +240,12 @@ void log_print(char *fmt, ...)
     fclose(log);
 }
 
+#ifdef LXDM_DEBUG
+#define dbg_printf log_print
+#else
+#define dbg_printf(fmt,...)
+#endif
+
 GSList *do_scan_xsessions(void)
 {
     GSList *xsessions = NULL;
@@ -445,18 +452,33 @@ int lxdm_auth_user(char *user, char *pass, struct passwd **ppw)
     char *enc;
 #endif
     if( !user )
+    {
+        dbg_printf("user==NULL\n");
         return AUTH_ERROR;
+    }
     if( !user[0] )
+    {
+        dbg_printf("user[0]==0\n");
         return AUTH_BAD_USER;
+    }
     pw = getpwnam(user);
     endpwent();
     if( !pw )
+    {
+        dbg_printf("user %s not found\n",user);
         return AUTH_BAD_USER;
+    }
     if( !pass )
     {
         *ppw = pw;
+        dbg_printf("user %s auth ok\n",user);
         return AUTH_SUCCESS;
     }
+    if(strstr(pw->pw_shell, "nologin"))
+    {
+        dbg_printf("user %s have nologin shell\n");
+        return AUTH_PRIV;
+    }
 #if !HAVE_LIBPAM
     sp = getspnam(user);
     if( !sp )
@@ -468,21 +490,27 @@ int lxdm_auth_user(char *user, char *pass, struct passwd **ppw)
         if( !pass[0] )
         {
             *ppw = pw;
+            dbg_printf("user %s auth with no password ok\n",user);
             return AUTH_SUCCESS;
         }
         else
+        {
+            dbg_printf("user %s password not match\n");
             return AUTH_FAIL;
+        }
     }
     enc = crypt(pass, real);
     if( strcmp(real, enc) )
+    {
+        dbg_printf("user %s password not match\n");
         return AUTH_FAIL;
-    if( strstr(pw->pw_shell, "nologin") )
-        return AUTH_PRIV;
+    }
 #else
     if(pamh) pam_end(pamh,0);
     if(PAM_SUCCESS != pam_start("lxdm", pw->pw_name, &conv, &pamh))
     {
         pamh=NULL;
+        dbg_printf("user %s start pam fail\n",user);
         return AUTH_FAIL;
     }
     else
@@ -492,11 +520,15 @@ int lxdm_auth_user(char *user, char *pass, struct passwd **ppw)
         ret=pam_authenticate(pamh,PAM_SILENT);
 	user_pass[0]=0;user_pass[1]=0;
 	if(ret!=PAM_SUCCESS)
+        {
+            dbg_printf("user %s auth fail with %d\n",user,ret);
             return AUTH_FAIL;
+        }
 	//ret=pam_setcred(pamh, PAM_ESTABLISH_CRED);
     }
 #endif
     *ppw = pw;
+    dbg_printf("user %s auth ok\n",pw->pw_name);
     return AUTH_SUCCESS;
 }
 
@@ -995,9 +1027,12 @@ void lxdm_do_login(struct passwd *pw, char *session, char *lang)
         if(alloc_lang)
             g_free(lang);
         ui_prepare();
+        dbg_printf("get session %s info fail\n",session);
     	return;
     }
 
+    dbg_printf("login user %s session %s lang %s\n",pw->pw_name,session_exec,lang);
+
     if( pw->pw_shell[0] == '\0' )
     {
         setusershell();
-- 
1.7.0.1