slim: Add SLiM X desktop manager and patches to ensure it is secure and supports...
authorDavid-John Willis <John.Willis@Distant-earth.com>
Tue, 27 Oct 2009 15:51:00 +0000 (15:51 +0000)
committerDavid-John Willis <John.Willis@Distant-earth.com>
Tue, 27 Oct 2009 15:51:00 +0000 (15:51 +0000)
14 files changed:
recipes/slim/slim/Makefile.oe [new file with mode: 0644]
recipes/slim/slim/Makefile.patch [new file with mode: 0644]
recipes/slim/slim/delay.patch [new file with mode: 0644]
recipes/slim/slim/fix-manpage.patch [new file with mode: 0644]
recipes/slim/slim/ftbfs_gcc_4.4.patch [new file with mode: 0644]
recipes/slim/slim/pam-unix2.patch [new file with mode: 0644]
recipes/slim/slim/rc.slim [new file with mode: 0644]
recipes/slim/slim/slim-conf.patch [new file with mode: 0644]
recipes/slim/slim/slim-dynwm [new file with mode: 0644]
recipes/slim/slim/slim.pamd [new file with mode: 0644]
recipes/slim/slim/update_slim_wmlist [new file with mode: 0644]
recipes/slim/slim/xauth_secret_support.patch [new file with mode: 0644]
recipes/slim/slim_1.3.1.bb [new file with mode: 0644]
recipes/slim/slim_themes1.2.3.bb.old [new file with mode: 0644]

