~ubuntu-branches/ubuntu/lucid/lxdm/lucid

« back to all changes in this revision

Viewing changes to src/lxdm.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-01-31 23:35:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100131233502-nzdhokfq6lbicgfr
Tags: 0.2.0~svn2307+git20100209-0ubuntu1
* New upstream snapshot, from git (40c1561c8d).
* debian/rules
 - Pass config file with CFLAGS to /etc/lxdm/default.list. This location will
   be updated by update-alternative to handle multiple configuration files.
 - Pass --libexecdir=/usr/lib/lxdm configure flag.
* debian/patches/
 - 14-lubuntu-config-file.patch: Removed, handle by update-alternative.
 - 13-plymouth-support.patch: Removed, merged upstream.
 - 12-replace-libexec.patch: removed, handle by --libexecdir=/usr/lib/lxdm
* debian/control
 - Add depends on librsvg2-common, the theme use SVG image.
* debian/lxdm.postinst & debian/prerm
 - Use update-alternate to configure default configuration file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <sys/vt.h>
55
55
#include <sys/ioctl.h>
56
56
 
 
57
#include <execinfo.h>
 
58
 
57
59
#if HAVE_LIBXMU
58
60
#include <X11/Xmu/WinUtil.h>
59
61
#endif
68
70
 
69
71
#include "lxdm.h"
70
72
 
71
 
#define XSESSIONS_DIR    "/usr/share/xsessions"
72
 
 
73
73
GKeyFile *config;
74
74
static pid_t server;
75
75
#if HAVE_LIBCK_CONNECTOR
115
115
        close(fd);
116
116
}
117
117
 
 
118
static gboolean plymouth_is_running(void)
 
119
{
 
120
        int status;
 
121
        gboolean res;
 
122
 
 
123
        res=g_spawn_command_line_sync ("/bin/plymouth --ping",NULL,NULL,&status,NULL);
 
124
        if(!res) return FALSE;
 
125
        return WIFEXITED (status) && WEXITSTATUS (status) == 0;
 
126
}
 
127
 
 
128
static void plymouth_quit_with_transition(void)
 
129
{
 
130
        g_spawn_command_line_sync("/bin/plymouth quit --retain-splash",NULL,NULL,NULL,NULL);
 
131
}
 
132
 
 
133
static void plymouth_quit_without_transition(void)
 
134
{
 
135
        g_spawn_command_line_sync("/bin/plymouth quit --retain-splash",NULL,NULL,NULL,NULL);
 
136
}
 
137
 
 
138
static void plymouth_prepare_transition(void)
 
139
{
 
140
//      g_spawn_command_line_sync ("/bin/plymouth deactivate",NULL,NULL,NULL,NULL);
 
141
}
 
142
 
118
143
void lxdm_get_tty(void)
119
144
{
120
145
    char *s = g_key_file_get_string(config, "server", "arg", 0);
123
148
    int len;
124
149
    int gotvtarg = 0;
125
150
    int nr = 0;
 
151
    gboolean plymouth;
 
152
    
 
153
    plymouth=plymouth_is_running();
 
154
    if(plymouth) plymouth_prepare_transition();
126
155
 
127
156
    old_tty=get_active_vt();
128
157
    if( !s ) s = g_strdup("/usr/bin/X");
138
167
            gotvtarg = 1;
139
168
        }
140
169
    }
141
 
    if( !gotvtarg )
 
170
    if(!gotvtarg)
142
171
    {
143
172
        /* support plymouth */
144
173
        nr = g_file_test("/var/spool/gdm/force-display-on-active-vt", G_FILE_TEST_EXISTS);
146
175
            /* use the active vt */
147
176
            tty = old_tty;
148
177
        if( nr ) unlink("/var/spool/gdm/force-display-on-active-vt");
 
178
        if(plymouth)
 
179
        {
 
180
                        nr=1;
 
181
                        plymouth_quit_with_transition();
 
182
                }
149
183
    }
 
184
    else
 
185
    {
 
186
                if(plymouth) /* set tty and plymouth running */
 
187
                        plymouth_quit_without_transition();
 
188
        }
150
189
    arg = g_renew(char *, arg, len + 10);
151
190
    if( !gotvtarg )
152
191
        arg[len++] = g_strdup_printf("vt%d", tty);
177
216
 
178
217
void log_print(char *fmt, ...)
179
218
{
180
 
    static FILE *log;
 
219
    FILE *log;
181
220
    va_list ap;
182
 
    if( !fmt )
183
 
    {
184
 
        if( log )
185
 
            fclose(log);
186
 
        log = 0;
187
 
        return;
188
 
    }
189
 
    if( !log )
190
 
    {
191
 
        log = fopen("/var/log/lxdm.log", "w");
192
 
        if( !log )
193
 
            return;
194
 
    }
 
221
    log = fopen("/var/log/lxdm.log", "a");
 
222
    if(!log) return;
195
223
    va_start(ap, fmt);
196
224
    vfprintf(log, fmt, ap);
197
225
    va_end(ap);
198
 
    fflush(log);
 
226
    fclose(log);
199
227
}
200
228
 
201
229
GSList *do_scan_xsessions(void)
404
432
    pamh = NULL;
405
433
}
406
434
 
 
435
#if 0
407
436
void append_pam_environ(char **env)
408
437
{
409
438
        int i,j,n;
429
458
        }
430
459
        free(penv);
431
460
}
 
461
#endif
432
462
 
433
463
#endif
434
464
 
848
878
        }
849
879
        
850
880
#if HAVE_LIBPAM
 
881
#if 0
851
882
                append_pam_environ(env);
852
883
#endif
 
884
#endif
853
885
 
854
886
#if 0
855
887
        if( !session || !session[0] ) /* this means use default session */
926
958
    return 1;
927
959
}
928
960
 
929
 
void sig_handler(int sig)
 
961
static void log_sigsegv(void)
 
962
{
 
963
        void *array[40];
 
964
        size_t size;
 
965
        int fd;
 
966
 
 
967
        fd=open("/var/log/lxdm.log",O_WRONLY|O_CREAT|O_APPEND,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 
968
        if(fd==-1) return;
 
969
 
 
970
        size=backtrace(array,40);
 
971
        backtrace_symbols_fd(array,size,fd);
 
972
 
 
973
        close(fd);
 
974
}
 
975
 
 
976
static void sig_handler(int sig)
930
977
{
931
978
    log_print("catch signal %d\n", sig);
932
979
    switch( sig )
935
982
    case SIGINT:
936
983
        lxdm_quit_self();
937
984
        break;
 
985
    case SIGSEGV:
 
986
        log_sigsegv();
 
987
        break;
938
988
    default:
939
989
        break;
940
990
    }
950
1000
    signal(SIGPIPE, sig_handler);
951
1001
    signal(SIGUSR1, sig_handler);
952
1002
    signal(SIGALRM, sig_handler);
 
1003
    signal(SIGSEGV, sig_handler);
953
1004
}
954
1005
 
955
1006
#if HAVE_LIBCK_CONNECTOR
992
1043
    self = arg[0];
993
1044
 
994
1045
    config = g_key_file_new();
995
 
    g_key_file_load_from_file(config, "/etc/lxdm/lxdm.conf", G_KEY_FILE_NONE, NULL);
 
1046
    g_key_file_load_from_file(config, CONFIG_FILE, G_KEY_FILE_NONE, NULL);
996
1047
 
997
1048
    get_lock();
998
1049
    atexit(exit_cb);