Hi!
I have played around with the entrance source, and hav emade some slight
progress.
It looks like the entrance_server just went into idle main loop after starting
the user session,
without ever showing the slightest interst in when or if the user terminated
the session later.
This is why it apparently had to be kicked out when shutting down and left a dysfunctional display
when simply logging out. I can't say that I have really solved the underlying problem, because it
would need some better understanding of the ecore API. What I did was
- adding a signal handler for SIGCHLD after running entrance_session_run forked
the X session, which
does a ecore_main_loop_quit() now
- adding a _logged=EINA_FALSE to entrance_session_shutdown, because the
entrance shutdown code got
stuck there.
- added a -d parameter to change the path to executables so they are drawn from
the src directory
instead of from installed PACKAGE_DIR for testing with xephyr.
The result is that now entrance quits immediately after session logout.
No idea if this solves too many problems there, but I have attached the git
diff output in case
anyone is interested.
regards
Peter
--
peter kollner <[email protected]>
diff --git a/src/bin/entrance_client.c b/src/bin/entrance_client.c
index f3e244e..ceafc8d 100644
--- a/src/bin/entrance_client.c
+++ b/src/bin/entrance_client.c
@@ -67,7 +67,7 @@ main(int argc, char **argv)
PT("connect shutdown");
entrance_connect_shutdown();
PT("conf shutdown");
- entrance_conf_init();
+ entrance_conf_shutdown();
PT("gui shutdown");
entrance_gui_shutdown();
PT("login shutdown");
diff --git a/src/bin/entrance_client.h b/src/bin/entrance_client.h
index 2bb7636..a18f274 100644
--- a/src/bin/entrance_client.h
+++ b/src/bin/entrance_client.h
@@ -6,7 +6,7 @@
#endif
#include <stdio.h>
-
+#include <time.h>
#include <Elementary.h>
#include "../event/entrance_event.h"
@@ -21,11 +21,16 @@
#include "entrance_gui.h"
#include "entrance_login.h"
-#define PT(f, x...) \
-do \
-{ \
- printf(__FILE__":%d "f"\n", __LINE__, ##x); \
- fflush(stdout); \
+#define PT(f, x...) \
+do \
+{ time_t time_p; \
+ char date_time[24]; \
+ time(&time_p); \
+ if(!strftime(date_time, 24, "%Y%m%d-%H%M%S%z", localtime(&time_p))) { \
+ strcpy(date_time, "stardate-unknown"); \
+ } \
+ printf("%s: "__FILE__":%d "f"\n", date_time, __LINE__, ##x); \
+ fflush(stdout); \
} while (0)
int entrance_client_main(void);
diff --git a/src/daemon/entrance.c b/src/daemon/entrance.c
index 26abdc8..aca5604 100644
--- a/src/daemon/entrance.c
+++ b/src/daemon/entrance.c
@@ -25,6 +25,7 @@ static void _entrance_wait(void);
static Eina_Bool _testing = 0;
static Eina_Bool _xephyr = 0;
+static Eina_Bool _debug = 0;
static Ecore_Exe *_entrance_client = NULL;
@@ -143,7 +144,11 @@ static void
_entrance_wait(void)
{
// XXX: use eina_prefix! hardcoding paths . :(
- execl(PACKAGE_BIN_DIR"/entrance_wait", PACKAGE_SBIN_DIR"/entrance", NULL);
+ if(_debug) {
+ execl("../daemon/entrance_wait", "../daemon/entrance", NULL);
+ } else {
+ execl(PACKAGE_BIN_DIR"/entrance_wait", PACKAGE_SBIN_DIR"/entrance",
NULL);
+ }
PT("HUM HUM HUM can't wait ...");
_exit(1);
}
@@ -259,11 +264,19 @@ _entrance_main(const char *dname)
chown(home_path, pwd->pw_uid, pwd->pw_gid);
}
+ if(_debug) {
+ snprintf(buf, sizeof(buf),
+ SUDO" --user %s HOME=%s "
+ "LD_LIBRARY_PATH="PACKAGE_LIB_DIR" "
+ "../bin/entrance_client -d %s -t %s",
+ user, home_path, dname, entrance_config->theme);
+ } else {
snprintf(buf, sizeof(buf),
SUDO" --user %s HOME=%s "
"LD_LIBRARY_PATH="PACKAGE_LIB_DIR" "
PACKAGE_BIN_DIR"/entrance_client -d %s -t %s",
user, home_path, dname, entrance_config->theme);
+ }
PT("Exec entrance_client: %s", buf);
_entrance_client =
@@ -272,8 +285,10 @@ _entrance_main(const char *dname)
NULL);
}
}
- else
- ecore_main_loop_quit();
+ else {
+ PT("Quit main loop");
+ ecore_main_loop_quit();
+ }
return ECORE_CALLBACK_CANCEL;
}
@@ -341,6 +356,7 @@ static const Ecore_Getopt options =
"If not, entrance will restart if the session is
"
"quit because of an error, or if the environment
"
"variable ENTRANCE_RESTART is set."),
+ ECORE_GETOPT_STORE_TRUE('d', "debug", "Start in debug mode. use
entrance client from ../bin directory"),
ECORE_GETOPT_STORE_TRUE('x', "xephyr", "run in test mode and use "
"Xephyr."),
ECORE_GETOPT_HELP ('h', "help"),
@@ -361,12 +377,12 @@ main (int argc, char ** argv)
unsigned char nodaemon = 0;
unsigned char fastexit = 0;
unsigned char quit_option = 0;
-
Ecore_Getopt_Value values[] =
{
ECORE_GETOPT_VALUE_BOOL(nodaemon),
ECORE_GETOPT_VALUE_BOOL(_testing),
ECORE_GETOPT_VALUE_BOOL(fastexit),
+ ECORE_GETOPT_VALUE_BOOL(_debug),
ECORE_GETOPT_VALUE_BOOL(_xephyr),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
diff --git a/src/daemon/entrance_server.c b/src/daemon/entrance_server.c
index 90fbe60..31aaeac 100644
--- a/src/daemon/entrance_server.c
+++ b/src/daemon/entrance_server.c
@@ -1,3 +1,5 @@
+#include <signal.h>
+#include <sys/wait.h>
#include <Ecore_Con.h>
#include "entrance.h"
#include "../event/entrance_event.h"
@@ -6,7 +8,6 @@ static Eina_Bool _entrance_server_add(void *data, int type,
void *event);
static Eina_Bool _entrance_server_del(void *data, int type, void *event);
static Eina_Bool _entrance_server_data(void *data, int type, void *event);
-
Ecore_Con_Server *_entrance_server = NULL;
Eina_List *_handlers = NULL;
@@ -54,12 +55,45 @@ _entrance_server_add(void *data EINA_UNUSED, int type
EINA_UNUSED, void *event E
return ECORE_CALLBACK_RENEW;
}
+static struct sigaction act, oldact;
+
+static void terminate() {
+ PT("All session children terminated.");
+ // restore old SIGCHLD action
+ sigaction(SIGCHLD, &oldact, NULL);
+ ecore_main_loop_quit();
+}
+
+static void sigchld_handler(int signum EINA_UNUSED) {
+ int session_pid, found, status;
+
+ found = waitpid(-1, &status, 0);
+ session_pid = entrance_session_pid_get();
+ PT("registered child pid: %d", session_pid);
+
+ PT("Wait returned child %d (status %d)", found, status);
+ if (found == session_pid) {
+ terminate();
+ }
+}
static Eina_Bool
_entrance_server_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event
EINA_UNUSED)
{
PT("server client disconnected");
-
+ if (entrance_session_pid_get()) {
+ act.sa_handler = sigchld_handler;
+ // act.sa_flags = SA_NOCLDWAIT;
+
+
+ if(sigaction(SIGCHLD, &act, &oldact) == -1) {
+ char errbuf[128];
+ strerror_r(errno, errbuf, 128);
+ PT("Error preparing SIGCHLD action: %s", errbuf );
+ }
+ PT("Preparing for termination of session");
+
+ }
return ECORE_CALLBACK_RENEW;
}
@@ -95,6 +129,7 @@ _entrance_server_read_cb(const void *data, size_t size
EINA_UNUSED, void *user_d
{
PT("opening session now ...");
entrance_session_login(eev->event.auth.session, EINA_TRUE);
+ PT("coming out of opening session");
}
else
entrance_session_close(EINA_FALSE);
diff --git a/src/daemon/entrance_session.c b/src/daemon/entrance_session.c
index f48c93a..68f6658 100644
--- a/src/daemon/entrance_session.c
+++ b/src/daemon/entrance_session.c
@@ -1,3 +1,5 @@
+#include <signal.h>
+#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include <grp.h>
@@ -190,7 +192,7 @@ _entrance_session_run(struct passwd *pwd, const char *cmd,
const char *cookie)
}
else if (pid > 0)
{
- entrance_session_pid_set(pid);
+ entrance_session_pid_set(pid);
}
else
{
@@ -284,7 +286,7 @@ void
entrance_session_shutdown(void)
{
Entrance_Xsession *xsession;
-
+ _logged = EINA_FALSE;
EINA_LIST_FREE(_xsessions, xsession)
{
eina_stringshare_del(xsession->name);
diff --git a/utils/entrance_xephyr.sh b/utils/entrance_xephyr.sh
index 4fe27e6..b078480 100755
--- a/utils/entrance_xephyr.sh
+++ b/utils/entrance_xephyr.sh
@@ -22,11 +22,11 @@ Xephyr :1 -nolisten tcp -noreset -ac -br -dpi $DPI -screen
$SCREEN &
sleep 1
if [ $GDB -eq 1 ]
then
- gdb --args entrance -x
+ gdb --args ./entrance -dx
elif [ $VALGRIND -eq 1 ]
then
- valgrind --leak-check=full entrance -x
+ valgrind --leak-check=full ./entrance -dx
else
- entrance -x
+ gdb ./entrance -ex "run -dx"
fi
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
enlightenment-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-users