Skip to content

Commit

Permalink
Bumped version number, wrote default configuration for xlshd, minor
Browse files Browse the repository at this point in the history
fixes.
  • Loading branch information
Nadrin committed Oct 12, 2011
1 parent fab3376 commit 4ebbe74
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
12 changes: 11 additions & 1 deletion Makefile
@@ -1,6 +1,9 @@
# xlsh - eXtended Login Shell
# See COPYING file for license details.

DESTDIR ?= /usr/local
CONFDIR ?= /etc

XLSH_SOURCE = src/xlsh.c src/libxlsh.c
XLSH_HEADERS = include/xlsh.h include/libxlsh.h include/config.h
XLSH_LIBS = -lreadline -lpam
Expand All @@ -16,7 +19,14 @@ xlsh: ${XLSH_SOURCE} ${XLSH_HEADERS}
xlshd: ${XLSHD_SOURCE} ${XLSHD_HEADERS}
${CC} -g -Wall -o $@ -I./include ${XLSHD_SOURCE} ${CFLAGS} ${LDFLAGS}

install: all
install -m 755 xlsh ${DESTDIR}/sbin/
install -m 755 xlshd ${DESTDIR}/sbin/
install -d -m 755 ${CONFDIR}/xlsh
install -m 644 etc/xlshrc ${CONFDIR}/xlsh
install -m 644 etc/Xresources ${CONFDIR}/xlsh

clean:
rm -f xlsh xlshd

.PHONY: all clean
.PHONY: all install clean
17 changes: 16 additions & 1 deletion README
Expand Up @@ -5,5 +5,20 @@ A simple login shell with readline functionality and PAM integration.
* When run stand-alone on a virtual console it can replace standard "login" program.
* When run in cooperation with X daemon component (xlshd) it can replace XDM/GDM/KDM.

Features:
* Small and simple, written entirely in C.
* Easily hackable because of compact codebase (~950 source lines).
* Uses PAM for authorization and session management.
* Entirely keyboard driven display manager replacement (when used with xlshd)
without the need for any fat libraries or GUI toolkits.
* Defaults configured before compilation, some of them can be changed by
setting few environment variables.
* Single shell script file (/etc/xlsh/xlshrc) for customizing how
xlshd launches xlsh.
* Introduces a concept of "pre-login shell" known from GNU/HURD.
* Only *three* important commands: 'login', 'reboot' and 'shutdown'.
* New commands can be easily added (if you need any) by editing xlsh.c
* Username autocompletion on TAB.

The only build dependencies are: make, a decent C compiler, libreadline and libpam.
Configuration options can be edited in src/config.h before compiling.
Configuration options can be edited in include/config.h before compiling.
5 changes: 5 additions & 0 deletions etc/Xresources
@@ -0,0 +1,5 @@
! Default resources for XLSH xterm instance.
*foreground: white
*background: black
*cursorColor: grey90
*visualBell: off
16 changes: 16 additions & 0 deletions etc/xlshrc
@@ -0,0 +1,16 @@
#!/bin/sh
# XLSH default startup script for X11.
TERMINAL=xterm
XRESFILE=/etc/xlsh/Xresources

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 - 150))

if ! which xlsh; then
xmessage -center 'xlsh cannot be found in PATH!'
exit 1
fi
[ -f "$XRESFILE" ] && xrdb "$XRESFILE"
exec $TERMINAL -g 80x24+$px+$py $(which xlsh)
3 changes: 2 additions & 1 deletion include/config.h
Expand Up @@ -17,6 +17,7 @@
#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"
Expand All @@ -28,7 +29,7 @@
#define XLSHD_XSERVER "/usr/bin/X"
#define XLSHD_XOPTIONS "-nolisten tcp -noreset"
#define XLSHD_XDISPLAY ":0"
#define XLSHD_XLSHRC "/etc/xlshrc"
#define XLSHD_XLSHRC "/etc/xlsh/xlshrc"
#define XLSHD_XWAIT 1
#define XLSHD_XRETRY 2

Expand Down
4 changes: 2 additions & 2 deletions include/libxlsh.h
Expand Up @@ -7,8 +7,8 @@
#ifndef __XLSH_LIBXLSH_H
#define __XLSH_LIBXLSH_H

#define XLSH_VERSION_API 1
#define XLSH_VERSION_STRING "0.1.0"
#define XLSH_VERSION_API 2
#define XLSH_VERSION_STRING "0.2.0"

#define XLSH_EOK 0x00
#define XLSH_EFATAL 0x01
Expand Down
7 changes: 6 additions & 1 deletion src/xlsh.c
Expand Up @@ -285,6 +285,7 @@ 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;
Expand Down Expand Up @@ -315,10 +316,14 @@ 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_config[XLSH_ID_DISPLAY].value)
if(xlsh_X) {
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);

if(terminal[0])
setenv("TERM", terminal, 1);

Expand Down

0 comments on commit 4ebbe74

Please sign in to comment.