version 1.60, 2005/11/02 22:03:17
|
version 1.68, 2006/10/31 19:47:32
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Sushma Fernandes (sushma_fernandes@hp.com) |
|
// Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) |
|
// Bapu Patil (bapu_patil@hp.com) |
|
// |
|
// Modified By: Dave Rosckes (rosckes@us.ibm.com) |
|
// Terry Martin, Hewlett-Packard Company (terry.martin@hp.com) |
|
// Amit K Arora, IBM (amita@in.ibm.com) for Bug#1428 |
|
// Seema Gupta (gseema@in.ibm.com) for Bug#1617 |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "System.h" | #include "System.h" |
| |
#include <windows.h> |
#include "Network.h" |
#ifndef _WINSOCKAPI_ |
#include "Mutex.h" |
#include <winsock2.h> |
|
#endif |
|
#include <fcntl.h> | #include <fcntl.h> |
#include <sys/types.h> | #include <sys/types.h> |
#include <time.h> | #include <time.h> |
|
|
return rename(oldPath, newPath) == 0; | return rename(oldPath, newPath) == 0; |
} | } |
| |
DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName) |
|
{ |
|
return DynamicLibraryHandle(LoadLibrary(fileName)); |
|
} |
|
|
|
void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle) |
|
{ |
|
FreeLibrary(HINSTANCE(libraryHandle)); |
|
} |
|
|
|
String System::dynamicLoadError(void) { |
|
return String(); |
|
} |
|
|
|
DynamicSymbolHandle System::loadDynamicSymbol( |
|
DynamicLibraryHandle libraryHandle, |
|
const char* symbolName) |
|
{ |
|
return DynamicSymbolHandle(GetProcAddress( |
|
(HINSTANCE)libraryHandle, symbolName)); |
|
} |
|
|
|
String System::getHostName() | String System::getHostName() |
{ | { |
static char hostname[PEGASUS_MAXHOSTNAMELEN + 1]; | static char hostname[PEGASUS_MAXHOSTNAMELEN + 1]; |
|
|
return String(pcSalt) + String((char *)pbBuffer); | return String(pcSalt) + String((char *)pbBuffer); |
} | } |
| |
|
String processUserName; |
|
Mutex processUserNameMut; |
|
|
Boolean System::isSystemUser(const char* userName) | Boolean System::isSystemUser(const char* userName) |
{ | { |
|
if(processUserName.size() == 0) |
|
{ |
|
// Lock and recheck the processUserName length in case two threads |
|
// enter this block simultaneously |
|
AutoMutex mut(processUserNameMut); |
|
if(processUserName.size() == 0) |
|
{ |
|
processUserName = getEffectiveUserName(); |
|
} |
|
} |
|
if(processUserName == userName) |
|
{ |
|
return true; |
|
} |
|
|
Boolean isSystemUser = false; | Boolean isSystemUser = false; |
| |
char mUserName[UNLEN+1]; | char mUserName[UNLEN+1]; |
|
|
return retVal; | return retVal; |
} | } |
| |
Boolean System::changeUserContext(const char* userName) |
Boolean System::lookupUserId( |
|
const char* userName, |
|
PEGASUS_UID_T& uid, |
|
PEGASUS_GID_T& gid) |
|
{ |
|
// ATTN: Implement this method to look up the specified user |
|
return false; |
|
} |
|
|
|
Boolean System::changeUserContext( |
|
const PEGASUS_UID_T& uid, |
|
const PEGASUS_GID_T& gid) |
{ | { |
// ATTN: Implement this method to change the process user context to the | // ATTN: Implement this method to change the process user context to the |
// specified user | // specified user |
|
|
// System ID constants for Logger::put and Logger::trace | // System ID constants for Logger::put and Logger::trace |
const String System::CIMSERVER = "cimserver"; // Server system ID | const String System::CIMSERVER = "cimserver"; // Server system ID |
| |
|
// check if a given IP address is defined on the local network interfaces |
|
Boolean System::isIpOnNetworkInterface(Uint32 inIP) |
|
{ |
|
SOCKET sock; |
|
int interfaces = 0; |
|
int errcode; |
|
|
|
if ( SOCKET_ERROR != ( sock = WSASocket(AF_INET, |
|
SOCK_RAW, 0, NULL, 0, 0) ) ) |
|
{ |
|
unsigned long *bytes_returned=0; |
|
char *output_buf = (char *)calloc(1, 256); |
|
int buf_size = 256; |
|
|
|
if ( 0 == (errcode = WSAIoctl(sock, |
|
SIO_ADDRESS_LIST_QUERY, |
|
NULL, |
|
0, |
|
output_buf, |
|
256, |
|
bytes_returned, |
|
NULL, |
|
NULL)) ) |
|
{ |
|
SOCKET_ADDRESS_LIST *addr_list; |
|
SOCKET_ADDRESS *addr; |
|
Uint32 ip; |
|
struct sockaddr_in *sin; |
|
|
|
addr_list = (SOCKET_ADDRESS_LIST *)output_buf; |
|
addr = addr_list->Address; |
|
|
|
sin = (struct sockaddr_in *)addr->lpSockaddr; |
|
|
|
for( ; interfaces < addr_list->iAddressCount; interfaces++) |
|
{ |
|
ip = sin->sin_addr.s_addr; |
|
addr++; |
|
sin = (struct sockaddr_in *)addr->lpSockaddr; |
|
if (ip == inIP) |
|
{ |
|
free(output_buf); |
|
closesocket(sock); |
|
return(true); |
|
} |
|
} |
|
} else { |
|
free(output_buf); |
|
return false; |
|
} |
|
free(output_buf); |
|
closesocket(sock); |
|
} |
|
return false; |
|
} |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
// AutoFileLock class |
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
AutoFileLock::AutoFileLock(const char* fileName) |
|
{ |
|
// ATTN: Not implemented |
|
} |
|
|
|
AutoFileLock::~AutoFileLock() |
|
{ |
|
// ATTN: Not implemented |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |