Enlightenment CVS committal

Author  : xcomputerman
Project : e17
Module  : apps/entrance

Dir     : e17/apps/entrance/src/client


Modified Files:
        EvasTextEntry.c entrance_auth.c entrance_auth.h 
        entrance_session.c main.c 


Log Message:
- Patch from atmos to fix various issues with starting sessions
- PAM should not close session until the session is actually over
- Print error message on ecore_evas_init() failure


===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/EvasTextEntry.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- EvasTextEntry.c     21 Oct 2003 22:36:06 -0000      1.4
+++ EvasTextEntry.c     1 Jan 2004 20:58:55 -0000       1.5
@@ -158,20 +158,24 @@
 {
    Evas_Text_Entry *e = NULL;
 
-   e = evas_object_smart_data_get(o);
-   if (e->passwd)
+   if (!o)
+      return;
+   if ((e = evas_object_smart_data_get(o)))
    {
-      int i, len;
-      char buf[e->buf.size];
+      if (e->passwd)
+      {
+         int i, len;
+         char buf[e->buf.size];
 
-      len = strlen(e->buf.text);
-      memset(buf, 0, e->buf.size);
-      for (i = 0; i < len; i++)
-         buf[i] = '*';
-      edje_object_part_text_set(e->edje.o, e->edje.part, buf);
+         len = strlen(e->buf.text);
+         memset(buf, 0, e->buf.size);
+         for (i = 0; i < len; i++)
+            buf[i] = '*';
+         edje_object_part_text_set(e->edje.o, e->edje.part, buf);
+      }
+      else
+         edje_object_part_text_set(e->edje.o, e->edje.part, e->buf.text);
    }
-   else
-      edje_object_part_text_set(e->edje.o, e->edje.part, e->buf.text);
 }
 static void
 _key_down_cb(void *data, Evas * e, Evas_Object * o, void *ev)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_auth.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- entrance_auth.c     13 Nov 2003 10:36:22 -0000      1.9
+++ entrance_auth.c     1 Jan 2004 20:58:55 -0000       1.10
@@ -78,11 +78,11 @@
 }
 
 /**
- * entrance_auth_free
- * @e the Entrance_Auth struct to be freed
+ * entrance_auth_session_end
+ * @e the Entrance_Auth handle for this session
  */
 void
-entrance_auth_free(Entrance_Auth * e)
+entrance_auth_session_end(Entrance_Auth * e)
 {
 #if HAVE_PAM
    if (e->pam.handle)
@@ -92,8 +92,31 @@
       e->pam.handle = NULL;
    }
 #endif
+   syslog(LOG_INFO, "Auth: Session Closed Successfully.");
+}
+
+/**
+ * entrance_auth_clear_pass - Clear password from memory
+ * @e the Entrance_Auth handle for this session
+ */
+void
+entrance_auth_clear_pass(Entrance_Auth * e)
+{
+   if(e->pw)
+      if(e->pw->pw_passwd)
+         free(e->pw->pw_passwd);
+   memset(e->pass, 0, sizeof(e->pass));
+}
 
