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

Francois Tigeot ftigeot at wolfpond.org
Wed May 11 03:04:22 PDT 2011


On Wed, May 11, 2011 at 08:58:09AM +0200, Francois Tigeot wrote:
> 
> I will certainly remove a bit more than this patch: the previous workaround
> commit will not be needed anymore.
> And maybe I should just delete this whole bunch of code. I mean: even if we
> test if we can get the user's home directory, what is the point ?

The last version of the patch.

Running a build at the moment; I will certainly push it in a few hours if the
result is good.

-- 
Francois Tigeot
-------------- next part --------------
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index edd9669..fd74162 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -197,30 +197,6 @@ namespace osl_Security
     }; // class getUserName
 
 
-
-    /** testing the method:
-        inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
-    */
-    class getHomeDir : public CppUnit::TestFixture
-    {
-    public:
-        sal_Bool bRes, bRes1;
-
-        void getHomeDir_001( )
-        {
-            ::osl::Security aSec;
-            ::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_TEST_SUITE( getHomeDir );
-        CPPUNIT_TEST( getHomeDir_001 );
-        CPPUNIT_TEST_SUITE_END( );
-    }; // class getHomeDir
-
     /** testing the method:
         inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
     */
@@ -393,11 +369,8 @@ 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_dir ), strHomeDirectory ) );
+                            ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( pw->pw_dir ), strHomeDirectory ) );
 
     /// get config directory;
     strConfigDirectory = strHomeDirectory.copy(0);


More information about the LibreOffice mailing list