summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Brunel2014-11-17 15:15:12 +0100
committerOlivier Brunel2015-06-08 19:26:10 +0200
commit63c15cbc85b0a37751daa70bb9da655676ed71d4 (patch)
tree08023e0965c3ced7e7a61267cf3e3afa5edb094d
parente934eb506f9f0fdbad50695cd63c1400d8bbcdc0 (diff)
downloadaur-63c15cbc85b0a37751daa70bb9da655676ed71d4.tar.gz
xlsh-without-x: Tweak PKGBUILD and add some patches
Refresh things a bit in the PKGBUILD, I've now forked xlsh and maintain my changes in a git repo; so we'll use the patches from there instead of one big "patch" file. Also adding patches that: - don't block signals, as this caused issues (e.g. w/ systemd on shutdown) - set up environment from PAM, so we get variables set from pam_env or logind Signed-off-by: Olivier Brunel <jjk@jjacky.com>
-rw-r--r--.SRCINFO25
-rw-r--r--0001-Add-compilation-option-for-login-completion.patch59
-rw-r--r--0002-Remove-X-support.patch599
-rw-r--r--0003-config.h-Tweak-prompt.patch26
-rw-r--r--0004-Makefile-Switch-prefix-to-usr.patch26
-rw-r--r--0005-Don-t-block-signals-as-it-caused-issues.patch96
-rw-r--r--0006-Set-environment-from-PAM.patch92
-rw-r--r--0007-Add-.gitignore.patch25
-rw-r--r--0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch47
-rw-r--r--PKGBUILD52
-rw-r--r--patch340
-rw-r--r--xlsh.install19
12 files changed, 1022 insertions, 384 deletions
diff --git a/.SRCINFO b/.SRCINFO
index cb8eb436a02..babc7dee326 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,19 +1,32 @@
pkgbase = xlsh-without-x
pkgdesc = eXtended Login Shell - fast, minimalistic login replacement (without X support)
pkgver = 0.2.2
- pkgrel = 2
+ pkgrel = 3
url = https://github.com/Nadrin/xlsh/wiki
- install = xlsh.install
arch = i686
arch = x86_64
license = GPL3
depends = pam
depends = readline
provides = xlsh=0.2.2
- source = https://github.com/Nadrin/xlsh/tarball/master
- source = patch
- md5sums = cf78ceec269cc3e35797fe6e8631c3b3
- md5sums = bf4e6b42787da0988ae56456d1246937
+ source = xlsh-0.2.2.tar.gz::https://github.com/Nadrin/xlsh/tarball/master
+ source = 0001-Add-compilation-option-for-login-completion.patch
+ source = 0002-Remove-X-support.patch
+ source = 0003-config.h-Tweak-prompt.patch
+ source = 0004-Makefile-Switch-prefix-to-usr.patch
+ source = 0005-Don-t-block-signals-as-it-caused-issues.patch
+ source = 0006-Set-environment-from-PAM.patch
+ source = 0007-Add-.gitignore.patch
+ source = 0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch
+ sha256sums = ffc8c31503d252d104f98259842a8da5163862870bfdfe0a07ffc0833b6a1102
+ sha256sums = 7c690c750fcb18d888782014f30109d5ed44b578f524a3cdae1ecaa3ae4fd6ae
+ sha256sums = e293e25e9a8cbbe15249efce8f1300a83b7f35396666aca0d300363146fd013a
+ sha256sums = 5fa5f298015fda12b67914a255dc1d6988716959ea1400eaa8fd9773ce42c435
+ sha256sums = 94b539e8efa4158c19c0ff950f45a157b7d412cd56e86194d790f76912f19da5
+ sha256sums = d6b8c6a83dbc95040200dc3b718f74be3922bf8b90db5683683adf12bd6f63de
+ sha256sums = fdf1af691da9be4278be4b51727bd9eb07b4c9b244b8a772adc8b85482679cbe
+ sha256sums = 33000c592e06a518c4893d4d95209ba809dca97ae8115e22bc784d4c67a84cab
+ sha256sums = 6d9f1a050fc46264cdcb7d7bc05325dc44fb94d0213be10acf0c51ca9d8c7da9
pkgname = xlsh-without-x
diff --git a/0001-Add-compilation-option-for-login-completion.patch b/0001-Add-compilation-option-for-login-completion.patch
new file mode 100644
index 00000000000..2032ff11ebe
--- /dev/null
+++ b/0001-Add-compilation-option-for-login-completion.patch
@@ -0,0 +1,59 @@
+From 1ee25d8e41581ac178545bde6dfa00229e3f809a Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Tue, 15 Nov 2011 15:02:59 +0100
+Subject: [PATCH 1/8] Add compilation option for login completion
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ include/config.h | 1 +
+ src/xlsh.c | 6 ++++++
+ 2 files changed, 7 insertions(+)
+
+diff --git a/include/config.h b/include/config.h
+index 743eaf0..3f6567e 100644
+--- a/include/config.h
++++ b/include/config.h
+@@ -25,6 +25,7 @@
+ #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
+diff --git a/src/xlsh.c b/src/xlsh.c
+index b8181e2..b22b4e4 100644
+--- a/src/xlsh.c
++++ b/src/xlsh.c
+@@ -516,6 +516,7 @@ static char* xlsh_cmd_match_command(const char* text, int state)
+ return NULL;
+ }
+
++#if XLSH_COMPLETION_LOGIN
+ static char* xlsh_cmd_match_user(const char* text, int state)
+ {
+ static size_t len;
+@@ -540,6 +541,7 @@ static char* xlsh_cmd_match_user(const char* text, int state)
+ endpwent();
+ return NULL;
+ }
++#endif
+
+ static char** xlsh_cmd_complete(const char* text, int start, int end)
+ {
+@@ -552,8 +554,12 @@ static char** xlsh_cmd_complete(const char* text, int start, int end)
+ return rl_completion_matches(const_cast.c,
+ xlsh_cmd_match_command);
+ else
++#if XLSH_COMPLETION_LOGIN
+ return rl_completion_matches(const_cast.c,
+ xlsh_cmd_match_user);
++#else
++ return NULL;
++#endif
+ }
+
+ int xlsh_cmd_loop(void)
+--
+2.1.3
+
diff --git a/0002-Remove-X-support.patch b/0002-Remove-X-support.patch
new file mode 100644
index 00000000000..44d4b9ae2d6
--- /dev/null
+++ b/0002-Remove-X-support.patch
@@ -0,0 +1,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 2/8] 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.1.3
+
diff --git a/0003-config.h-Tweak-prompt.patch b/0003-config.h-Tweak-prompt.patch
new file mode 100644
index 00000000000..bde0b6720b7
--- /dev/null
+++ b/0003-config.h-Tweak-prompt.patch
@@ -0,0 +1,26 @@
+From 46d3104ffba1ffc66e085597c25475cd0ff0cb9c Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:02:26 +0100
+Subject: [PATCH 3/8] config.h: Tweak prompt
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ include/config.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/config.h b/include/config.h
+index ec20fc5..9e00c4a 100644
+--- a/include/config.h
++++ b/include/config.h
+@@ -10,7 +10,7 @@
+ // Tweak parameters to suit your needs before compiling.
+
+ #define XLSH_EXEC "./.xsession"
+-#define XLSH_PROMPT "xlsh (%s)> "
++#define XLSH_PROMPT "> "
+ #define XLSH_TMPDIR "/tmp"
+ #define XLSH_SHELLS "/etc/shells"
+ #define XLSH_ISSUE "/etc/issue"
+--
+2.1.3
+
diff --git a/0004-Makefile-Switch-prefix-to-usr.patch b/0004-Makefile-Switch-prefix-to-usr.patch
new file mode 100644
index 00000000000..14530505ce6
--- /dev/null
+++ b/0004-Makefile-Switch-prefix-to-usr.patch
@@ -0,0 +1,26 @@
+From 00915458dd640b9d3cf538ae48f308d9ff65448e Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:02:38 +0100
+Subject: [PATCH 4/8] Makefile: Switch prefix to /usr
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 8fae9a2..f4fd67c 100644
+--- a/Makefile
++++ b/Makefile
+@@ -4,7 +4,7 @@
+ .DEFAULT_GOAL = all
+ .PHONY: all install install-strip installdirs uninstall clean
+
+-prefix = /usr/local
++prefix = /usr
+
+ exec_prefix = $(prefix)
+ sbindir = $(exec_prefix)/sbin
+--
+2.1.3
+
diff --git a/0005-Don-t-block-signals-as-it-caused-issues.patch b/0005-Don-t-block-signals-as-it-caused-issues.patch
new file mode 100644
index 00000000000..79e0c83a230
--- /dev/null
+++ b/0005-Don-t-block-signals-as-it-caused-issues.patch
@@ -0,0 +1,96 @@
+From b3f9bdb405acef29cefd4b3f3d02a1903ba80d09 Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:09:28 +0100
+Subject: [PATCH 5/8] Don't block signals, as it caused issues
+
+Blocking signals doesn't seem to be required (xlsh will be restarted
+automatically anyways, just as when using command exit (login doesn't
+block them either)) but blocking them can cause trouble, e.g. when
+using systemd, it could lead to systemd sending a signal and wait, but
+since it was blocked one needed to manually use command exit for xlsh
+to end/system to shutdown.
+
+(There was also the issue that blocking SIGINT/SIGHUP was not restoring
+them upon login would have them still blocked with the session, leading
+to issues thereafter.)
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ include/libxlsh.h | 1 -
+ src/libxlsh.c | 8 --------
+ src/xlsh.c | 7 -------
+ 3 files changed, 16 deletions(-)
+
+diff --git a/include/libxlsh.h b/include/libxlsh.h
+index 4a5d6ee..16ca799 100644
+--- a/include/libxlsh.h
++++ b/include/libxlsh.h
+@@ -23,7 +23,6 @@
+ #define XLSH_DETACH 0x02
+
+ size_t libxlsh_strnlen(const char* s, size_t maxlen);
+-void libxlsh_proc_sigmask(void);
+ pid_t libxlsh_proc_exec(const char* cmdline, int flags);
+ pid_t libxlsh_pid_read(const char* filename);
+ int libxlsh_pid_lock(const char* filename, pid_t pid, int flags);
+diff --git a/src/libxlsh.c b/src/libxlsh.c
+index 8f7556b..1a26e32 100644
+--- a/src/libxlsh.c
++++ b/src/libxlsh.c
+@@ -16,8 +16,6 @@
+ #include <config.h>
+ #include <libxlsh.h>
+
+-static sigset_t xlsh_default_sigmask;
+-
+ // Compatibility functions
+ size_t libxlsh_strnlen(const char* s, size_t maxlen)
+ {
+@@ -27,11 +25,6 @@ size_t libxlsh_strnlen(const char* s, size_t maxlen)
+ }
+
+ // Process functions
+-void libxlsh_proc_sigmask(void)
+-{
+- sigprocmask(0, NULL, &xlsh_default_sigmask);
+-}
+-
+ pid_t libxlsh_proc_exec(const char* cmdline, int flags)
+ {
+ pid_t pid;
+@@ -52,7 +45,6 @@ pid_t libxlsh_proc_exec(const char* cmdline, int flags)
+
+ if(flags & XLSH_DETACH)
+ setsid();
+- sigprocmask(SIG_SETMASK, &xlsh_default_sigmask, NULL);
+ execv(argv[0], argv);
+ exit(EXIT_FAILURE);
+ }
+diff --git a/src/xlsh.c b/src/xlsh.c
+index ab20703..e4fbf7c 100644
+--- a/src/xlsh.c
++++ b/src/xlsh.c
+@@ -606,7 +606,6 @@ int main(int argc, char** argv)
+ {
+ char* opt_exec = NULL;
+ int retvalue;
+- sigset_t sigmask;
+
+ if(argc > 1) {
+ if(strcmp(argv[1], "-h") == 0)
+@@ -618,12 +617,6 @@ int main(int argc, char** argv)
+ fprintf(stderr, "%s: You need to have root privileges\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+-
+- libxlsh_proc_sigmask();
+- sigemptyset(&sigmask);
+- sigaddset(&sigmask, SIGINT);
+- sigaddset(&sigmask, SIGHUP);
+- sigprocmask(SIG_BLOCK, &sigmask, NULL);
+
+ xlsh_config_init(opt_exec);
+ xlsh_sys_issue(xlsh_config[XLSH_ID_ISSUE].value);
+--
+2.1.3
+
diff --git a/0006-Set-environment-from-PAM.patch b/0006-Set-environment-from-PAM.patch
new file mode 100644
index 00000000000..b668bdf9ca6
--- /dev/null
+++ b/0006-Set-environment-from-PAM.patch
@@ -0,0 +1,92 @@
+From bdfd5079433180aac28b68be796d52c5bfbd7c8c Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:13:27 +0100
+Subject: [PATCH 6/8] Set environment from PAM
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ src/xlsh.c | 48 ++++++++++++++++++++++++++++++++----------------
+ 1 file changed, 32 insertions(+), 16 deletions(-)
+
+diff --git a/src/xlsh.c b/src/xlsh.c
+index e4fbf7c..3fc1711 100644
+--- a/src/xlsh.c
++++ b/src/xlsh.c
+@@ -259,11 +259,31 @@ int xlsh_session_close(pam_handle_t* handle)
+ return XLSH_EOK;
+ }
+
++static void _putenv (pam_handle_t *handle, const char *name, const char *value)
++{
++ char buf[256], *b = buf;
++ size_t len;
++
++ if (!value)
++ return;
++
++ len = strlen (name) + strlen (value) + 2; /* '=' + NUL */
++ if (len > 256)
++ b = malloc (sizeof (char) * len);
++
++ strcpy (b, name);
++ strcat (b, "=");
++ strcat (b, value);
++ pam_putenv(handle, b);
++
++ if (b != buf)
++ free(b);
++}
++
+ int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg0)
+ {
+ struct passwd* pwinfo;
+ const char* pwname;
+- char terminal[256];
+ pid_t proc_shell;
+
+ const char* _arg0 = arg0;
+@@ -275,6 +295,8 @@ int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg
+ return XLSH_ERROR;
+
+ if((proc_shell = fork()) == 0) {
++ char **envp;
++
+ chdir(pwinfo->pw_dir);
+
+ if(initgroups(pwname, pwinfo->pw_gid) == -1)
+@@ -284,23 +306,17 @@ int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg
+ if(setuid(pwinfo->pw_uid) == -1)
+ exit(EXIT_FAILURE);
+
++ _putenv(handle, "USER", pwinfo->pw_name);
++ _putenv(handle, "LOGNAME", pwinfo->pw_name);
++ _putenv(handle, "HOME", pwinfo->pw_dir);
++ _putenv(handle, "SHELL", session);
++ if(!pam_getenv(handle, "PATH"))
++ _putenv(handle, "PATH", xlsh_config[XLSH_ID_PATH].value);
+ if(getenv("TERM"))
+- strncpy(terminal, getenv("TERM"), 256);
+- else
+- *terminal = 0;
+-
+- clearenv();
+- setenv("USER", pwinfo->pw_name, 1);
+- setenv("LOGNAME", pwinfo->pw_name, 1);
+- setenv("HOME", pwinfo->pw_dir, 1);
+- setenv("PATH", xlsh_config[XLSH_ID_PATH].value, 1);
+-
+- setenv("SHELL", session, 1);
+-
+- if(*terminal)
+- setenv("TERM", terminal, 1);
++ _putenv(handle, "TERM", getenv("TERM"));
+
+- execlp(session, _arg0, (char*)0);
++ envp = pam_getenvlist(handle);
++ execle(session, _arg0, (char*)0, envp);
+ exit(EXIT_FAILURE);
+ }
+ else if(proc_shell == -1)
+--
+2.1.3
+
diff --git a/0007-Add-.gitignore.patch b/0007-Add-.gitignore.patch
new file mode 100644
index 00000000000..25827c19617
--- /dev/null
+++ b/0007-Add-.gitignore.patch
@@ -0,0 +1,25 @@
+From 9fcf959b7b3634ea7496e7cd141a34db449550d8 Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:18:54 +0100
+Subject: [PATCH 7/8] Add .gitignore
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ .gitignore | 5 +++++
+ 1 file changed, 5 insertions(+)
+ create mode 100644 .gitignore
+
+diff --git a/.gitignore b/.gitignore
+new file mode 100644
+index 0000000..542369b
+--- /dev/null
++++ b/.gitignore
+@@ -0,0 +1,5 @@
++*.o
++*.lo
++*.la
++*.swp
++/xlsh
+--
+2.1.3
+
diff --git a/0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch b/0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch
new file mode 100644
index 00000000000..a571f2fceaa
--- /dev/null
+++ b/0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch
@@ -0,0 +1,47 @@
+From 99969e2f933da2131fc21db94d2792d90072f4b8 Mon Sep 17 00:00:00 2001
+From: Olivier Brunel <jjk@jjacky.com>
+Date: Sun, 16 Nov 2014 18:23:42 +0100
+Subject: [PATCH 8/8] Makefile: Install in $prefix/bin not $prefix/sbin
+
+Signed-off-by: Olivier Brunel <jjk@jjacky.com>
+---
+ Makefile | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index f4fd67c..12364ef 100644
+--- a/Makefile
++++ b/Makefile
+@@ -7,7 +7,7 @@
+ prefix = /usr
+
+ exec_prefix = $(prefix)
+-sbindir = $(exec_prefix)/sbin
++bindir = $(exec_prefix)/bin
+
+ SHELL = /bin/sh
+ INSTALL = install
+@@ -37,16 +37,16 @@ xlsh: $(XLSH_OBJ)
+ xlsh: LDLIBS=$(XLSH_LIBS)
+
+ install: installdirs
+- $(INSTALL_PROGRAM) xlsh $(DESTDIR)$(sbindir)
++ $(INSTALL_PROGRAM) xlsh $(DESTDIR)$(bindir)
+
+ install-strip: installdirs
+- $(INSTALL_PROGRAM_STRIP) xlsh $(DESTDIR)$(sbindir)
++ $(INSTALL_PROGRAM_STRIP) xlsh $(DESTDIR)$(bindir)
+
+ installdirs:
+- $(INSTALL_DIR) $(DESTDIR)$(sbindir)
++ $(INSTALL_DIR) $(DESTDIR)$(bindir)
+
+ uninstall:
+- rm -f ${DESTDIR}$(sbindir)/xlsh
++ rm -f ${DESTDIR}$(bindir)/xlsh
+
+ clean:
+ rm -f $(PROGRAMS)
+--
+2.1.3
+
diff --git a/PKGBUILD b/PKGBUILD
index 70c1ba6c40a..fda9ec5d50a 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,38 +2,52 @@
# Contributor: Michał Siejak <my_fistname@my_lastname.pl>
pkgname=xlsh-without-x
pkgver=0.2.2
-pkgrel=2
+pkgrel=3
pkgdesc="eXtended Login Shell - fast, minimalistic login replacement (without X support)"
arch=('i686' 'x86_64')
url="https://github.com/Nadrin/xlsh/wiki"
license=('GPL3')
depends=('pam' 'readline')
provides=('xlsh=0.2.2')
-source=(https://github.com/Nadrin/xlsh/tarball/master
- patch)
-install=xlsh.install
+source=("xlsh-$pkgver.tar.gz::https://github.com/Nadrin/xlsh/tarball/master"
+ '0001-Add-compilation-option-for-login-completion.patch'
+ '0002-Remove-X-support.patch'
+ '0003-config.h-Tweak-prompt.patch'
+ '0004-Makefile-Switch-prefix-to-usr.patch'
+ '0005-Don-t-block-signals-as-it-caused-issues.patch'
+ '0006-Set-environment-from-PAM.patch'
+ '0007-Add-.gitignore.patch'
+ '0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch')
+sha256sums=('ffc8c31503d252d104f98259842a8da5163862870bfdfe0a07ffc0833b6a1102'
+ '7c690c750fcb18d888782014f30109d5ed44b578f524a3cdae1ecaa3ae4fd6ae'
+ 'e293e25e9a8cbbe15249efce8f1300a83b7f35396666aca0d300363146fd013a'
+ '5fa5f298015fda12b67914a255dc1d6988716959ea1400eaa8fd9773ce42c435'
+ '94b539e8efa4158c19c0ff950f45a157b7d412cd56e86194d790f76912f19da5'
+ 'd6b8c6a83dbc95040200dc3b718f74be3922bf8b90db5683683adf12bd6f63de'
+ 'fdf1af691da9be4278be4b51727bd9eb07b4c9b244b8a772adc8b85482679cbe'
+ '33000c592e06a518c4893d4d95209ba809dca97ae8115e22bc784d4c67a84cab'
+ '6d9f1a050fc46264cdcb7d7bc05325dc44fb94d0213be10acf0c51ca9d8c7da9')
prepare() {
- cd "$srcdir"
+ mv Nadrin-xlsh-* xlsh
+ cd xlsh
- folder=$(ls |grep Nadrin)
- mv $folder/* .
- rmdir $folder
-
- patch -p1 -i patch
-
- sed -e 's/$(exec_prefix)\/sbin/$(exec_prefix)\/bin/' -i Makefile
+ patch -p1 -i ../0001-Add-compilation-option-for-login-completion.patch
+ patch -p1 -i ../0002-Remove-X-support.patch
+ patch -p1 -i ../0003-config.h-Tweak-prompt.patch
+ patch -p1 -i ../0004-Makefile-Switch-prefix-to-usr.patch
+ patch -p1 -i ../0005-Don-t-block-signals-as-it-caused-issues.patch
+ patch -p1 -i ../0006-Set-environment-from-PAM.patch
+ patch -p1 -i ../0007-Add-.gitignore.patch
+ patch -p1 -i ../0008-Makefile-Install-in-prefix-bin-not-prefix-sbin.patch
}
build() {
- cd "$srcdir"
- make
+ cd xlsh
+ make
}
package() {
- cd "$srcdir"
- make DESTDIR="$pkgdir" install
+ cd xlsh
+ make DESTDIR="$pkgdir" install
}
-
-md5sums=('cf78ceec269cc3e35797fe6e8631c3b3'
- 'bf4e6b42787da0988ae56456d1246937')
diff --git a/patch b/patch
deleted file mode 100644
index 819ad807acb..00000000000
--- a/patch
+++ /dev/null
@@ -1,340 +0,0 @@
-diff -r c2c082c4832e Makefile
---- a/Makefile Tue Nov 15 13:02:40 2011 +0100
-+++ b/Makefile Fri Nov 18 10:31:51 2011 +0100
-@@ -4,7 +4,7 @@
- .DEFAULT_GOAL = all
- .PHONY: all install install-strip installdirs uninstall clean
-
--prefix = /usr/local
-+prefix = /usr
-
- exec_prefix = $(prefix)
- bindir = $(exec_prefix)/bin
-@@ -26,49 +26,33 @@
- .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 -r c2c082c4832e include/config.h
---- a/include/config.h Tue Nov 15 13:02:40 2011 +0100
-+++ b/include/config.h Fri Nov 18 10:31:51 2011 +0100
-@@ -9,26 +9,36 @@
-
- // Tweak parameters to suit your needs before compiling.
-
-+#define XLSH_X_SUPPORT 0
-+
- #define XLSH_EXEC "./.xsession"
--#define XLSH_PROMPT "xlsh (%s)> "
-+#define XLSH_PROMPT "> "
- #define XLSH_TMPDIR "/tmp"
- #define XLSH_SHELLS "/etc/shells"
- #define XLSH_ISSUE "/etc/issue"
- #define XLSH_PATH "/bin:/usr/bin:/usr/local/bin"
- #define XLSH_REBOOT "/sbin/shutdown -r now"
- #define XLSH_HALT "/sbin/shutdown -h now"
-+#if XLSH_X_SUPPORT
- #define XLSH_XRDB "/usr/bin/xrdb -remove"
-+#endif
- #define XLSH_XTTY "/dev/console"
-+#if XLSH_X_SUPPORT
- #define XLSH_XTTY_NAME "X11"
-+#endif
- #define XLSH_DATEFMT "%Y-%m-%d"
- #define XLSH_TIMEFMT "%H:%M"
- #define XLSH_PAM_TTY "login"
-+#if XLSH_X_SUPPORT
- #define XLSH_PAM_X11 "xlshd"
-+#endif
-
-+#define XLSH_COMPLETION_LOGIN 0
- #define XLSH_COMPLETION_SHOWROOT 1
- #define XLSH_COMPLETION_MINUID 1000
- #define XLSH_COMPLETION_MAXUID 65534
-
-+#if XLSH_X_SUPPORT
- #define XLSHD_TMPDIR XLSH_TMPDIR
- #define XLSHD_SHELL "/bin/sh"
- #define XLSHD_PIDFILE "/var/run/xlshd.pid"
-@@ -38,5 +48,6 @@
- #define XLSHD_XLSHRC "/etc/xlsh/xlshrc"
- #define XLSHD_XWAIT 1
- #define XLSHD_XRETRY 2
-+#endif
-
- #endif
-diff -r c2c082c4832e include/libxlsh.h
---- a/include/libxlsh.h Tue Nov 15 13:02:40 2011 +0100
-+++ b/include/libxlsh.h Fri Nov 18 10:31:51 2011 +0100
-@@ -24,6 +24,7 @@
-
- size_t libxlsh_strnlen(const char* s, size_t maxlen);
- void libxlsh_proc_sigmask(void);
-+void libxlsh_restore_sigmask(void);
- pid_t libxlsh_proc_exec(const char* cmdline, int flags);
- pid_t libxlsh_pid_read(const char* filename);
- int libxlsh_pid_lock(const char* filename, pid_t pid, int flags);
-diff -r c2c082c4832e include/xlsh.h
---- a/include/xlsh.h Tue Nov 15 13:02:40 2011 +0100
-+++ b/include/xlsh.h Fri Nov 18 10:31:51 2011 +0100
-@@ -58,7 +58,9 @@
- int xlsh_session_exec(pam_handle_t* handle, const char* session, const char* arg0);
-
- int xlsh_session_tty(const char* user, const char* shell);
-+#if XLSH_X_SUPPORT
- int xlsh_session_x(const char* user, const char* shell);
-+#endif
-
- int xlsh_sys_getinfo(xlsh_system_t* sysinfo);
- int xlsh_sys_issue(const char* issuefile);
-diff -r c2c082c4832e src/libxlsh.c
---- a/src/libxlsh.c Tue Nov 15 13:02:40 2011 +0100
-+++ b/src/libxlsh.c Fri Nov 18 10:31:51 2011 +0100
-@@ -32,6 +32,11 @@
- sigprocmask(0, NULL, &xlsh_default_sigmask);
- }
-
-+void libxlsh_restore_sigmask(void)
-+{
-+ sigprocmask(SIG_SETMASK, &xlsh_default_sigmask, NULL);
-+}
-+
- pid_t libxlsh_proc_exec(const char* cmdline, int flags)
- {
- pid_t pid;
-diff -r c2c082c4832e src/xlsh.c
---- a/src/xlsh.c Tue Nov 15 13:02:40 2011 +0100
-+++ b/src/xlsh.c Fri Nov 18 10:31:51 2011 +0100
-@@ -51,7 +51,9 @@
- { NULL, NULL, NULL },
- };
-
-+#if XLSH_X_SUPPORT
- static int xlsh_X = 0;
-+#endif
-
- static void xlsh_usage(char* argv0)
- {
-@@ -99,18 +101,22 @@
- return XLSH_EARG;
- }
-
-+#if XLSH_X_SUPPORT
- if(xlsh_X) {
- if(!arg_shell)
- arg_shell = xlsh_config[XLSH_ID_EXEC].value;
- return xlsh_session_x(arg_user, arg_shell);
- }
- else
-+#endif
- return xlsh_session_tty(arg_user, arg_shell);
- }
-
- int xlsh_func_reboot(int argc, char** argv)
- {
-+#if XLSH_X_SUPPORT
- pid_t xlshd_pid;
-+#endif
-
- printf("Initiating system reboot ...\n");
- if(libxlsh_proc_exec(XLSH_REBOOT, XLSH_DETACH) == -1) {
-@@ -118,28 +124,34 @@
- return XLSH_ERROR;
- }
-
-+#if XLSH_X_SUPPORT
- xlshd_pid = libxlsh_pid_read(XLSHD_PIDFILE);
- if(xlshd_pid > 0)
- kill(xlshd_pid, SIGTERM);
--
-+#endif
-+
- pause();
- return XLSH_EDONE;
- }
-
- int xlsh_func_shutdown(int argc, char** argv)
- {
-+#if XLSH_X_SUPPORT
- pid_t xlshd_pid;
--
-+#endif
-+
- 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;
- }
-
-+#if XLSH_X_SUPPORT
- xlshd_pid = libxlsh_pid_read(XLSHD_PIDFILE);
- if(xlshd_pid > 0)
- kill(xlshd_pid, SIGTERM);
--
-+#endif
-+
- pause();
- return XLSH_EDONE;
- }
-@@ -242,9 +254,11 @@
- if(pam_start(service, user, &conv, &pam_handle) != PAM_SUCCESS)
- return XLSH_ERROR;
-
-+#if XLSH_X_SUPPORT
- if(xlsh_X)
- pam_set_item(pam_handle, PAM_TTY, XLSH_XTTY);
- else
-+#endif
- pam_set_item(pam_handle, PAM_TTY, ttyname(0));
-
- if(pam_authenticate(pam_handle, 0) != PAM_SUCCESS) {
-@@ -318,6 +332,7 @@
- setenv("HOME", pwinfo->pw_dir, 1);
- setenv("PATH", xlsh_config[XLSH_ID_PATH].value, 1);
-
-+#if XLSH_X_SUPPORT
- if(xlsh_X) {
- setenv("SHELL", pwinfo->pw_shell, 1);
- setenv("DISPLAY", xlsh_config[XLSH_ID_DISPLAY].value, 1);
-@@ -325,11 +340,13 @@
- wait(&proc_wait);
- }
- else
-+#endif
- setenv("SHELL", session, 1);
-
- if(*terminal)
- setenv("TERM", terminal, 1);
-
-+ libxlsh_restore_sigmask();
- execlp(session, _arg0, (char*)0);
- exit(EXIT_FAILURE);
- }
-@@ -382,6 +399,7 @@
- return XLSH_EDONE;
- }
-
-+#if XLSH_X_SUPPORT
- int xlsh_session_x(const char* user, const char* shell)
- {
- pid_t proc_session;
-@@ -446,6 +464,7 @@
-
- return XLSH_EOK;
- }
-+#endif
-
- // Configuration
- void xlsh_config_init(char* exec_arg)
-@@ -516,6 +535,7 @@
- return NULL;
- }
-
-+#if XLSH_COMPLETION_LOGIN
- static char* xlsh_cmd_match_user(const char* text, int state)
- {
- static size_t len;
-@@ -540,6 +560,7 @@
- endpwent();
- return NULL;
- }
-+#endif
-
- static char** xlsh_cmd_complete(const char* text, int start, int end)
- {
-@@ -552,8 +573,12 @@
- return rl_completion_matches(const_cast.c,
- xlsh_cmd_match_command);
- else
-+#if XLSH_COMPLETION_LOGIN
- return rl_completion_matches(const_cast.c,
- xlsh_cmd_match_user);
-+#else
-+ return NULL;
-+#endif
- }
-
- int xlsh_cmd_loop(void)
-@@ -569,7 +594,7 @@
- int retvalue = XLSH_EOK;
-
- xlsh_sys_getinfo(&sysinfo);
-- snprintf(prompt, 256, XLSH_PROMPT, sysinfo.ttyname);
-+ snprintf(prompt, 256, XLSH_PROMPT);
-
- rl_attempted_completion_function = xlsh_cmd_complete;
- while((line = xlsh_cmd_readline(prompt))) {
-@@ -623,6 +648,7 @@
- strcpy(tty_path, XLSH_XTTY);
- strncpy(sysinfo->ttypath, tty_path + 5, sizeof(sysinfo->ttypath));
-
-+#if XLSH_X_SUPPORT
- if(xlsh_X) {
- disp_name = getenv("DISPLAY");
- if(disp_name[0] == ':')
-@@ -631,6 +657,7 @@
- tty_name = tty_path;
- }
- else
-+#endif
- tty_name = tty_path + 5;
- strncpy(sysinfo->ttyname, tty_name, sizeof(sysinfo->ttyname));
-
-@@ -721,8 +748,10 @@
- sigaddset(&sigmask, SIGHUP);
- sigprocmask(SIG_BLOCK, &sigmask, NULL);
-
-+#if XLSH_X_SUPPORT
- if(getenv("DISPLAY"))
- xlsh_X = 1;
-+#endif
-
- xlsh_config_init(opt_exec);
- xlsh_sys_issue(xlsh_config[XLSH_ID_ISSUE].value);
diff --git a/xlsh.install b/xlsh.install
deleted file mode 100644
index c8dc33318b1..00000000000
--- a/xlsh.install
+++ /dev/null
@@ -1,19 +0,0 @@
-# xlsh post-install info
-post_install() {
- cat <<EOF
-
-To use xlsh as /bin/login replacement edit /etc/inittab file and replace
-your usual agetty invocations with:
-
-c1:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty1 linux
-c2:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty2 linux
-c3:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty3 linux
-c4:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty4 linux
-c5:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty5 linux
-c6:2345:respawn:/sbin/agetty -8 -s 38400 -n -l /usr/sbin/xlsh tty6 linux
-
-For more information see:
- https://github.com/Nadrin/xlsh/wiki/Arch-Installation
-
-EOF
-}