-   e->pw = struct_passwd_free(e->pw);
+/**
+ * entrance_auth_free
+ * @e the Entrance_Auth struct to be freed
+ */
+void
+entrance_auth_free(Entrance_Auth * e)
+{
+   if(e->pw)
+      e->pw = struct_passwd_free(e->pw);
 
    memset(e->pass, 0, sizeof(e->pass));
    free(e);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_auth.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- entrance_auth.h     31 Oct 2003 04:39:52 -0000      1.5
+++ entrance_auth.h     1 Jan 2004 20:58:55 -0000       1.6
@@ -54,6 +54,8 @@
 
 Entrance_Auth *entrance_auth_new(void);
 void entrance_auth_free(Entrance_Auth * e);
+void entrance_auth_session_end(Entrance_Auth * e);
+void entrance_auth_clear_pass(Entrance_Auth * e);
 
 /* 0 on success, 1 on failure */
 int entrance_auth_cmp_pam(Entrance_Auth * e);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- entrance_session.c  23 Dec 2003 02:43:12 -0000      1.24
+++ entrance_session.c  1 Jan 2004 20:58:55 -0000       1.25
@@ -2,6 +2,10 @@
 #include "entrance_session.h"
 #include <X11/Xlib.h>
 #include <Esmart/container.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
 /**
 @file entrance_session.c
 @brief Variables and Data relating to an instance of the interface
@@ -36,6 +40,7 @@
    e = (Entrance_Session *) malloc(sizeof(struct _Entrance_Session));
    memset(e, 0, sizeof(struct _Entrance_Session));
 
+   openlog("entrance", LOG_NOWAIT, LOG_DAEMON);
    e->auth = entrance_auth_new();
    e->config = entrance_config_parse(PACKAGE_CFG_DIR "/entrance_config.db");
    if (!e->config)
@@ -82,10 +87,10 @@
 {
    if (e)
    {
-      entrance_auth_free(e->auth);
-      entrance_config_free(e->config);
-      ecore_evas_free(e->ee);
-      free(e->session);
+      if(e->auth) entrance_auth_free(e->auth);
+      if(e->config) entrance_config_free(e->config);
+      if(e->ee) ecore_evas_free(e->ee);
+      if(e->session) free(e->session);
 
       free(e);
    }
@@ -222,6 +227,7 @@
 {
    char buf[PATH_MAX];
    char *session_key = NULL;
+   pid_t pid;
 
    entrance_auth_setup_environment(e->auth);
 
@@ -248,7 +254,9 @@
 
    syslog(LOG_CRIT, "Executing %s", buf);
 
-   ecore_evas_shutdown();
+   ecore_evas_free(e->ee);
+   e->ee = NULL;
+
    ecore_x_sync();
 
    syslog(LOG_NOTICE, "Starting session for user \"%s\".", e->auth->user);
@@ -260,27 +268,39 @@
       if (pam_open_session(e->auth->pam.handle, 0) != PAM_SUCCESS)
       {
          syslog(LOG_CRIT, "Unable to open PAM session. Aborting.");
-         exit(1);
+        ecore_main_loop_quit();
       }
    }
 #endif
 
-   if (initgroups(e->auth->pw->pw_name, e->auth->pw->pw_gid))
-      syslog(LOG_CRIT,
+   switch((pid = fork()))
+   {
+     case 0:
+       if (initgroups(e->auth->pw->pw_name, e->auth->pw->pw_gid))
+           syslog(LOG_CRIT,
              "Unable to initialize group (is entrance running as root?).");
-
-   if (setgid(e->auth->pw->pw_gid))
-      syslog(LOG_CRIT, "Unable to set group id.");
-
-   if (setuid(e->auth->pw->pw_uid))
-      syslog(LOG_CRIT, "Unable to set user id.");
-
-   entrance_auth_free(e->auth); /* clear users's password out of memory */
-   execl("/bin/sh", "/bin/sh", "-c", buf, NULL);
-/*   system(buf); */
-   ecore_x_shutdown();
-   ecore_shutdown();
-   exit(0);
+       if (setgid(e->auth->pw->pw_gid))
+           syslog(LOG_CRIT, "Unable to set group id.");
+       if (setuid(e->auth->pw->pw_uid))
+           syslog(LOG_CRIT, "Unable to set user id.");
+       entrance_auth_free(e->auth); 
+       e->auth = NULL;
+       execl("/bin/sh", "/bin/sh", "-c", buf, NULL);
+       exit(0);
+       break;
+     case -1:
+        syslog(LOG_INFO, "FORK FAILED, UH OH");
+       exit(0);
+     default:
+       break;
+   }
+   /* clear users's password out of memory */
+   entrance_auth_clear_pass(e->auth); 
+   if (waitpid(pid, NULL, 0) == pid)
+   {
+       entrance_auth_session_end(e->auth);
+       syslog(LOG_CRIT, "User Xsession Ended");
+   }
 }
 
 static void
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/main.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- main.c      23 Dec 2003 04:54:32 -0000      1.26
+++ main.c      1 Jan 2004 20:58:55 -0000       1.27
@@ -58,8 +58,8 @@
 static int
 exit_cb(void *data, int ev_type, void *ev)
 {
+    fprintf(stderr, "HELP\n");
    ecore_main_loop_quit();
-//    exit(0);
    return 1;
 }
 
@@ -71,7 +71,13 @@
 window_del_cb(Ecore_Evas * ee)
 {
    ecore_main_loop_quit();
-//    exit(0);
+#if 0
+   entrance_session_free(session);
+   ecore_evas_shutdown();
+   ecore_x_shutdown();
+   ecore_shutdown();
+#endif
+   exit(0);
 }
 
 /**
@@ -286,15 +292,9 @@
 static void
 done_cb(void *data, Evas_Object * o, const char *emission, const char *source)
 {
-   if (session->authed)
-   {
-      entrance_session_start_user_session(session);
-   }
-   else
-   {
+   if (!session->authed)
       syslog(LOG_CRIT, "Theme attempted to launch session without finishing 
authentication. Please fix your theme.");
-      exit(0);
-   }
+   ecore_main_loop_quit();
 }
 
 /**
@@ -374,7 +374,9 @@
    if (session->config->reboot.allow)
    {
       pid_t pid;
-
+      
+      entrance_session_free(session);
+      session = NULL;
       switch (pid = fork())
       {
         case 0:
@@ -414,6 +416,8 @@
 
    if (session->config->halt.allow)
    {
+      entrance_session_free(session);
+      session = NULL;
       switch (pid = fork())
       {
         case 0:
@@ -506,8 +510,9 @@
    int g_x = WINW, g_y = WINH;
    char *theme = NULL;
    int fs_en = 1;
+   
+   session = entrance_session_new();
 
-   openlog("entrance", LOG_NOWAIT, LOG_DAEMON);
 /*   if (argv[1])
       snprintf(buf, PATH_MAX, "%s", argv[1]);*/
    
@@ -589,12 +594,11 @@
 #endif
    ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_cb, NULL);
 
-   session = entrance_session_new();
    if (ecore_evas_init())
    {
       /* init edje and set frametime to 60 fps ? */
       edje_init();
-      edje_frametime_set(1.0 / 60.0);
+      edje_frametime_set(2.0 / 60.0);
 
       /* setup our ecore_evas */
       /* testing mode decides entrance window size * * Use rendering engine
@@ -646,6 +650,7 @@
       if (!edje_object_file_set(edje, buf, "Main"))
       {
          syslog(LOG_CRIT, "Failed to load theme %s\n", theme);
+        entrance_session_free(session);
          exit(1);
       }
       evas_object_move(edje, 0, 0);
@@ -741,8 +746,20 @@
 
       entrance_session_ecore_evas_set(session, e);
       entrance_session_run(session);
+      fprintf(stderr, "%s", "BING\n");
+      
+      if(session->authed) {
+       entrance_session_start_user_session(session);
+      }
       entrance_session_free(session);
       closelog();
+      ecore_evas_shutdown();
+      ecore_x_shutdown();
+      ecore_shutdown();
+   } else {
+      fprintf(stderr, "Fatal error: Could not initialize ecore_evas!\n");
+      exit(1);
    }
+
    return (0);
 }




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to