summarylogtreecommitdiffstats
path: root/0002-Remove-X-support.patch
blob: 3f52adfcb539197f950903d7750124f832eefb36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
From 45ea617f995180bf704a760709efa86401b9394a Mon Sep 17 00:00:00 2001
From: Olivier Brunel <jjk@jjacky.com>
Date: Tue, 15 Nov 2011 15:42:46 +0100
Subject: [PATCH 02/11] Remove X support

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
---
 Makefile         |  22 +-----
 etc/Xresources   |   5 --
 etc/pam.d/xlshd  |   8 ---
 etc/xlshrc       |  25 -------
 include/config.h |  13 ----
 include/xlsh.h   |   1 -
 src/xlsh.c       | 113 ++-----------------------------
 src/xlshd.c      | 199 -------------------------------------------------------
 8 files changed, 6 insertions(+), 380 deletions(-)
 delete mode 100644 etc/Xresources
 delete mode 100644 etc/pam.d/xlshd
 delete mode 100644 etc/xlshrc
 delete mode 100644 src/xlshd.c

diff --git a/Makefile b/Makefile
index 3cabb06..8fae9a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,9 +7,7 @@
 prefix = /usr/local
 
 exec_prefix = $(prefix)
-bindir      = $(exec_prefix)/bin
 sbindir     = $(exec_prefix)/sbin
-sysconfdir  = /etc
 
 SHELL = /bin/sh
 INSTALL = install
@@ -26,49 +24,33 @@ ALL_CFLAGS = -I./include $(CFLAGS) $(CMACROS)
 .SUFFIXES: .o
 vpath %.c ./src
 
-PROGRAMS      = xlsh xlshd
+PROGRAMS      = xlsh
 
 XLSH_OBJ      = xlsh.o libxlsh.o
 XLSH_SOURCE   = xlsh.c libxlsh.c
 XLSH_HEADERS  = xlsh.h libxlsh.h config.h
 XLSH_LIBS     = -lreadline -lpam
 
-XLSHD_OBJ     = xlshd.o libxlsh.o
-XLSHD_SOURCE  = xlshd.c libxlsh.c
-XLSHD_HEADERS = config.h libxlsh.h
-
 all: $(PROGRAMS)
 
 xlsh: $(XLSH_OBJ)
 xlsh: LDLIBS=$(XLSH_LIBS)
 
-xlshd: $(XLSHD_OBJ)
-
 install: installdirs
 	$(INSTALL_PROGRAM) xlsh $(DESTDIR)$(sbindir)
-	$(INSTALL_PROGRAM) xlshd $(DESTDIR)$(sbindir)
-	$(INSTALL_DATA) etc/xlshrc $(DESTDIR)$(sysconfdir)/xlsh
-	$(INSTALL_DATA) etc/Xresources $(DESTDIR)$(sysconfdir)/xlsh
-	$(INSTALL_DATA) etc/pam.d/xlshd $(DESTDIR)$(sysconfdir)/pam.d
 
 install-strip: installdirs
 	$(INSTALL_PROGRAM_STRIP) xlsh $(DESTDIR)$(sbindir)
-	$(INSTALL_PROGRAM_STRIP) xlshd $(DESTDIR)$(sbindir)
-	$(INSTALL_DATA) etc/xlshrc $(DESTDIR)$(sysconfdir)/xlsh
-	$(INSTALL_DATA) etc/Xresources $(DESTDIR)$(sysconfdir)/xlsh
 
 installdirs:
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
-	$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/xlsh
-	$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/pam.d
 
 uninstall:
 	rm -f ${DESTDIR}$(sbindir)/xlsh
-	rm -f ${DESTDIR}$(sbindir)/xlshd
 
 clean:
 	rm -f $(PROGRAMS)
-	rm -f $(XLSH_OBJ) $(XLSHD_OBJ)
+	rm -f $(XLSH_OBJ)
 
 %.o: %.c
 	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< -o $@
