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); }
void DJRestartIfRunning(PCSTR daemon, LWException **exc) { BOOLEAN running; LWException *inner = NULL; DJGetDaemonStatus(daemon, &running, &inner); if(!LW_IS_OK(inner) && inner->code == ERROR_SERVICE_NOT_FOUND) { //The daemon isn't installed LW_HANDLE(&inner); running = FALSE; } LW_CLEANUP(exc, inner); if(!running) goto cleanup; DJ_LOG_INFO("Restarting '%s'", daemon); LW_TRY(exc, DJStartStopDaemon(daemon, FALSE, &LW_EXC)); DJ_LOG_INFO("Starting '%s'", daemon); LW_TRY(exc, DJStartStopDaemon(daemon, TRUE, &LW_EXC)); cleanup: LW_HANDLE(&inner); }
void DoNsswitch( JoinProcessOptions *options, LWException **exc ) { LWException *restartException = NULL; NsswitchConf conf; DWORD ceError = ERROR_SUCCESS; memset(&conf, 0, sizeof(conf)); LW_TRY(exc, ConfigureApparmor(options->joiningDomain, &LW_EXC)); if(options->joiningDomain) LW_CLEANUP_CTERR(exc, DJFixMethodsConfigFile()); else LW_CLEANUP_CTERR(exc, DJUnconfigMethodsConfigFile()); ceError = ReadNsswitchConf(&conf, "", TRUE); if(ceError == ERROR_FILE_NOT_FOUND) { ceError = ERROR_SUCCESS; if (options->warningCallback != NULL) { options->warningCallback(options, "Could not find file", "Could not find nsswitch file"); } goto cleanup; } LW_CLEANUP_CTERR(exc, ceError); if(options->joiningDomain) { LW_TRY(exc, RemoveCompat(&conf, NULL, &LW_EXC)); } LW_CLEANUP_CTERR(exc, UpdateNsswitchConf(&conf, options->joiningDomain)); if(conf.modified) LW_CLEANUP_CTERR(exc, WriteNsswitchConfiguration("", &conf)); else DJ_LOG_INFO("nsswitch not modified"); CTCaptureOutputToExc( SCRIPTDIR "/ConfigureLogin nsswitch_restart", &restartException); if(restartException != NULL && restartException->code == ERROR_BAD_COMMAND) { if (options->warningCallback) { options->warningCallback(options, "Some services require manual restart", restartException->longMsg); } LW_HANDLE(&restartException); } LW_CLEANUP(exc, restartException); LW_TRY(exc, RestartDtloginIfRunning(options, &LW_EXC)); if (options->joiningDomain && options->warningCallback != NULL) { options->warningCallback(options, "System restart required", "Your system has been configured to authenticate to " "Active Directory for the first time. It is recommended " "that you restart your system to ensure that all applications " "recognize the new settings."); } cleanup: FreeNsswitchConfContents(&conf); }
static void RestartDtloginIfRunning(JoinProcessOptions *options, LWException **exc) { BOOLEAN doRestart; BOOLEAN inX; LWException *inner = NULL; DistroInfo distro; memset(&distro, 0, sizeof(distro)); DJGetDaemonStatus("dtlogin", &doRestart, &inner); if(!LW_IS_OK(inner) && inner->code == ERROR_SERVICE_NOT_FOUND) { LW_HANDLE(&inner); goto cleanup; } LW_CLEANUP(exc, inner); if(doRestart) { /* Dtlogin will only be restarted if no one is logged in. */ LW_CLEANUP_CTERR(exc, CTIsUserInX(&inX)); if(inX) { doRestart = FALSE; /* If we're disabling domain logins, it isn't critical that * dtlogin is restarted. Without lwiauthd running, domain * users won't be able to log in anyway. */ if(options->joiningDomain) { LW_CLEANUP_CTERR(exc, DJGetDistroInfo(NULL, &distro)); if(distro.os == OS_SUNOS) { if (options->warningCallback != NULL) { options->warningCallback(options, "Unable to restart dtlogin", "The dtlogin process needs to be restarted for domain users to interactively login graphically, but it cannot be restarted at this time because a user is currently logged in. After the user exits, please run these commands as root, outside of an Xwindows session:\n\n" "/etc/init.d/dtlogin stop\n" "/etc/init.d/dtlogin start"); } } else if(distro.os == OS_HPUX) { if (options->warningCallback != NULL) { options->warningCallback(options, "Unable to restart dtlogin", "The dtlogin process needs to be restarted for domain users to interactively login graphically, but it cannot be restarted at this time because a user is currently logged in. After the user exits, please run these commands as root, outside of an Xwindows session:\n\n" "/sbin/init.d/dtlogin.rc stop\n" "/sbin/init.d/dtlogin.rc start"); } } else if(distro.os == OS_AIX) { if (options->warningCallback != NULL) { options->warningCallback(options, "Unable to restart dtlogin", "The dtlogin process needs to be restarted for domain users to interactively login graphically, but it cannot be restarted at this time because a user is currently logged in. After the user exits, please run these commands as root, outside of an Xwindows session:\n\n" "kill `cat /var/dt/Xpid`\n" "/etc/rc.dt"); } } else { if (options->warningCallback != NULL) { options->warningCallback(options, "Unable to restart dtlogin", "The dtlogin process needs to be restarted for domain users to interactively login graphically, but it cannot be restarted at this time because a user is currently logged in. After the user exits, please restart dtlogin."); } } } } } if(doRestart) { LW_TRY(exc, DJStartStopDaemon("dtlogin", FALSE, &LW_EXC)); LW_TRY(exc, DJStartStopDaemon("dtlogin", TRUE, &LW_EXC)); } cleanup: LW_HANDLE(&inner); DJFreeDistroInfo(&distro); }