⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smpd_cmd_args.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
	printf("Domain administrators can enable these options for hosts and users\nin Active Directory on the domain controller.\n");	ExitProcess(0);    }    if (smpd_get_opt(argcp, argvp, "-remove_spn"))    {	if (smpd_remove_scp())	{	    printf("Service Principal Name removed from the domain controller.\n");	}	else	{	    printf("Error: Failed to remove the Service Principal Name from the domain controller.\n");	}	ExitProcess(0);    }    if (smpd_get_opt(argcp, argvp, "-mgr"))    {	/* Set a ctrl-handler to kill child processes if this smpd is killed */	if (!SetConsoleCtrlHandler(smpd_ctrl_handler, TRUE))	{	    result = GetLastError();	    smpd_dbg_printf("unable to set the ctrl handler for the smpd manager, error %d.\n", result);	}	smpd_process.bService = SMPD_FALSE;	if (!smpd_get_opt_string(argcp, argvp, "-read", read_handle_str, 20))	{	    smpd_err_printf("manager started without a read pipe handle.\n");	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (!smpd_get_opt_string(argcp, argvp, "-write", write_handle_str, 20))	{	    smpd_err_printf("manager started without a write pipe handle.\n");	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	hRead = smpd_decode_handle(read_handle_str);	hWrite = smpd_decode_handle(write_handle_str);	smpd_dbg_printf("manager creating listener and session sets.\n");	result = MPIDU_Sock_create_set(&set);	if (result != MPI_SUCCESS)	{	    smpd_err_printf("MPIDU_Sock_create_set(listener) failed,\nsock error: %s\n", get_sock_error_string(result));	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	smpd_process.set = set;	smpd_dbg_printf("created set for manager listener, %d\n", MPIDU_Sock_get_sock_set_id(set));	port = 0;	result = MPIDU_Sock_listen(set, NULL, &port, &listener); 	if (result != MPI_SUCCESS)	{	    smpd_err_printf("MPIDU_Sock_listen failed,\nsock error: %s\n", get_sock_error_string(result));	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	smpd_dbg_printf("smpd manager listening on port %d\n", port);	result = smpd_create_context(SMPD_CONTEXT_LISTENER, set, listener, -1, &smpd_process.listener_context);	if (result != SMPD_SUCCESS)	{	    smpd_err_printf("unable to create a context for the smpd listener.\n");	    smpd_exit_fn(FCNAME);	    return result;	}	result = MPIDU_Sock_set_user_ptr(listener, smpd_process.listener_context);	if (result != MPI_SUCCESS)	{	    smpd_err_printf("MPIDU_Sock_set_user_ptr failed,\nsock error: %s\n", get_sock_error_string(result));	    smpd_exit_fn(FCNAME);	    return result;	}	smpd_process.listener_context->state = SMPD_MGR_LISTENING;	memset(str, 0, 20);	snprintf(str, 20, "%d", port);	smpd_dbg_printf("manager writing port back to smpd.\n");	if (!WriteFile(hWrite, str, 20, &num_written, NULL))	{	    smpd_err_printf("WriteFile failed, error %d\n", GetLastError());	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	CloseHandle(hWrite);	if (num_written != 20)	{	    smpd_err_printf("wrote only %d bytes of 20\n", num_written);	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	smpd_dbg_printf("manager reading account and password from smpd.\n");	if (!ReadFile(hRead, smpd_process.UserAccount, SMPD_MAX_ACCOUNT_LENGTH, &num_read, NULL))	{	    smpd_err_printf("ReadFile failed, error %d\n", GetLastError());	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (num_read != SMPD_MAX_ACCOUNT_LENGTH)	{	    smpd_err_printf("read only %d bytes of %d\n", num_read, SMPD_MAX_ACCOUNT_LENGTH);	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (!ReadFile(hRead, smpd_process.UserPassword, SMPD_MAX_PASSWORD_LENGTH, &num_read, NULL))	{	    smpd_err_printf("ReadFile failed, error %d\n", GetLastError());	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (num_read != SMPD_MAX_PASSWORD_LENGTH)	{	    smpd_err_printf("read only %d bytes of %d\n", num_read, SMPD_MAX_PASSWORD_LENGTH);	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (!ReadFile(hRead, smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH, &num_read, NULL))	{	    smpd_err_printf("ReadFile failed, error %d\n", GetLastError());	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	if (num_read != SMPD_PASSPHRASE_MAX_LENGTH)	{	    smpd_err_printf("read only %d bytes of %d\n", num_read, SMPD_PASSPHRASE_MAX_LENGTH);	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	smpd_process.credentials_prompt = SMPD_FALSE;	result = smpd_enter_at_state(set, SMPD_MGR_LISTENING);	if (result != SMPD_SUCCESS)	{	    smpd_err_printf("state machine failed.\n");	}	/*	result = MPIDU_Sock_finalize();	if (result != MPI_SUCCESS)	{	    smpd_err_printf("MPIDU_Sock_finalize failed,\nsock error: %s\n", get_sock_error_string(result));	}	*/	smpd_exit(0);	smpd_exit_fn(FCNAME);	ExitProcess(0);    }#endif    /* check for the status option */    if (smpd_get_opt_string(argcp, argvp, "-status", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))    {	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_DO_STATUS;    }    else if (smpd_get_opt(argcp, argvp, "-status"))    {	smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_DO_STATUS;    }    /* check for console options */    if (smpd_get_opt_string(argcp, argvp, "-console", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))    {	smpd_process.do_console = 1;    }    else if (smpd_get_opt(argcp, argvp, "-console"))    {	smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;    }    if (smpd_process.do_console)    {	/* This may need to be changed to avoid conflict */	if (smpd_get_opt(argcp, argvp, "-p"))	{	    smpd_process.use_process_session = 1;	}    }    if (smpd_get_opt_string(argcp, argvp, "-shutdown", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))    {	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_SHUTDOWN;    }    else if (smpd_get_opt(argcp, argvp, "-shutdown"))    {	smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_SHUTDOWN;    }    if (smpd_get_opt_string(argcp, argvp, "-restart", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))    {	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_RESTART;    }    else if (smpd_get_opt(argcp, argvp, "-restart"))    {#ifdef HAVE_WINDOWS_H	printf("restarting the smpd service...\n");	smpd_stop_service();	Sleep(1000);	smpd_start_service();	smpd_exit(0);#else	smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_RESTART;#endif    }    if (smpd_get_opt_string(argcp, argvp, "-version", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))    {	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_VERSION;    }    else if (smpd_get_opt(argcp, argvp, "-version"))    {	printf("%s\n", SMPD_VERSION);	fflush(stdout);	smpd_exit(0);    }    /* These commands are handled by mpiexec although doing them here is an alternate solution.    if (smpd_get_opt_two_strings(argcp, argvp, "-add_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH, smpd_process.job_key_account, SMPD_MAX_ACCOUNT_LENGTH))    {	if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))	    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	if (smpd_get_opt_string(argcp, argvp, "-password", smpd_process.job_key_password, SMPD_MAX_PASSWORD_LENGTH)	    smpd_process.builtin_cmd = SMPD_CMD_ADD_JOB_KEY_AND_PASSWORD;	else	    smpd_process.builtin_cmd = SMPD_CMD_ADD_JOB_KEY;	smpd_process.do_console = 1;    }    if (smpd_get_opt_string(argcp, argvp, "-remove_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH))    {	if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))	    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_REMOVE_JOB_KEY;    }    if (smpd_get_opt_string(argcp, argvp, "-associate_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH))    {	if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))	    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	smpd_process.do_console = 1;	smpd_process.builtin_cmd = SMPD_CMD_ASSOCIATE_JOB_KEY;    }    */    smpd_get_opt_string(argcp, argvp, "-phrase", smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH);    if (smpd_get_opt(argcp, argvp, "-getphrase"))    {	printf("passphrase for smpd: ");fflush(stdout);	smpd_get_password(smpd_process.passphrase);    }    if (smpd_get_opt_string(argcp, argvp, "-smpdfile", smpd_process.smpd_filename, SMPD_MAX_FILENAME))    {	struct stat s;	if (stat(smpd_process.smpd_filename, &s) == 0)	{	    if (s.st_mode & 00077)	    {		printf(".smpd file cannot be readable by anyone other than the current user.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }	}    }    if (smpd_get_opt_string(argcp, argvp, "-traceon", filename, SMPD_MAX_FILENAME))    {	smpd_process.do_console_returns = SMPD_TRUE;	if (*argcp > 1)	{	    for (i=1; i<*argcp; i++)	    {		strcpy(smpd_process.console_host, (*argvp)[i]);		smpd_process.do_console = 1;		smpd_process.builtin_cmd = SMPD_CMD_SET;		strcpy(smpd_process.key, "logfile");		strcpy(smpd_process.val, filename);		result = smpd_do_console();		if (result != SMPD_SUCCESS)		{		    smpd_err_printf("Unable to set the logfile name on host '%s'\n", smpd_process.console_host);		    smpd_exit_fn(FCNAME);		    return result;		}		smpd_process.do_console = 1;		smpd_process.builtin_cmd = SMPD_CMD_SET;		strcpy(smpd_process.key, "log");		strcpy(smpd_process.val, "yes");		result = smpd_do_console();		if (result != SMPD_SUCCESS)		{		    smpd_err_printf("Unable to set the log option on host '%s'\n", smpd_process.console_host);		    smpd_exit_fn(FCNAME);		    return result;		}		smpd_process.do_console = 1;		smpd_process.builtin_cmd = SMPD_CMD_RESTART;		result = smpd_do_console();		if (result != SMPD_SUCCESS)		{		    smpd_err_printf("Unable to restart the smpd on host '%s'\n", smpd_process.console_host);		    smpd_exit_fn(FCNAME);		    return result;		}	    }	}	else	{	    result = smpd_set_smpd_data("logfile", filename);	    result = smpd_set_smpd_data("log", "yes");#ifdef HAVE_WINDOWS_H	    printf("restarting the smpd service...\n");	    smpd_stop_service();	    Sleep(1000);	    smpd_start_service();#else	    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	    smpd_process.do_console = 1;	    smpd_process.builtin_cmd = SMPD_CMD_RESTART;	    result = smpd_do_console();	    if (result != SMPD_SUCCESS)	    {		smpd_err_printf("Unable to restart the smpd on host '%s'\n", smpd_process.console_host);		smpd_exit_fn(FCNAME);		return result;	    }#endif	}	smpd_exit_fn(FCNAME);	smpd_exit(result);    }    if (smpd_get_opt(argcp, argvp, "-traceoff"))    {	smpd_process.do_console_returns = SMPD_TRUE;	if (*argcp > 1)	{	    for (i=1; i<*argcp; i++)	    {		strcpy(smpd_process.console_host, (*argvp)[i]);		smpd_process.do_console = 1;		smpd_process.builtin_cmd = SMPD_CMD_SET;		strcpy(smpd_process.key, "log");		strcpy(smpd_process.val, "no");		result = smpd_do_console();		if (result != SMPD_SUCCESS)		{		    smpd_err_printf("Unable to set the log option on host '%s'\n", smpd_process.console_host);		    smpd_exit_fn(FCNAME);		    return result;		}		smpd_process.do_console = 1;		smpd_process.builtin_cmd = SMPD_CMD_RESTART;		result = smpd_do_console();		if (result != SMPD_SUCCESS)		{		    smpd_err_printf("Unable to restart the smpd on host '%s'\n", smpd_process.console_host);		    smpd_exit_fn(FCNAME);		    return result;		}	    }	}	else	{	    result = smpd_set_smpd_data("log", "no");#ifdef HAVE_WINDOWS_H	    printf("restarting the smpd service...\n");	    smpd_stop_service();	    Sleep(1000);	    smpd_start_service();#else	    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);	    smpd_process.do_console = 1;	    smpd_process.builtin_cmd = SMPD_CMD_RESTART;	    result = smpd_do_console();	    if (result != SMPD_SUCCESS)	    {		smpd_err_printf("Unable to restart the smpd on host '%s'\n", smpd_process.console_host);		smpd_exit_fn(FCNAME);		return result;	    }#endif	}	smpd_exit_fn(FCNAME);	smpd_exit(result);    }    if (smpd_process.do_console)    {	result = smpd_do_console();	smpd_exit_fn(FCNAME);	return result;    }    smpd_exit_fn(FCNAME);    return SMPD_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -