switch to eina_log

devs/bu5hm4n/session_bug
Michael Bouchaud 8 years ago
parent 60ee7d4596
commit 9f5b5e40b3
  1. 27
      src/bin/entrance_client.c
  2. 18
      src/bin/entrance_client.h
  3. 8
      src/bin/entrance_conf.c
  4. 6
      src/bin/entrance_conf_main.c
  5. 4
      src/bin/entrance_conf_theme.c
  6. 12
      src/bin/entrance_conf_user.c
  7. 41
      src/bin/entrance_connect.c
  8. 3
      src/bin/entrance_fill.c
  9. 27
      src/bin/entrance_gui.c
  10. 10
      src/bin/entrance_login.c
  11. 4
      src/bin/entrance_test.c
  12. 181
      src/daemon/entrance.c
  13. 20
      src/daemon/entrance.h
  14. 17
      src/daemon/entrance_action.c
  15. 4
      src/daemon/entrance_ck_launch.c
  16. 11
      src/daemon/entrance_config.c
  17. 20
      src/daemon/entrance_history.c
  18. 49
      src/daemon/entrance_pam.c
  19. 32
      src/daemon/entrance_server.c
  20. 48
      src/daemon/entrance_session.c
  21. 4
      src/daemon/entrance_test.c
  22. 2
      src/daemon/entrance_wait.c
  23. 13
      src/daemon/entrance_xserver.c

@ -3,10 +3,6 @@
#include <Ecore_X.h>
#include <Ecore_Getopt.h>
time_t current_time;
struct tm *local_time;
char entrance_time_d[4096];
static const Ecore_Getopt options =
{
"entrance_client",
@ -49,37 +45,38 @@ main(int argc, char **argv)
return EXIT_FAILURE;
if (quit_option)
return EXIT_SUCCESS;
eina_init();
if (!display)
{
fprintf(stderr, "A display is required!\n");
PT("A display is required!");
eina_shutdown();
return EXIT_FAILURE;
}
eina_init();
ecore_init();
ecore_x_init(display);
elm_init(argc, argv);
PT("login init\n");
PT("login init");
entrance_login_init();
PT("gui init\n");
PT("gui init");
if (!entrance_gui_init(theme)) return EXIT_FAILURE;
PT("conf init\n");
PT("conf init");
entrance_conf_init();
PT("connect init\n");
PT("connect init");
entrance_connect_init();
elm_run();
PT("connect shutdown\n");
PT("connect shutdown");
entrance_connect_shutdown();
PT("conf shutdown\n");
PT("conf shutdown");
entrance_conf_init();
PT("gui shutdown\n");
PT("gui shutdown");
entrance_gui_shutdown();
PT("login shutdown\n");
PT("login shutdown");
entrance_login_shutdown();
elm_shutdown();
ecore_x_shutdown();
ecore_shutdown();
eina_shutdown();
PT("exit\n");
PT("exit");
return EXIT_SUCCESS;
}

