diff --git a/gdm-look-at-runlevel.patch b/gdm-look-at-runlevel.patch
new file mode 100644
index 0000000..f7952bb
--- /dev/null
+++ b/gdm-look-at-runlevel.patch
@@ -0,0 +1,57 @@
+Index: gdm-2.28.0/daemon/gdm-static-display.c
+===================================================================
+--- gdm-2.28.0.orig/daemon/gdm-static-display.c
++++ gdm-2.28.0/daemon/gdm-static-display.c
+@@ -26,6 +26,7 @@
+ #include <fcntl.h>
+ #include <pwd.h>
+ #include <unistd.h>
++#include <utmp.h>
+ #include <string.h>
+ #include <signal.h>
+ #include <sys/stat.h>
+@@ -96,6 +97,29 @@ gdm_static_display_manage (GdmDisplay *d
+ }
+ 
+ static gboolean
++gdm_static_display_should_manage_again (void)
++{
++        struct utmp *ut;
++
++        setutent();
++        while ((ut = getutent()) != NULL) {
++                if (ut->ut_type == RUN_LVL) {
++                        char current;
++                        current = ut->ut_pid % 256;
++                        endutent();
++
++                        if (current == '0' || current == '6')
++                                return FALSE;
++                        return TRUE;
++                }
++        }
++
++        endutent();
++
++        return TRUE;
++}
++
++static gboolean
+ gdm_static_display_finish (GdmDisplay *display)
+ {
+         int status;
+@@ -108,9 +132,11 @@ gdm_static_display_finish (GdmDisplay *d
+         /* restart static displays */
+         gdm_display_unmanage (display);
+ 
+-        status = gdm_display_get_status (display);
+-        if (status != GDM_DISPLAY_FAILED) {
+-                gdm_display_manage (display);
++        if (gdm_static_display_should_manage_again ()) {
++                status = gdm_display_get_status (display);
++                if (status != GDM_DISPLAY_FAILED) {
++                        gdm_display_manage (display);
++                }
+         }
+ 
+         return TRUE;
diff --git a/gdm.changes b/gdm.changes
index fc4c00c..82ccf00 100644
--- a/gdm.changes
+++ b/gdm.changes
@@ -1,3 +1,13 @@
+-------------------------------------------------------------------
+Tue Oct 20 09:26:00 CEST 2009 - vuntz@opensuse.org
+
+- Add gdm-look-at-runlevel.patch to work around issue where gdm
+  blocks the restart/shutdown process because of a race there.
+  Should fix bnc#540482.
+- Version the Provides/Obsoletes to fix a rpmlint warning.
+- Reorder packageand() arguments for the branding supplements to
+  fix rpmlint warning.
+
 -------------------------------------------------------------------
 Fri Oct  2 19:33:46 CEST 2009 - vuntz@opensuse.org
 
diff --git a/gdm.spec b/gdm.spec
index bc9fa5d..2fe37aa 100644
--- a/gdm.spec
+++ b/gdm.spec
@@ -43,7 +43,7 @@ BuildRequires:  zenity
 License:        GPL v2 or later
 Group:          System/GUI/GNOME
 Version:        2.28.0
-Release:        1
+Release:        2
 Summary:        The GNOME 2.x Display Manager
 Source:         %{name}-%{version}.tar.bz2
 Source1:        gdm.pamd
@@ -91,13 +91,15 @@ Patch37:        gdm-autologin-once.patch
 Patch38:        gdm-devkit-power.patch
 # PATCH-FIX-UPSTREAM gdm-polkit-gnome-path.patch bgo597050 vuntz@opensuse.org -- Use the right patch for the polkit agent. The current patch is a quick workaround for now, until we know how upstream wants to fix this.
 Patch39:        gdm-polkit-gnome-path.patch
+# PATCH-FIX-UPSTREAM gdm-look-at-runlevel.patch bnc540482 bgo599180 vuntz@opensuse.org -- Look at the current runlevel before managing the display again, so we don't do this when shutting down or rebooting
+Patch40:        gdm-look-at-runlevel.patch
 # PATCH-FIX-OPENSUSE gdm-selinux.patch -- Small changes to make it compile fine with SELinux
 Patch60:        gdm-selinux.patch
 Url:            http://www.gnome.org/
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 DocDir:         %{_defaultdocdir}
-Provides:       gdm2
-Obsoletes:      gdm2
+Provides:       gdm2 = %{version}
+Obsoletes:      gdm2 < %{version}
 Obsoletes:      fast-user-switch-applet <= 2.22.0
 Requires:       %{name}-branding
 Requires:       %{name}-lang = %{version}
@@ -124,7 +126,7 @@ Summary:        The GNOME 2.x Display Manager
 Group:          System/GUI/GNOME
 Provides:       %{name}-branding = %{version}
 Conflicts:      otherproviders(%{name}-branding)
-Supplements:    packageand(branding-upstream:%{name})
+Supplements:    packageand(%{name}:branding-upstream)
 #BRAND: Provide two equal files - /usr/share/gdm/defaults.conf and
 #BRAND: factory-defaults.conf with default configuration of gdm.
 #BRAND: Branding package requires the package with the default theme.
@@ -165,6 +167,7 @@ gnome-patch-translation-prepare
 %patch37 -p1
 %patch38 -p1
 %patch39 -p1
+%patch40 -p1
 %patch60
 # gnome-patch-translation-update