Hello community,
here is the log from the commit of package kdelibs4 for openSUSE:Factory
checked in at Thu Jul 23 16:45:50 CEST 2009.
--------
--- KDE/kdelibs4/kdelibs4.changes 2009-06-24 19:55:26.000000000 +0200
+++ kdelibs4/kdelibs4.changes 2009-07-21 22:25:53.000000000 +0200
@@ -1,0 +2,20 @@
+Tue Jul 21 22:25:46 CEST 2009 - dmueller@suse.de
+
+- update to 4.2.98
+
+-------------------------------------------------------------------
+Tue Jul 21 14:34:03 CEST 2009 - llunak@novell.com
+
+- bison and flex requires for Solid
+
+-------------------------------------------------------------------
+Tue Jul 21 14:20:07 CEST 2009 - llunak@novell.com
+
+- add protection against OOM-killer from KDE trunk
+
+-------------------------------------------------------------------
+Wed Jul 8 18:09:54 CEST 2009 - dmueller@suse.de
+
+- update to 4.2.96
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
kdelibs-4.2.95.tar.bz2
New:
----
kdelibs-4.2.98.tar.bz2
oom-protect.diff
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ kdelibs4.spec ++++++
--- /var/tmp/diff_new_pack.LqJAwA/_old 2009-07-23 16:33:14.000000000 +0200
+++ /var/tmp/diff_new_pack.LqJAwA/_new 2009-07-23 16:33:14.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package kdelibs4 (Version 4.2.95)
+# spec file for package kdelibs4 (Version 4.2.98)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -22,7 +22,7 @@
BuildRequires: libQtWebKit-devel libattr-devel libpng-devel libqt4-devel libtiff-devel libxslt-devel unzip
BuildRequires: libsoprano-devel pcre-devel phonon-devel shared-mime-info
BuildRequires: kde4-filesystem strigi strigi-devel update-desktop-files
-BuildRequires: OpenEXR-devel automoc4 enchant-devel fam-devel libacl-devel utempter
+BuildRequires: OpenEXR-devel automoc4 bison enchant-devel fam-devel flex libacl-devel utempter
%if %suse_version > 1110
BuildRequires: xz-devel
%endif
@@ -38,7 +38,7 @@
Group: System/GUI/KDE
Summary: KDE Base Libraries
Url: http://www.kde.org
-Version: 4.2.95
+Version: 4.2.98
Release: 1
Requires: libstrigi0 >= %( echo `rpm -q --queryformat '%{VERSION}' strigi-devel`)
Requires: soprano >= %( echo `rpm -q --queryformat '%{VERSION}' libsoprano-devel`)
@@ -65,6 +65,7 @@
Patch13: kjs-mark-register-stack.diff
Patch17: flash-player-non-oss.diff
Patch18: plasma-libs.diff
+Patch19: oom-protect.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if %suse_version > 1010
%requires_ge libqt4-x11
@@ -105,6 +106,7 @@
%patch13
%patch17
%patch18
+%patch19
#
# define KDE version exactly
#
++++++ kdelibs-4.2.95.tar.bz2 -> kdelibs-4.2.98.tar.bz2 ++++++
KDE/kdelibs4/kdelibs-4.2.95.tar.bz2 kdelibs4/kdelibs-4.2.98.tar.bz2 differ: char 11, line 1
++++++ oom-protect.diff ++++++
Index: kinit/start_kdeinit.c
===================================================================
--- kinit/start_kdeinit.c (revision 0)
+++ kinit/start_kdeinit.c (revision 1000474)
@@ -0,0 +1,176 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2006 Lubos Lunak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define EXECUTE BIN_INSTALL_DIR "/kdeinit4"
+
+#ifdef KDEINIT_OOM_PROTECT
+
+/*
+ Prevent getting killed by bad heuristic in Linux OOM-killer.
+ This wrapper decreases the chance OOM killer kills it (or its children,
+ namely kdeinit), opens a pipe and forks. Child drops privileges
+ and launches kdeinit. Since processes started by kdeinit should
+ not have this protection, kdeinit will after forking send the new
+ PID using the pipe and wait for a signal. This parent will reset the protection
+ and SIGUSR1 the process to continue.
+ returns 1 if pid is valid
+*/
+
+static int set_protection( pid_t pid, int enable )
+{
+ char buf[ 1024 ];
+ int procfile;
+ sprintf( buf, "/proc/%d/stat", pid );
+ if( !enable ) {
+ /* Be paranoid and check that the pid we got from the pipe
+ belongs to this user. */
+ struct stat st;
+ if( lstat( buf, &st ) < 0 || st.st_uid != getuid())
+ return 0;
+ }
+ sprintf( buf, "/proc/%d/oom_adj", pid );
+ procfile = open( buf, O_WRONLY );
+ if( procfile >= 0 ) {
+ if( enable )
+ write( procfile, "-5", sizeof( "-5" ));
+ else
+ write( procfile, "0", sizeof( "0" ));
+ close( procfile );
+ }
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ int pipes[ 2 ];
+ int new_argc;
+ const char** new_argv;
+ char helper_num[ 1024 ];
+ unsigned i;
+ char** orig_environ = NULL;
+ char header[ 7 ];
+ if( pipe( pipes ) < 0 ) {
+ perror( "pipe()" );
+ return 1;
+ }
+ if( argc < 0 || argc > 1000 )
+ abort(); /* paranoid */
+ set_protection( getpid(), 1 );
+ switch( fork()) {
+ case -1:
+ perror( "fork()" );
+ return 1;
+ default: /* parent, drop privileges and exec */
+ if (setgid(getgid())) {
+ perror("setgid()");
+ return 1;
+ }
+ if (setuid(getuid()) || geteuid() != getuid()) {
+ perror("setuid()");
+ return 1;
+ }
+ close( pipes[ 0 ] );
+ /* read original environment passed by start_kdeinit_wrapper */
+ if( read( 0, header, 7 ) == 7 && strncmp( header, "environ", 7 ) == 0 ) {
+ unsigned count;
+ if( read( 0, &count, sizeof( unsigned )) == sizeof( unsigned )
+ && count && count < (1<<16)) {
+ char** env = malloc(( count + 1 ) * sizeof( char* ));
+ int ok = 1;
+ for( i = 0;
+ i < count && ok;
+ ++i ) {
+ unsigned len;
+ if( read( 0, &len, sizeof( unsigned )) == sizeof( unsigned )
+ && len && len < (1<<12)) {
+ env[ i ] = malloc( len + 1 );
+ if( (unsigned) read( 0, env[ i ], len ) == len ) {
+ env[ i ][ len ] = '\0';
+ } else {
+ ok = 0;
+ }
+ }
+ }
+ if( ok ) {
+ env[ i ] = NULL;
+ orig_environ = env;
+ }
+ }
+ }
+ if(argc == 0)
+ return 1;
+ new_argc = argc + 2;
+ new_argv = malloc( sizeof( char* ) * ( new_argc + 1 ));
+ if( new_argv == NULL )
+ return 1;
+ new_argv[ 0 ] = EXECUTE;
+ new_argv[ 1 ] = "--oom-pipe";
+ sprintf( helper_num, "%d", pipes[ 1 ] );
+ new_argv[ 2 ] = helper_num;
+ for( i = 1;
+ i <= (unsigned) argc;
+ ++i )
+ new_argv[ i + 2 ] = argv[ i ];
+ if( orig_environ )
+ execve(EXECUTE, (char**)new_argv, orig_environ);
+ else
+ execv(EXECUTE, (char**)new_argv);
+ perror(EXECUTE);
+ return 1;
+ case 0: /* child, keep privileges and do the privileged work */
+ close( pipes[ 1 ] );
+ for(;;) {
+ pid_t pid = 0;
+ int ret = read( pipes[ 0 ], &pid, sizeof( pid_t ));
+ if( ret < 0 && errno == EINTR )
+ continue;
+ if( ret <= 0 ) /* pipe closed or error, exit */
+ _exit(0);
+ if( pid != 0 ) {
+ if (set_protection( pid, 0 ))
+ kill( pid, SIGUSR1 );
+ }
+ }
+ }
+}
+
+#else /* not Linux, the simple non-setuid case */
+
+int main(int argc, char **argv)
+{
+ if(argc == 0)
+ return 1;
+ argv[0] = (char*)EXECUTE;
+ execv(EXECUTE,argv);
+ perror(EXECUTE);
+ return 1;
+}
+#endif
Index: kinit/start_kdeinit_wrapper.c
===================================================================
--- kinit/start_kdeinit_wrapper.c (revision 0)
+++ kinit/start_kdeinit_wrapper.c (revision 1000474)
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2007 Lubos Lunak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#define EXECUTE LIBEXEC_INSTALL_DIR "/start_kdeinit"
+
+#ifdef KDEINIT_OOM_PROTECT
+
+/*
+ The start_kdeinit wrapper is setuid, which means some shell variables like LD_LIBRARY_PATH
+ get unset before it's launched. However kdeinit is used to launch most of KDE, so such variables
+ should not be dropped. Therefore this wrapper for the setuid wrapper read the environment
+ and writes it to start_kdeinit's stdin, which after dropping priviledges reads it and uses it
+ for launching the real kdeinit.
+*/
+int main(int argc, char **argv)
+{
+ int pipes[ 2 ];
+ if(argc == 0)
+ return 1;
+ if( pipe( pipes ) < 0 ) {
+ perror( "pipe()" );
+ return 1;
+ }
+ switch( fork()) {
+ case -1:
+ perror( "fork()" );
+ return 1;
+ default: /* parent, exec */
+ close( pipes[ 1 ] );
+ close( 0 ); /* stdin */
+ dup2( pipes[ 0 ], 0 );
+ close( pipes[ 0 ] );
+ argv[ 0 ] = (char*)EXECUTE;
+ execvp(EXECUTE, argv);
+ perror("start_kdeinit");
+ return 1;
+ case 0: { /* child, pass env and exit */
+ extern char** environ;
+ int i;
+ close( pipes[ 0 ] );
+ write( pipes[ 1 ], "environ", 7 ); /* header, just in case */
+ for( i = 0;
+ environ[ i ] != NULL;
+ ++i )
+ {}
+ write( pipes[ 1 ], &i, sizeof( int )); /* write count */
+ for( i = 0;
+ environ[ i ] != NULL;
+ ++i )
+ {
+ int len = strlen( environ[ i ] );
+ write( pipes[ 1 ], &len, sizeof( int )); /* write length */
+ write( pipes[ 1 ], environ[ i ], strlen( environ[ i ] ));
+ }
+ close( pipes[ 1 ] );
+ }
+ }
+ return 0;
+}
+
+#else /* not Linux, the simple non-setuid case */
+
+int main(int argc, char **argv)
+{
+ if(argc == 0)
+ return 1;
+ argv[0] = (char*)EXECUTE;
+ execvp(EXECUTE,argv);
+ perror("start_kdeinit");
+ return 1;
+}
+#endif
Index: kinit/kinit.cpp
===================================================================
--- kinit/kinit.cpp (revision 1000153)
+++ kinit/kinit.cpp (revision 1000474)
@@ -22,6 +22,7 @@
#define QT_NO_CAST_FROM_ASCII
#include
+#include
#include
#include
@@ -34,6 +35,7 @@
#include // Needed on some systems.
#endif
+#include
#include
#include
#include "proctitle.h"
@@ -84,12 +86,6 @@
#include
#endif
-#if KDE_IS_VERSION( 3, 90, 0 )
-#ifdef __GNUC__
-#warning Check if Linux OOM-killer still sucks and if yes, forwardport revision 579164 and following fixes.
-#endif
-#endif
-
// #define SKIP_PROCTITLE 1
extern char **environ;
@@ -421,6 +417,38 @@
return QFile::encodeName(execpath);
}
+#ifdef KDEINIT_OOM_PROTECT
+static int oom_pipe = -1;
+
+static void oom_protect_sighandler( int ) {
+}
+
+static void reset_oom_protect() {
+ if( oom_pipe <= 0 )
+ return;
+ struct sigaction act, oldact;
+ act.sa_handler = oom_protect_sighandler;
+ act.sa_flags = 0;
+ sigemptyset( &act.sa_mask );
+ sigaction( SIGUSR1, &act, &oldact );
+ sigset_t sigs, oldsigs;
+ sigemptyset( &sigs );
+ sigaddset( &sigs, SIGUSR1 );
+ sigprocmask( SIG_BLOCK, &sigs, &oldsigs );
+ pid_t pid = getpid();
+ if( write( oom_pipe, &pid, sizeof( pid_t )) > 0 ) {
+ sigsuspend( &oldsigs ); // wait for the signal to come
+ }
+ sigprocmask( SIG_SETMASK, &oldsigs, NULL );
+ sigaction( SIGUSR1, &oldact, NULL );
+ close( oom_pipe );
+ oom_pipe = -1;
+}
+#else
+static void reset_oom_protect() {
+}
+#endif
+
static pid_t launch(int argc, const char *_name, const char *args,
const char *cwd=0, int envc=0, const char *envs=0,
bool reset_env = false,
@@ -505,6 +533,7 @@
/** Child **/
close(d.fd[0]);
close_fds();
+ reset_oom_protect();
// Try to chdir, either to the requested directory or to the user's document path by default.
// We ignore errors - if you write a desktop file with Exec=foo and Path=/doesnotexist,
@@ -1601,6 +1630,10 @@
printf("KDE: %s\n", KDE_VERSION_STRING);
exit(0);
}
+#ifdef KDEINIT_OOM_PROTECT
+ if (strcmp(safe_argv[i], "--oom-pipe") == 0 && i+1