summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Hjalmarsson <gunnarhj@ubuntu.com>2014-10-21 13:13:57 +0200
committerGunnar Hjalmarsson <gunnarhj@ubuntu.com>2014-10-21 13:13:57 +0200
commit4af079bdc272ac706d252bc6fa23eb038b8dee8c (patch)
treeb37fd2c54377cc9b1d98abc9b479b41807890b22
parent72b0adf6b3ee0d3c9851d852abc727cadc913d3f (diff)
downloadlightdm-git-4af079bdc272ac706d252bc6fa23eb038b8dee8c.tar.gz
Show warning dialog instead of interrupted login if syntax error in ~/.profile etc
-rw-r--r--debian/config-error-dialog.sh35
-rw-r--r--debian/lightdm-session23
-rw-r--r--debian/lightdm.install1
-rw-r--r--debian/patches/05_translate_debian_files.patch7
4 files changed, 61 insertions, 5 deletions
diff --git a/debian/config-error-dialog.sh b/debian/config-error-dialog.sh
new file mode 100644
index 00000000..da62087d
--- /dev/null
+++ b/debian/config-error-dialog.sh
@@ -0,0 +1,35 @@
+# Copyright (C) 2014 Canonical Ltd
+# Author: Gunnar Hjalmarsson <gunnarhj@ubuntu.com>
+#
+# 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, version 3 of the License.
+#
+# See http://www.gnu.org/copyleft/gpl.html the full text of the license.
+
+# This file may be sourced by the function source_with_error_check() in
+# /usr/sbin/lightdm-session
+
+export TEXTDOMAIN=lightdm
+. /usr/bin/gettext.sh
+
+if $SYNTAX; then
+ PARA1=$(eval_gettext 'The configuration file $CONFIG_FILE contains
+invalid syntax and could not be loaded:')
+else
+ PARA1=$(eval_gettext 'Error found when loading $CONFIG_FILE:')
+fi
+
+PARA2=$(gettext 'As a result the session will not be configured correctly.
+You should fix the problem as soon as feasible.')
+
+TEXT="$PARA1\n\n$(fold -s $ERR)\n\n$PARA2"
+
+if [ -x /usr/bin/kdialog ]; then
+ TEXT_FILE=$(mktemp --tmpdir config-err-kdialog-XXXXXX)
+ echo -n "$TEXT" > "$TEXT_FILE"
+ kdialog --textbox "$TEXT_FILE" 500 300
+ rm -f "$TEXT_FILE"
+elif [ -x /usr/bin/zenity ]; then
+ zenity --warning --no-wrap --text="$TEXT"
+fi
diff --git a/debian/lightdm-session b/debian/lightdm-session
index 2a86cbf6..172af59e 100644
--- a/debian/lightdm-session
+++ b/debian/lightdm-session
@@ -20,11 +20,30 @@ errormsg () {
exit 1
}
+# temporary storage of error messages
+ERR=$(mktemp --tmpdir config-err-XXXXXX)
+
+source_with_error_check () {
+ CONFIG_FILE="$1"
+ if sh -n "$CONFIG_FILE" 2>"$ERR"; then
+ echo "Loading $CONFIG_FILE";
+ . "$CONFIG_FILE" 2>"$ERR"
+ if [ -s "$ERR" ]; then
+ SYNTAX=false
+ . /usr/lib/lightdm/config-error-dialog.sh
+ fi
+ else
+ SYNTAX=true
+ . /usr/lib/lightdm/config-error-dialog.sh
+ fi
+ cat "$ERR" >>/dev/stderr
+ truncate -s 0 "$ERR"
+}
+
# Load profile
for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
if [ -f "$file" ]; then
- echo "Loading profile from $file";
- . "$file"
+ source_with_error_check "$file"
fi
done
diff --git a/debian/lightdm.install b/debian/lightdm.install
index 1da4aeb9..27d46b65 100644
--- a/debian/lightdm.install
+++ b/debian/lightdm.install
@@ -9,6 +9,7 @@ etc/lightdm/lightdm.conf usr/share/doc/lightdm/
etc/lightdm/keys.conf usr/share/doc/lightdm/
etc/apparmor.d
debian/lightdm-session usr/sbin
+debian/config-error-dialog.sh usr/lib/lightdm
debian/guest-session-auto.sh usr/lib/lightdm
debian/lightdm-greeter-session usr/lib/lightdm
debian/source_lightdm.py usr/share/apport/package-hooks
diff --git a/debian/patches/05_translate_debian_files.patch b/debian/patches/05_translate_debian_files.patch
index 382192c5..5c322aa8 100644
--- a/debian/patches/05_translate_debian_files.patch
+++ b/debian/patches/05_translate_debian_files.patch
@@ -3,12 +3,13 @@ Description: Grab translatable strings from debian/* files
Forwarded: not-needed
Author: Gunnar Hjalmarsson <gunnarhj@ubuntu.com>
---- lightdm.orig/po/POTFILES.in 2014-01-23 19:17:23.143894000 +0100
-+++ lightdm/po/POTFILES.in 2014-07-24 23:28:19.519106226 +0200
-@@ -1,5 +1,7 @@
+--- lightdm.orig/po/POTFILES.in 2014-09-30 05:00:39.000000000 +0200
++++ lightdm/po/POTFILES.in 2014-10-19 18:08:09.576134427 +0200
+@@ -1,5 +1,8 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
++debian/config-error-dialog.sh
+debian/guest-account.sh
+debian/guest-session-auto.sh
src/lightdm.c