Don't make upowerd crash when run under systemd (#834359)
This commit is contained in:
parent
6a9a3db55b
commit
d7730c8012
60
0001-Don-t-crash-if-HOME-is-empty.patch
Normal file
60
0001-Don-t-crash-if-HOME-is-empty.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 490c134a282c7091ee20918022bcf6a3607ec99a Mon Sep 17 00:00:00 2001
|
||||
From: Bastien Nocera <hadess@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
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
Name: libimobiledevice
|
||||
Version: 1.1.4
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
Summary: Library for connecting to mobile devices
|
||||
|
||||
Group: System Environment/Libraries
|
||||
@ -30,6 +30,8 @@ BuildRequires: swig
|
||||
Obsoletes: libimobiledevice-python < %{version}-%{release}
|
||||
%endif
|
||||
|
||||
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
|
||||
@ -52,6 +54,7 @@ Python bindings for libimobiledevice.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .empty-home
|
||||
|
||||
# Fix dir permissions on html docs
|
||||
chmod +x docs/html
|
||||
@ -95,6 +98,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Sep 05 2012 Bastien Nocera <bnocera@redhat.com> 1.1.4-4
|
||||
- Don't make upowerd crash when run under systemd (#834359)
|
||||
|
||||
* Fri Aug 10 2012 Rex Dieter <rdieter@fedoraproject.org> - 1.1.4-3
|
||||
- disable broken python/cython bindings (for now, currently FTBFS)
|
||||
- track soname
|
||||
|
||||
Loading…
Reference in New Issue
Block a user