merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0526-lockfile-dont-do-dns-lookup.diff
blob3a397b84377685afc28e21233adc093264071984
1 diff --git desktop/source/app/lockfile.cxx desktop/source/app/lockfile.cxx
2 index b1bba75..a026115 100644
3 --- desktop/source/app/lockfile.cxx
4 +++ desktop/source/app/lockfile.cxx
5 @@ -36,6 +36,8 @@
6 #include <tools/prewin.h>
7 #include <windows.h>
8 #include <tools/postwin.h>
9 +#else
10 +#include <unistd.h>
11 #endif
12 #include <sal/types.h>
13 #include <osl/file.hxx>
14 @@ -53,6 +55,37 @@ using namespace ::rtl;
15 using namespace ::utl;
18 +static rtl::OString impl_getHostname()
20 + rtl::OString aHost;
21 +#ifdef WNT
22 + /*
23 + prevent windows from connecting to the net to get it's own
24 + hostname by using the netbios name
25 + */
26 + sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
27 + char* szHost = new char[sz];
28 + if (GetComputerName(szHost, (LPDWORD)&sz))
29 + aHost = OString(szHost);
30 + else
31 + aHost = OString("UNKNOWN");
32 + delete[] szHost;
33 +#else
34 + /* Don't do dns lookup on Linux either */
35 + sal_Char pHostName[1024];
37 + if ( gethostname( pHostName, sizeof( pHostName ) - 1 ) == 0 )
38 + {
39 + pHostName[sizeof( pHostName ) - 1] = '\0';
40 + aHost = OString( pHostName );
41 + }
42 + else
43 + aHost = OString("UNKNOWN");
44 +#endif
46 + return aHost;
49 namespace desktop {
51 // initialize static members...
52 @@ -158,25 +191,9 @@ namespace desktop {
54 ByteString aHost = aConfig.ReadKey( Hostkey() );
55 ByteString aUser = aConfig.ReadKey( Userkey() );
57 // lockfile from same host?
58 - ByteString myHost;
59 -#ifdef WNT
60 - /*
61 - prevent windows from connecting to the net to get it's own
62 - hostname by using the netbios name
63 - */
64 - sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
65 - char* szHost = new char[sz];
66 - if (GetComputerName(szHost, (LPDWORD)&sz))
67 - myHost = OString(szHost);
68 - else
69 - myHost = OString("UNKNOWN");
70 - delete[] szHost;
71 -#else
72 - oslSocketResult sRes;
73 - myHost = OUStringToOString(
74 - SocketAddr::getLocalHostname( &sRes ), RTL_TEXTENCODING_ASCII_US );
75 -#endif
76 + ByteString myHost( impl_getHostname() );
77 if (aHost == myHost) {
78 // lockfile by same UID
79 OUString myUserName;
80 @@ -196,24 +213,7 @@ namespace desktop {
81 aConfig.SetGroup(Group());
83 // get information
84 - ByteString aHost;
85 -#ifdef WNT
86 - /*
87 - prevent windows from connecting to the net to get it's own
88 - hostname by using the netbios name
89 - */
90 - sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
91 - char* szHost = new char[sz];
92 - if (GetComputerName(szHost, (LPDWORD)&sz))
93 - aHost = OString(szHost);
94 - else
95 - aHost = OString("UNKNOWN");
96 - delete[] szHost;
97 -#else
98 - oslSocketResult sRes;
99 - aHost = OUStringToOString(
100 - SocketAddr::getLocalHostname( &sRes ), RTL_TEXTENCODING_ASCII_US );
101 -#endif
102 + ByteString aHost( impl_getHostname() );
103 OUString aUserName;
104 Security aSecurity;
105 aSecurity.getUserName( aUserName );