@ -21,21 +21,13 @@
#include "entrance_gui.h"
#include "entrance_login.h"
#define PT(f, x...) \
do \
{ \
current_time = time(NULL); \
local_time = localtime(&current_time); \
memset(entrance_time_d, 0, sizeof(entrance_time_d)); \
strftime(entrance_time_d, sizeof(entrance_time_d), \
"%b %_2d %T", local_time); \
fprintf(stderr, "(%s) "PACKAGE"_client: "f, entrance_time_d, ##x); \
#define PT(f, x...) \
do \
{ \
printf(__FILE__"%d : "f"", __LINE__, ##x); \
fflush(stdout); \
} while (0)
extern time_t current_time;
extern struct tm *local_time;
extern char entrance_time_d[4096];
int entrance_client_main(void);
#endif /* ENTRANCE_H_ */

@ -71,7 +71,7 @@ _entrance_conf_end(Evas_Object *win)
Entrance_Conf_Module *conf;
Eina_List *l;
PT("Delete config panel\n");
PT("Delete config panel");
evas_object_del(win);
EINA_LIST_FOREACH(_entrance_conf->modules, l, conf)
conf->end();
@ -200,7 +200,7 @@ _entrance_conf_bg_del(void *data, Evas_Object *obj EINA_UNUSED)
void
entrance_conf_init(void)
{
PT("conf init\n");
PT("conf init");
_entrance_conf = calloc(1, sizeof(Entrance_Int_Conf));
_entrance_conf->background_fill =
entrance_fill_new("thumb",
@ -219,7 +219,7 @@ entrance_conf_shutdown(void)
{
Entrance_Conf_Module *conf;
PT("conf shutdown\n");
PT("conf shutdown");
entrance_conf_user_shutdown();
entrance_conf_main_shutdown();
entrance_conf_theme_shutdown();
@ -248,7 +248,7 @@ entrance_conf_module_register(const char *label, Entrance_Conf_Begin begin, Entr
void
entrance_conf_begin(Evas_Object *obj, Evas_Object *parent)
{
PT("Build config panel\n");
PT("Build config panel");
Evas_Object *win, *bg, *bx, *hbx, *sc, *nf, *o;
Entrance_Conf_Module *conf;
Eina_List *l;

@ -98,7 +98,7 @@ _entrance_conf_vkbd_changed(void *data EINA_UNUSED, Evas_Object *obj, void *even
{
Elm_Actionslider_Pos p;
PT("User change vkbd state\n");
PT("User change vkbd state");
p = elm_actionslider_indicator_pos_get(obj);
_entrance_int_conf_main->vkbd_enabled = !!(p == ELM_ACTIONSLIDER_RIGHT);
@ -343,7 +343,7 @@ _entrance_conf_main_apply(void)
void
entrance_conf_main_init(void)
{
PT("conf main init\n");
PT("conf main init");
entrance_conf_module_register("Main",
_entrance_conf_main_begin,
_entrance_conf_main_end,
@ -355,6 +355,6 @@ entrance_conf_main_init(void)
void
entrance_conf_main_shutdown(void)
{
PT("conf main shutdown\n");
PT("conf main shutdown");
}

@ -184,7 +184,7 @@ _entrance_conf_theme_apply(void)
void
entrance_conf_theme_init(void)
{
PT("conf theme init\n");
PT("conf theme init");
entrance_conf_module_register("Theme Selector",
_entrance_conf_theme_begin,
_entrance_conf_theme_end,
@ -196,7 +196,7 @@ entrance_conf_theme_init(void)
void
entrance_conf_theme_shutdown(void)
{
PT("conf theme shutdown\n");
PT("conf theme shutdown");
}

@ -208,12 +208,12 @@ _entrance_conf_remembersession_changed(void *data EINA_UNUSED, Evas_Object *obj,
{
if ((event_info) && !strcmp(event_info, "Enabled"))
{
PT("Turned remember session on\n");
PT("Turned remember session on");
_entrance_int_conf_user->remember_session = EINA_TRUE;
}
else
{
PT("Turned remember session off\n");
PT("Turned remember session off");
_entrance_int_conf_user->remember_session = EINA_FALSE;
}
_entrance_conf_remembersession_update(obj);
@ -244,7 +244,7 @@ _entrance_conf_user_auth(void *data, const char *user, Eina_Bool granted)
_entrance_int_conf_user->remember_session =
eu->remember_session;
/*
printf("init %s %s | %s %s | %s | %d\n",
printf("init %s %s | %s %s | %s | %d",
_entrance_int_conf_user->bg.path,
_entrance_int_conf_user->bg.group,
_entrance_int_conf_user->image.path,
@ -469,7 +469,7 @@ _entrance_conf_user_apply(void)
eina_stringshare_replace(&eu->lsess, _entrance_int_conf_user->lsess);
entrance_connect_conf_user_send(eu);
/*
printf("%s | %s\n%s | %s\n%s | %s\n%s | %s\n%d | %d\n%s | %s\n",
printf("%s | %s%s | %s%s | %s%s | %s%d | %d%s | %s",
eu->bg.path, _entrance_int_conf->bg.path,
eu->bg.group, _entrance_int_conf->bg.group,
eu->image.path, _entrance_int_conf->image.path,
@ -482,7 +482,7 @@ _entrance_conf_user_apply(void)
void
entrance_conf_user_init(void)
{
PT("conf user init\n");
PT("conf user init");
_entrance_session_fill =
entrance_fill_new("default",
_entrance_conf_session_text_get,
@ -501,7 +501,7 @@ entrance_conf_user_init(void)
void
entrance_conf_user_shutdown(void)
{
PT("conf user shutdown\n");
PT("conf user shutdown");
entrance_fill_del(_entrance_session_fill);
}

@ -19,14 +19,14 @@ static Eina_List *_auth_list = NULL;
static Eina_Bool
_entrance_connect_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
PT("connected\n");
PT("connected");
return ECORE_CALLBACK_RENEW;
}
static Eina_Bool
_entrance_connect_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
PT("disconnected\n");
PT("disconnected");
_entrance_connect = NULL;
return ECORE_CALLBACK_RENEW;
@ -66,51 +66,50 @@ _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_
if (eev->type == ENTRANCE_EVENT_STATUS)
{
if (eev->event.status.granted)
PT("Auth granted :)\n");
PT("Auth granted :)");
else
PT("Auth error :(\n");
PT("Auth error :(");
_entrance_connect_auth(eev->event.status.login,
eev->event.status.granted);
}
else if (eev->type == ENTRANCE_EVENT_MAXTRIES)
{
PT("Max tries !\n");
PT("Max tries !");
entrance_gui_auth_max_tries();
}
else if (eev->type == ENTRANCE_EVENT_XSESSIONS)
{
PT("Xsession received\n");
PT("Xsession received");
entrance_gui_xsessions_set(eev->event.xsessions.xsessions);
}
else if (eev->type == ENTRANCE_EVENT_USERS)
{
PT("Users received\n");
PT("Users received");
entrance_gui_users_set(eev->event.users.users);
}
else if (eev->type == ENTRANCE_EVENT_ACTIONS)
{
PT("Action received\n");
PT("Action received");
entrance_gui_actions_set(eev->event.actions.actions);
}
else if (eev->type == ENTRANCE_EVENT_CONF_GUI)
{
PT("Gui conf received\n");
PT("Gui conf received");
entrance_gui_conf_set(&(eev->event.conf_gui));
}
else if (eev->type == ENTRANCE_EVENT_POOLS)
{
PT("Pools received\n");
PT("Pools received");
entrance_gui_pools_set(&(eev->event.pools));
}
else if (eev->type == ENTRANCE_EVENT_THEMES)
{
PT("Themes received\n");
PT("Themes received");
entrance_gui_themes_set(eev->event.themes.themes);
}
else
{
PT("UNKNOW signal ");
fprintf(stderr, "%d\n", eev->type);
PT("UNKNOW signal %d", eev->type);
}
//free(eev);
}
@ -129,7 +128,7 @@ entrance_connect_auth_send(const char *login, const char *password, const char *
{
Entrance_Event eev;
PT("Request auth\n");
PT("Request auth");
eev.event.auth.login = login;
eev.event.auth.password = password;
eev.event.auth.session = session;
@ -143,7 +142,7 @@ entrance_connect_action_send(unsigned char id)
{
Entrance_Event eev;
PT("Request action %d\n", id);
PT("Request action %d", id);
eev.event.action.action = id;
eev.type = ENTRANCE_EVENT_ACTION;
entrance_event_send(&eev);
@ -153,7 +152,7 @@ void
entrance_connect_conf_gui_send(Entrance_Conf_Gui_Event *ev)
{
Entrance_Event eev;
PT("Send gui config\n");
PT("Send gui config");
eev.event.conf_gui.bg.path = ev->bg.path;
eev.event.conf_gui.bg.group = ev->bg.group;
eev.event.conf_gui.theme = ev->theme;
@ -166,7 +165,7 @@ void
entrance_connect_conf_user_send(Entrance_Login *el)
{
Entrance_Event eev;
PT("Send user config\n");
PT("Send user config");
eev.event.conf_user.login = el->login;
eev.event.conf_user.lsess = el->lsess;
eev.event.conf_user.image.group = el->image.group;
@ -183,7 +182,7 @@ entrance_connect_conf_user_send(Entrance_Login *el)
void *
entrance_connect_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data)
{
PT("auth handler add\n");
PT("auth handler add");
Entrance_Connect_Auth *auth;
auth = malloc(sizeof(Entrance_Connect_Auth));
auth->func = func;
@ -195,7 +194,7 @@ entrance_connect_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data)
void
entrance_connect_auth_cb_del(void *auth)
{
PT("auth handler remove\n");
PT("auth handler remove");
_auth_list = eina_list_remove(_auth_list, auth);
}
@ -210,9 +209,9 @@ entrance_connect_init(void)
_entrance_connect = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM,
"entrance", 42, NULL);
if (_entrance_connect)
PT("client server init ok\n");
PT("client server init ok");
else
PT("client server init fail\n");
PT("client server init fail");
h = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
_entrance_connect_add, NULL);
_handlers = eina_list_append(_handlers, h);

@ -189,8 +189,7 @@ entrance_fill(Evas_Object *obj, Entrance_Fill *ef, const Eina_List *contents, En
_entrance_fill_hoversell(obj, ef, contents, fill_cb, func, data);
else
{
PT("Unknow object type to fill ");
fprintf(stderr, "%s\n", type);
PT("Unknow object type to fill %s", type);
}
}
}

@ -77,12 +77,11 @@ entrance_gui_init(const char *theme)
int x, y, w, h;
int ww = 0, hh = 0;
PT("Gui init: ");
fprintf(stderr, "%s\n", theme);
PT("Gui init: %s", theme);
_gui = calloc(1, sizeof(Entrance_Gui));
if (!_gui)
{
PT("Not Enough memory\n");
PT("Not Enough memory");
return 1;
}
_gui->theme = eina_stringshare_add(theme);
@ -91,8 +90,7 @@ entrance_gui_init(const char *theme)
char *tmp = getenv("DISPLAY");
if (tmp && *tmp)
{
PT("client Using display name");
fprintf(stderr, " %s\n", tmp);
PT("client Using display name %s", tmp);
}
#endif
@ -116,8 +114,7 @@ entrance_gui_init(const char *theme)
screen->edj = ol;
if (!ol)
{
PT("Tut Tut Tut no theme");
fprintf(stderr, "%s\n", "entrance");
PT("Tut Tut Tut no theme for entrance");
return j;
}
elm_object_part_content_set(o, "entrance.screen", ol);
@ -204,7 +201,7 @@ entrance_gui_shutdown(void)
Entrance_Screen *screen;
Entrance_Xsession *xsession;
Entrance_Image *img;
PT("Gui shutdown\n");
PT("Gui shutdown");
evas_object_del(_gui->win);
EINA_LIST_FREE(_gui->screens, screen)
{
@ -338,7 +335,7 @@ entrance_gui_theme_get (Evas_Object *win, const char *group)
PACKAGE_DATA_DIR"/themes/%s.edj", _gui->theme);
if (!elm_layout_file_set(edje, buf, group))
{
PT("Can't load %s theme fallback to default\n", _gui->theme);
PT("Can't load %s theme fallback to default", _gui->theme);
elm_layout_file_set(edje, PACKAGE_DATA_DIR"/themes/default.edj",
group);
}
@ -386,7 +383,7 @@ void
entrance_gui_actions_set(Eina_List *actions)
{
if (!actions) return;
PT("Actions set\n");
PT("Actions set");
_gui->actions = actions;
_entrance_gui_actions_populate();
}
@ -428,7 +425,7 @@ _entrance_gui_users_populate(void)
if (!style)
style = "default"; //theme has not settet a style
PT("Add users list, using item style: %s\n", style);
PT("Add users list, using item style: %s", style);
ef = entrance_fill_new(style,
_entrance_gui_user_text_get,
_entrance_gui_user_content_get,
@ -666,7 +663,7 @@ entrance_gui_user_bg_set(const char *path, const char *group)
Entrance_Screen *screen;
Evas_Object *o;
PT("User Background - %s %s\n", path, group);
PT("User Background - %s %s", path, group);
EINA_LIST_FOREACH(_gui->screens, l, screen)
{
if (path || group)
@ -695,14 +692,14 @@ _entrance_gui_update(void)
Evas_Object *bg = NULL;
if (_gui->changed & ENTRANCE_CONF_WALLPAPER)
{
PT("Set background %s - %s\n", _gui->bg.path, _gui->bg.group);
PT("Set background %s - %s", _gui->bg.path, _gui->bg.group);
bg = _entrance_gui_background_obj_get(screen->transition, _gui->bg.path, _gui->bg.group);
if (!bg)
{
const char *path;
const char *group;
if ((_gui->bg.group) || (_gui->bg.path))
PT("Failed to load new background, fallback on the theme default! \n");
PT("Failed to load new background, fallback on the theme default! ");
bg = entrance_gui_theme_get(screen->transition,
"entrance/background/default");
edje_object_file_get(elm_layout_edje_get(bg), &path, &group);
@ -948,7 +945,7 @@ _entrance_gui_cb_window_property(void *data EINA_UNUSED, int type EINA_UNUSED, v
ev = event_info;
if (ev->atom == ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK)
{
PT("screen managed\n");
PT("screen managed");
elm_exit();
}

@ -160,13 +160,13 @@ _login_password_catch(Evas_Object *widget, Eina_Bool catch)
{
if (catch)
{
PT("catch password\n");
PT("catch password");
login->handler = ecore_event_handler_add(
ECORE_EVENT_KEY_DOWN, _login_key_down_cb, widget);
}
else
{
PT("uncatch password\n");
PT("uncatch password");
ecore_event_handler_del(login->handler);
login->handler = NULL;
}
@ -219,12 +219,12 @@ _login_key_down_cb(void *data, int type EINA_UNUSED, void *event)
{
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
{
PT("focus previous\n");
PT("focus previous");
elm_object_focus_next(data, ELM_FOCUS_PREVIOUS);
}
else
{
PT("focus next\n");
PT("focus next");
elm_object_focus_next(data, ELM_FOCUS_NEXT);
}
}
@ -548,7 +548,7 @@ entrance_login_add(Evas_Object *obj, Entrance_Login_Cb login_cb, void *data)
void
entrance_login_xsessions_populate(Evas_Object *widget, Eina_List *xsessions)
{
PT("Session set\n");
PT("Session set");
Evas_Object *o;
LOGIN_GET(widget);

@ -21,14 +21,14 @@ _theme_get(Evas_Object *win, const char *group)
static void
_signal(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig, const char *src)
{
printf("Event: %s - %s \n", sig, src);
printf("Event: %s - %s ", sig, src);
}
static void
_shutdown(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("Quit\n");
printf("Quit");
elm_exit();
}

@ -2,21 +2,24 @@
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <Eina.h>
#include "Ecore_Getopt.h"
#include <xcb/xcb.h>
#define ENTRANCE_DISPLAY ":0.0"
#define ENTRANCE_XEPHYR ":1.0"
time_t current_time;
struct tm *local_time;
char entrance_time_d[4096];
static Eina_Bool _open_log();
static Eina_Bool _entrance_main(const char *dname);
static void _remove_lock();
static void _signal_cb(int sig);
static void _signal_log(int sig);
static void _entrance_autologin_lock_set(void);
static Eina_Bool _entrance_autologin_lock_get(void);
static Eina_Bool _entrance_client_error(void *data, int type, void *event);
static Eina_Bool _entrance_client_data(void *data, int type, void *event);
static Eina_Bool _entrance_client_del(void *data, int type, void *event);
static void _entrance_wait(void);
static Eina_Bool _testing = 0;
static Eina_Bool _xephyr = 0;
@ -27,7 +30,7 @@ static Ecore_Exe *_entrance_client = NULL;
static void
_signal_cb(int sig)
{
PT("signal %d received\n", sig);
PT("signal %d received", sig);
//FIXME if I don't have main loop at this time ?
if (_entrance_client)
ecore_exe_terminate(_entrance_client);
@ -38,7 +41,7 @@ _signal_cb(int sig)
static void
_signal_log(int sig EINA_UNUSED)
{
PT("reopen the log file\n");
PT("reopen the log file");
entrance_close_log();
_open_log();
}
@ -58,14 +61,14 @@ _get_lock()
f = fopen(entrance_config->lockfile, "w");
if (!f)
{
PT("Couldn't create lockfile!\n");
PT("Couldn't create lockfile!");
return (EINA_FALSE);
}
snprintf(buf, sizeof(buf), "%d\n", my_pid);
snprintf(buf, sizeof(buf), "%d", my_pid);
if (!fwrite(buf, strlen(buf), 1, f))
{
fclose(f);
PT("Couldn't write the lockfile\n");
PT("Couldn't write the lockfile");
return EINA_FALSE;
}
fclose(f);
@ -80,7 +83,7 @@ _get_lock()
if (pid == my_pid)
return EINA_TRUE;
PT("A lock file are present another instance are present ?\n");
PT("A lock file are present another instance are present ?");
return EINA_FALSE;
}
@ -93,9 +96,9 @@ _update_lock()
FILE *f;
char buf[128];
f = fopen(entrance_config->lockfile, "w");
snprintf(buf, sizeof(buf), "%d\n", getpid());
snprintf(buf, sizeof(buf), "%d", getpid());
if (!fwrite(buf, strlen(buf), 1, f))
PT("Coudn't update lockfile\n");
PT("Coudn't update lockfile");
fclose(f);
}
@ -112,15 +115,15 @@ _open_log()
elog = fopen(entrance_config->logfile, "a");
if (!elog)
{
PT("could not open logfile !\n");
PT("could not open logfile !");
return EINA_FALSE;
}
fclose(elog);
if (!freopen(entrance_config->logfile, "a", stdout))
PT("Error on reopen stdout\n");
PT("Error on reopen stdout");
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
if (!freopen(entrance_config->logfile, "a", stderr))
PT("Error on reopen stderr\n");
PT("Error on reopen stderr");
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
return EINA_TRUE;
}
@ -139,42 +142,51 @@ _entrance_wait(void)
{
// XXX: use eina_prefix! hardcoding paths . :(
execl(PACKAGE_BIN_DIR"/entrance_wait", PACKAGE_SBIN_DIR"/entrance", NULL);
PT("HUM HUM HUM can't wait ...\n\n\n");
PT("HUM HUM HUM can't wait ...");
_exit(1);
}
static Eina_Bool
_entrance_client_error(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Exe_Event_Data *ev)
_entrance_client_error(void *data EINA_UNUSED, int type, void *event)
{
char buf[4096];
size_t size = ev->size;
Ecore_Exe_Event_Data *ev;
size_t size;
ev = event;
size = ev->size;
if ((unsigned int)ev->size > sizeof(buf) - 1)
size = sizeof(buf) - 1;
strncpy(buf, (char*)ev->data, size);
PT("Client error: %s", buf);
EINA_LOG_DOM_ERR(_entrance_client_log, "%s", buf);
return ECORE_CALLBACK_DONE;
}
static Eina_Bool
_entrance_client_data(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Exe_Event_Data *ev)
_entrance_client_data(void *d EINA_UNUSED, int t EINA_UNUSED, void *event)
{
char buf[4096];
size_t size = ev->size;
Ecore_Exe_Event_Data *ev;
size_t size;
ev = event;
size = ev->size;
if ((unsigned int)ev->size > sizeof(buf) - 1)
size = sizeof(buf) - 1;
strncpy(buf, (char*)ev->data, size);
PT("Client output: %s", buf);
snprintf(buf, size + 1, "%s", (char*)ev->data);
EINA_LOG_DOM_INFO(_entrance_client_log, "%s", buf);
return ECORE_CALLBACK_DONE;
}
static Eina_Bool
_entrance_main(const char *dname)
{
PT("starting...\n");
PT("starting...");
if (!entrance_config->autologin)
{
if (!_entrance_client)
@ -183,7 +195,7 @@ _entrance_main(const char *dname)
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_entrance_client_del, NULL);
ecore_event_handler_add(ECORE_EXE_EVENT_ERROR,
(Ecore_Event_Handler_Cb)_entrance_client_error, NULL);
_entrance_client_error, NULL);
ecore_event_handler_add(ECORE_EXE_EVENT_DATA,
(Ecore_Event_Handler_Cb)_entrance_client_data, NULL);
snprintf(buf, sizeof(buf),
@ -191,7 +203,7 @@ _entrance_main(const char *dname)
"LD_LIBRARY_PATH="PACKAGE_LIB_DIR" "
PACKAGE_BIN_DIR"/entrance_client -d %s -t %s",
dname, entrance_config->theme);
PT("Exec entrance_client: %s\n", buf);
PT("Exec entrance_client: %s", buf);
_entrance_client = ecore_exe_pipe_run(buf, ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR, NULL);
}
@ -209,20 +221,50 @@ _entrance_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
ev = event;
if (ev->exe != _entrance_client)
return ECORE_CALLBACK_PASS_ON;
PT("client have terminated\n");
PT("client have terminated");
ecore_main_loop_quit();
_entrance_client = NULL;
return ECORE_CALLBACK_DONE;
}
static void
_entrance_autologin_lock_set(void)
{
system("touch /var/cache/entrance/login");
}
static Eina_Bool
_entrance_autologin_lock_get(void)
{
FILE *f;
char buf[4096];
double uptime, sleep_time;
struct stat st_login;
f = fopen("/proc/uptime", "r");
if (f)
{
fgets(buf, sizeof(buf), f);
fscanf(f, "%lf %lf", &uptime, &sleep_time);
fclose(f);
if (stat("/var/run/entrance/login", &st_login) > 0)
return EINA_FALSE;
else
return EINA_TRUE;
}
return EINA_FALSE;
}
static const Ecore_Getopt options =
{
PACKAGE,
"%prog [options]",
VERSION,
"(C) 2011 Enlightenment, see AUTHORS",
"(C) 201e Enlightenment, see AUTHORS",
"GPL, see COPYING",
"Entrance is a login manager, written using core efl libraries",
EINA_TRUE,
@ -230,8 +272,8 @@ static const Ecore_Getopt options =
ECORE_GETOPT_STORE_TRUE('n', "nodaemon", "Don't daemonize."),
ECORE_GETOPT_STORE_TRUE('t', "test", "run in test mode."),
ECORE_GETOPT_STORE_TRUE('e', "fastexit", "Will change the way entrance \
handles the exit of the created session.\n If set, entrance will exit if the session \
quits.\n If not, entrance will restart if the session is quit because of an error, \
handles the exit of the created session. If set, entrance will exit if the session \
quits. 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('x', "xephyr", "run in test mode and use Xephyr."),
ECORE_GETOPT_HELP ('h', "help"),
@ -266,10 +308,18 @@ main (int argc, char ** argv)
ECORE_GETOPT_VALUE_NONE
};
eina_init();
eina_log_threads_enable();
ecore_init();
_entrance_log = eina_log_domain_register("entrance", EINA_COLOR_CYAN);
_entrance_client_log = eina_log_domain_register("entrance_client", EINA_COLOR_CYAN);
eina_log_domain_level_set("entrance", 5);
eina_log_domain_level_set("entrance_client", 5);
args = ecore_getopt_parse(&options, values, argc, argv);
if (args < 0)
{
PT("ERROR: could not parse options.\n");
PT("ERROR: could not parse options.");
return -1;
}
@ -278,7 +328,7 @@ main (int argc, char ** argv)
if (getuid() != 0)
{
fprintf(stderr, "Sorry, only root can run this program!\n");
fprintf(stderr, "Sorry, only root can run this program!");
return 1;
}
if (!_xephyr && getenv("ENTRANCE_XEPHYR"))
@ -287,7 +337,7 @@ main (int argc, char ** argv)
if (fastexit)
{
putenv(strdup("ENTRANCE_FAST_QUIT=1"));
PT("Fast exit enabled !\n");
PT("Fast exit enabled !");
}
if (_xephyr)
@ -323,7 +373,7 @@ main (int argc, char ** argv)
{
if (daemon(0, 1) == -1)
{
PT("Error on daemonize !\n");
PT("Error on daemonize !");
quit_option = EINA_TRUE;
}
_update_lock();
@ -342,7 +392,7 @@ main (int argc, char ** argv)
}
if (!_testing && !_open_log())
{
PT("Can't open log file !!!!\n");
PT("Can't open log file !!!!");
entrance_config_shutdown();
exit(1);
}
@ -353,6 +403,7 @@ main (int argc, char ** argv)
{
char *quit;
entrance_xserver_wait();
sleep(5);
entrance_session_init(dname);
entrance_session_end(entrance_user);
entrance_session_shutdown();
@ -360,14 +411,14 @@ main (int argc, char ** argv)
if (quit)
{
unsetenv("ENTRANCE_QUIT");
PT("Last DE Session quit with error!\n");
PT("Last DE Session quit with error!");
}
_remove_lock();
PT("Entrance will quit, bye bye :).\n");
PT("Entrance will quit, bye bye :).");
entrance_close_log();
exit(1);
}
PT("Welcome\n");
PT("Welcome");
ecore_init();
efreet_init();
/* Initialise event handler */
@ -381,32 +432,35 @@ main (int argc, char ** argv)
signal(SIGALRM, _signal_cb);
signal(SIGUSR2, _signal_log);
PT("session init\n");
PT("session init");
entrance_session_init(dname);
entrance_session_cookie();
if (!_xephyr)
{
PT("xserver init\n");
PT("xserver init");
pid = entrance_xserver_init(_entrance_main, dname);
}
else
_entrance_main(dname);
PT("history init\n");
{
putenv(strdup("ENTRANCE_XPID=-1"));
_entrance_main(dname);
}
PT("history init");
entrance_history_init();
if (entrance_config->autologin)
if ((entrance_config->autologin) && _entrance_autologin_lock_get())
{
PT("autologin init\n");
PT("autologin init");
xcb_connection_t *disp = NULL;
disp = xcb_connect(dname, NULL);
PT("main loop begin\n");
PT("main loop begin");
ecore_main_loop_begin();
PT("auth user\n");
PT("auth user");
#ifdef HAVE_PAM
entrance_pam_init(PACKAGE, dname, NULL);
entrance_pam_item_set(ENTRANCE_PAM_ITEM_USER,
entrance_config->userlogin);
#endif
PT("login user\n");
PT("login user");
entrance_session_login(
entrance_history_user_session_get(entrance_config->userlogin),
EINA_FALSE);
@ -415,60 +469,61 @@ main (int argc, char ** argv)
}
else
{
PT("action init\n");
PT("action init");
entrance_action_init();
PT("server init\n");
PT("server init");
entrance_server_init();
PT("starting main loop\n");
PT("starting main loop");
ecore_main_loop_begin();
PT("main loop end\n");
PT("main loop end");
entrance_server_shutdown();
PT("server shutdown\n");
PT("server shutdown");
entrance_action_shutdown();
PT("action shutdown\n");
PT("action shutdown");
}
entrance_history_shutdown();
PT("history shutdown\n");
PT("history shutdown");
if (_xephyr)
{
//ecore_exe_terminate(xephyr);
PT("Xephyr shutdown\n");
PT("Xephyr shutdown");
}
else
{
entrance_xserver_shutdown();
PT("xserver shutdown\n");
PT("xserver shutdown");
}
#ifdef HAVE_PAM
entrance_pam_shutdown();
PT("pam shutdown\n");
PT("pam shutdown");
#endif
_entrance_autologin_lock_set();
efreet_shutdown();
PT("ecore shutdown\n");
PT("ecore shutdown");
ecore_shutdown();
PT("session shutdown\n");
PT("session shutdown");
entrance_session_shutdown();
if (entrance_session_logged_get())
{
PT("user logged, waiting...\n");
PT("user logged, waiting...");
_entrance_wait();
/* no more running here */
}
_remove_lock();
PT("config shutdown\n");
PT("config shutdown");
entrance_config_shutdown();
PT("eet shutdown\n");
PT("eet shutdown");
eet_shutdown();
free(dname);
if (!_xephyr)
{
PT("ending xserver\n");
PT("ending xserver");
kill(pid, SIGTERM);
entrance_xserver_end();
entrance_xserver_wait();
}
else
PT("No session to wait, exiting\n");
PT("No session to wait, exiting");
entrance_close_log();
return 0;
}

@ -26,20 +26,14 @@
#include "entrance_image.h"
#include "entrance_theme.h"
#define PT(f, x...) \
do \
{ \
current_time = time(NULL); \
local_time = localtime(&current_time); \
memset(entrance_time_d, 0, sizeof(entrance_time_d)); \
strftime(entrance_time_d, sizeof(entrance_time_d), \
"%b %_2d %T", local_time); \
fprintf(stderr, "(%s) "PACKAGE": "f, entrance_time_d, ##x); \
} while (0)
int _entrance_log;
int _entrance_client_log;
extern time_t current_time;
extern struct tm *local_time;
extern char entrance_time_d[4096];
#define PT(f, x...) \
do \
{ \
EINA_LOG_DOM_INFO(_entrance_log, f, ##x); \
} while (0)
void entrance_close_log();

@ -136,7 +136,7 @@ _entrance_action_shutdown(void *data EINA_UNUSED)
static void
_entrance_action_reboot(void *data EINA_UNUSED)
{
PT("Reboot\n");
PT("Reboot");
_action_exe = ecore_exe_run(entrance_config->command.reboot, NULL);
}
@ -149,7 +149,7 @@ _entrance_action_exe_event_del_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
if (!ev->exe) return ret;
if (ev->exe == _action_exe)
{
PT("action quit requested by user\n");
PT("action quit requested by user");
ecore_main_loop_quit();
ret = ECORE_CALLBACK_DONE;
}
@ -204,12 +204,15 @@ _entrance_action_grub2_get(void)
PT("trying to open "GRUB2_FILE);
f = eina_file_open(GRUB2_FILE, EINA_FALSE);
if (!f) return ;
fprintf(stderr, " o");
if (!f)
{
PT("Unable to open "GRUB2_FILE);
return ;
}
data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
if (!data) goto on_error;
fprintf(stderr, "k\n");
PT("open "GRUB2_FILE" ok");
s = data;
r2 = NULL;
@ -241,7 +244,7 @@ _entrance_action_grub2_get(void)
if (!grub2_ok)
{
grub2_ok = 1;
PT("GRUB2 save mode found\n");
PT("GRUB2 save mode found");
}
else
{
@ -268,7 +271,7 @@ _entrance_action_grub2_get(void)
if (!action) goto end_line;
sprintf(action, "Reboot on %s", local);
PT("GRUB2 '%s'\n", action);
PT("GRUB2 '%s'", action);
_entrance_actions =
eina_list_append(_entrance_actions,
_entrance_action_add(action,

@ -31,10 +31,10 @@ main (int argc, char **argv)
ck_connector_get_cookie(ck), 1);
}
else
fprintf(stderr, "entrance_ck: error connecting to ConsoleKit\n");
fprintf(stderr, "entrance_ck: error connecting to ConsoleKit");
}
else
fprintf(stderr, "entrance_ck: can't set up connection to ConsoleKit\n");
fprintf(stderr, "entrance_ck: can't set up connection to ConsoleKit");
if (argc > 1)

@ -54,8 +54,7 @@ _users_get(void)
f = fopen(SYSTEM_CONFIG_DIR"/entrance/entrance.conf", "rb");
if (!f)
{
fprintf(stderr,
PACKAGE": Could not open "SYSTEM_CONFIG_DIR"/entrance/entrance.conf\n");
PT(PACKAGE": Could not open "SYSTEM_CONFIG_DIR"/entrance/entrance.conf");
return;
}
@ -80,7 +79,7 @@ _users_get(void)
fclose(f);
if (eet_data_undump(ef, ENTRANCE_CONFIG_KEY, text, textlen, 1))
fprintf(stderr, PACKAGE": Updating configuration\n");
PT(PACKAGE": Updating configuration");
free(text);
eet_close(ef);
}
@ -104,7 +103,7 @@ _cache_get(void)
if (!config)
{
PT(": Warning no configuration found! This must "
"not append, we will go back to default configuration\n");
"not append, we will go back to default configuration");
config = (Entrance_Config *) calloc(1, sizeof(Entrance_Config));
_defaults_set(config);
}
@ -117,7 +116,7 @@ _cache_get(void)
static void
_config_free(Entrance_Config *config)
{
PT("Config free\n");
PT("Config free");
eina_stringshare_del(config->session_path);
eina_stringshare_del(config->command.xinit_path);
eina_stringshare_del(config->command.xinit_args);
@ -232,7 +231,7 @@ entrance_config_set(const Entrance_Conf_Gui_Event *conf)
}
if (update)
{
PT("Config save\n");
PT("Config save");
if (!ecore_file_is_dir("/var/cache/"PACKAGE))
ecore_file_mkdir("/var/cache/"PACKAGE);
file = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE,

@ -70,7 +70,7 @@ _entrance_history_read(void)
if (!(ef)
|| !(_entrance_history = eet_data_read(ef, _eddh, ENTRANCE_SESSION_KEY)))
{
PT("Error on reading last session login\n");
PT("Error on reading last session login");
_entrance_history = calloc(1, sizeof(Entrance_History));
}
eet_close(ef);
@ -83,7 +83,7 @@ _entrance_history_write(void)
if (_history_update)
{
PT("writing history file\n");
PT("writing history file");
ef = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_HISTORY_FILE,
EET_FILE_MODE_READ_WRITE);
if (!ef)
@ -92,7 +92,7 @@ _entrance_history_write(void)
if (!eet_data_write(ef, _eddh, ENTRANCE_SESSION_KEY,