#ifndef __PSUtilitiesDefs_h__
#define __PSUtilitiesDefs_h__ 1
#include <sys/time.h>
#include <openssl/cast.h>
#include <PasswordServer/CPSPluginDefines.h>
#define kSASLPluginDisabledPath "/usr/lib/sasl2/disabled"
enum {
kCPSUtilWaitingForConnection = 1,
kCPSUtilOK = 0,
kCPSUtilFail = -1,
kCPSUtilServiceUnavailable = -2,
kCPSUtilParameterError = -3,
kCPSUtilMemoryError = -4
};
enum {
kPWSearchLocalFile = 0x0001, kPWSearchReplicaFile = 0x0002, kPWSearchDirectory = 0x0004, kPWSearchRegisteredServices = 0x0008 };
typedef enum {
kReplicaIPSet_CurrentForLDAP,
kReplicaIPSet_LocallyHosted,
kReplicaIPSet_InSubnet,
kReplicaIPSet_PrivateNet,
kReplicaIPSet_Wide
} ReplicaIPLevel;
typedef enum PWServerErrorType {
kPolicyError,
kSASLError,
kConnectionError,
kGeneralError
} PWServerErrorType;
typedef struct PWServerError {
int err;
PWServerErrorType type;
} PWServerError;
typedef struct SASLMechInfo {
char name[SASL_MECHNAMEMAX + 1];
char filename[256];
bool requiresPlain;
} SASLMechInfo;
typedef enum PWKnownMech {
kKnownMechLM,
kKnownMechNT,
kKnownMechNTLMv2,
kKnownMechMS_CHAPv2,
kKnownMechCRAM_MD5,
kKnownMechDIGEST_MD5, kKnownMechWEBDAV_DIGEST, kKnownMechAPOP,
kKnownMechPPS,
kKnownMechOther,
kKnownMechCount
} PWKnownMech;
typedef struct PWAuthStats {
uint16_t structVersion; uint16_t connCount; time_t timeStampStart; time_t timeStampEnd; uint8_t replicatorIncomingPct; uint8_t replicatorOutgoingPct; uint16_t authGoodCount[kKnownMechCount];
uint16_t authBadCount[kKnownMechCount];
} PWAuthStats;
#ifdef __cplusplus
extern "C" {
#endif
void psfwSetUSR1Debug( bool on );
void writeToServer( FILE *out, char *buf );
PWServerError readFromServer( int fd, char *buf, unsigned long bufLen );
void writeToServerWithCASTKey( FILE *out, char *buf, CAST_KEY *inKey, unsigned char *inOutIV );
PWServerError readFromServerWithCASTKey( int fd, char *buf, unsigned long bufLen, CAST_KEY *inKey, unsigned char *inOutIV );
PWServerError readFromServerGetData( int fd, char *buf, unsigned long bufLen, unsigned long *outByteCount );
PWServerError readFromServerGetLine( int fd, char *buf, unsigned long bufLen, bool inCanReadMore, unsigned long *inOutByteCount );
PWServerError readFromServerGetErrorCode( char *buf );
void ConvertHexToBinary( const char *inHexStr, unsigned char *outData, unsigned long *outLen );
int ConvertBinaryTo64( const char *inData, unsigned long inLen, char *outHexStr );
int Convert64ToBinary( const char *inHexStr, char *outData, unsigned long maxLen, unsigned long *outLen );
long ConnectToServer( sPSContextData *inContext );
Boolean Connected( sPSContextData *inContext );
long IdentifyReachableReplica( CFMutableArrayRef inServerArray, const char *inHexHash, sPSServerEntry *outReplica, int *outSock );
long IdentifyReachableReplicaByIP(
sPSServerEntry *entrylist,
CFIndex servCount,
const char *inHexHash,
sPSServerEntry *outReplica,
int *outSock );
long ConvertCFArrayToServerArray( CFArrayRef inCFArray, sPSServerEntry **outServerArray, CFIndex *outCount );
long GetBigNumber( sPSContextData *inContext, char **outBigNumStr );
PWServerError SendFlush( sPSContextData *inContext,
const char *inCommandStr,
const char *inArg1Str,
const char *inArg2Str );
PWServerError SendFlushRead( sPSContextData *inContext,
const char *inCommandStr,
const char *inArg1Str,
const char *inArg2Str,
char *inOutBuf,
unsigned long inBufLen );
char *SendFlushReadAssembleCommand(
const char *inCommandStr,
const char *inArg1Str,
const char *inArg2Str );
void StripRSAKey( char *inOutUserID );
long GetPasswordServerList( CFMutableArrayRef *outServerList, int inConfigSearchOptions );
long GetPasswordServerListForKeyHash( CFMutableArrayRef *outServerList, int inConfigSearchOptions, const char *inKeyHash );
long GetServerListFromLocalCache( CFMutableArrayRef inOutServerList );
long GetServerListFromFile( CFMutableArrayRef inOutServerList );
long GetServerListFromFileForKeyHash( CFMutableArrayRef inOutServerList, const char *inKeyHash );
long GetServerFromDict( CFDictionaryRef serverDict, int inIPIndex, sPSServerEntry *outServerEntry );
int SaveLocalReplicaCache( CFMutableArrayRef inReplicaArray, sPSServerEntry *inLastContactEntry );
void AppendToArrayIfUnique( CFMutableArrayRef inArray, sPSServerEntry *inServerEntry );
ReplicaIPLevel ReplicaPriority( sPSServerEntry *inReplica, unsigned long *iplist );
bool ReplicaInIPSet( sPSServerEntry *inReplica, ReplicaIPLevel inLevel );
long pwsf_LocalIPList( unsigned long **outIPList );
long getconn_async(const char *host, const char *port, struct timeval *inOpenTimeout, float *outConnectTime, int *inOutSocket);
long testconn_udp(const char *host, const char *port, int *outSocket);
pid_t pwsf_ProcessIsRunning( const char *inProcName );
bool pwsf_GetSASLMechInfo( const char *inMechName, char **outPluginFileName, bool *outRequiresPlainTextOnDisk );
int pwsf_mkdir_p( const char *path, mode_t mode );
int EnumerateDirectory( const char *inDirPath, const char *inStartsWith, CFMutableArrayRef *outFileArray );
int pwsf_EnumerateDirectory( const char *inDirPath, const char *inStartsWith, CFMutableArrayRef *outFileArray );
int pwsf_LaunchTask(const char *path, char *const argv[]);
int pwsf_LaunchTaskWithIO(
const char *path,
char *const argv[],
const char* inputBuf,
char* outputBuf,
int outputBufSize,
bool *outExitedBeforeInput);
int pwsf_LaunchTaskWithIO2(
const char *path,
char *const argv[],
const char* inputBuf,
char* outputBuf,
int outputBufSize,
char* errBuf,
int errBufSize);
#ifdef __cplusplus
};
#endif
#endif // __PSUtilitiesDefs_h__