diff --git a/recipes/slim/slim/Makefile.oe b/recipes/slim/slim/Makefile.oe
new file mode 100644 (file)
index 0000000..ade4e29
--- /dev/null
@@ -0,0 +1,64 @@
+# Makefile for slim - OpenEmbedded
+#######################################################
+
+
+LDFLAGS=-lXft -lX11 -lfreetype -lXrender -lfontconfig -lpng12 -lz -lm -lcrypt -lXmu -lpng -ljpeg -lrt
+CUSTOM=-DHAVE_SHADOW
+
+USE_PAM=1
+ifdef USE_PAM
+LDFLAGS+= -lpam
+CUSTOM+= -DUSE_PAM
+endif
+
+#######################################################
+
+NAME=slim
+VERSION=1.3.1
+
+DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
+               -DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\"
+
+OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \
+       panel.o util.o
+ifdef USE_PAM
+OBJECTS+=PAM.o
+endif
+
+all: slim
+
+slim: $(OBJECTS)
+       $(CXX) $(LDFLAGS) $(OBJECTS) -o $(NAME)
+
+.cpp.o:
+       $(CXX) $(CXXFLAGS) $(DEFINES) $(CUSTOM) -c $< -o $@
+
+.c.o:
+       $(CC) $(CFLAGS) $(DEFINES) $(CUSTOM) -c $< -o $@
+
+install: slim install-theme
+       install -D -m 755 slim $(DESTDIR)$(PREFIX)/bin/slim
+       install -D -m 644 slim.1 $(DESTDIR)$(MANDIR)/man1/slim.1
+       test -e $(DESTDIR)$(CFGDIR)/slim.conf || \
+               install -D -m 644 slim.conf $(DESTDIR)$(CFGDIR)/slim.conf
+
+clean:
+       @rm -f slim *.o
+
+dist:
+       @rm -rf $(NAME)-$(VERSION)
+       @mkdir $(NAME)-$(VERSION)
+       @cp -r *.cpp *.h *.c Makefile Makefile.* COPYING ChangeLog INSTALL README TODO \
+               xinitrc.sample slim.1 THEMES themes slim.conf $(NAME)-$(VERSION)
+       @rm -rf $(NAME)-$(VERSION)/themes/.svn  $(NAME)-$(VERSION)/themes/default/.svn
+       @tar cvzf $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)
+       @rm -rf $(NAME)-$(VERSION)
+
+
+install-theme:
+       install -D -m 644 themes/default/slim.theme \
+                $(DESTDIR)$(PREFIX)/share/slim/themes/default/slim.theme
+       install -D -m 644 themes/default/panel.png \
+                $(DESTDIR)$(PREFIX)/share/slim/themes/default/panel.png
+       install -D -m 644 themes/default/background.jpg \
+                $(DESTDIR)$(PREFIX)/share/slim/themes/default/background.jpg
diff --git a/recipes/slim/slim/Makefile.patch b/recipes/slim/slim/Makefile.patch
new file mode 100644 (file)
index 0000000..957b517
--- /dev/null
@@ -0,0 +1,20 @@
+--- a/Makefile  2009-08-23 13:56:12.000000000 +0900
++++ b/Makefile 2009-08-23 13:56:51.000000000 +0900
+@@ -7,7 +7,7 @@
+ CC=/usr/bin/gcc
+ CFLAGS=-Wall -I. -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/libpng12 -I/usr/include
+ CXXFLAGS=$(CFLAGS)
+-LDFLAGS=-lXft -lX11 -lfreetype -lXrender -lfontconfig -lpng12 -lz -lm -lcrypt -lXmu -lpng -ljpeg
++LDFLAGS=-L/usr/X11R6/lib -lXft -lX11 -lpng12 -lm -lXmu -lpng -ljpeg
+ CUSTOM=-DHAVE_SHADOW
+ ifdef USE_PAM
+ LDFLAGS+= -lpam
+@@ -15,7 +15,7 @@
+ endif
+ PREFIX=/usr
+ CFGDIR=/etc
+-MANDIR=/usr/man
++MANDIR=/usr/share/man
+ DESTDIR=
+ #######################################################
diff --git a/recipes/slim/slim/delay.patch b/recipes/slim/slim/delay.patch
new file mode 100644 (file)
index 0000000..abab191
--- /dev/null
@@ -0,0 +1,12 @@
+--- slim-1.3.1-orig/app.cpp.orig        2007-07-15 22:09:28.000000000 +0800
++++ slim-1.3.1/app.cpp     2008-05-06 23:33:40.000000000 +0800
+@@ -884,9 +884,6 @@
+             ServerPID = -1;
+             break;
+         }
+-        alarm(15);
+-        pause();
+-        alarm(0);
+
+         // Wait for server to start up
+         if(WaitForServer() == 0) {
diff --git a/recipes/slim/slim/fix-manpage.patch b/recipes/slim/slim/fix-manpage.patch
new file mode 100644 (file)
index 0000000..24f0d9e
--- /dev/null
@@ -0,0 +1,9 @@
+Index: slim-1.3.0/slim.1
+===================================================================
+--- slim-1.3.0.orig/slim.1     2008-09-13 11:20:32.000000000 +0000
++++ slim-1.3.0/slim.1  2008-09-13 11:20:35.000000000 +0000
+@@ -1,4 +1,3 @@
+-." Text automatically generated by txt2man-1.4.7
+ .TH slim 1 "January 09, 2006" "" ""
+ .SH NAME
+ \fBslim \fP- Simple LogIn Manager
diff --git a/recipes/slim/slim/ftbfs_gcc_4.4.patch b/recipes/slim/slim/ftbfs_gcc_4.4.patch
new file mode 100644 (file)
index 0000000..7038636
--- /dev/null
@@ -0,0 +1,12 @@
+# From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=505332
+
+--- a/switchuser.h     2009-09-21 16:10:43.000000000 +0900
++++ b/switchuser.h     2009-09-21 16:11:06.000000000 +0900
+@@ -18,6 +18,7 @@
+ #include <pwd.h>
+ #include <grp.h>
+ #include <paths.h>
++#include <cstdio>
+ #include <iostream>
+ #include "const.h"
+ #include "cfg.h"
diff --git a/recipes/slim/slim/pam-unix2.patch b/recipes/slim/slim/pam-unix2.patch
new file mode 100644 (file)
index 0000000..2163d20
--- /dev/null
@@ -0,0 +1,89 @@
+diff -rc slim-1.3.1-orig/app.cpp slim-1.3.1/app.cpp
+*** slim-1.3.1-orig/app.cpp    2008-09-26 02:54:15.000000000 +0200
+--- slim-1.3.1/app.cpp 2009-02-17 19:50:06.000000000 +0100
+***************
+*** 41,48 ****
+      Panel* panel = *static_cast<Panel**>(appdata_ptr);
+      int result = PAM_SUCCESS;
+      for (int i=0; i<num_msg; i++){
+!         resp[i]->resp=0;
+!         resp[i]->resp_retcode=0;
+          switch(msg[i]->msg_style){
+              case PAM_PROMPT_ECHO_ON:
+                  // We assume PAM is asking for the username
+--- 41,48 ----
+      Panel* panel = *static_cast<Panel**>(appdata_ptr);
+      int result = PAM_SUCCESS;
+      for (int i=0; i<num_msg; i++){
+!         (*resp)[i].resp=0;
+!         (*resp)[i].resp_retcode=0;
+          switch(msg[i]->msg_style){
+              case PAM_PROMPT_ECHO_ON:
+                  // We assume PAM is asking for the username
+***************
+*** 51,63 ****
+                      case Panel::Suspend:
+                      case Panel::Halt:
+                      case Panel::Reboot:
+!                         resp[i]->resp=strdup("root");
+                          break;
+  
+                      case Panel::Console:
+                      case Panel::Exit:
+                      case Panel::Login:
+!                         resp[i]->resp=strdup(panel->GetName().c_str());
+                          break;
+                  }
+                  break;
+--- 51,63 ----
+                      case Panel::Suspend:
+                      case Panel::Halt:
+                      case Panel::Reboot:
+!                         (*resp)[i].resp=strdup("root");
+                          break;
+  
+                      case Panel::Console:
+                      case Panel::Exit:
+                      case Panel::Login:
+!                         (*resp)[i].resp=strdup(panel->GetName().c_str());
+                          break;
+                  }
+                  break;
+***************
+*** 73,79 ****
+  
+                      default:
+                          panel->EventHandler(Panel::Get_Passwd);
+!                         resp[i]->resp=strdup(panel->GetPasswd().c_str());
+                          break;
+                  }
+                  break;
+--- 73,79 ----
+  
+                      default:
+                          panel->EventHandler(Panel::Get_Passwd);
+!                         (*resp)[i].resp=strdup(panel->GetPasswd().c_str());
+                          break;
+                  }
+                  break;
+***************
+*** 89,97 ****
+      }
+      if (result!=PAM_SUCCESS){
+          for (int i=0; i<num_msg; i++){
+!             if (resp[i]->resp==0) continue;
+!             free(resp[i]->resp);
+!             resp[i]->resp=0;
+          };
+          free(*resp);
+          *resp=0;
+--- 89,97 ----
+      }
+      if (result!=PAM_SUCCESS){
+          for (int i=0; i<num_msg; i++){
+!             if ((*resp)[i].resp==0) continue;
+!             free((*resp)[i].resp);
+!             (*resp)[i].resp=0;
+          };
+          free(*resp);
+          *resp=0;
diff --git a/recipes/slim/slim/rc.slim b/recipes/slim/slim/rc.slim
new file mode 100644 (file)
index 0000000..87bc714
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          slim
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: SLiM Display Manager (and wrapper script)
+# Description:       init script for the SLiM Display Manager
+### END INIT INFO
+
+case $1 in
+start)
+       rm /var/run/slim.lock
+       /usr/bin/slim-dynwm -d
+       ;;
+stop)
+       killall /usr/bin/slim-dynwm
+       ;;
+restart)
+       $0 stop
+       sleep 2
+       $0 start
+       ;;
+*)
+       echo "usage: $0 [start|stop|restart]"
+       ;;
+esac
+
+# End of file
diff --git a/recipes/slim/slim/slim-conf.patch b/recipes/slim/slim/slim-conf.patch
new file mode 100644 (file)
index 0000000..aae7eb5
--- /dev/null
@@ -0,0 +1,56 @@
+--- a/slim.conf 2009-08-23 13:48:20.000000000 +0900
++++ b/slim.conf        2009-08-23 13:53:50.000000000 +0900
+@@ -1,17 +1,17 @@
+ # Path, X server and arguments (if needed)
+ # Note: -xauth $authfile is automatically appended
+-default_path        ./:/bin:/usr/bin:/usr/local/bin
+-default_xserver     /usr/bin/X
+-#xserver_arguments   -dpi 75
++default_path        /bin:/usr/bin:/usr/local/bin:/usr/bin/X11
++default_xserver     /usr/bin/X11/X
++xserver_arguments   -nolisten tcp
+ # Commands for halt, login, etc.
+ halt_cmd            /sbin/shutdown -h now
+ reboot_cmd          /sbin/shutdown -r now
+-console_cmd         /usr/bin/xterm -C -fg white -bg black +sb -T "Console login" -e /bin/sh -c "/bin/cat /etc/issue; exec /bin/login"
++console_cmd         /usr/bin/x-terminal-emulator -C -fg white -bg black +sb -T "Console login" -e /bin/sh -c "/bin/cat /etc/issue.net; exec /bin/login"
+ #suspend_cmd        /usr/sbin/suspend
+ # Full path to the xauth binary
+-xauth_path         /usr/bin/xauth 
++xauth_path         /usr/bin/X11/xauth
+ # Xauth file for server
+ authfile           /var/run/slim.auth
+@@ -33,7 +33,7 @@
+ # to adjust the command according to your preferred shell,
+ # i.e. for freebsd use:
+ # login_cmd           exec /bin/sh - ~/.xinitrc %session
+-login_cmd           exec /bin/bash -login ~/.xinitrc %session
++login_cmd           exec /bin/bash -login /etc/X11/Xsession %session
+ # Commands executed when starting and exiting a session.
+ # They can be used for registering a X11 session with
+@@ -51,10 +51,10 @@
+ # The current chosen session name is replaced in the login_cmd
+ # above, so your login command can handle different sessions.
+ # see the xinitrc.sample file shipped with slim sources
+-sessions            xfce4,icewm,wmaker,blackbox
++sessions            default,startxfce4,openbox,ion3,icewm,wmaker,blackbox,awesome
+ # Executed when pressing F11 (requires imagemagick)
+-screenshot_cmd      import -window root /slim.png
++screenshot_cmd      screenshot_cmd      scrot /tmp/slim.png
+ # welcome message. Available variables: %host, %domain
+ welcome_msg         Welcome to %host
+@@ -81,7 +81,7 @@
+ # current theme, use comma separated list to specify a set to 
+ # randomly choose from
+-current_theme       default
++current_theme       debian-moreblue-orbit
+ # Lock file
+ lockfile            /var/run/slim.lock
diff --git a/recipes/slim/slim/slim-dynwm b/recipes/slim/slim/slim-dynwm
new file mode 100644 (file)
index 0000000..49c9d47
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+update_slim_wmlist
+if [ "x$1" = "x-nodaemon" ]; then
+  shift
+  exec slim "$@"
+else
+  slim -d "$@"
+fi
diff --git a/recipes/slim/slim/slim.pamd b/recipes/slim/slim/slim.pamd
new file mode 100644 (file)
index 0000000..d0112e0
--- /dev/null
@@ -0,0 +1,19 @@
+# Begin /etc/pam.d/slim
+
+auth       required     pam_shells.so
+auth       include      system-auth
+auth       optional     pam_securetty.so
+auth       optional     pam_gnome_keyring.so
+
+account    required     pam_nologin.so
+account    include      system-auth
+
+password   include      system-auth
+
+session    include      system-auth
+session    required     pam_mkhomedir.so skel=/etc/skel/ umask=0022
+session    optional     pam_lastlog.so nowtmp
+session    optional     pam_mail.so dir=/var/mail standard
+session    optional     pam_gnome_keyring.so  auto_start
+
+# End /etc/pam.d/slim
diff --git a/recipes/slim/slim/update_slim_wmlist b/recipes/slim/slim/update_slim_wmlist
new file mode 100644 (file)
index 0000000..0f11653
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/perl -w
+#
+# update_slim_wmlist, based on:
+# update_wdm_wmlist, (c) 1998 Marcelo Magall√≥n <mmagallo@debian.org>
+# rewriten to use the x-window-manager alternative
+# modified to also use the x-session-manager alternative by Arthur Korn
+# Copyright 2000 Wichert Akkerman <wakkerma@debian.org>
+# Modified to use the freedesktop.org .desktop like kdm and gdm
+#
+# This script will read the list of installed window managers from
+# the freedesktop .desktop files in <etc>/X11/sessions/:<etc>/dm/Sessions/:
+# <share>/xsessions/
+# and update the sessions line in /etc/slim.conf.
+# BEWARE: It doesn't ask any questions about this. It just does it. It
+# takes an optional list of window managers.
+
+use strict;
+use File::DesktopEntry;
+
+my $wm_list='';
+my %desktop_files;
+
+unless (@ARGV) {
+    #my @wm_list = ('default');
+    my @wm_list;
+    foreach my $dir ('/etc/X11/sessions/','/etc/dm/Sessions/','/usr/share/xsessions/') {
+           next unless (opendir DIR, $dir);
+           my @files;
+           @files = grep { /\.desktop$/ && -r "$dir/$_" } readdir(DIR);
+           foreach my $file (@files) {
+                  push @{$desktop_files{$file}}, "$dir/$file";
+           }
+    }
+    DESKTOP: foreach my $desktop_file (keys(%desktop_files)) {
+           foreach my $file (@{$desktop_files{$desktop_file}}) {
+                   my $entry = File::DesktopEntry->new_from_file($file);
+                   next DESKTOP if (defined($entry->get_value('Hidden'))
+                       and $entry->get_value('Hidden') eq 'true');
+                   if ($entry->get_value('Name') =~ /^gnome$/i) {
+                           push (@wm_list, 'gnome');
+                   }
+                   elsif ($entry->get_value('Name') =~ /^kde$/i) {
+                           push (@wm_list, 'kde');
+                   }
+                   elsif (defined($entry->get_value('Exec'))) {
+                           push (@wm_list, $entry->get_value('Exec'));
+                   }
+                   else { # not found, go to next file
+                           next;
+                   }
+                   # found, proceed to next destop file
+                   next DESKTOP;
+           }
+    }
+   $wm_list = join (',', sort @wm_list) . ',custom';
+} else {
+    $wm_list = join (',', sort @ARGV);
+}
+
+open (SLIM_CONFIG_FILE, '</etc/slim.conf')
+    or die "Can't open /etc/slim.conf for reading: $!";
+open (NEW_SLIM_CONFIG_FILE, '>/etc/slim.conf.new')
+    or die "Can't open /etc/slim.conf.new for writing: $!";
+
+while (<SLIM_CONFIG_FILE>) {
+    s|^(sessions\s*).*|$1$wm_list|;
+    print NEW_SLIM_CONFIG_FILE;
+}
+
+close(SLIM_CONFIG_FILE);
+close(NEW_SLIM_CONFIG_FILE);
+
+rename '/etc/slim.conf.new', '/etc/slim.conf'
+    or die "Can't rename /etc/slim.conf.new: $!";
+
+exit 0;
diff --git a/recipes/slim/slim/xauth_secret_support.patch b/recipes/slim/slim/xauth_secret_support.patch
new file mode 100644 (file)
index 0000000..c2d4044
--- /dev/null
@@ -0,0 +1,316 @@
+# From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529306
+# Commited to upstream.
+
+diff --git a/Makefile b/Makefile
+index a01bafd..9bd5555 100644
+--- a/Makefile
++++ b/Makefile
+@@ -7,7 +7,7 @@ CXX=/usr/bin/g++
+ CC=/usr/bin/gcc
+ CFLAGS=-Wall -I. -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/libpng12 -I/usr/include
+ CXXFLAGS=$(CFLAGS)
+-LDFLAGS=-L/usr/X11R6/lib -lXft -lX11 -lpng12 -lm -lXmu -lpng -ljpeg
++LDFLAGS=-L/usr/X11R6/lib -lXft -lX11 -lpng12 -lm -lXmu -lpng -ljpeg -lrt
+ CUSTOM=-DHAVE_SHADOW
+ ifdef USE_PAM
+ LDFLAGS+= -lpam
+@@ -25,7 +25,8 @@ VERSION=1.3.1
+ DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
+               -DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\"
+-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o
++OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \
++      panel.o util.o
+ ifdef USE_PAM
+ OBJECTS+=PAM.o
+ endif
+diff --git a/Makefile.freebsd b/Makefile.freebsd
+index 3ff326e..c925a39 100644
+--- a/Makefile.freebsd
++++ b/Makefile.freebsd
+@@ -24,7 +24,8 @@ VERSION=1.3.1
+ DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
+               -DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\"
+-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o
++OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \
++      panel.o util.o
+ .ifdef USE_PAM
+   OBJECTS+=PAM.o 
+ .endif
+diff --git a/Makefile.netbsd b/Makefile.netbsd
+index ad8bb8b..45f33e6 100644
+--- a/Makefile.netbsd
++++ b/Makefile.netbsd
+@@ -24,7 +24,8 @@ VERSION=1.3.1
+ DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
+               -DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\"
+-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o
++OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \
++      panel.o util.o
+ .ifdef USE_PAM
+   OBJECTS+=PAM.o 
+ .endif
+diff --git a/Makefile.openbsd b/Makefile.openbsd
+index b1829f8..1205b84 100644
+--- a/Makefile.openbsd
++++ b/Makefile.openbsd
+@@ -20,7 +20,8 @@ VERSION=1.3.1
+ DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \
+               -DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\"
+-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o
++OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \
++      util.o panel.o
+ .SUFFIXES: .c.o .cpp.o
+diff --git a/app.cpp b/app.cpp
+index 83ae947..0ac8c3a 100644
+--- a/app.cpp
++++ b/app.cpp
+@@ -24,6 +24,7 @@
+ #include <algorithm>
+ #include "app.h"
+ #include "numlock.h"
++#include "util.h"
+ #ifdef HAVE_SHADOW
+@@ -128,15 +129,18 @@ void User1Signal(int sig) {
+ #ifdef USE_PAM
+-App::App(int argc, char** argv):
+-    pam(conv, static_cast<void*>(&LoginPanel)){
++App::App(int argc, char** argv)
++  : pam(conv, static_cast<void*>(&LoginPanel)),
+ #else
+-App::App(int argc, char** argv){
++App::App(int argc, char** argv)
++  :
+ #endif
++    mcookiesize(32)           // Must be divisible by 4
++{
+     int tmp;
+     ServerPID = -1;
+     testing = false;
+-    mcookie = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
++    mcookie = string(App::mcookiesize, 'a');
+     daemonmode = false;
+     force_nodaemon = false;
+     firstlogin = true;
+@@ -1127,13 +1131,13 @@ string App::findValidRandomTheme(const string& set)
+         name = name.substr(0, name.length() - 1);
+     }
+-    srandom(getpid()+time(NULL));
++    Util::srandom(Util::makeseed());
+     vector<string> themes;
+     string themefile;
+     Cfg::split(themes, name, ',');
+     do {
+-        int sel = random() % themes.size();
++        int sel = Util::random() % themes.size();
+         name = Cfg::Trim(themes[sel]);
+         themefile = string(THEMESDIR) +"/" + name + THEMESFILE;
+@@ -1160,33 +1164,33 @@ void App::replaceVariables(string& input,
+ }
++/*
++ * We rely on the fact that all bits generated by Util::random()
++ * are usable, so we are taking full words from its output.
++ */
+ void App::CreateServerAuth() {
+     /* create mit cookie */
+-    int i, r;
+-    int hexcount = 0;
+-        string authfile;
+-    string cmd;
++    uint16_t word;
++    uint8_t hi, lo;
++    int i;
++    string authfile;
+     const char *digits = "0123456789abcdef";
+-        srand( time(NULL) );
+-    for ( i = 0; i < 31; i++ ) {
+-        r = rand()%16;
+-                mcookie[i] = digits[r];
+-                if (r>9)
+-                        hexcount++;
++    Util::srandom(Util::makeseed());
++    for (i = 0; i < App::mcookiesize; i+=4) {
++        word = Util::random() & 0xffff;
++        lo = word & 0xff;
++        hi = word >> 8;
++        mcookie[i] = digits[lo & 0x0f];
++        mcookie[i+1] = digits[lo >> 4];
++        mcookie[i+2] = digits[hi & 0x0f];
++        mcookie[i+3] = digits[hi >> 4];
+     }
+-        /* MIT-COOKIE: even occurrences of digits and hex digits */
+-        if ((hexcount%2) == 0) {
+-                r = rand()%10;
+-        } else {
+-                r = rand()%5+10;
+-        }
+-        mcookie[31] = digits[r];
+     /* reinitialize auth file */
+     authfile = cfg->getOption("authfile");
+     remove(authfile.c_str());
+     putenv(StrConcat("XAUTHORITY=", authfile.c_str()));
+-    cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie;
+-    system(cmd.c_str());
++    Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
++      authfile);
+ }
+ char* App::StrConcat(const char* str1, const char* str2) {
+diff --git a/app.h b/app.h
+index 7b4bd10..9a44269 100644
+--- a/app.h
++++ b/app.h
+@@ -101,6 +101,8 @@ private:
+     
+     std::string themeName;
+     std::string mcookie;
++
++    const int mcookiesize;
+ };
+diff --git a/switchuser.cpp b/switchuser.cpp
+index e72a8fc..ec298e1 100644
+--- a/switchuser.cpp
++++ b/switchuser.cpp
+@@ -10,6 +10,7 @@
+ */
+ #include "switchuser.h"
++#include "util.h"
+ using namespace std;
+@@ -53,10 +54,10 @@ void SwitchUser::Execute(const char* cmd) {
+ }
+ void SwitchUser::SetClientAuth(const char* mcookie) {
+-    int r;
++    bool r;
+     string home = string(Pw->pw_dir);
+     string authfile = home + "/.Xauthority";
+     remove(authfile.c_str());
+-    string cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie;
+-    r = system(cmd.c_str());
++    r = Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
++      authfile);
+ }
+diff --git a/util.cpp b/util.cpp
+new file mode 100644
+index 0000000..5ed972f
+--- /dev/null
++++ b/util.cpp
+@@ -0,0 +1,69 @@
++/* SLiM - Simple Login Manager
++   Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru>
++
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 2 of the License, or
++   (at your option) any later version.
++*/
++
++#include <sys/types.h>
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <time.h>
++#include <unistd.h>
++
++#include "util.h"
++
++/*
++ * Adds the given cookie to the specified Xauthority file.
++ * Returns true on success, false on fault.
++ */
++bool Util::add_mcookie(const std::string &mcookie, const char *display,
++    const std::string &xauth_cmd, const std::string &authfile)
++{
++      FILE *fp;
++      std::string cmd = xauth_cmd + " -f " + authfile + " -q";
++
++      fp = popen(cmd.c_str(), "w");
++      if (!fp)
++              return false;
++      fprintf(fp, "remove %s\n", display);
++      fprintf(fp, "add %s %s %s\n", display, ".", mcookie.c_str());
++      fprintf(fp, "exit\n");
++
++      pclose(fp);
++      return true;
++}
++
++/*
++ * Interface for random number generator.  Just now it uses ordinary
++ * random/srandom routines and serves as a wrapper for them.
++ */
++void Util::srandom(unsigned long seed)
++{
++      ::srandom(seed);
++}
++
++long Util::random(void)
++{
++      return ::random();
++}
++
++/*
++ * Makes seed for the srandom() using "random" values obtained from
++ * getpid(), time(NULL) and others.
++ */
++long Util::makeseed(void)
++{
++      struct timespec ts;
++      long pid = getpid();
++      long tm = time(NULL);
++
++      if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
++              ts.tv_sec = ts.tv_nsec = 0;
++      }
++
++      return pid + tm + (ts.tv_sec ^ ts.tv_nsec);
++}
+diff --git a/util.h b/util.h
+new file mode 100644
+index 0000000..b8d2993
+--- /dev/null
++++ b/util.h
+@@ -0,0 +1,24 @@
++/* SLiM - Simple Login Manager
++   Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru>
++
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 2 of the License, or
++   (at your option) any later version.
++*/
++#ifndef __UTIL_H__
++#define __UTIL_H__
++
++#include <string>
++
++namespace Util {
++      bool add_mcookie(const std::string &mcookie, const char *display,
++          const std::string &xauth_cmd, const std::string &authfile);
++
++      void srandom(unsigned long seed);
++      long random(void);
++
++      long makeseed(void);
++};
++
++#endif /* __UTIL_H__ */
diff --git a/recipes/slim/slim_1.3.1.bb b/recipes/slim/slim_1.3.1.bb
new file mode 100644 (file)
index 0000000..a038ea6
--- /dev/null
@@ -0,0 +1,98 @@
+DESCRIPTION="Simple Login Manager"
+HOMEPAGE="http://slim.berlios.de"
+LICENSE = "GPL"
+
+PR = "r0.4"
+
+inherit update-rc.d
+
+DEPEND="virtual/x11 libxmu libpng libjpeg libpam freetype"
+
+RDEPEND="${DEPEND} perl xauth"
+    
+S = "${WORKDIR}/${PN}-${PV}/"
+
+SRC_URI=" \
+  http://download.berlios.de/${PN}/${P}.tar.gz \
+  file://fix-manpage.patch;patch=1 \
+#  file://slim-conf.patch;patch=1 \
+  file://ftbfs_gcc_4.4.patch;patch=1 \
+  file://Makefile.patch;patch=1 \
+  file://xauth_secret_support.patch;patch=1 \
+  file://delay.patch;patch=1 \  
+  file://pam-unix2.patch;patch=1 \    
+  file://rc.slim \
+  file://slim-dynwm \
+  file://update_slim_wmlist \
+  file://Makefile.oe \  
+  file://slim.pamd \
+"
+
+EXTRA_OEMAKE += " \
+  USE_PAM=1 \
+  PREFIX=${prefix} \
+  CFGDIR=${sysconfdir} \
+  MANDIR=${mandir} \
+  DESTDIR=${D} \
+  CFLAGS+=-I${STAGING_INCDIR}/freetype2 \
+  CXXFLAGS+=-I${STAGING_INCDIR}/freetype2 \
+  LDFLAGS+=-lXft \
+  LDFLAGS+=-lX11 \
+  LDFLAGS+=-lfreetype \
+  LDFLAGS+=-lXrender \
+  LDFLAGS+=-lfontconfig \
+  LDFLAGS+=-lpng12 \
+  LDFLAGS+=-lz \
+  LDFLAGS+=-lm \
+  LDFLAGS+=-lcrypt \
+  LDFLAGS+=-lXmu \
+  LDFLAGS+=-lpng \
+  LDFLAGS+=-ljpeg \
+  LDFLAGS+=-lrt \
+  LDFLAGS+=-lpam \
+"
+
+#EXTRA_OEMAKE += "-I${STAGING_INCDIR}/freetype2"
+#EXTRA_OEMAKE += 'EXTRA_CFLAGS="-I${STAGING_INCDIR}/freetype2"'
+
+#do_compile_prepend() {
+#  # respect C[XX]FLAGS, fix crosscompile,
+#  # fix linking order for --as-needed"
+#  sed -i -e "s:^CXX=.*:CXX=$(CXX) ${CXXFLAGS}:" \
+#    -e "s:^CC=.*:CC=$(CC) ${CFLAGS}:" \
+#    -e "s:^MANDIR=.*:MANDIR=/usr/share/man:" \
+#    -e "s:^\t\(.*\)\ \$(LDFLAGS)\ \(.*\):\t\1\ \2\ \$(LDFLAGS):g" \
+#    -r -e "s:^LDFLAGS=(.*):LDFLAGS=\1 ${LDFLAGS}:" \
+#    Makefile"
+#}
+
+do_compile_prepend() {
+  cp -pP ${WORKDIR}/Makefile.oe ${S}/Makefile
+}
+
+#  USE_PAM=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} CC=${TARGET_CC} \
+#               CXX=${TARGET_CXX} DESTDIR=${D} MANDIR=${mandir} PREFIX=${prefix} CFGDIR=${sysconfdir}
+
+do_install() {
+  oe_runmake install 
+  install -d ${D}${bindir}
+  install -m 0755 ${WORKDIR}/slim-dynwm ${D}${bindir}/
+  install -m 0755 ${WORKDIR}/update_slim_wmlist ${D}${bindir}/
+  install -d ${D}${sysconfdir}/pam.d/  
+  install -m 0644 ${WORKDIR}/slim.pamd ${D}${sysconfdir}/pam.d/slim
+  install -d ${D}${sysconfdir}/init.d/
+  cp -pP ${WORKDIR}/rc.slim ${D}${sysconfdir}/init.d/slim-init
+}
+
+INITSCRIPT_NAME = "slim-init"
+INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ."
+
+pkg_postinst_${PN} () {
+# Register SLiM as default DM
+mkdir -p ${sysconfdir}/X11/
+echo "${bindir}/slim-dynwm" > ${sysconfdir}/X11/default-display-manager
+}
+
+pkg_postrm_${PN} () {
+sed -i /slim-dynwm/d ${sysconfdir}/X11/default-display-manager || true
+}
diff --git a/recipes/slim/slim_themes1.2.3.bb.old b/recipes/slim/slim_themes1.2.3.bb.old
new file mode 100644 (file)
index 0000000..0c4e7b4
--- /dev/null
@@ -0,0 +1,23 @@
+DESCRIPTION = "GNOME editor"
+SECTION = "x11/gnome"
+LICENSE = "GPL"
+
+DEPENDS = "iso-codes gnome-common glib-2.0 gtk+ gconf gtksourceview2"
+RDEPENDS += " gtksourceview2"
+
+PR = "r1"
+
+inherit gnome pkgconfig
+
+EXTRA_OECONF = "--disable-scrollkeeper"
+
+do_configure_prepend () {
+       cp ${STAGING_DATADIR}/gnome-common/data/omf.make ${S}
+}
+
+do_stage () {
+       autotools_stage_all
+}
+
+FILES_${PN} += "${libdir}/gedit-2/plugin* ${datadir}/gedit-2"
+FILES_${PN}-dbg += "${libdir}/gedit-2/plugin-loaders/.debug ${libdir}/gedit-2/plugins/.debug"