[Libreoffice] [PATCH] Fix osl_Security::getHomeDir test under fakeroot

Miklos Vajna vmiklos at frugalware.org
Sun May 8 05:23:22 PDT 2011


Hi,

See the attached patch, I needed it to build 3.4beta4 under fakeroot
(for some reason I did not have this issue with beta3).

Can someone sign it off and push to -3-4, please?

Thanks.
-------------- next part --------------
From f68130520cad8ff76559f6e5bf202cf076297b9d Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos at frugalware.org>
Date: Sun, 8 May 2011 14:13:51 +0200
Subject: [PATCH] Fix osl_Security::getHomeDir test under fakeroot

fakeroot uses LD_PRELOAD to let getuid() return 0, so getpwuid() will
not return the correct home directory. If we are under fakeroot, the
HOME environment variable can be used to do so.
---
 sal/qa/osl/security/osl_Security.cxx |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index e93714b..93fa96a 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -393,8 +393,11 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
     strUserName = ::rtl::OUString::createFromAscii( pw->pw_name );
 
     /// get home directory;
+    char *pw_dir = pw->pw_dir;
+    if( getenv( "FAKEROOTKEY" ) )
+        pw_dir = getenv("HOME");
     CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.",
-                            ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( pw->pw_dir ), strHomeDirectory ) );
+                            ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( pw_dir ), strHomeDirectory ) );
 
     /// get config directory;
     strConfigDirectory = strHomeDirectory.copy(0);
-- 
1.7.4.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110508/f2e7bc14/attachment.pgp>


More information about the LibreOffice mailing list