コード例 #1
0
bool
init_monitoring( void ) {
  set_service_name();
  add_message_received_callback( get_service_name(), handle_notification );
  add_message_replied_callback( get_service_name(), handle_reply );
  return true;
}
コード例 #2
0
bool send_monitoring_subscribe_request() {
  buffer *request = create_monitoring_subscribe_request( get_service_name() );

  bool ret = send_request_message( MONITORING_SERVICE, // To
                                   get_service_name(), // From
                                   MONITORING_SUBSCRIBE_REQUEST, // Tag
                                   request->data, request->length, NULL );
  info( "[send_monitoring_subscribe_request] ( tag = %#x, data = %p, length = %u ).", 
          MONITORING_SUBSCRIBE_REQUEST, request->data, request->length );
  free_buffer( request );
  return ret;
}
コード例 #3
0
ファイル: pam_auth.c プロジェクト: bmiklautz/FreeRDS
long freerds_authenticate_pam(char* username, char* password, int* errorcode)
{
	int error;
	char service_name[256];
	struct t_auth_info* auth_info;

	get_service_name(service_name);
	auth_info = malloc(sizeof(struct t_auth_info));
	ZeroMemory(auth_info, sizeof(struct t_auth_info));
	strcpy(auth_info->user_pass.user, username);
	if (password) {
		strcpy(auth_info->user_pass.pass, password);
	}
	auth_info->pamc.conv = &verify_pam_conv;
	auth_info->pamc.appdata_ptr = &(auth_info->user_pass);
	error = pam_start(service_name, 0, &(auth_info->pamc), &(auth_info->ph));

	if (error != PAM_SUCCESS)
	{
		if (errorcode != NULL)
			*errorcode = error;

		printf("pam_start failed: %s\n", pam_strerror(auth_info->ph, error));
		free(auth_info);
		return 0;
	}

	error = pam_authenticate(auth_info->ph, 0);

	if (error != PAM_SUCCESS)
	{
		if (errorcode != NULL)
			*errorcode = error;

		printf("pam_authenticate failed: %s\n", pam_strerror(auth_info->ph, error));
		free(auth_info);
		return 0;
	}

	error = pam_acct_mgmt(auth_info->ph, 0);

	if (error != PAM_SUCCESS)
	{
		if (errorcode != NULL)
			*errorcode = error;

		printf("pam_acct_mgmt failed: %s\n", pam_strerror(auth_info->ph, error));
		free(auth_info);
		return 0;
	}

	return (long) auth_info;
}
コード例 #4
0
ファイル: ConnmanManager.cpp プロジェクト: roland-wilhelm/vhd
ConnmanService* ConnmanManager::create_service(const gchar *a_object_path) {

	ConnmanService *service = NULL;
	gint ret = 0;

	DBG3();

	if(a_object_path == NULL) {

		ERR("no object path.");
		return NULL;
	}

	DBG("object path '%s'.", a_object_path);

	if(m_services == NULL) {

		m_services = g_hash_table_new(g_str_hash, g_str_equal);
		if(m_services == NULL) {

			ERR("cannot create hash table for services.");
			return NULL;
		}
	}

	service = lookup_service(a_object_path);
	if(service != NULL) {

		DBG("service '%s' already exists.", a_object_path);
		return service;
	}

	DBG("create new service '%s'.", a_object_path);
	service = new ConnmanService(get_service_name(), a_object_path, CONNMAN_SERVICE_INTERFACE);
	if(service == NULL) {

		ERR("cannot allocate new connman service.");
		return NULL;
	}

	ret = service->create_service_sync();
	if(ret < 0) {

		ERR("cannot create new connman service.");
		delete service;
		return NULL;
	}

	return service;
}
コード例 #5
0
ファイル: svccntrl.c プロジェクト: AVGirl/dynamorio
BOOL show_svcs_cb(ServiceHandle service, void **param)
{
    static const char *automatic="auto";
    static const char *manual="manual";
    static const char *disabled="disabled";
    static const char *unknown="<unknown>";
    const char *typename;
    DWORD type = get_service_start_type(service);
    typename = (type == SERVICE_AUTO_START ? automatic :
                            (type == SERVICE_DEMAND_START ? manual :
                             (type == SERVICE_DISABLED ? disabled :
                              unknown)));
    printf("%S %s\n", get_service_name(service), typename);
    return TRUE;
}
コード例 #6
0
ファイル: service.c プロジェクト: AzerTyQsdF/osx
BOOL isValidService(char *display_name) {
    char service_key[MAX_PATH];
    char *service_name;
    HKEY hkey;
    
    /* Remove spaces from display name to create service name */
    strcpy(service_key, "System\\CurrentControlSet\\Services\\");
    service_name = get_service_name(display_name);
    strcat(service_key, service_name);

    if (RegOpenKey(HKEY_LOCAL_MACHINE, service_key, &hkey) != ERROR_SUCCESS) {
        return FALSE;
    }
    RegCloseKey(hkey);
    return TRUE;
}
コード例 #7
0
bool
send_port_loading_request( uint64_t datapathid, uint16_t port_no, void *user_data ) {
  /* user_data is port_info */
  
  buffer *request = create_monitoring_port_loading_request( datapathid, port_no );

  bool ret = send_request_message( MONITORING_SERVICE, // To
                                   get_service_name(), // From
                                   MONITORING_PORT_LOADING_REQUEST, // Tag
                                   request->data, request->length, user_data );
  
  debug( "[send_port_loading_request] ( tag = %#x, data = %p, length = %u ).", 
          MONITORING_PORT_LOADING_REQUEST, request->data, request->length );
  free_buffer( request );
  return ret;
}
コード例 #8
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "export failed");
        abort();
    }

    // register this iref with the name service
    char my_service_name[128];
    get_service_name(my_service_name, 128, disp_get_core_id());
    err = nameservice_register(my_service_name, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        abort();
    }
    exported = true;
}
コード例 #9
0
static void bind_core(coreid_t core) {
    errval_t err;
    iref_t iref;
    char core_service_name[128];
    get_service_name(core_service_name, 128, core);
    err = nameservice_blocking_lookup(core_service_name, &iref);
    if (err_is_fail(err)) {
        fprintf(stderr, "could not connect to the xcorecapbench.\n"
                "Terminating.\n");
        abort();
    }
    err = xcorecapbench_bind(iref, bind_cb, (void*)(uintptr_t)core, 
                             get_default_waitset(), IDC_BIND_FLAGS_DEFAULT);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "bind failed");
        abort();
    }
}
コード例 #10
0
ファイル: VideoPlayDlg.cpp プロジェクト: piaoxue85/tsfriend
void CVideoPlayDlg::UpdateProgramList()
{
	POSITION  pos = pTblList->GetHeadPosition();
	CTable  * pT , * pSdt = NULL;
	PMTSection * pPmtS;
	u16 ProgramNumber, VideoPid;
	CString ServiceName;
	CListCtrl * pListCtrl ;
	u8 ProgramIndex = 0;
	while(pos)
	{
		pT = (CTable *)(pTblList->GetNext(pos));
		
		if(pT->GetTableID()== ACTUAL_TRANSPORT_SERVICE_DESCRIPTION)
		{
			pSdt = pT;
		}
	}
	 pos = pTblList->GetHeadPosition();
	ProgramListCtrl.DeleteAllItems();
	while(pos)
	{
		pT = (CTable *)(pTblList->GetNext(pos));
		if(pT->GetTableID()== PROGRAM_MAP_INFORMATION)
		{
			pPmtS = (PMTSection * )(pT->GetSection()->GetSectionData());
			ProgramNumber = pPmtS->program_number_hi*256 + pPmtS->program_number_low;
			if((NULL == pSdt)||(0 == get_service_name(pSdt, ProgramNumber, ServiceName)))
			{
				ServiceName.Format("Program %d", ProgramNumber);;
			}
			VideoPid = get_video_pid(pT);
			ServiceName.AppendFormat(" vid : %d ",VideoPid);
			if(VideoPid  !=  INVALID_PID )
			{
				//GetDlgItem(IDC_LIST_OF_PROGRAMS);
				ProgramListCtrl.InsertItem(ProgramIndex,(LPCTSTR) ServiceName);
				ProgramListCtrl.SetItemData(ProgramIndex,(DWORD_PTR)VideoPid);
				
				ProgramIndex++;
			}
		}
	}
}
コード例 #11
0
ファイル: service.c プロジェクト: AzerTyQsdF/osx
void InstallService(pool *p, char *display_name, int argc, char **argv, int reconfig)
{
    TCHAR szPath[MAX_PATH];
    TCHAR szQuotedPath[512];
    char *service_name;
    int regargc = 0;
    char default_depends[] = "Tcpip\0Afd\0";
    char *depends = default_depends;
    size_t depends_len = sizeof(default_depends);
    char **regargv = malloc((argc + 4) * sizeof(char*));
    char **newelem = regargv;

    regargc += 4;
    *(newelem++) = "-d";
    *(newelem++) = ap_server_root;
    *(newelem++) = "-f";
    *(newelem++) = ap_server_confname;

    while (++argv, --argc) {
        if ((**argv == '-') && strchr("kndf", argv[0][1]))
            --argc, ++argv; /* Skip already handled -k -n -d -f options */
        else if ((**argv == '-') && (argv[0][1] == 'W')) 
        {
            /* Catch this service -W dependency 
             * the depends list is null seperated, double-null terminated
             */
            char *service = get_service_name(*(argv + 1));
            size_t add_len = strlen(service) + 1;
            char *more_depends = malloc(depends_len + add_len);
            memcpy (more_depends, depends, depends_len - 1);
            memcpy (more_depends + depends_len - 1, service, add_len);
            depends_len += add_len;
            depends = more_depends;
            depends[depends_len - 1] = '\0';
            ++argv, --argc;
        }
        else if ((**argv != '-') || !strchr("iuw", argv[0][1]))
            *(newelem++) = *argv, ++regargc;  /* Ignoring -i -u -w options */
    }

    /* Remove spaces from display name to create service name */
    service_name = get_service_name(display_name);
    
    printf(reconfig ? "Reconfiguring the %s service\n"
                    : "Installing the %s service\n", 
           display_name);

    if (GetModuleFileName( NULL, szPath, 512 ) == 0)
    {
        ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
        "GetModuleFileName failed");
        return;
    }

    if (isWindowsNT())
    {
        SC_HANDLE schService;
        SC_HANDLE schSCManager;

        ap_snprintf(szQuotedPath, sizeof(szQuotedPath), "\"%s\" --ntservice", szPath);

        schSCManager = OpenSCManager(
                            NULL,                 // machine (local)
                            NULL,                 // database (default)
                            SC_MANAGER_ALL_ACCESS // access required
                            );
        if (!schSCManager) {
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "OpenSCManager failed");
            return;
        }
        
        /* Added dependencies for the following: TCPIP, AFD
         * AFD is the winsock handler, TCPIP is self evident
         *
         * RPCSS is the Remote Procedure Call (RPC) Locator
         * required for DCOM communication.  I am far from
         * convinced we should toggle this, but be warned that
         * future apache modules or ISAPI dll's may depend on it.
         * Also UNC share users may need the networking service 
         * started (usually "LanmanWorkstation").  "ProtectedStorage" 
         * may be needed depending on how files and registry keys are 
         * stored.  And W3SVC may be needed to wait until IIS has
         * glommed and released 0.0.0.0:80 if the admin allocates 
         * two different IP's to Apache and IIS on the same port.
         */
        if (reconfig) 
        {
            schService = OpenService(schSCManager, service_name, 
                                     SERVICE_ALL_ACCESS);
            if (!schService)
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
                             "OpenService failed");
            else if (!ChangeServiceConfig(
                        schService,                 // Service handle
                        SERVICE_WIN32_OWN_PROCESS,  // service type
                        SERVICE_AUTO_START,         // start type
                        SERVICE_ERROR_NORMAL,       // error control type
                        szQuotedPath,               // service's binary
                        NULL,                       // no load ordering group
                        NULL,                       // no tag identifier
                        depends,                    // dependencies
                        NULL,                       // user account
                        NULL,                       // account password
                        display_name)) {            // service display name
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
		             "ChangeServiceConfig failed");
                /* !schService aborts configuration below */
                CloseServiceHandle(schService);
                schService = NULL;
            }
        }
        else /* !reconfig */
        {
            schService = CreateService(
                        schSCManager,               // SCManager database
                        service_name,               // name of service
                        display_name,               // name to display
                        SERVICE_ALL_ACCESS,         // desired access
                        SERVICE_WIN32_OWN_PROCESS,  // service type
                        SERVICE_AUTO_START,         // start type
                        SERVICE_ERROR_NORMAL,       // error control type
                        szQuotedPath,               // service's binary
                        NULL,                       // no load ordering group
                        NULL,                       // no tag identifier
                        depends,                    // dependencies
                        NULL,                       // user account
                        NULL);                      // account password
            if (!schService)
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
                             "CreateService failed");
        }
        if (schService)
            CloseServiceHandle(schService);
        
        CloseServiceHandle(schSCManager);
        
        if (!schService)
            return;
    }
    else /* !isWindowsNT() */
    {
        HKEY hkey;
        DWORD rv;

        ap_snprintf(szQuotedPath, sizeof(szQuotedPath),
                    "\"%s\" -k start -n %s", 
                    szPath, service_name);
        /* Create/Find the RunServices key */
        rv = RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows"
                          "\\CurrentVersion\\RunServices", &hkey);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Could not create/open the RunServices registry key");
            return;
        }

        /* Attempt to add the value for our service */
        rv = RegSetValueEx(hkey, service_name, 0, REG_SZ, 
                           (unsigned char *)szQuotedPath, 
                           strlen(szQuotedPath) + 1);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Unable to install service: "
                         "Could not add to RunServices Registry Key");
            RegCloseKey(hkey);
            return;
        }

        RegCloseKey(hkey);

        /* Create/Find the Service key for Monitor Applications to iterate */
        ap_snprintf(szPath, sizeof(szPath), 
                    "SYSTEM\\CurrentControlSet\\Services\\%s", service_name);
        rv = RegCreateKey(HKEY_LOCAL_MACHINE, szPath, &hkey);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Could not create/open the %s registry key", szPath);
            return;
        }

        /* Attempt to add the ImagePath value to identify it as Apache */
        rv = RegSetValueEx(hkey, "ImagePath", 0, REG_SZ, 
                           (unsigned char *)szQuotedPath, 
                           strlen(szQuotedPath) + 1);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Unable to install service: "
                         "Could not add ImagePath to %s Registry Key", 
                         service_name);
            RegCloseKey(hkey);
            return;
        }

        /* Attempt to add the DisplayName value for our service */
        rv = RegSetValueEx(hkey, "DisplayName", 0, REG_SZ, 
                           (unsigned char *)display_name, 
                           strlen(display_name) + 1);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Unable to install service: "
                         "Could not add DisplayName to %s Registry Key", 
                         service_name);
            RegCloseKey(hkey);
            return;
        }

        RegCloseKey(hkey);
    }

    /* Both Platforms: Now store the args in the registry */
    if (ap_registry_set_service_args(p, regargc, regargv, service_name)) {
        return;
    }

    printf("The %s service has been %s successfully.\n", 
           display_name, reconfig ? "reconfigured" : "installed");
}
コード例 #12
0
ファイル: service.c プロジェクト: AzerTyQsdF/osx
int send_signal_to_service(char *display_name, char *sig, 
                           int argc, char **argv)
{
    DWORD       service_pid;
    HANDLE      hwnd;
    SC_HANDLE   schService;
    SC_HANDLE   schSCManager;
    char       *service_name;
    int success = FALSE;

    enum                        { start,      restart,      stop, unknown } action;
    static char *param[] =      { "start",    "restart",    "shutdown" };
    static char *participle[] = { "starting", "restarting", "stopping" };
    static char *past[]       = { "started",  "restarted",  "stopped"  };

    for (action = start; action < unknown; action++)
        if (!strcasecmp(sig, param[action]))
            break;

    if (action == unknown) {
        printf("signal must be start, restart, or shutdown\n");
        return FALSE;
    }

    service_name = get_service_name(display_name);

    if (isWindowsNT()) 
    {
        schSCManager = OpenSCManager(
                            NULL,                   // machine (NULL == local)
                            NULL,                   // database (NULL == default)
                            SC_MANAGER_ALL_ACCESS   // access required
                            );
        if (!schSCManager) {
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "OpenSCManager failed");
            return FALSE;
        }
        
        schService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);

        if (schService == NULL) {
            /* Could not open the service */
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "OpenService failed");
            CloseServiceHandle(schSCManager);
            return FALSE;
        }
        
        if (!QueryServiceStatus(schService, &globdat.ssStatus)) {
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "QueryService failed");
            CloseServiceHandle(schService);
            CloseServiceHandle(schSCManager);
        }
    }
    else /* !isWindowsNT() */
    {
        /* Locate the window named service_name of class ApacheWin95ServiceMonitor
         * from the active top level windows
         */
        hwnd = FindWindow("ApacheWin95ServiceMonitor", service_name);
        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid))
            globdat.ssStatus.dwCurrentState = SERVICE_RUNNING;
        else
            globdat.ssStatus.dwCurrentState = SERVICE_STOPPED;
    }

    if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED 
            && action == stop) {
        printf("The %s service is not started.\n", display_name);
        return FALSE;
    }
    else if (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING 
                 && action == start) {
        printf("The %s service has already been started.\n", display_name);
        strcpy(sig, "");
        return FALSE;
    }
    else
    {
        printf("The %s service is %s.\n", display_name, participle[action]);

        if (isWindowsNT()) 
        {
            if (action == stop)
                success = ap_stop_service(schService);
            else if ((action == start) 
                     || ((action == restart) 
                            && (globdat.ssStatus.dwCurrentState 
                                    == SERVICE_STOPPED)))
            {
                /* start NT service needs service args */
                char **args = malloc(argc * sizeof(char*));
                int i, j;
                for (i = 1, j = 0; i < argc; i++) {
                    if ((argv[i][0] == '-') && ((argv[i][1] == 'k') 
                                             || (argv[i][1] == 'n')))
                        ++i;
                    else
                        args[j++] = argv[i];
                }
                success = ap_start_service(schService, j, args);
            }
            else if (action == restart)
                success = ap_restart_service(schService);
        }
        else /* !isWindowsNT()) */
        {
            char prefix[20];
            ap_snprintf(prefix, sizeof(prefix), "ap%ld", (long)service_pid);
            setup_signal_names(prefix);

            if (action == stop) {
                int ticks = 60;
                ap_start_shutdown();
                while (--ticks)
                {
                    if (!IsWindow(hwnd)) {
                        success = TRUE;
                        break;
                    }
                    Sleep(1000);
                }
            }
            else if (action == restart) 
            {   
                /* This gets a bit tricky... start and restart (of stopped service)
                 * will simply fall through and *THIS* process will fade into an
                 * invisible 'service' process, detaching from the user's console.
                 * We need to change the restart signal to "start", however,
                 * if the service was not -yet- running, and we do return FALSE
                 * to assure main() that we haven't done anything yet.
                 */
                if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED) 
                {
                    printf("The %s service has %s.\n", display_name, 
                           past[action]);
                    strcpy(sig, "start");
                    return FALSE;
                }
                
                ap_start_restart(1);
                success = TRUE;
            }
            else /* action == start */
            {
                printf("The %s service is %s.\n", display_name, 
                       past[action]);
                return FALSE;
            }
        }

        if( success )
            printf("The %s service has %s.\n", display_name, past[action]);
        else
            printf("Failed to %s the %s service.\n", sig, display_name);
    }

    if (isWindowsNT()) {
        CloseServiceHandle(schService);
        CloseServiceHandle(schSCManager);
    }
    return success;
}
コード例 #13
0
ファイル: service.c プロジェクト: AzerTyQsdF/osx
void RemoveService(char *display_name)
{
    char *service_name;
    BOOL success = FALSE;

    printf("Removing the %s service\n", display_name);

    /* Remove spaces from display name to create service name */
    service_name = get_service_name(display_name);
    
    if (isWindowsNT())
    {
        SC_HANDLE   schService;
        SC_HANDLE   schSCManager;
    
        schSCManager = OpenSCManager(
                            NULL,                   // machine (NULL == local)
                            NULL,                   // database (NULL == default)
                            SC_MANAGER_ALL_ACCESS   // access required
                            );
        if (!schSCManager) {
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "OpenSCManager failed");
            return;
        }

        schService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);

        if (schService == NULL) {
            /* Could not open the service */
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "OpenService failed");
        }
        else {
            /* try to stop the service */
            ap_stop_service(schService);

            // now remove the service
            if (DeleteService(schService) == 0)
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                             "DeleteService failed");
            else
                success = TRUE;
            CloseServiceHandle(schService);
        }
        /* SCM removes registry parameters  */
        CloseServiceHandle(schSCManager);
    }
    else /* !isWindowsNT() */
    {
        HKEY hkey;
        DWORD service_pid;
        DWORD rv;
        HWND hwnd;

        /* Locate the named window of class ApacheWin95ServiceMonitor
         * from the active top level windows
         */
        hwnd = FindWindow("ApacheWin95ServiceMonitor", service_name);
        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid))
        {
            int ticks = 120;
            char prefix[20];
            ap_snprintf(prefix, sizeof(prefix), "ap%ld", (long)service_pid);
            setup_signal_names(prefix);
            ap_start_shutdown();
            while (--ticks) {
                if (!IsWindow(hwnd))
                    break;
                Sleep(1000);
            }
        }

        /* Open the RunServices key */
        rv = RegOpenKey(HKEY_LOCAL_MACHINE, 
                "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices",
                    &hkey);
        if (rv != ERROR_SUCCESS) {
            SetLastError(rv);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Could not open the RunServices registry key.");
        } 
        else {
            /* Delete the registry value for this service */
            rv = RegDeleteValue(hkey, service_name);
            if (rv != ERROR_SUCCESS) {
                SetLastError(rv);
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                             "Unable to remove service: "
                             "Could not delete the RunServices entry.");
            }
            else
                success = TRUE;
        }
        RegCloseKey(hkey);

        /* Open the Services key */
        rv = RegOpenKey(HKEY_LOCAL_MACHINE, 
                        "SYSTEM\\CurrentControlSet\\Services", &hkey);
        if (rv != ERROR_SUCCESS) {
            rv = RegDeleteValue(hkey, service_name);
            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                         "Could not open the Services registry key.");
            success = FALSE;
        } 
        else {
            /* Delete the registry key for this service */
            rv = RegDeleteKey(hkey, service_name);
            if (rv != ERROR_SUCCESS) {
                SetLastError(rv);
                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
                             "Unable to remove service: "
                             "Could not delete the Services registry key.");
                success = FALSE;
            }
        }
        RegCloseKey(hkey);
    }
    if (success)
        printf("The %s service has been removed successfully.\n", 
               display_name);
}
コード例 #14
0
void monkey::service::system_service::on_registered()
{
	std::cout << get_service_name() << " is registered" <<std::endl;
}
コード例 #15
0
ファイル: prefs.c プロジェクト: ayttm/ayttm
void ayttm_prefs_read_file(char *file)
{
	const int buffer_size = 1024;
	char buff[buffer_size];
	char *const param = buff;	/* just another name for buff... */
	FILE *fp = NULL;

	snprintf(buff, buffer_size, "%s", file);

	fp = fopen(buff, "r");

	if (fp == NULL) {
		char tmp[1024];
		snprintf(tmp, 1024, "%sprefs", config_dir);
		if (!strcmp(file, tmp)) {
			printf("Creating prefs file [%s]\n", buff);
			ayttm_prefs_write();
		}
		return;
	}

	fgets(param, buffer_size, fp);

	while (!feof(fp)) {
		int pref_type = CORE_PREF;
		char *val = buff;

		s_strip_whitespace(param);

		if (!strcasecmp(param, "plugins"))
			pref_type = PLUGIN_PREF;
		else if (!strcasecmp(param, "connections"))
			pref_type = SERVICE_PREF;

		if (pref_type != CORE_PREF) {
			for (;;) {
				int id = -1;
				char *plugin_name = NULL;
				LList *session_prefs = NULL;

				fgets(param, buffer_size, fp);

				s_strip_whitespace(param);

				if (!strcasecmp(param, "end"))
					break;

				switch (pref_type) {
				case PLUGIN_PREF:
					plugin_name = strdup(param);
					break;

				case SERVICE_PREF:
					id = get_service_id(param);
					break;

				default:
					assert(FALSE);
					break;
				}

				for (;;) {
					LList *old_session_prefs = NULL;

					fgets(param, buffer_size, fp);

					s_strip_whitespace(param);

					if (!strcasecmp(param, "end")) {
						switch (pref_type) {
						case PLUGIN_PREF:
							old_session_prefs =
								SetPref
								(plugin_name,
								session_prefs);

							free(plugin_name);
							break;

						case SERVICE_PREF:
							old_session_prefs =
								SetPref
								(get_service_name
								(id),
								session_prefs);
							break;

						default:
							assert(FALSE);
							break;
						}

						if (old_session_prefs != NULL) {
							eb_debug(DBG_CORE,
								"Freeing old_session_prefs\n");
							value_pair_free
								(old_session_prefs);
						}
						break;
					} else {
						val = param;

						while (*val != 0 && *val != '=')
							val++;

						if (*val == '=') {
							*val = '\0';
							val++;
						}

						/* strip off quotes */
						if (*val == '"') {
							val++;
							val[strlen(val) - 1] =
								'\0';
						}

						eb_debug(DBG_CORE,
							"Adding %s:%s to session_prefs\n",
							param, val);
						session_prefs =
							value_pair_add
							(session_prefs, param,
							val);
					}
				}
			}
			continue;
		}
		/* if(pref_type != CORE_PREF) */
		val = param;

		while (*val != 0 && *val != '=')
			val++;

		if (*val == '=') {
			*val = '\0';
			val++;
		}

		cSetLocalPref(param, val);

		fgets(param, buffer_size, fp);
	}

	fclose(fp);

	if (iGetLocalPref("do_proxy_auth") != 0)
		ay_proxy_set_default(iGetLocalPref("proxy_type"),
			cGetLocalPref("proxy_host"),
			iGetLocalPref("proxy_port"),
			cGetLocalPref("proxy_user"),
			cGetLocalPref("proxy_password"));
	else
		ay_proxy_set_default(iGetLocalPref("proxy_type"),
			cGetLocalPref("proxy_host"),
			iGetLocalPref("proxy_port"), NULL, NULL);
}
コード例 #16
0
bool
finalize_monitoring( void ) {
  delete_message_received_callback( get_service_name(), handle_notification );
  delete_message_replied_callback( get_service_name(), handle_reply );
  return true;
}