diff --git a/etc/Xresources b/etc/Xresources
deleted file mode 100644
index c2f3e0b..0000000
--- a/etc/Xresources
+++ /dev/null
@@ -1,5 +0,0 @@
-! Default resources for XLSH xterm instance.
-*foreground:  #FFD7AF
-*background:  #1F1F1F
-*cursorColor: #B99B86
-*visualBell:  off
diff --git a/etc/pam.d/xlshd b/etc/pam.d/xlshd
deleted file mode 100644
index 862b83f..0000000
--- a/etc/pam.d/xlshd
+++ /dev/null
@@ -1,8 +0,0 @@
-#%PAM-1.0
-auth		required	pam_unix.so
-auth		required	pam_nologin.so
-auth		required	pam_env.so
-account		required	pam_unix.so
-password	required	pam_unix.so
-session		required	pam_unix.so
-session		required	pam_limits.so
diff --git a/etc/xlshrc b/etc/xlshrc
deleted file mode 100644
index ca9fbba..0000000
--- a/etc/xlshrc
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-# XLSH default startup script for X11.
-TERMINAL=xterm
-XRESFILE=/etc/xlsh/Xresources
-BGCOLOR="rgb:1E/23/1F"
-
-screen_w=$(xwininfo -root | grep Width | cut -f2 -d':')
-screen_h=$(xwininfo -root | grep Height | cut -f2 -d':')
-px=$(($screen_w/2 - 240))
-py=$(($screen_h/2 - 120))
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
-export PATH
-if ! which xlsh; then
-  xmessage -center "xlsh cannot be found in PATH!"
-  exit 1
-fi
-
-xrdb -merge "$XRESFILE"
-xsetroot -solid "$BGCOLOR"
-if which xdotool; then
-  ( xwindow=$(xdotool search --sync --class $TERMINAL)
-    xdotool windowfocus "$xwindow" )&
-fi
-exec $TERMINAL -g 80x15+$px+$py -e $(which xlsh)
diff --git a/include/config.h b/include/config.h
index 3f6567e..ec20fc5 100644
--- a/include/config.h
+++ b/include/config.h
@@ -17,27 +17,14 @@
 #define XLSH_PATH      "/bin:/usr/bin:/usr/local/bin"
 #define XLSH_REBOOT    "/sbin/shutdown -r now"
 #define XLSH_HALT      "/sbin/shutdown -h now"
-#define XLSH_XRDB      "/usr/bin/xrdb -remove"
 #define XLSH_XTTY      "/dev/console"
-#define XLSH_XTTY_NAME "X11"
 #define XLSH_DATEFMT   "%Y-%m-%d"
 #define XLSH_TIMEFMT   "%H:%M"
 #define XLSH_PAM_TTY   "login"
-#define XLSH_PAM_X11   "xlshd"
 
 #define XLSH_COMPLETION_LOGIN    0
 #define XLSH_COMPLETION_SHOWROOT 1
 #define XLSH_COMPLETION_MINUID   1000
 #define XLSH_COMPLETION_MAXUID   65534
 
-#define XLSHD_TMPDIR   XLSH_TMPDIR
-#define XLSHD_SHELL    "/bin/sh"
-#define XLSHD_PIDFILE  "/var/run/xlshd.pid"
-#define XLSHD_XSERVER  "/usr/bin/X"
-#define XLSHD_XOPTIONS "-nolisten tcp -noreset"
-#define XLSHD_XDISPLAY ":0"
-#define XLSHD_XLSHRC   "/etc/xlsh/xlshrc"
-#define XLSHD_XWAIT    1
-#define XLSHD_XRETRY   2
-
 #endif
diff --git a/include/xlsh.h b/include/xlsh.h
index 14191ba..a536996 100644
--- a/include/xlsh.h
+++ b/include/xlsh.h
@@ -58,7 +58,6 @@ int xlsh_session_close(pam_handle_t* handle);
 int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg0);
 
 int xlsh_session_tty(const char* user, const char* shell);
-int xlsh_session_x(const char* user, const char* shell);
 
 int xlsh_sys_getinfo(xlsh_system_t* sysinfo);
 int xlsh_sys_issue(const char* issuefile);
diff --git a/src/xlsh.c b/src/xlsh.c
index b22b4e4..ab20703 100644
--- a/src/xlsh.c
+++ b/src/xlsh.c
@@ -51,7 +51,6 @@ static xlsh_command_t xlsh_commands[] = {
   { NULL, NULL, NULL },
 };
 
-static int xlsh_X = 0;
 
 static void xlsh_usage(char* argv0)
 {
@@ -99,18 +98,11 @@ int xlsh_func_login(int argc, char** argv)
     return XLSH_EARG;
   }
 
