Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/entrance
Dir : e17/apps/entrance/src/client
Modified Files:
entrance_login.c entrance_session.c
Log Message:
moe loging - and ACTUALLY work. executing entrance_login via bin/sh loses
child process info etc thus waitpit() will never wait for the x session. exe
directly ith no shell in between - and now its all happy.
===================================================================
RCS file: /cvs/e/e17/apps/entrance/src/client/entrance_login.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- entrance_login.c 16 Aug 2005 04:03:27 -0000 1.5
+++ entrance_login.c 28 Sep 2006 03:17:46 -0000 1.6
@@ -3,6 +3,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <errno.h>
+#include <signal.h>
#include "../config.h"
@@ -29,10 +31,18 @@
}
#endif
+static void
+child(int sig, siginfo_t *si, void *foo)
+{
+ syslog(LOG_INFO, "Child exit signal.");
+}
+
int
main(int argc, char **argv)
{
pid_t pid = -1;
+ int status;
+ struct sigaction action;
#ifdef HAVE_PAM
char *user = NULL;
@@ -59,10 +69,11 @@
}
pid = atoi(argv[1]);
-#if HAVE_PAM
+#ifdef HAVE_PAM
user = argv[2];
display = argv[3];
+ syslog(LOG_CRIT, "Wait for %s on %s", user, display);
if (user && display)
{
e = entrance_auth_new();
@@ -75,7 +86,12 @@
}
#endif
- if (waitpid(pid, NULL, 0) == pid)
+ action.sa_sigaction = child;
+ action.sa_flags = SA_RESTART | SA_SIGINFO;
+ sigemptyset(&action.sa_mask);
+ sigaction(SIGCHLD, &action, NULL);
+ syslog(LOG_CRIT, "Wait for pid %i", pid);
+ if (waitpid(pid, &status, 0) == pid)
{
#ifdef HAVE_PAM
if (e)
@@ -85,8 +101,10 @@
entrance_auth_free(e);
}
#endif
+ syslog(LOG_CRIT, "Wait done - child exited normally");
closelog();
exit(0);
}
+ syslog(LOG_CRIT, "Wait error: %s", strerror(errno));
return -1;
}
===================================================================
RCS file: /cvs/e/e17/apps/entrance/src/client/entrance_session.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -3 -r1.88 -r1.89
--- entrance_session.c 27 Sep 2006 12:11:47 -0000 1.88
+++ entrance_session.c 28 Sep 2006 03:17:46 -0000 1.89
@@ -378,7 +378,7 @@
entrance_session_start_user_session(Entrance_Session * e)
{
pid_t pid;
- char buf[PATH_MAX];
+ char buf[PATH_MAX], pids[128];
char *shell = NULL;
char *user = NULL;
struct passwd *pwent = NULL;
@@ -472,7 +472,7 @@
/* replace this process with a clean small one that just waits for its
*/
/* child to exit.. passed on the cmd-line */
- _entrance_session_execute_in_shell(user,shell,buf);
+ _entrance_session_execute_in_shell(user, shell, buf);
break;
case -1:
syslog(LOG_INFO, "FORK FAILED, UH OH");
@@ -482,20 +482,20 @@
#ifdef HAVE_PAM
if (e->config->auth == ENTRANCE_USE_PAM)
{
- snprintf(buf, sizeof(buf), "%s/%s/entrance_login %i %s %s",
+ snprintf(buf, sizeof(buf), "%s/%s/entrance_login",
PACKAGE_LIB_DIR, PACKAGE, (int) pid, pwent->pw_name,
e->display);
}
else
#endif
{
- snprintf(buf, sizeof(buf), "%s/%s/entrance_login %i",
+ snprintf(buf, sizeof(buf), "%s/%s/entrance_login",
PACKAGE_LIB_DIR, PACKAGE, (int) pid);
}
shell = strdup("/bin/sh");
/* this bypasses a race condition where entrance loses its x
connection before the wm gets it and x goes and resets itself */
- sleep(10);
+ sleep(30);
/*
* FIXME These should be called!
ecore_x_shutdown();
@@ -503,14 +503,31 @@
*/
break;
}
+/* no need to free - we are goign to exec ourselves and be replaced
struct_passwd_free(pwent);
entrance_session_free(e);
if (shell) free(shell);
if (user) free(user);
+ */
/* replace this process with a clean small one that just waits for its */
/* child to exit.. passed on the cmd-line */
- execl("/bin/sh", "/bin/sh", "-l", "-c", buf, NULL);
+ /* this causes entreance to reset - bad bad bad */
+ snprintf(pids, sizeof(pids), "%i", (int)pid);
+ snprintf(buf, sizeof(buf), "%s/%s/entrance_login", PACKAGE_LIB_DIR,
PACKAGE);
+#ifdef HAVE_PAM
+ if (e->config->auth == ENTRANCE_USE_PAM)
+ {
+ syslog(LOG_NOTICE, "Exec entrance login replacement: %s %s %s %s", buf,
pids, pwent->pw_name, e->display);
+ execl(buf, buf, pids, pwent->pw_name, e->display, NULL);
+ }
+ else
+#endif
+ {
+ syslog(LOG_NOTICE, "Exec entrance login replacement: %s %s", buf, pids);
+ execl(buf, buf, pids, NULL);
+ }
+ pause();
if (buf) free(buf);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs