version 1.67, 2006/11/08 20:38:30
|
version 1.70.2.2, 2007/06/12 09:31:58
|
|
|
#endif | #endif |
| |
#if defined (PEGASUS_OS_TYPE_UNIX) || (PEGASUS_OS_VMS) | #if defined (PEGASUS_OS_TYPE_UNIX) || (PEGASUS_OS_VMS) |
# ifndef PEGASUS_OS_OS400 |
|
# include <unistd.h> | # include <unistd.h> |
# endif |
|
# include <fcntl.h> // File locking | # include <fcntl.h> // File locking |
# define PEGASUS_UID_T uid_t | # define PEGASUS_UID_T uid_t |
# define PEGASUS_GID_T gid_t | # define PEGASUS_GID_T gid_t |
|
|
static String getHostName(); | static String getHostName(); |
static String getFullyQualifiedHostName (); | static String getFullyQualifiedHostName (); |
static String getSystemCreationClassName (); | static String getSystemCreationClassName (); |
static String getHostIP(const String &hostName); |
|
| |
static Uint32 _acquireIP(const char* hostname); |
// Gets IP address assosiated with hostName. af indicates the |
|
// type of address (ipv4 or ipv6) returned. |
|
static Boolean getHostIP(const String &hostName, int *af, String &hostIP); |
|
|
|
// Gets IP address in binary form. af indicates the type of |
|
// address (ipv4 or ipv6) returned. Address will be copied to dst. |
|
static Boolean _acquireIP(const char* hostname, int *af, void *dst); |
| |
static Uint32 lookupPort( | static Uint32 lookupPort( |
const char * serviceName, | const char * serviceName, |
Uint32 defaultPort); | Uint32 defaultPort); |
| |
/** | /** |
Attempts to validate that the input hostName represents the same host as |
Attempts to find the given IP address(32bit) on any of the local defined |
the host represented by the value returned by the |
network interfaces |
getFullyQualifiedHostName() method. |
|
|
|
@param hostName the host name to validate |
|
|
|
@return True if the input hostName can be validated to represent the |
|
same host; |
|
False otherwise |
|
*/ |
|
static Boolean sameHost (const String & hostName); |
|
|
|
/** |
|
* Attempts to find the given IP address(32bit) on any of the local defined |
|
* network interfaces |
|
*/ | */ |
static Boolean isIpOnNetworkInterface(Uint32 inIP); | static Boolean isIpOnNetworkInterface(Uint32 inIP); |
| |
/** | /** |
* Attempts to resolve a given hostname |
Attempts to resolve a given hostname |
* this function possibly can take some as it can request information |
this function possibly can take some as it can request information |
* from the DNS |
from the DNS |
* |
|
* Return: return value == true if successful, false if not successful |
@param resolvedNameIP On successful hostname resolution, this output |
* the IP address that was determined resides in resolvedNameIP |
parameter contains the IP address that was determined. |
*/ |
@return true if successful, false if not successful. |
static Boolean resolveHostNameAtDNS(const char* hostname, Uint32 * resolvedNameIP); |
*/ |
|
static Boolean resolveHostNameAtDNS( |
/** |
const char* hostname, |
* Attempts to resolve a given IP address |
Uint32* resolvedNameIP); |
* this function possibly can take some as it can request information |
|
* from the DNS |
/** |
* Return: return value == true if successful, false if not successful |
Attempts to resolve a given IP address |
* the IP address that was determined resides in resolvedNameIP |
this function possibly can take some as it can request information |
|
from the DNS |
|
@param resolvedIP On successful hostname resolution, this output |
|
parameter contains the IP address that was determined. |
|
@return true if successful, false if not successful. |
*/ | */ |
static Boolean resolveIPAtDNS(Uint32 ip_addr, Uint32 * resolvedIP); | static Boolean resolveIPAtDNS(Uint32 ip_addr, Uint32 * resolvedIP); |
| |
/** | /** |
* Bundling function used to determine if a given hostname or IP address |
Bundling function used to determine if a given hostname or IP address |
* belongs to the local host |
belongs to the local host |
* this function has the potential to take some time as it will possibly |
this function has the potential to take some time as it will possibly |
* use the DNS |
use the DNS |
*/ | */ |
static Boolean isLocalHost(const String &hostName); | static Boolean isLocalHost(const String &hostName); |
| |
|
/** |
|
Checks binIPAddress represented by address family and returns true |
|
if binary representation matches with loopback ip address. binIPAddress |
|
must be in host-byte order. |
|
*/ |
|
static Boolean isLoopBack(int af, void *binIPAddress); |
|
|
static String getEffectiveUserName(); | static String getEffectiveUserName(); |
| |
/** | /** |
|
|
| |
/** | /** |
This function is used to encrypt the user's password. | This function is used to encrypt the user's password. |
The encryption is compatible with Apache's password file (generated using |
The encryption is compatible with Apache's password file (generated |
the htpasswd command ) |
using the htpasswd command) |
| |
@param password Password to be encrypted. | @param password Password to be encrypted. |
@param salt Two character string chosen from the set [a-zA-Z0-9./]. | @param salt Two character string chosen from the set [a-zA-Z0-9./]. |
|
|
| |
/** | /** |
This function returns the privileged user name on the system. | This function returns the privileged user name on the system. |
|
|
@return the privileged user name | @return the privileged user name |
*/ | */ |
static String getPrivilegedUserName(); | static String getPrivilegedUserName(); |
|
|
of the specified user group. | of the specified user group. |
| |
@param userName User name to be verified. | @param userName User name to be verified. |
|
|
@param groupName User group name. | @param groupName User group name. |
| |
@return true if the user is a member of the user group, |
@return true if the user is a member of the user group, false otherwise. |
false otherwise. |
@throw InternalSystemError - If there is an error accessing the |
|
specified user or group information. |
@throw InternalSystemError - If there is an error |
|
accessing the specified user or group information. |
|
*/ | */ |
static Boolean isGroupMember(const char* userName, const char* groupName); | static Boolean isGroupMember(const char* userName, const char* groupName); |
| |
|
|
@return True if the user and group IDs were retrieved | @return True if the user and group IDs were retrieved |
successfully, false otherwise. | successfully, false otherwise. |
*/ | */ |
#ifndef PEGASUS_OS_OS400 |
|
static Boolean lookupUserId( | static Boolean lookupUserId( |
const char* userName, | const char* userName, |
PEGASUS_UID_T& uid, | PEGASUS_UID_T& uid, |
PEGASUS_GID_T& gid); | PEGASUS_GID_T& gid); |
#endif |
|
| |
/** | /** |
Changes the process user context to the specified user and group ID. |
Changes the process user context to the specified user and group. |
|
IMPORTANT: This method uses non-reentrant functions and should only |
|
be called in a single-threaded program. |
|
@param userName User name to set as the process user context. |
@param uid User ID to set as the process user context. | @param uid User ID to set as the process user context. |
@param gid Group ID to set as the process group context. | @param gid Group ID to set as the process group context. |
@return True if the user context is successfully changed, | @return True if the user context is successfully changed, |
false otherwise. | false otherwise. |
*/ | */ |
#ifndef PEGASUS_OS_OS400 |
static Boolean changeUserContext_SingleThreaded( |
static Boolean changeUserContext( |
const char* userName, |
const PEGASUS_UID_T& uid, | const PEGASUS_UID_T& uid, |
const PEGASUS_GID_T& gid); | const PEGASUS_GID_T& gid); |
#endif |
|
| |
/** | /** |
This function is used to get the process ID of the calling process. | This function is used to get the process ID of the calling process. |
|
|
@return Process ID | @return Process ID |
*/ | */ |
static Uint32 getPID(); | static Uint32 getPID(); |