static void DoSetHostname(JoinProcessOptions *options, LWException **exc) { LWException *inner = NULL; DWORD ceError; LW_TRY(exc, DJSetComputerName(options->computerName, options->domainName, &LW_EXC)); #ifndef ENABLE_MINIMAL ceError = DJConfigureHostsEntry(NULL); if(ceError == ERROR_FILE_NOT_FOUND) { ceError = ERROR_SUCCESS; #if !defined(__LWI_DARWIN__) DJ_LOG_WARNING("Warning: Could not find nsswitch file"); #endif } LW_CLEANUP_CTERR(exc, ceError); #endif #ifndef ENABLE_MINIMAL DJRestartIfRunning("nscd", &inner); if(!LW_IS_OK(inner) && inner->code == ERROR_FILE_NOT_FOUND) LW_HANDLE(&inner); LW_CLEANUP(exc, inner); #endif cleanup: LW_HANDLE(&inner); }
DWORD DJConfigureNameServiceSwitch(const char *testPrefix, BOOLEAN enable) { DWORD ceError = ERROR_SUCCESS; NsswitchConf conf; if(testPrefix == NULL) testPrefix = ""; ceError = ReadNsswitchConf(&conf, testPrefix, TRUE); if(ceError == ERROR_FILE_NOT_FOUND) { ceError = ERROR_SUCCESS; DJ_LOG_WARNING("Warning: Could not find nsswitch file"); goto cleanup; } GCE(ceError); ceError = UpdateNsswitchConf(&conf, enable); if(conf.modified) WriteNsswitchConfiguration(testPrefix, &conf); else DJ_LOG_INFO("nsswitch not modified"); cleanup: FreeNsswitchConfContents(&conf); return ceError; }
void PrintWarning(const JoinProcessOptions *options, const char *title, const char *message) { PSTR wrapped = NULL; int columns; if(CTGetTerminalWidth(fileno(stdout), &columns)) columns = -1; //This function doesn't return a DWORD, so we have to recover as much //as possible. if(!CTWordWrap(message, &wrapped, 4, columns)) fprintf(stdout, "Warning: %s\n%s\n\n", title, wrapped); else fprintf(stdout, "Warning: %s\n%s\n\n", title, message); CT_SAFE_FREE_STRING(wrapped); DJ_LOG_WARNING("%s\n%s", title, message); }
static DWORD FillMissingPassword( PCSTR username, PSTR* ppszPassword ) { DWORD ceError = ERROR_SUCCESS; PSTR pszPassword = NULL; PCSTR pszEnvPassword = NULL; pszEnvPassword = getenv("PASSWORD"); if (pszEnvPassword == NULL) { fprintf(stdout, "%s's password: "******"\n"); } else { DJ_LOG_WARNING("Retrieved password from envionmental variable"); ceError = CTStrdup(pszEnvPassword, &pszPassword); BAIL_ON_CENTERIS_ERROR(ceError); } if (!IsNullOrEmptyString(pszPassword)) { *ppszPassword = pszPassword; pszPassword = NULL; } error: if (pszPassword) CTFreeString(pszPassword); return ceError; }
static QueryResult QueryNsswitch(const JoinProcessOptions *options, LWException **exc) { QueryResult result = FullyConfigured; BOOLEAN configured; BOOLEAN exists; BOOLEAN hasBadSeLinux; NsswitchConf conf; DWORD ceError = ERROR_SUCCESS; uid_t uid = 0; gid_t gid = 0; mode_t mode = 0; memset(&conf, 0, sizeof(conf)); if (options->enableMultipleJoins) { result = NotApplicable; goto cleanup; } if (options->joiningDomain) { ceError = ReadNsswitchConf(&conf, NULL, FALSE); if(ceError == ERROR_FILE_NOT_FOUND) { ceError = ERROR_SUCCESS; DJ_LOG_WARNING("Warning: Could not find nsswitch file"); goto cleanup; } LW_CLEANUP_CTERR(exc, ceError); LW_TRY(exc, result = RemoveCompat(&conf, NULL, &LW_EXC)); if(result == CannotConfigure || result == NotConfigured) { goto cleanup; } LW_CLEANUP_CTERR(exc, CTGetOwnerAndPermissions( conf.filename, &uid, &gid, &mode)); if ((mode & 0444) != 0444) { // The user has to fix the permissions result = CannotConfigure; goto cleanup; } LW_CLEANUP_CTERR(exc, UpdateNsswitchConf(&conf, TRUE)); if(conf.modified) { LW_CLEANUP_CTERR(exc, UnsupportedSeLinuxEnabled(&hasBadSeLinux)); if(hasBadSeLinux) result = CannotConfigure; else result = NotConfigured; goto cleanup; } LW_CLEANUP_CTERR(exc, DJHasMethodsCfg(&exists)); if(exists) { LW_CLEANUP_CTERR(exc, DJIsMethodsCfgConfigured(&configured)); if(!configured) { result = NotConfigured; goto cleanup; } } LW_CLEANUP_CTERR(exc, IsApparmorConfigured(&configured)); if(!configured) { result = NotConfigured; goto cleanup; } } else { LW_CLEANUP_CTERR(exc, DJHasMethodsCfg(&exists)); if(exists) { LW_CLEANUP_CTERR(exc, DJIsMethodsCfgConfigured(&configured)); if(configured) { result = NotConfigured; goto cleanup; } } } cleanup: FreeNsswitchConfContents(&conf); return result; }