Fix a nasty race condition/crash reported by 'goebbels@wp.pl' : when an

X session finishes, slim goes to restart X, but if the machine is being
halted, slim gets a SIGTERM, and the signal handler tries to kill the X
server without checking if is has been restarted yet. Boom.
While here, fix xauth path.
This commit is contained in:
landry 2009-11-05 19:05:12 +00:00
parent e8993af13a
commit e9ec1693c7
4 changed files with 66 additions and 15 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.6 2009/09/04 20:24:25 landry Exp $
# $OpenBSD: Makefile,v 1.7 2009/11/05 19:05:12 landry Exp $
COMMENT= simple login manager
DISTNAME= slim-1.3.1
PKGNAME= ${DISTNAME}p0
PKGNAME= ${DISTNAME}p1
CATEGORIES= x11
HOMEPAGE= http://slim.berlios.de/

View File

@ -1,10 +1,10 @@
$OpenBSD: patch-app_cpp,v 1.1 2009/09/04 20:24:25 landry Exp $
$OpenBSD: patch-app_cpp,v 1.2 2009/11/05 19:05:12 landry Exp $
Slim used to spawn 'xauth add . <COOKIE>' via the system() call, so the
cookie itself was visible. On multi-user system one can poll for the
xauth processes via ps and gather cookies for X sessions.
fixes CVE-2009-1756
--- app.cpp.orig Fri Sep 4 21:58:08 2009
+++ app.cpp Fri Sep 4 22:07:29 2009
--- app.cpp.orig Fri Sep 26 02:54:15 2008
+++ app.cpp Wed Oct 28 19:31:08 2009
@@ -32,6 +32,62 @@
using namespace std;
@ -68,7 +68,17 @@ fixes CVE-2009-1756
#ifdef USE_PAM
#include <string>
@@ -131,12 +187,12 @@ void User1Signal(int sig) {
@@ -104,7 +160,8 @@ extern App* LoginApp;
void CatchSignal(int sig) {
cerr << APPNAME << ": unexpected signal " << sig << endl;
- LoginApp->StopServer();
+ if (LoginApp->serverStarted)
+ LoginApp->StopServer();
LoginApp->RemoveLock();
exit(ERR_EXIT);
}
@@ -131,12 +188,13 @@ void User1Signal(int sig) {
App::App(int argc, char** argv):
pam(conv, static_cast<void*>(&LoginPanel)){
#else
@ -77,13 +87,32 @@ fixes CVE-2009-1756
#endif
int tmp;
ServerPID = -1;
+ serverStarted = false;
testing = false;
- mcookie = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ mcookie = string(App::mcookiesize, 'a');
daemonmode = false;
force_nodaemon = false;
firstlogin = true;
@@ -1127,13 +1183,13 @@ string App::findValidRandomTheme(const string& set)
@@ -856,6 +914,8 @@ int App::StartServer() {
char* args = new char[argOption.length()+2]; // NULL plus vt
strcpy(args, argOption.c_str());
+ serverStarted = false;
+
int argc = 1;
int pos = 0;
bool hasVtSet = false;
@@ -935,7 +995,7 @@ int App::StartServer() {
}
delete args;
-
+ serverStarted = true;
return ServerPID;
}
@@ -1127,13 +1187,13 @@ string App::findValidRandomTheme(const string& set)
name = name.substr(0, name.length() - 1);
}
@ -99,7 +128,7 @@ fixes CVE-2009-1756
name = Cfg::Trim(themes[sel]);
themefile = string(THEMESDIR) +"/" + name + THEMESFILE;
@@ -1159,34 +1215,32 @@ void App::replaceVariables(string& input,
@@ -1159,34 +1219,32 @@ void App::replaceVariables(string& input,
}
}

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-app_h,v 1.1 2009/09/04 20:24:25 landry Exp $
--- app.h.orig Fri Sep 4 21:55:48 2009
+++ app.h Fri Sep 4 22:04:27 2009
$OpenBSD: patch-app_h,v 1.2 2009/11/05 19:05:12 landry Exp $
--- app.h.orig Fri Sep 26 02:54:15 2008
+++ app.h Wed Oct 28 19:30:39 2009
@@ -28,6 +28,16 @@
#include "PAM.h"
#endif
@ -18,7 +18,15 @@ $OpenBSD: patch-app_h,v 1.1 2009/09/04 20:24:25 landry Exp $
class App {
public:
App(int argc, char** argv);
@@ -101,6 +111,8 @@ class App { (private)
@@ -36,6 +46,7 @@ class App { (public)
int GetServerPID();
void StopServer();
+ bool serverStarted;
// Lock functions
void GetLock();
void RemoveLock();
@@ -101,6 +112,8 @@ class App { (public)
std::string themeName;
std::string mcookie;

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-slim_conf,v 1.3 2008/11/05 13:36:41 pea Exp $
$OpenBSD: patch-slim_conf,v 1.4 2009/11/05 19:05:12 landry Exp $
--- slim.conf.orig Fri Sep 26 02:54:15 2008
+++ slim.conf Mon Nov 3 22:14:42 2008
@@ -1,13 +1,14 @@
+++ slim.conf Thu Nov 5 19:02:22 2009
@@ -1,17 +1,18 @@
# Path, X server and arguments (if needed)
# Note: -xauth $authfile is automatically appended
-default_path ./:/bin:/usr/bin:/usr/local/bin
@ -21,6 +21,11 @@ $OpenBSD: patch-slim_conf,v 1.3 2008/11/05 13:36:41 pea Exp $
#suspend_cmd /usr/sbin/suspend
# Full path to the xauth binary
-xauth_path /usr/bin/xauth
+xauth_path ${X11BASE}/bin/xauth
# Xauth file for server
authfile /var/run/slim.auth
@@ -32,8 +33,8 @@ authfile /var/run/slim.auth
# NOTE: if your system does not have bash you need
# to adjust the command according to your preferred shell,
@ -32,6 +37,15 @@ $OpenBSD: patch-slim_conf,v 1.3 2008/11/05 13:36:41 pea Exp $
# Commands executed when starting and exiting a session.
# They can be used for registering a X11 session with
@@ -54,7 +55,7 @@ login_cmd exec /bin/bash -login ~/.xinitrc %
sessions xfce4,icewm,wmaker,blackbox
# Executed when pressing F11 (requires imagemagick)
-screenshot_cmd import -window root /slim.png
+screenshot_cmd import -window root /tmp/slim.png
# welcome message. Available variables: %host, %domain
welcome_msg Welcome to %host
@@ -84,7 +85,7 @@ reboot_msg The system is rebooting...
current_theme default