The patch looked good for the most part, but the following caught my eye
+ case PAM_PROMPT_ECHO_ON: + reply[replies].resp_retcode = PAM_SUCCESS; + reply[replies].resp = (char *) strdup(e->user); + break; + case PAM_PROMPT_ECHO_OFF: + reply[replies].resp_retcode = PAM_SUCCESS; + reply[replies].resp = (char *) strdup(e->pass); + break;
e is going to be NULL in these cases(right?), will those cases ever be reached, or are they simply copy & paste from the other code(which they appear to be) If they are copy & paste i say we create a pam.[ch] and just keep the functions there, entrance and entrance_login can just link off of them in one place.
Lemme know what you think.
I know, the patch was a bit quick. Here is a new and improved patch.
Sebastian
? mkinstalldirs Index: AUTHORS =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/AUTHORS,v retrieving revision 1.2 diff -u -r1.2 AUTHORS --- AUTHORS 26 May 2003 05:59:43 -0000 1.2 +++ AUTHORS 12 Jan 2005 11:08:22 -0000 @@ -1,5 +1,6 @@ Ibukun Olumuyiwa <[EMAIL PROTECTED]> Corey Donohoe <[EMAIL PROTECTED]> Tilman Sauerbeck <[EMAIL PROTECTED]> +Sebastian Dransfeld <[EMAIL PROTECTED]> Credits to Chris Thomas for some of the original work on elogin. Index: src/client/Makefile.am =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/Makefile.am,v retrieving revision 1.15 diff -u -r1.15 Makefile.am --- src/client/Makefile.am 27 Jun 2004 17:05:27 -0000 1.15 +++ src/client/Makefile.am 12 Jan 2005 11:08:23 -0000 @@ -19,7 +19,9 @@ entrance_LDADD = @edje_libs@ @ecore_libs@ @edb_libs@ @evas_libs@ \ @esmart_libs@ -lesmart_container -lesmart_text_entry -entrance_login_SOURCES = entrance_login.c +entrance_login_SOURCES = entrance_login.c \ + entrance_auth.c \ + util.c entrance_edit_SOURCES = entrance_edit.c \ entrance_config.c entrance_user.c \ Index: src/client/entrance_auth.c =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_auth.c,v retrieving revision 1.23 diff -u -r1.23 entrance_auth.c --- src/client/entrance_auth.c 5 Jan 2005 23:10:28 -0000 1.23 +++ src/client/entrance_auth.c 12 Jan 2005 11:08:25 -0000 @@ -2,7 +2,7 @@ @file entrance_auth.c @brief Variables and data relating to system authentication */ -#include"entrance_auth.h" +#include "entrance_auth.h" #include "util.h" static char * @@ -87,7 +87,7 @@ #if HAVE_PAM if (e->pam.handle) { - pam_close_session(e->pam.handle, 0); + /*pam_close_session(e->pam.handle, 0);*/ pam_end(e->pam.handle, PAM_SUCCESS); e->pam.handle = NULL; } @@ -147,12 +147,12 @@ #if HAVE_PAM /** - * _entrance_auth_pam_initialize - initialize PAM session, structures etc. + * entrance_auth_pam_initialize - initialize PAM session, structures etc. * This function will call pam_start() and set the conversation * function and others. */ -static int -_entrance_auth_pam_initialize(Entrance_Auth * e, const char *display) +int +entrance_auth_pam_initialize(Entrance_Auth * e, const char *display) { int pamerr; @@ -213,7 +213,7 @@ int result = AUTH_FAIL; int pamerr; - if (_entrance_auth_pam_initialize(e, display) != E_SUCCESS) + if (entrance_auth_pam_initialize(e, display) != E_SUCCESS) return ERROR_NO_PAM_INIT; if ((pamerr = pam_authenticate(e->pam.handle, 0)) == PAM_SUCCESS) Index: src/client/entrance_auth.h =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_auth.h,v retrieving revision 1.12 diff -u -r1.12 entrance_auth.h --- src/client/entrance_auth.h 27 Dec 2004 06:45:14 -0000 1.12 +++ src/client/entrance_auth.h 12 Jan 2005 11:08:25 -0000 @@ -67,6 +67,10 @@ void entrance_auth_session_end(Entrance_Auth * e); void entrance_auth_clear_pass(Entrance_Auth * e); +#ifdef HAVE_PAM +int entrance_auth_pam_initialize(Entrance_Auth * e, const char *display); +#endif + /* 0 on success, 1 on failure */ int entrance_auth_cmp(Entrance_Auth * e, const char *display, int mode); void entrance_auth_pass_set(Entrance_Auth * e, const char *str); Index: src/client/entrance_login.c =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_login.c,v retrieving revision 1.2 diff -u -r1.2 entrance_login.c --- src/client/entrance_login.c 4 Feb 2004 20:59:35 -0000 1.2 +++ src/client/entrance_login.c 12 Jan 2005 11:08:25 -0000 @@ -4,16 +4,65 @@ #include <sys/types.h> #include <sys/wait.h> +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif + +#ifdef HAVE_PAM +# include "entrance_auth.h" +#endif + +#ifdef HAVE_PAM +int +entrance_end_user_session(Entrance_Auth *e) +{ + int pamerr; + + if (!e->pam.handle) + return ERROR_NO_PAM_INIT; + + syslog(LOG_INFO, "Ending session for user \"%s\".", e->user); + + if ((pamerr = pam_close_session(e->pam.handle, 0)) != PAM_SUCCESS) + { + syslog(LOG_CRIT, "PAM: %s.", pam_strerror(e->pam.handle, pamerr)); + return ERROR_NO_PAM_INIT; + } + + return E_SUCCESS; +} +#endif + int main(int argc, char **argv) { pid_t pid; + char *user; + char *display; +#ifdef HAVE_PAM + Entrance_Auth *e; +#endif - if (argc != 2) + if (argc != 4) return 0; - pid = atoi(argv[1]); - if (waitpid(pid, NULL, 0) == pid) + user = argv[1]; + display = argv[2]; + pid = atoi(argv[3]); + +#ifdef HAVE_PAM + e = entrance_auth_new(); + if (entrance_auth_user_set(e, user)) + return -1; + entrance_auth_pam_initialize(e, display); +#endif + + if (waitpid(pid, NULL, 0) == pid) { +#ifdef HAVE_PAM + entrance_end_user_session(e); + entrance_auth_free(e); +#endif exit(0); + } return -1; } Index: src/client/entrance_session.c =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.c,v retrieving revision 1.67 diff -u -r1.67 entrance_session.c --- src/client/entrance_session.c 27 Dec 2004 06:45:14 -0000 1.67 +++ src/client/entrance_session.c 12 Jan 2005 11:08:25 -0000 @@ -357,6 +357,7 @@ pid_t pid; char buf[PATH_MAX]; char *shell = NULL; + char *user, *display; entrance_auth_setup_environment(e->auth, e->display); if ((e->session) && (strlen(e->session) > 0)) @@ -385,6 +386,7 @@ ecore_evas_free(e->ee); e->ee = NULL; } + edje_shutdown(); ecore_evas_shutdown(); ecore_x_sync(); entrance_ipc_shutdown(); @@ -428,14 +430,18 @@ break; } _entrance_session_user_list_fix(e); + user = strdup(e->auth->user); + display = strdup(e->display); entrance_session_free(e); /* this bypasses a race condition where entrance loses its x connection */ /* before the wm gets it and x goes and resets itself */ sleep(10); /* replace this rpcoess with a clean small one that just waits for its */ /* child to exit.. passed on the cmd-line */ - snprintf(buf, sizeof(buf), "%s/entrance_login %i", PACKAGE_BIN_DIR, - (int) pid); + snprintf(buf, sizeof(buf), "%s/entrance_login %s %s %i", PACKAGE_BIN_DIR, + user, display, (int) pid); + free(user); + free(display); execl("/bin/sh", "/bin/sh", "-c", buf, NULL); } Index: src/client/main.c =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/main.c,v retrieving revision 1.69 diff -u -r1.69 main.c --- src/client/main.c 4 Jan 2005 23:44:44 -0000 1.69 +++ src/client/main.c 12 Jan 2005 11:08:26 -0000 @@ -768,19 +768,25 @@ specified in config. On systems with * hardware acceleration, GL should improve performance appreciably */ if (!session->config->engine) + { e = ecore_evas_software_x11_new(NULL, 0, 0, 0, g_x, g_y); + ew = ecore_evas_software_x11_window_get(e); + } #ifdef HAVE_ECORE_GL_X11 else if (session->config->engine) + { e = ecore_evas_gl_x11_new(NULL, 0, 0, 0, g_x, g_y); + ew = ecore_evas_gl_x11_window_get(e); + } #endif else { fprintf(stderr, "Warning: Invalid Evas engine specified in config. Defaulting to software engine.\n"); e = ecore_evas_software_x11_new(NULL, 0, 0, 0, g_x, g_y); + ew = ecore_evas_software_x11_window_get(e); } - ew = ecore_evas_software_x11_window_get(e); if (session->testing) ecore_evas_title_set(e, "Entrance - Testing Mode"); else