Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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
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 );

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.