summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2006-11-26 17:17:58 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2006-11-26 17:17:58 +0000
commitc2d27a7a41fcdd03e7d35c9899cb651aeb5b0490 (patch)
treece321a68237d7ec327fa0e05dad249f10d18bfe3 /app
parent848535c62a7213ef065583f0a95895147fbae1f4 (diff)
OpenBSD customization:
- hack for XFree86 3.3.x X servers - ssh-agent integration - fvwm default window manager
Diffstat (limited to 'app')
-rw-r--r--app/xinit/Makefile.am4
-rw-r--r--app/xinit/configure.ac21
-rw-r--r--app/xinit/startx.cpp1
-rw-r--r--app/xinit/xinit.c41
-rw-r--r--app/xinit/xinitrc.cpp61
5 files changed, 80 insertions, 48 deletions
diff --git a/app/xinit/Makefile.am b/app/xinit/Makefile.am
index ca7260400..0e4a5dd0b 100644
--- a/app/xinit/Makefile.am
+++ b/app/xinit/Makefile.am
@@ -81,7 +81,9 @@ PROGCPPDEFS = \
-DXTERM=@XTERM@ \
-DXSERVER=@XSERVER@ \
-DXAUTH=@XAUTH@ \
- -DXINIT=@XINIT@
+ -DXINIT=@XINIT@ \
+ -DWM=@WM@ \
+ -DXCONSOLE=@XCONSOLE@
SCRIPTDEFS = \
-DXINITDIR=$(XINITDIR) $(PROGCPPDEFS) -DLIBDIR=$(libdir) \
diff --git a/app/xinit/configure.ac b/app/xinit/configure.ac
index 55648bcfe..5ee8daad8 100644
--- a/app/xinit/configure.ac
+++ b/app/xinit/configure.ac
@@ -49,6 +49,8 @@ DEFAULT_XTERM=xterm
DEFAULT_XSERVER=${bindir}/X
DEFAULT_XAUTH=xauth
DEFAULT_XINIT=xinit
+DEFAULT_WM=fvwm
+DEFAULT_XCONSOLE=xconsole
AC_ARG_WITH(xrdb,
AS_HELP_STRING([--with-xrdb=XRDB], [Path to xrdb]),
@@ -90,6 +92,16 @@ AC_ARG_WITH(xinit,
[XINIT="$withval"],
[XINIT="$DEFAULT_XINIT"])
+AC_ARG_WITH(wm,
+ AS_HELP_STRING([--with-wm=WM], [Path to default window manager]),
+ [WM="$withval"],
+ [WM="$DEFAULT_WM"])
+
+AC_ARG_WITH(xconsole,
+ AS_HELP_STRING([--with-xconsole=XCONSOLE], [Path to xconsole]),
+ [XCONSOLE="$withval"],
+ [XCONSOLE="$DEFAULT_XCONSOLE"])
+
# Checks for pkg-config packages
PKG_CHECK_MODULES(XINIT, x11)
@@ -104,6 +116,13 @@ AC_SUBST(XINIT_LIBS)
AC_PATH_PROGS(MCOOKIE, [mcookie], [$MCOOKIE],
[$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/local/bin])
+
+case $host_os in
+ *openbsd*)
+ MCOOKIE='dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -e \\\"%08x\\\"'
+ ;;
+esac
+
if test "x$MCOOKIE" != x ; then
STARTX_COOKIE_FLAGS='-DHAS_COOKIE_MAKER -DMK_COOKIE="$(MCOOKIE)"'
fi
@@ -131,6 +150,8 @@ AC_SUBST(XTERM)
AC_SUBST(XSERVER)
AC_SUBST(XAUTH)
AC_SUBST(XINIT)
+AC_SUBST(WM)
+AC_SUBST(XCONSOLE)
# Defines which X servers are listed in help output in xinit.c
# Cheat, lie, and assume all the world is Xorg for now
diff --git a/app/xinit/startx.cpp b/app/xinit/startx.cpp
index eba83b88f..a12ba76b1 100644
--- a/app/xinit/startx.cpp
+++ b/app/xinit/startx.cpp
@@ -191,6 +191,7 @@ dummy=0
XCOMM create a file with auth information for the server. ':0' is a dummy.
xserverauthfile=$HOME/.serverauth.$$
+trap "rm -f $xserverauthfile" ERR HUP INT QUIT ILL TRAP KILL BUS TERM
xauth -q -f $xserverauthfile << EOF
add :$dummy . $mcookie
EOF
diff --git a/app/xinit/xinit.c b/app/xinit/xinit.c
index 818f754a1..61041abd7 100644
--- a/app/xinit/xinit.c
+++ b/app/xinit/xinit.c
@@ -1,5 +1,6 @@
/* $Xorg: xinit.c,v 1.5 2001/02/09 02:05:49 xorgcvs Exp $ */
-/* $XdotOrg: $ */
+/* $XdotOrg: xc/programs/xinit/xinit.c,v 1.4 2005/10/04 01:27:34 ajax Exp $ */
+/* $OpenBSD: xinit.c,v 1.2 2006/11/26 17:17:57 matthieu Exp $ */
/*
@@ -36,6 +37,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xos.h>
#include <stdio.h>
#include <ctype.h>
+#include <sys/param.h>
#ifdef X_POSIX_C_SOURCE
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
@@ -156,6 +158,9 @@ char xserverrcbuf[256];
#define OK_EXIT 0
#define ERR_EXIT 1
+char *default_wrapper = BINDIR "/Xwrapper";
+char real_server[MAXPATHLEN];
+char test_path[MAXPATHLEN];
char *default_server = "X";
char *default_display = ":0"; /* choose most efficient */
char *default_client[] = {"xterm", "-geometry", "+1+1", "-n", "login", NULL};
@@ -273,7 +278,8 @@ main(int argc, char *argv[], char *envp[])
register char **sptr = server;
register char **cptr = client;
register char **ptr;
- int pid;
+ char *path, *p;
+ int pid, n;
int client_given = 0, server_given = 0;
int client_args_given = 0, server_args_given = 0;
int start_of_client_args, start_of_server_args;
@@ -346,7 +352,36 @@ main(int argc, char *argv[], char *envp[])
if (argc == 0 ||
#ifndef __UNIXOS2__
(**argv != '/' && **argv != '.')) {
- *sptr++ = default_server;
+ /* hack for the Xfree86 3.3.6 servers: if the X link
+ points to XF86_*, start Xwrapper instead of X */
+ path = strdup(getenv("PATH"));
+ if (path == NULL) {
+ Error("Can't find PATH\n");
+ exit(1);
+ }
+ /* Walk through the PATH */
+ for (p = strtok(path, ":"); p != NULL; p = strtok(NULL, ":")) {
+ strlcpy(test_path, p, sizeof(test_path));
+ strlcat(test_path, "/", sizeof(test_path));
+ strlcat(test_path, default_server, sizeof(test_path));
+ if ((n = readlink(test_path, real_server,
+ sizeof(real_server) - 1)) > 0) {
+ real_server[n] = '\0';
+ /* if the target path contains XF86_, we
+ need Xwrapper */
+ if (strstr(real_server, "XF86_") != NULL) {
+ *sptr++ = default_wrapper;
+ } else {
+ *sptr++ = default_server;
+ }
+ break;
+ }
+ }
+ if (p == NULL) {
+ Error("Can't find X link\n");
+ exit(1);
+ }
+ free(path);
#else
(**argv != '/' && **argv != '\\' && **argv != '.' &&
!(isalpha(**argv) && (*argv)[1]==':'))) {
diff --git a/app/xinit/xinitrc.cpp b/app/xinit/xinitrc.cpp
index 4f52f1318..6c100734b 100644
--- a/app/xinit/xinitrc.cpp
+++ b/app/xinit/xinitrc.cpp
@@ -1,5 +1,6 @@
XCOMM!SHELL_CMD
XCOMM $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $
+XCOMM $OpenBSD: xinitrc.cpp,v 1.2 2006/11/26 17:17:57 matthieu Exp $
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
@@ -24,52 +25,24 @@ if [ -f $usermodmap ]; then
XMODMAP $usermodmap
fi
-XCOMM start some nice programs
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-if [ -r /etc/default/xdesktops ]; then
- . /etc/default/xdesktops
+XCOMM if we have private ssh key(s), start ssh-agent and add the key(s)
+id1=$HOME/.ssh/identity
+id2=$HOME/.ssh/id_dsa
+id3=$HOME/.ssh/id_rsa
+if [ -x /usr/bin/ssh-agent ] && [ -f $id1 -o -f $id2 -o -f $id3 ];
+then
+ eval `ssh-agent -s`
+ ssh-add < /dev/null
fi
-if [ -r $HOME/.x11rc ]; then
- . $HOME/.x11rc
-else
- if [ -r /etc/default/X11 ]; then
- . /etc/default/X11
- fi
-fi
+XCOMM start some nice programs
-#if defined(__SCO__)
-if [ -n "$XSESSION" ]; then
- case "$XSESSION" in
- [Yy][Ee][Ss])
- [ -x /usr/bin/X11/scosession ] && exec /usr/bin/X11/scosession
- ;;
- esac
-fi
+XCLOCK -geometry 50x50-1+1 &
+XCONSOLE -iconic &
+XTERM -geometry 80x24 &
+WM || XTERM
-if [ -n "$XDESKTOP" ]; then
- exec `eval echo $"$XDESKTOP"`
-else
- if [ -x /usr/bin/X11/pmwm -a -x /usr/bin/X11/scoterm ]; then
- /usr/bin/X11/scoterm 2> /dev/null &
- exec /usr/bin/X11/pmwm 2> /dev/null
- fi
-fi
-#elif defined(__UNIXWARE__)
-if [ -n "$XDESKTOP" ]; then
- exec `eval echo $"$XDESKTOP"`
-else
- if [ -x /usr/X/bin/pmwm ]; then
- exec /usr/X/bin/pmwm 2> /dev/null
- fi
+if [ "$SSH_AGENT_PID" ]; then
+ ssh-add -D < /dev/null
+ eval `ssh-agent -s -k`
fi
-#endif
-
-XCOMM This is the fallback case if nothing else is executed above
-#endif /* !defined(__SCO__) && !defined(__UNIXWARE__) */
-TWM &
-XCLOCK -geometry 50x50-1+1 &
-XTERM -geometry 80x50+494+51 &
-XTERM -geometry 80x20+494-0 &
-exec XTERM -geometry 80x66+0+0 -name login