[libimobiledevice/f17] Don't make upowerd crash when run under systemd (#834359)
Bastien Nocera
hadess at fedoraproject.org
Thu Sep 13 09:20:27 UTC 2012
commit b05f4101d85b27645358ed964dc87045f03e3451
Author: Bastien Nocera <hadess at hadess.net>
Date: Wed Sep 5 10:51:36 2012 +0100
Don't make upowerd crash when run under systemd (#834359)
Conflicts:
libimobiledevice.spec
0001-Don-t-crash-if-HOME-is-empty.patch | 60 +++++++++++++++++++++++++++++++
libimobiledevice.spec | 8 ++++-
2 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/0001-Don-t-crash-if-HOME-is-empty.patch b/0001-Don-t-crash-if-HOME-is-empty.patch
new file mode 100644
index 0000000..eed0bae
--- /dev/null
+++ b/0001-Don-t-crash-if-HOME-is-empty.patch
@@ -0,0 +1,60 @@
+From 490c134a282c7091ee20918022bcf6a3607ec99a Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess at hadess.net>
+Date: Wed, 5 Sep 2012 10:07:15 +0100
+Subject: [PATCH] Don't crash if $HOME is empty
+
+If both $XDG_CONFIG_HOME and $HOME are unset, we'd try to copy a NULL
+string, causing a crash. This is the environment systemd provides to
+its daemons, and that was causing upowerd to crash.
+
+http://libiphone.lighthouseapp.com/projects/27916-libiphone/tickets/273-patch-fix-segfault-when-running-with-home-unset#ticket-273-2
+http://libiphone.lighthouseapp.com/projects/27916/tickets/265-userpref_get_config_dir-segfaults-when-home-is-undefined
+https://bugzilla.redhat.com/show_bug.cgi?id=834359
+---
+ src/userpref.c | 23 ++++++++++++++++++++++-
+ 1 file changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/src/userpref.c b/src/userpref.c
+index a0c3545..0e774b7 100644
+--- a/src/userpref.c
++++ b/src/userpref.c
+@@ -102,6 +102,20 @@ static char *userpref_utf16_to_utf8(wchar_t *unistr, long len, long *items_read,
+ }
+ #endif
+
++static const char *userpref_get_tmp_dir()
++{
++ const char *cdir = getenv("TMPDIR");
++ if (cdir && cdir[0])
++ return cdir;
++ cdir = getenv("TMP");
++ if (cdir && cdir[0])
++ return cdir;
++ cdir = getenv("TEMP");
++ if (cdir && cdir[0])
++ return cdir;
++ return "/tmp";
++}
++
+ static const char *userpref_get_config_dir()
+ {
+ if (__config_dir[0]) return __config_dir;
+@@ -125,7 +139,14 @@ static const char *userpref_get_config_dir()
+ const char *cdir = getenv("XDG_CONFIG_HOME");
+ if (!cdir) {
+ cdir = getenv("HOME");
+- strcpy(__config_dir, cdir);
++ if (!cdir || !cdir[0]) {
++ const char *tdir = userpref_get_tmp_dir();
++ strcpy(__config_dir, tdir);
++ strcat(__config_dir, DIR_SEP_S);
++ strcat(__config_dir, "root");
++ } else {
++ strcpy(__config_dir, cdir);
++ }
+ strcat(__config_dir, DIR_SEP_S);
+ strcat(__config_dir, ".config");
+ } else {
+--
+1.7.11.2
+
diff --git a/libimobiledevice.spec b/libimobiledevice.spec
index 882a0c5..9cea5fd 100644
--- a/libimobiledevice.spec
+++ b/libimobiledevice.spec
@@ -2,7 +2,7 @@
Name: libimobiledevice
Version: 1.1.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Library for connecting to mobile devices
Group: System Environment/Libraries
@@ -22,6 +22,8 @@ BuildRequires: Cython
BuildRequires: swig
BuildRequires: usbmuxd-devel
+Patch0: 0001-Don-t-crash-if-HOME-is-empty.patch
+
%description
libimobiledevice is a library for connecting to mobile devices including phones
and music players
@@ -46,6 +48,7 @@ Python bindings for libimobiledevice.
%prep
%setup -q
+%patch0 -p1 -b .empty-home
# Fix dir permissions on html docs
chmod +x docs/html
@@ -87,6 +90,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%{python_sitearch}/imobiledevice*
%changelog
+* Thu Sep 13 2012 Bastien Nocera <bnocera at redhat.com> 1.1.4-2
+- Don't make upowerd crash when run under systemd (#834359)
+
* Tue Apr 10 2012 Peter Robinson <pbrobinson at fedoraproject.org> - 1.1.4-1
- New 1.1.4 release
More information about the scm-commits
mailing list