diff options
author | jjacky | 2012-02-07 15:41:26 +0100 |
---|---|---|
committer | Olivier Brunel | 2015-06-08 19:26:10 +0200 |
commit | 55e3caf1bf0cbc9ff4c4cf6c1a982d32f94f4e4e (patch) | |
tree | 85f8318ac9c011b9a8cde8aaf0d08ef927c8cd4b /patch | |
download | aur-55e3caf1bf0cbc9ff4c4cf6c1a982d32f94f4e4e.tar.gz |
first commit
Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Diffstat (limited to 'patch')
-rw-r--r-- | patch | 340 |
1 files changed, 340 insertions, 0 deletions
diff --git a/patch b/patch new file mode 100644 index 000000000000..819ad807acb5 --- /dev/null +++ b/patch @@ -0,0 +1,340 @@ +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); |