X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FUtils%2FUtils_Identity.cxx;h=f6cc2369967afaf9997833c0cfe673565c4ae03e;hb=1119e0f3b0ead5c13e8f458fc9a75b7797420dd8;hp=c890fe3b20cc07cdb0fb038b48c4f01606e022b2;hpb=703cf8ca778de35a6b463d4b4fca7c36697d717f;p=modules%2Fkernel.git diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index c890fe3b2..f6cc23699 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -71,6 +71,8 @@ const char* get_adip( void ) #endif const hostent* pour_adip=gethostbyname(hostid.nodename); + if(pour_adip == NULL) + pour_adip=gethostbyname("localhost"); ASSERT(pour_adip!=NULL); const in_addr ip_addr=*(struct in_addr*)(pour_adip->h_addr) ; return duplicate(inet_ntoa(ip_addr)); @@ -91,7 +93,7 @@ const char* duplicate( const char *const str ) ; const char* get_uname( void ) { - static std::string hostName(256, 0); + static std::string hostName(4096, 0); static DWORD nSize = hostName.length(); static int res = ::GetComputerNameEx(ComputerNameDnsFullyQualified, &hostName[0], &nSize); ASSERT( res ); @@ -125,7 +127,7 @@ const char* get_adip( void ) const char* const get_pwname( void ) { - static std::string retVal(256, 0); + static std::string retVal(4096, 0); static DWORD dwSize = retVal.length() + 1; static int res = GetUserName( &retVal[0], &dwSize ); ASSERT( res ); @@ -138,7 +140,7 @@ PSID getuid() { PTOKEN_OWNER pTKowner = NULL; LPVOID buffer = NULL; DWORD dwsize = 0; - + if ( !OpenProcessToken ( GetCurrentProcess (), TOKEN_QUERY, &hProcessToken )) return 0; if (!GetTokenInformation(hProcessToken, TokenOwner, buffer, dwsize, &dwsize)) return 0; pTKowner = (PTOKEN_OWNER)buffer; @@ -146,7 +148,7 @@ PSID getuid() { retVal = pTKowner->Owner; } if ( hProcessToken != INVALID_HANDLE_VALUE ) CloseHandle ( hProcessToken ); - + return retVal; } @@ -161,13 +163,13 @@ Identity::Identity( const char *name ): _name(duplicate(name)),\ _adip(get_adip()),\ _uid(getuid()) ,\ _pwname(get_pwname()) ,\ - _dir(getcwd(NULL,256)),\ + _dir(getcwd(NULL,4096)),\ _pid(getpid()) ,\ _start(time(NULL)),\ _cstart(ctime(&_start)) //CCRT { - ASSERT(strlen(_dir)<256); + ASSERT(strlen(_dir)<4096); } @@ -179,9 +181,9 @@ Identity::~Identity(void) //delete [] (char*)_dir ; //(char*&)_dir = NULL ; free((char*)_dir); -#ifndef WIN32 +#ifndef WIN32 // free the memory only on Unix - // becasue at Windows it is the same static variable + // because in Windows it is the same static variable // (function get_adip() returns the same char* as get_uname() ) delete [] (char*)_adip ; #endif