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

📄 net_rpc_service.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	if ( config.displayname ) {		rpcstr_pull( ascii_string, config.displayname->buffer, sizeof(ascii_string), -1, STR_TERMINATE );		d_printf("\tDisplay Name         = %s\n", ascii_string);	}done:		rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService  );	rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM  );	return werror_to_ntstatus(result);}	/****************************************************************************************************************************************/static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,					const char *domain_name, 					struct cli_state *cli,					struct rpc_pipe_client *pipe_hnd,					TALLOC_CTX *mem_ctx, 					int argc,					const char **argv ){	POLICY_HND hSCM;	WERROR result = WERR_GENERAL_FAILURE;	fstring servicename;		if (argc != 1 ) {		d_printf("Usage: net rpc service status <service>\n");		return NT_STATUS_OK;	}	fstrcpy( servicename, argv[0] );	/* Open the Service Control Manager */		result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE  );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Failed to open Service Control Manager.  [%s]\n", dos_errstr(result));		return werror_to_ntstatus(result);	}		result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, 		SVCCTL_CONTROL_STOP, SVCCTL_STOPPED );			rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM  );			return werror_to_ntstatus(result);}	/****************************************************************************************************************************************/static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,					const char *domain_name, 					struct cli_state *cli,					struct rpc_pipe_client *pipe_hnd,					TALLOC_CTX *mem_ctx, 					int argc,					const char **argv ){	POLICY_HND hSCM;	WERROR result = WERR_GENERAL_FAILURE;	fstring servicename;		if (argc != 1 ) {		d_printf("Usage: net rpc service status <service>\n");		return NT_STATUS_OK;	}	fstrcpy( servicename, argv[0] );	/* Open the Service Control Manager */		result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE  );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Failed to open Service Control Manager.  [%s]\n", dos_errstr(result));		return werror_to_ntstatus(result);	}		result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, 		SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED );			rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM  );			return werror_to_ntstatus(result);}	/****************************************************************************************************************************************/static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,					const char *domain_name, 					struct cli_state *cli,					struct rpc_pipe_client *pipe_hnd,					TALLOC_CTX *mem_ctx, 					int argc,					const char **argv ){	POLICY_HND hSCM;	WERROR result = WERR_GENERAL_FAILURE;	fstring servicename;		if (argc != 1 ) {		d_printf("Usage: net rpc service status <service>\n");		return NT_STATUS_OK;	}	fstrcpy( servicename, argv[0] );	/* Open the Service Control Manager */		result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE  );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Failed to open Service Control Manager.  [%s]\n", dos_errstr(result));		return werror_to_ntstatus(result);	}		result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, 		SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING );			rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM  );			return werror_to_ntstatus(result);}	/****************************************************************************************************************************************/static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,					const char *domain_name, 					struct cli_state *cli,					struct rpc_pipe_client *pipe_hnd,					TALLOC_CTX *mem_ctx, 					int argc,					const char **argv ){	POLICY_HND hSCM, hService;	WERROR result = WERR_GENERAL_FAILURE;	fstring servicename;	uint32 state = 0;		if (argc != 1 ) {		d_printf("Usage: net rpc service status <service>\n");		return NT_STATUS_OK;	}	fstrcpy( servicename, argv[0] );	/* Open the Service Control Manager */		result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE  );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Failed to open Service Control Manager.  [%s]\n", dos_errstr(result));		return werror_to_ntstatus(result);	}		/* Open the Service */		result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, 		servicename, SC_RIGHT_SVC_START );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Failed to open service.  [%s]\n", dos_errstr(result));		goto done;	}		/* get the status */	result = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, &hService, NULL, 0 );	if ( !W_ERROR_IS_OK(result) ) {		d_fprintf(stderr, "Query status request failed.  [%s]\n", dos_errstr(result));		goto done;	}		result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_RUNNING, &state  );		if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) )		d_printf("Successfully started service: %s\n", servicename );	else		d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) );	done:		rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService  );	rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM  );	return werror_to_ntstatus(result);}/****************************************************************************************************************************************/static int rpc_service_list( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_list_internal, argc, argv );}/****************************************************************************************************************************************/static int rpc_service_start( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_start_internal, argc, argv );}/****************************************************************************************************************************************/static int rpc_service_stop( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_stop_internal, argc, argv );}/****************************************************************************************************************************************/static int rpc_service_resume( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_resume_internal, argc, argv );}/****************************************************************************************************************************************/static int rpc_service_pause( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_pause_internal, argc, argv );}/****************************************************************************************************************************************/static int rpc_service_status( int argc, const char **argv ){	return run_rpc_command( NULL, PI_SVCCTL, 0, 		rpc_service_status_internal, argc, argv );}/****************************************************************************************************************************************/static int net_help_service( int argc, const char **argv ){	d_printf("net rpc service list               View configured Win32 services\n");	d_printf("net rpc service start <service>    Start a service\n");	d_printf("net rpc service stop <service>     Stop a service\n");	d_printf("net rpc service pause <service>    Pause a service\n");	d_printf("net rpc service resume <service>   Resume a paused service\n");	d_printf("net rpc service status <service>   View the current status of a service\n");		return -1;}/****************************************************************************************************************************************/int net_rpc_service(int argc, const char **argv) {	struct functable func[] = {		{"list", rpc_service_list},		{"start", rpc_service_start},		{"stop", rpc_service_stop},		{"pause", rpc_service_pause},		{"resume", rpc_service_resume},		{"status", rpc_service_status},		{NULL, NULL}	};		if ( argc )		return net_run_function( argc, argv, func, net_help_service );			return net_help_service( argc, argv );}

⌨️ 快捷键说明

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