DWORD PrintPamConfig( FILE *fp, PLSA_PAM_CONFIG pConfig ) { DWORD dwError = 0; if (fputs( "[HKEY_THIS_MACHINE\\Services\\lsass\\Parameters\\PAM]\n", fp) < 0) { dwError = LwMapErrnoToLwError(errno); } BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "LogLevel", pConfig->pszLogLevel); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintBoolean(fp, "DisplayMotd", pConfig->bLsaPamDisplayMOTD); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "UserNotAllowedError", pConfig->pszAccessDeniedMessage); BAIL_ON_UP_ERROR(dwError); if (fputs("\n", fp) < 0) { dwError = LwMapErrnoToLwError(errno); } BAIL_ON_UP_ERROR(dwError); error: return dwError; }
static DWORD DJAppendNameValuePair( PSTR pszFilePath, PSTR pszName, PSTR pszValue ) { DWORD ceError = ERROR_SUCCESS; FILE* fp = NULL; if ((fp = fopen(pszFilePath, "a")) == NULL) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } if (fprintf(fp, "\n%s=%s\n", pszName, pszValue) < 0) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } fclose(fp); fp = NULL; error: if (fp) fclose(fp); return ceError; }
static VOID EventLogShutdownRPCServer( VOID ) { DWORD dwError = 0; dwError = EventLogStopRpcServer(); BAIL_ON_VMEVENT_ERROR(dwError); if (gEventLogServerGlobals.pRPCServerThread) { dwError = LwMapErrnoToLwError( dcethread_interrupt( gEventLogServerGlobals.pRPCServerThread)); BAIL_ON_VMEVENT_ERROR(dwError); dwError = LwMapErrnoToLwError( dcethread_join( gEventLogServerGlobals.pRPCServerThread, NULL)); BAIL_ON_VMEVENT_ERROR(dwError); gEventLogServerGlobals.pRPCServerThread = NULL; } error: return; }
static DWORD LwSmWaitSignals( int* pSig ) { DWORD dwError = 0; sigset_t set; static int waitSignals[] = { SIGTERM, SIGHUP, -1 }; int sig = -1; int i = 0; if (sigemptyset(&set) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } for (i = 0; waitSignals[i] != -1; i++) { if (sigaddset(&set, waitSignals[i]) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } } for (;;) { if (sigwait(&set, &sig) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } switch (sig) { case SIGTERM: case SIGHUP: *pSig = sig; goto cleanup; default: break; } } cleanup: return dwError; error: goto cleanup; };
/* // TODO: Check access and removability before actual deletion */ DWORD LsaRemoveDirectory( PSTR pszPath ) { DWORD dwError = 0; DIR* pDir = NULL; struct dirent* pDirEntry = NULL; struct stat statbuf; CHAR szBuf[PATH_MAX+1]; if ((pDir = opendir(pszPath)) == NULL) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } while ((pDirEntry = readdir(pDir)) != NULL) { if (!strcmp(pDirEntry->d_name, "..") || !strcmp(pDirEntry->d_name, ".")) continue; sprintf(szBuf, "%s/%s", pszPath, pDirEntry->d_name); memset(&statbuf, 0, sizeof(struct stat)); if (stat(szBuf, &statbuf) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } if ((statbuf.st_mode & S_IFMT) == S_IFDIR) { dwError = LsaRemoveDirectory(szBuf); BAIL_ON_LSA_ERROR(dwError); if (rmdir(szBuf) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } } else { dwError = LsaRemoveFile(szBuf); BAIL_ON_LSA_ERROR(dwError); } } error: if (pDir) closedir(pDir); return dwError; }
static DWORD LwSmConfigureSignals( VOID ) { DWORD dwError = 0; sigset_t set; static int blockSignals[] = { SIGTERM, SIGCHLD, SIGHUP, -1 }; int i = 0; struct sigaction intAction; memset(&intAction, 0, sizeof(intAction)); if (sigemptyset(&set) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } for (i = 0; blockSignals[i] != -1; i++) { if (sigaddset(&set, blockSignals[i]) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } } dwError = LwMapErrnoToLwError(pthread_sigmask(SIG_SETMASK, &set, NULL)); BAIL_ON_ERROR(dwError); intAction.sa_handler = LwSmHandleSigint; intAction.sa_flags = 0; if (sigaction(SIGINT, &intAction, NULL) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } cleanup: return dwError; error: goto cleanup; }
DWORD CTMatchProgramToPID( PCSTR pszProgramName, pid_t pid ) { DWORD ceError = ERROR_SUCCESS; CHAR szBuf[PATH_MAX+1]; FILE* pFile = NULL; #if defined(__LWI_DARWIN__) || defined(__LWI_FREEBSD__) sprintf(szBuf, "ps -p %d -o command= | grep %s", pid, pszProgramName); #elif defined(__LWI_SOLARIS__) || defined(__LWI_HP_UX__) || defined(__LWI_AIX__) sprintf(szBuf, "PS=ps; [ -x /bin/ps ] && PS=/bin/ps; UNIX95=1 $PS -p %ld -o comm= | grep %s", (long)pid, pszProgramName); #else sprintf(szBuf, "UNIX95=1 ps -p %ld -o cmd= | grep %s", (long)pid, pszProgramName); #endif pFile = popen(szBuf, "r"); if (pFile == NULL) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } /* Assume that we won't find the process we are looking for */ ceError = ERROR_PROC_NOT_FOUND; while (TRUE) { if (NULL == fgets(szBuf, PATH_MAX, pFile)) { if (feof(pFile)) { break; } else { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } } CTStripWhitespace(szBuf); if (!IsNullOrEmptyString(szBuf)) { /* Well what do you know, it was found! */ ceError = ERROR_SUCCESS; break; } } error: if (pFile) pclose(pFile); return ceError; }
DWORD LwSmTableAddEntry( PLW_SERVICE_INFO pInfo, PSM_TABLE_ENTRY* ppEntry ) { DWORD dwError = 0; BOOL bLocked = TRUE; PSM_TABLE_ENTRY pEntry = NULL; dwError = LwAllocateMemory(sizeof(*pEntry), OUT_PPVOID(&pEntry)); BAIL_ON_ERROR(dwError); LwSmLinkInit(&pEntry->link); LwSmLinkInit(&pEntry->waiters); pEntry->bValid = TRUE; dwError = LwSmCopyServiceInfo(pInfo, &pEntry->pInfo); dwError = LwMapErrnoToLwError(pthread_mutex_init(&pEntry->lock, NULL)); BAIL_ON_ERROR(dwError); pEntry->pLock = &pEntry->lock; dwError = LwMapErrnoToLwError(pthread_cond_init(&pEntry->event, NULL)); BAIL_ON_ERROR(dwError); pEntry->pEvent = &pEntry->event; dwError = LwSmTableReconstructEntry(pEntry); BAIL_ON_ERROR(dwError); LOCK(bLocked, gServiceTable.pLock); LwSmLinkInsertBefore(&gServiceTable.entries, &pEntry->link); pEntry->dwRefCount++; UNLOCK(bLocked, gServiceTable.pLock); *ppEntry = pEntry; cleanup: return dwError; error: if (pEntry) { LwSmTableFreeEntry(pEntry); } goto cleanup; }
DWORD InstallLwiCompat( PCSTR pSmbdPath ) { DWORD error = 0; PSTR pSambaDir = NULL; PSTR pLwiCompat = NULL; PCSTR pLikewiseLwiCompat = LIBDIR "/" LWICOMPAT_FILENAME; error = GetIdmapDir( pSmbdPath, &pSambaDir); BAIL_ON_LSA_ERROR(error); error = LwAllocateStringPrintf( &pLwiCompat, "%s/%s", pSambaDir, LWICOMPAT_FILENAME ); BAIL_ON_LSA_ERROR(error); if (unlink(pLwiCompat) < 0) { if (errno != ENOENT) { error = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(error); } } if (symlink(pLikewiseLwiCompat, pLwiCompat) < 0) { error = LwMapErrnoToLwError(errno); if (error == ERROR_FILE_NOT_FOUND) { LW_RTL_LOG_ERROR("Cannot access idmap directory %s. Please ensure you have winbind installed", pSambaDir); } BAIL_ON_LSA_ERROR(error); } LW_RTL_LOG_INFO("Linked idmapper %s to %s", pLwiCompat, pLikewiseLwiCompat); cleanup: LW_SAFE_FREE_STRING(pSambaDir); LW_SAFE_FREE_STRING(pLwiCompat); return error; }
NTSTATUS EVTSvcmStop( PLW_SVCM_INSTANCE pInstance ) { DWORD dwError = 0; EVT_LOG_INFO("Eventlog Service exiting..."); gbExitNow = TRUE; if (gbRegisteredTcpIp) { dwError = EVTUnregisterAllEndpoints(); BAIL_ON_EVT_ERROR(dwError); dwError = EVTStopListen(); BAIL_ON_EVT_ERROR(dwError); } dwError = LwmEvtSrvStopListenThread(); BAIL_ON_EVT_ERROR(dwError); if (gbRegisteredTcpIp) { dwError = LwMapErrnoToLwError(dcethread_interrupt(gNetworkThread)); BAIL_ON_EVT_ERROR(dwError); dwError = LwMapErrnoToLwError(dcethread_join(gNetworkThread, NULL)); BAIL_ON_EVT_ERROR(dwError); } cleanup: LwEvtDbShutdownEventDatabase(); EVTSetConfigDefaults(); EVTFreeSecurityDescriptor(gServerInfo.pAccess); gServerInfo.pAccess = NULL; return LwWin32ErrorToNtStatus(dwError); error: EVT_LOG_ERROR("Eventlog exiting due to error [code:%d]", dwError); goto cleanup; }
DWORD LsaCheckFileExists( PCSTR pszPath, PBOOLEAN pbFileExists ) { DWORD dwError = 0; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); while (1) { if (stat(pszPath, &statbuf) < 0) { if (errno == EINTR) { continue; } else if (errno == ENOENT) { *pbFileExists = 0; break; } dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } else { *pbFileExists = 1; break; } } error: return dwError; }
DWORD LsaCheckSockExists( PSTR pszPath, PBOOLEAN pbSockExists ) { DWORD dwError = 0; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); while (1) { if (stat(pszPath, &statbuf) < 0) { if (errno == EINTR) { continue; } else if (errno == ENOENT || errno == ENOTDIR) { *pbSockExists = 0; break; } dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } else { *pbSockExists = (((statbuf.st_mode & S_IFMT) == S_IFSOCK) ? TRUE : FALSE); break; } } error: return dwError; }
DWORD CTGetFileTimeStamps( PCSTR pszFilePath, time_t *patime, /* time of last access */ time_t *pmtime, /* time of last modification */ time_t *pctime ) /* time of last status change */ { DWORD ceError = ERROR_SUCCESS; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); if (stat(pszFilePath, &statbuf) < 0) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } if ( patime ) { *patime = statbuf.st_atime; } if ( pmtime ) { *pmtime = statbuf.st_mtime; } if ( pctime ) { *pctime = statbuf.st_ctime; } error: return ceError; }
DWORD CTGetOwnerAndPermissions( PCSTR pszSrcPath, uid_t * uid, gid_t * gid, mode_t * mode ) { DWORD ceError = ERROR_SUCCESS; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); if (stat(pszSrcPath, &statbuf) < 0) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } *uid = statbuf.st_uid; *gid = statbuf.st_gid; *mode = statbuf.st_mode; error: return ceError; }
DWORD CTCheckFileExists( PCSTR pszPath, PBOOLEAN pbFileExists ) { DWORD ceError = ERROR_SUCCESS; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); while (1) { if (stat(pszPath, &statbuf) < 0) { if (errno == EINTR) { continue; } else if (errno == ENOENT || errno == ENOTDIR) { *pbFileExists = FALSE; break; } ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } else { *pbFileExists = (((statbuf.st_mode & S_IFMT) == S_IFREG) ? TRUE : FALSE); break; } } error: return ceError; }
static DWORD InitializeRPCServer( VOID ) { DWORD dwError = 0; dwError = EventLogStartRpcServer(); BAIL_ON_VMEVENT_ERROR(dwError); dwError = LwMapErrnoToLwError( dcethread_create( &gEventLogServerGlobals.pRPCServerThread, NULL, EventLogListenRpcServer, NULL)); BAIL_ON_VMEVENT_ERROR(dwError); while (!EventLogCheckRPCServerIsActive()) { // Wait for RPC Server to come up. } error: return dwError; }
static DWORD LwSmNotify( DWORD Error ) { DWORD dwError = 0; int ret = 0; do { ret = write(gState.notifyPipe[1], &Error, sizeof(Error)); } while (ret < 0 && errno == EINTR); if (ret < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_ERROR(dwError); } cleanup: close(gState.notifyPipe[1]); return dwError; error: goto cleanup; }
DWORD CTChangeOwner( PCSTR pszPath, uid_t uid, gid_t gid ) { DWORD ceError = ERROR_SUCCESS; while (1) { if (chown(pszPath, uid, gid) < 0) { if (errno == EINTR) { continue; } ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } else { break; } } error: return ceError; }
DWORD DJGetComputerName( PSTR* ppszComputerName ) { DWORD ceError = ERROR_SUCCESS; CHAR szBuf[256+1]; PSTR pszTmp = NULL; if (gethostname(szBuf, 256) < 0) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } pszTmp = szBuf; while (*pszTmp != '\0') { if (*pszTmp == '.') { *pszTmp = '\0'; break; } pszTmp++; } if (IsNullOrEmptyString(szBuf)) { ceError = ERROR_INVALID_COMPUTERNAME; BAIL_ON_CENTERIS_ERROR(ceError); } ceError = CTAllocateString(szBuf, ppszComputerName); BAIL_ON_CENTERIS_ERROR(ceError); error: return ceError; }
DWORD CTGetCurrentDirectoryPath( PSTR* ppszPath ) { DWORD ceError = ERROR_SUCCESS; CHAR szBuf[PATH_MAX+1]; PSTR pszPath = NULL; if (getcwd(szBuf, PATH_MAX) == NULL) { ceError = LwMapErrnoToLwError(errno); BAIL_ON_CENTERIS_ERROR(ceError); } ceError = CTAllocateString(szBuf, &pszPath); BAIL_ON_CENTERIS_ERROR(ceError); *ppszPath = pszPath; return ceError; error: if (pszPath) { CTFreeString(pszPath); } return ceError; }
DWORD LwChangeOwner( PCSTR pszPath, uid_t uid, gid_t gid ) { DWORD dwError = 0; while (1) { if (lchown(pszPath, uid, gid) < 0) { if (errno == EINTR) { continue; } dwError = LwMapErrnoToLwError(errno); BAIL_ON_LW_ERROR(dwError); } else { break; } } error: return dwError; }
DWORD CTGetTerminalWidth(int terminalFid, int *width) { DWORD ceError = ERROR_SUCCESS; #ifdef TIOCGWINSZ struct winsize size = {0}; const char *fromEnv = getenv("COLUMNS"); if(ioctl(terminalFid, TIOCGWINSZ, &size) == -1 || size.ws_col == 0) { if(fromEnv != NULL) { size.ws_col = atoi(fromEnv); } else { ceError = LwMapErrnoToLwError(errno); CLEANUP_ON_DWORD(ceError); } } if(size.ws_col < 1) { ceError = ERROR_INVALID_OPERATION; CLEANUP_ON_DWORD(ceError); } *width = size.ws_col; #else *width = -1; #endif cleanup: return ceError; }
DWORD LsaGetOwnerAndPermissions( PCSTR pszSrcPath, uid_t * uid, gid_t * gid, mode_t * mode ) { DWORD dwError = 0; struct stat statbuf; memset(&statbuf, 0, sizeof(struct stat)); if (stat(pszSrcPath, &statbuf) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } *uid = statbuf.st_uid; *gid = statbuf.st_gid; *mode = statbuf.st_mode; error: return dwError; }
// This function is just a wrapper to getting the current time as a time_t. DWORD LsaGetCurrentTimeSeconds( OUT time_t* pTime ) { DWORD dwError = 0; struct timeval current_tv; // ISSUE-2008/10/30-dalmeida -- Is gettimeofday() any better worse than time()? // Preserve gettimeofday() since the code we are replacing currently uses that. if (gettimeofday(¤t_tv, NULL) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } *pTime = current_tv.tv_sec; cleanup: return dwError; error: *pTime = 0; goto cleanup; }
DWORD LsaGetCurrentDirectoryPath( PSTR* ppszPath ) { DWORD dwError = 0; CHAR szBuf[PATH_MAX+1]; PSTR pszPath = NULL; if (getcwd(szBuf, PATH_MAX) == NULL) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } dwError = LwAllocateString(szBuf, &pszPath); BAIL_ON_LSA_ERROR(dwError); *ppszPath = pszPath; return dwError; error: if (pszPath) { LwFreeString(pszPath); } return dwError; }
DWORD LwKrb5SetProcessDefaultCachePath( PCSTR pszCachePath ) { DWORD dwError = 0; PSTR pszEnvironmentEntry = NULL; static volatile PSTR pszSavedEnvironmentEntry = NULL; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; BOOLEAN bLocked = FALSE; dwError = pthread_mutex_lock(&lock); if (dwError) { dwError = LwMapErrnoToLwError(dwError); BAIL_ON_LW_ERROR(dwError); } bLocked = TRUE; dwError = LwAllocateStringPrintf(&pszEnvironmentEntry, "KRB5CCNAME=%s", pszCachePath); BAIL_ON_LW_ERROR(dwError); /* * putenv requires that the buffer not be free'd. */ if (putenv(pszEnvironmentEntry) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LW_ERROR(dwError); } LW_SAFE_FREE_STRING(pszSavedEnvironmentEntry); pszSavedEnvironmentEntry = pszEnvironmentEntry; pszEnvironmentEntry = NULL; error: LW_SAFE_FREE_STRING(pszEnvironmentEntry); if (bLocked) { pthread_mutex_unlock(&lock); } return dwError; }
DWORD LsaChangeOwner( PCSTR pszPath, uid_t uid, gid_t gid ) { DWORD dwError = 0; struct stat statbuf = {0}; if (lstat(pszPath, &statbuf) < 0) { dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } while (1) { if (S_ISLNK(statbuf.st_mode)) { if (lchown(pszPath, uid, gid) < 0) { if (errno == EINTR) { continue; } dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } else { break; } } else { if (chown(pszPath, uid, gid) < 0) { if (errno == EINTR) { continue; } dwError = LwMapErrnoToLwError(errno); BAIL_ON_LSA_ERROR(dwError); } else { break; } } } error: return dwError; }
NTSTATUS EVTSvcmStart( PLW_SVCM_INSTANCE pInstance, ULONG ArgCount, PWSTR* ppArgs, ULONG FdCount, int* pFds ) { DWORD dwError = 0; BOOLEAN bRegisterTcpIp = TRUE; dwError = EVTSetServerDefaults(); BAIL_ON_EVT_ERROR(dwError); dwError = LwEvtDbCreateDB(gServerInfo.bReplaceDB); BAIL_ON_EVT_ERROR(dwError); if (gServerInfo.bReplaceDB) { goto cleanup; } dwError = EVTReadEventLogConfigSettings(); if (dwError != 0) { EVT_LOG_ERROR("Failed to read eventlog configuration. Error code: [%u]\n", dwError); dwError = 0; } dwError = EVTGetRegisterTcpIp(&bRegisterTcpIp); BAIL_ON_EVT_ERROR(dwError); dwError = LwEvtDbInitEventDatabase(); BAIL_ON_EVT_ERROR(dwError); dwError = LwmEvtSrvStartListenThread(); BAIL_ON_EVT_ERROR(dwError); dwError = EVTRegisterInterface(); BAIL_ON_EVT_ERROR(dwError); if (bRegisterTcpIp) { dwError = LwMapErrnoToLwError(dcethread_create( &gNetworkThread, NULL, EVTNetworkThread, &gbExitNow)); BAIL_ON_EVT_ERROR(dwError); gbRegisteredTcpIp = TRUE; } cleanup: return LwWin32ErrorToNtStatus(dwError); error: goto cleanup; }
DWORD UpLocalPrintConfig( FILE *fp, PLOCAL_CONFIG pConfig ) { DWORD dwError = 0; if (fputs( "[HKEY_THIS_MACHINE\\Services\\lsass\\Parameters\\Providers\\Local]\n", fp) < 0) { dwError = LwMapErrnoToLwError(errno); } BAIL_ON_UP_ERROR(dwError); //dwError = UpPrintBoolean(fp, "EnableEventlog", pConfig->bEnableEventLog); //BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "LoginShellTemplate", pConfig->pszLoginShell); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "HomeDirPrefix", pConfig->pszHomedirPrefix); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "HomeDirTemplate", pConfig->pszHomedirTemplate); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintBoolean(fp, "CreateHomeDir", pConfig->bCreateHomedir); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "HomeDirUmask", pConfig->pszUmask); BAIL_ON_UP_ERROR(dwError); dwError = UpPrintString(fp, "SkeletonDirs", pConfig->pszSkelDirs); BAIL_ON_UP_ERROR(dwError); if (fputs("\n", fp) < 0) { dwError = LwMapErrnoToLwError(errno); } BAIL_ON_UP_ERROR(dwError); error: return dwError; }
VOID SrvSvcRpcShutdown( VOID ) { DWORD dwError = ERROR_SUCCESS; BOOLEAN bInLock = FALSE; SRVSVC_LOCK_MUTEX(bInLock, &gSrvsServerInfo.mutex); if (gSrvsServerInfo.pServerBinding) { dwError = SrvSvcUnregisterForRPC(gSrvsServerInfo.pServerBinding); BAIL_ON_SRVSVC_ERROR(dwError); gSrvsServerInfo.pServerBinding = NULL; } if (gSrvsServerInfo.pRegistryBinding) { dwError = WinRegUnregisterForRPC(gSrvsServerInfo.pRegistryBinding); BAIL_ON_SRVSVC_ERROR(dwError); gSrvsServerInfo.pRegistryBinding = NULL; } if (gSrvsServerInfo.pRpcListenerThread) { dwError = LwMapErrnoToLwError(dcethread_interrupt(gSrvsServerInfo.pRpcListenerThread)); BAIL_ON_SRVSVC_ERROR(dwError); dwError = LwMapErrnoToLwError(dcethread_join(gSrvsServerInfo.pRpcListenerThread, NULL)); BAIL_ON_SRVSVC_ERROR(dwError); } if (gSrvsServerInfo.pSessionSecDesc) { SrvSvcSrvDestroyServerSecurityDescriptor(gSrvsServerInfo.pSessionSecDesc); gSrvsServerInfo.pSessionSecDesc = NULL; } error: SRVSVC_UNLOCK_MUTEX(bInLock, &gSrvsServerInfo.mutex); return; }