-  if(xlsh_X) {
-    if(!arg_shell)
-      arg_shell = xlsh_config[XLSH_ID_EXEC].value;
-    return xlsh_session_x(arg_user, arg_shell);
-  }
-  else
     return xlsh_session_tty(arg_user, arg_shell);
 }
 
 int xlsh_func_reboot(int argc, char** argv)
 {
-  pid_t xlshd_pid;
 
   printf("Initiating system reboot ...\n");
   if(libxlsh_proc_exec(XLSH_REBOOT, XLSH_DETACH) == -1) {
@@ -118,28 +110,18 @@ int xlsh_func_reboot(int argc, char** argv)
     return XLSH_ERROR;
   }
 
-  xlshd_pid = libxlsh_pid_read(XLSHD_PIDFILE);
-  if(xlshd_pid > 0)
-    kill(xlshd_pid, SIGTERM);
-
   pause();
   return XLSH_EDONE;
 }
 
 int xlsh_func_shutdown(int argc, char** argv)
 {
-  pid_t xlshd_pid;
-
   printf("Initiating system shutdown ...\n");
   if(libxlsh_proc_exec(XLSH_HALT, XLSH_DETACH) == -1) {
     fprintf(stderr, "Failed to execute: %s\n", XLSH_HALT);
     return XLSH_ERROR;
   }
 
-  xlshd_pid = libxlsh_pid_read(XLSHD_PIDFILE);
-  if(xlshd_pid > 0)
-    kill(xlshd_pid, SIGTERM);
-
   pause();
   return XLSH_EDONE;
 }
