[Libreoffice] [PATCH] Problematic homedir check in osl_Security.cxx

Francois Tigeot ftigeot at wolfpond.org
Tue May 10 12:54:15 PDT 2011


Hi,

I've been bitten by the assert in line 216 of osl_Security.cxx in ure

    CPPUNIT_ASSERT_MESSAGE( "#test comment#: getHomeDir and compare it
	with the info we get at the beginning.",
		( sal_True == strHomeDirectory.equals( strHome ) ) && ( sal_True == bRes ) );

Basically, this test checks
- if libreoffice can get the value of $HOME
- if $HOME is equal to the initial user directory defined by the system

I've been bitten by this check trying to package LibreOffice in pkgsrc [1].
pkgsrc sets the value of $HOME to an empty directory to check if programs do
not dump garbage into it or try to do something too clever for their own good

The CPPUNIT_ASSERT check comes straight from the first recorded version of the
osl_Security.cxx file, back in 2003.

According to the comment above it, it was a test for the function returning
the value of the home directory :

    /** testing the method: inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString&
        strDirectory) const; */

This is not what it is doing now: it is also checking if $HOME is equal to
pw->pw_dir on Unix system, and this is the part which fails.

I've spend some time in opengrok checking for home directory usage, and I
see no justification for this new check.

Instead, I've found
- many duplicated implementations of functions to get the home directory,
including one which returns a hardcoded /
- some code implementing part of the C library for obsolete versions of
NetBSD systems.

There have been recent commits to remove part of the brain damage of the
CPPUNIT assert, but it is not enough.
I believe that the $HOME / pw_dir comparison the assert is now doing is wrong
and should be simply removed. The attached patch transforms the assert so that
it only checks for success in running the getHomeDir function.

[1]: http://www.pkgsrc.org/

-- 
Francois Tigeot
-------------- next part --------------
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index edd9669..2cb2b3d 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -212,8 +212,8 @@ namespace osl_Security
             ::rtl::OUString strHome;
             bRes = aSec.getHomeDir( strHome );
 
-            CPPUNIT_ASSERT_MESSAGE( "#test comment#: getHomeDir and compare it with the info we get at the beginning.",
-                                     ( sal_True == strHomeDirectory.equals( strHome ) ) && ( sal_True == bRes ) );
+            CPPUNIT_ASSERT_MESSAGE( "#test comment#: getHomeDir .",
+                                                    ( sal_True == bRes ) );
         }
 
         CPPUNIT_TEST_SUITE( getHomeDir );


More information about the LibreOffice mailing list