@@ -241,11 +223,7 @@ int xlsh_session_open(const char* service, const char* user,
 
   if(pam_start(service, user, &conv, &pam_handle) != PAM_SUCCESS)
     return XLSH_ERROR;
-  
-  if(xlsh_X)
-    pam_set_item(pam_handle, PAM_TTY, XLSH_XTTY);
-  else
-    pam_set_item(pam_handle, PAM_TTY, ttyname(0));
+  pam_set_item(pam_handle, PAM_TTY, ttyname(0));
 
   if(pam_authenticate(pam_handle, 0) != PAM_SUCCESS) {
     pam_end(pam_handle, 0);
@@ -287,7 +265,6 @@ int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg
   const char* pwname;
   char terminal[256];
   pid_t proc_shell;
-  int   proc_wait = 0;
 
   const char* _arg0 = arg0;
   if(!arg0) _arg0 = session;
@@ -318,14 +295,7 @@ int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg
     setenv("HOME", pwinfo->pw_dir, 1);
     setenv("PATH", xlsh_config[XLSH_ID_PATH].value, 1);
     
-    if(xlsh_X) {
-      setenv("SHELL", pwinfo->pw_shell, 1);
-      setenv("DISPLAY", xlsh_config[XLSH_ID_DISPLAY].value, 1);
-      if(libxlsh_proc_exec(XLSH_XRDB, 0) > 0)
-	wait(&proc_wait);
-    }
-    else
-      setenv("SHELL", session, 1);
+    setenv("SHELL", session, 1);
 		
     if(*terminal)
       setenv("TERM", terminal, 1);
@@ -382,70 +352,6 @@ int xlsh_session_tty(const char* user, const char* shell)
   return XLSH_EDONE;
 }
 
-int xlsh_session_x(const char* user, const char* shell)
-{
-  pid_t proc_session;
-  int   proc_result;
-  char  buffer[PATH_MAX];
-
-  sigset_t sigset[2];
-  int      waitflag;
-  
-  pam_handle_t* pam_handle;
-  
-  if((proc_session = fork()) == 0) {
-    if(xlsh_session_open(XLSH_PAM_X11, user, &pam_handle) != XLSH_EOK) {
-      fprintf(stderr, "Authorization failed\n");
-      exit(EXIT_FAILURE);
-    }
-
-    setsid();
-    if(xlsh_session_exec(pam_handle, shell, NULL) != XLSH_EOK) {
-      fprintf(stderr, "Cannot execute shell process: %s\n", shell);
-      exit(EXIT_FAILURE);
-    }
-
-    waitflag = 0;
-    kill(getppid(), SIGUSR1);
-    wait(&waitflag);
-    
-    xlsh_session_close(pam_handle);
-    exit(EXIT_SUCCESS);
-  }
-  else {
-    if(proc_session == -1) {
-      fprintf(stderr, "Could not fork child process: %s\n", strerror(errno));
-      return XLSH_ERROR;
-    }
-
-    sigemptyset(&sigset[0]);
-    sigaddset(&sigset[0], SIGCHLD);
-    sigaddset(&sigset[0], SIGUSR1);
-    sigprocmask(SIG_BLOCK, &sigset[0], &sigset[1]);
-    
-    snprintf(buffer, PATH_MAX, "%s/.xlsh-%d.pid",
-	     xlsh_config[XLSH_ID_TMPDIR].value, getppid());
-    libxlsh_pid_lock(buffer, proc_session, 1);
-    
-    proc_result = sigwaitinfo(&sigset[0], NULL);
-    sigprocmask(SIG_SETMASK, &sigset[1], NULL);
-
-    switch(proc_result) {
-    case SIGCHLD:
-      unlink(buffer);
-      return XLSH_ERROR;
-    case SIGUSR1:
-      return XLSH_EDONE;
-    default:
-      fprintf(stderr, "wait() syscall failed for session process: %s\n",
-	      strerror(errno));
-      unlink(buffer);
-      return XLSH_ERROR;
-    }
-  }
-    
-  return XLSH_EOK;
-}
 
 // Configuration
 void xlsh_config_init(char* exec_arg)
@@ -616,7 +522,7 @@ int xlsh_sys_getinfo(xlsh_system_t* sysinfo)
   struct tm *tminfo;
   time_t timeval;
   
-  char* disp_name, *tty_name;
+  char *tty_name;
   char  tty_path[PATH_MAX];
   
   memset(sysinfo, 0, sizeof(xlsh_system_t));
@@ -629,15 +535,7 @@ int xlsh_sys_getinfo(xlsh_system_t* sysinfo)
     strcpy(tty_path, XLSH_XTTY);
   strncpy(sysinfo->ttypath, tty_path + 5, sizeof(sysinfo->ttypath));
   
-  if(xlsh_X) {
-    disp_name = getenv("DISPLAY");
-    if(disp_name[0] == ':')
-      disp_name++;
-    sprintf(tty_path, "%s/%s", XLSH_XTTY_NAME, disp_name);
-    tty_name = tty_path;
-  }
-  else
-    tty_name = tty_path + 5;
+  tty_name = tty_path + 5;
   strncpy(sysinfo->ttyname, tty_name, sizeof(sysinfo->ttyname));
   
   timeval = time(NULL);
@@ -727,9 +625,6 @@ int main(int argc, char** argv)
   sigaddset(&sigmask, SIGHUP);
   sigprocmask(SIG_BLOCK, &sigmask, NULL);
 
-  if(getenv("DISPLAY"))
-    xlsh_X = 1;
-  
   xlsh_config_init(opt_exec);
   xlsh_sys_issue(xlsh_config[XLSH_ID_ISSUE].value);
   
diff --git a/src/xlshd.c b/src/xlshd.c
deleted file mode 100644
index 3c79581..0000000
--- a/src/xlshd.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* eXtended Login Shell (X daemon)
- * (c) 2011 MichaƂ Siejak
- *
- * See COPYING file for license details.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <config.h>
-#include <libxlsh.h>
-
-static void xlshd_usage(const char* argv0)
-{
-  fprintf(stderr, "eXtended Login Shell X daemon, version %s\n", XLSH_VERSION_STRING);
-  fprintf(stderr, "usage: %s [-f|-h] [display]\n", argv0);
-  exit(EXIT_FAILURE);
-}
-
-static void xlshd_sig_daemonize(int signum)
-{
-  switch(signum) {
-  case SIGALRM: exit(EXIT_FAILURE);
-  case SIGCHLD: exit(EXIT_FAILURE);
-  case SIGUSR1: exit(EXIT_SUCCESS);
-  }
-}
-
-static volatile sig_atomic_t xlshd_quit = 0;
-static void xlshd_sig_quit(int signum)
-{
-  xlshd_quit = 1;
-}
-
-void xlshd_daemonize(const char* argv0)
-{
-  pid_t pid;
-  struct sigaction sighandler;
-  struct sigaction def_sigchld, def_sigusr1, def_sigalrm;
-  
-  memset(&sighandler, 0, sizeof(struct sigaction));
-  sighandler.sa_handler = xlshd_sig_daemonize;
-
-  sigaction(SIGCHLD, &sighandler, &def_sigchld);
-  sigaction(SIGUSR1, &sighandler, &def_sigusr1);
-  sigaction(SIGALRM, &sighandler, &def_sigalrm);
-
-  pid = fork();
-  if(pid < 0) {
-    fprintf(stderr, "%s: Could not daemonize: %s\n", argv0, strerror(errno));
-    exit(EXIT_FAILURE);
-  }
-  if(pid > 0) {
-    alarm(2);
-    pause();
-    exit(EXIT_FAILURE);
-  }
-
-  sigaction(SIGCHLD, &def_sigchld, NULL);
-  sigaction(SIGUSR1, &def_sigusr1, NULL);
-  sigaction(SIGALRM, &def_sigalrm, NULL);
-
-  umask(S_IWGRP | S_IWOTH);
-  chdir("/");
-  if(setsid() < 0)
-    exit(EXIT_FAILURE);
-
-  kill(getppid(), SIGUSR1);
-}
-
-int main(int argc, char** argv)
-{
-  int  opt_index          = 1;
-  int  opt_nodaemon       = 0;
-  
-  const char* opt_display = XLSHD_XDISPLAY;
-
-  char buffer[PATH_MAX];
-  pid_t xserver_pid  = 0;
-  pid_t xrc_pid      = 0;
-  pid_t xsession_pid = 0;
-
-  sigset_t sigmask;
-  struct sigaction sighandler;
-  int waitflag, retval;
-  
-  if(argc > opt_index && strcmp(argv[opt_index], "-h")==0)
-    xlshd_usage(argv[0]);
-  if(argc > opt_index && strcmp(argv[opt_index], "-f")==0) {
-    opt_nodaemon = 1;
-    opt_index++;
-  }
-  if(argc > opt_index)
-    opt_display = argv[opt_index];
-
-  if(geteuid() != 0) {
-    fprintf(stderr, "%s: You need to have root privileges\n", argv[0]);
-    return EXIT_FAILURE;
-  }
-
-  switch(libxlsh_pid_lock(XLSHD_PIDFILE, getpid(), 0)) {
-  case XLSH_EFOUND:
-    fprintf(stderr, "%s: Pidfile %s exists, aborted\n",
-	    argv[0], XLSHD_PIDFILE);
-    return EXIT_FAILURE;
-  case XLSH_ERROR:
-    fprintf(stderr, "%s: Cannot create pidfile: %s\n",
-	    argv[0], XLSHD_PIDFILE);
-    return EXIT_FAILURE;
-  }
-  
-  if(!opt_nodaemon) {
-    xlshd_daemonize(argv[0]);
-    libxlsh_pid_lock(XLSHD_PIDFILE, getpid(), XLSH_OVERWRITE);
-  }
-  
-  stdin  = freopen("/dev/null", "r", stdin);
-  stdout = freopen("/dev/null", "w", stdout);
-  stderr = freopen("/dev/null", "w", stderr);
-
-  libxlsh_proc_sigmask();
-
-  sigemptyset(&sigmask);
-  sigaddset(&sigmask, SIGHUP);
-  sigaddset(&sigmask, SIGUSR1);
-  sigaddset(&sigmask, SIGUSR2);
-  sigprocmask(SIG_BLOCK, &sigmask, NULL);
-
-  memset(&sighandler, 0, sizeof(struct sigaction));
-  sighandler.sa_handler = xlshd_sig_quit;
-  sigaction(SIGTERM, &sighandler, NULL);
-  sigaction(SIGINT, &sighandler, NULL);
-
-  retval = EXIT_SUCCESS;
-  while(!xlshd_quit) {
-    xserver_pid  = 0;
-    xsession_pid = 0;
-    xrc_pid      = 0;
-    
-    snprintf(buffer, PATH_MAX, "%s %s %s", XLSHD_XSERVER, XLSHD_XOPTIONS, opt_display);
-    if((xserver_pid = libxlsh_proc_exec(buffer, 0)) < 0) {
-      retval = EXIT_FAILURE;
-      break;
-    }
-  
-    setenv("DISPLAY", opt_display, 1);
-    sleep(XLSHD_XWAIT);
-
-    snprintf(buffer, PATH_MAX, "%s %s", XLSHD_SHELL, XLSHD_XLSHRC);
-    if((xrc_pid = libxlsh_proc_exec(buffer, 0)) < 0) {
-      kill(xserver_pid, SIGTERM);
-      retval = EXIT_FAILURE;
-      break;
-    }
-
-    waitflag = 1;
-    waitpid(xrc_pid, &waitflag, 0);
-    if(xlshd_quit) break;
-
-    snprintf(buffer, PATH_MAX, "%s/.xlsh-%d.pid", XLSHD_TMPDIR, xrc_pid);
-    xsession_pid = libxlsh_pid_read(buffer);
-    if(xsession_pid > 0) {
-      while(!kill(xsession_pid, 0) && !xlshd_quit)
-	sleep(XLSHD_XWAIT);
-      unlink(buffer);
-    }
-
-    if(xlshd_quit) break;
-
-    waitflag = -1;
-    kill(xserver_pid, SIGTERM);
-    wait(&waitflag);
-    sleep(XLSHD_XRETRY);
-  }
-
-  if(xsession_pid > 0) {
-    kill(xsession_pid, SIGTERM);
-    sleep(XLSHD_XWAIT);
-  }
-  if(xrc_pid > 0)
-    kill(xrc_pid, SIGTERM);
-  if(xserver_pid > 0) {
-    waitflag = -1;
-    kill(xserver_pid, SIGTERM);
-    wait(&waitflag);
-  }
-
-  unlink(XLSHD_PIDFILE);
-  return retval;
-}
-- 
2.7.0