예제 #1
0
static
struct Action* _get_action(GKeyFile* file, const char* group_name)
{
    GError* error = NULL;
    gchar* name = g_key_file_get_locale_string(file,
                                               group_name,
                                               G_KEY_FILE_DESKTOP_KEY_NAME,
                                               NULL,
                                               &error);
    if (error != NULL) {
        g_warning("[%s] %s", __func__, error->message);
        g_error_free(error);
        return NULL;
    }

    gchar* exec = g_key_file_get_string(file,
                                        group_name,
                                        G_KEY_FILE_DESKTOP_KEY_EXEC,
                                        &error);
    if (error != NULL) {
        g_warning("[%s] %s", __func__, error->message);
        g_error_free(error);
        g_free(name);
        return NULL;
    }
    /* g_debug("[%s] name: %s, exec: %s", __func__, name, exec); */
    struct Action* action = action_new(name, exec);

    g_free(name);
    g_free(exec);

    return action;
}
예제 #2
0
파일: vlst.c 프로젝트: rvba/minuit
void vlst_update_data( t_vlst *vlst,t_vlst *caller)
{
	t_action *action = action_new("action");
	t_dict *dict = dict_make( "args");

	action->act = exe_vlst;
	action->args = dict;

	dict_symbol_add(action->args,"vlst",dt_null,vlst);
	dict_symbol_add(action->args,"caller",dt_null,caller);

	exe_add_action(action);
}
예제 #3
0
void add_exe_remove_brick(t_brick *brick)
{
	t_scene *sc = scene_get();
	scene_store( sc, 1);
	t_action *action = action_new("action");

	action->act = exe_remove_brick;

	t_dict *dict = dict_make("args");
	action->args = dict;
	action->brick = brick;

	dict_symbol_add(action->args,"brick",dt_null,brick);

	exe_add_action(action);

	scene_store( sc, 0);
}
예제 #4
0
void add_exe_add_brick(t_brick *brick,t_brick *brick_target,void (* f)(t_action *))
{
	t_scene *sc = scene_get();
	scene_store( sc, 1);
	t_action *action = action_new("action");

	action->act = f;

	t_dict *dict = dict_make("args");
	action->args = dict;
	action->brick = brick;

	dict_symbol_add(action->args,"brick",dt_null,brick);
	dict_symbol_add(action->args,"target",dt_null,brick_target);

	exe_add_action(action);

	scene_store( sc, 0);
}
예제 #5
0
OPENVPN_EXPORT void
openvpn_plugin_close_v1 (openvpn_plugin_handle_t handle)
{
  ldap_context_t *context = (ldap_context_t *) handle;
  action_t *action = action_new( );

  if (DOINFO (context->verb))
    LOGINFO( "%s() called", __FUNCTION__ );
  if( action){
    action->type = LDAP_AUTH_ACTION_QUIT;
    action_push( context->action_list, action );
    if( DODEBUG( context->verb ) )
      LOGDEBUG ("Waiting for thread to return");
    pthread_join( action_thread, NULL );
    if( DODEBUG( context->verb ) )
      LOGDEBUG ("Thread returned queries left in queue: %d", list_length( context->action_list ));
    pthread_attr_destroy( &action_thread_attr );
    pthread_mutex_destroy( &action_mutex );
    pthread_cond_destroy( &action_cond );
  }
  ldap_context_free( context );
  //pthread_exit(NULL);
}
예제 #6
0
OPENVPN_EXPORT int
openvpn_plugin_func_v2 (openvpn_plugin_handle_t handle,
                        const int type,
                        const char *argv[],
                        const char *envp[],
                        void *per_client_context,
                        struct openvpn_plugin_string_list **return_list)
{
  ldap_context_t *context = (ldap_context_t *) handle;
  auth_context_t *auth_context = NULL;
  action_t *action = NULL;


  int res = OPENVPN_PLUGIN_FUNC_ERROR;

  if (type == OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY){
    /* get username/password/auth_control_file from envp string array */
    const char *username = get_env ("username", envp);
    const char *password = get_env ("password", envp);
    const char *auth_control_file = get_env ( "auth_control_file", envp );
    const char *pf_file = get_env ("pf_file", envp);



    /* required parameters check */
    if (!username){
      LOGERROR("No username supplied to OpenVPN plugin");
      return OPENVPN_PLUGIN_FUNC_ERROR;
    }

    auth_context = auth_context_new( );
    if( !auth_context ){
      LOGERROR( "Could not allocate auth_context before calling thread" );
      return res;
    }
    if( username ) auth_context->username = strdup( username );
    if( password ) auth_context->password = strdup( password );
    if( pf_file ) auth_context->pf_file = strdup( pf_file );
    if( auth_control_file ) auth_context->auth_control_file = strdup( auth_control_file );
    /* If some argument were missing or could not be duplicate */
    if( !(auth_context->username && auth_context->password && auth_context->auth_control_file ) ){
      auth_context_free( auth_context );
      return res;
    }
    action = action_new( );
    action->type = LDAP_AUTH_ACTION_AUTH;
    action->context = auth_context;
    action->client_context = per_client_context;
    action->context_free_func = (void *)auth_context_free;
    action_push( context->action_list, action );
    return OPENVPN_PLUGIN_FUNC_DEFERRED;
  }
  else if (type == OPENVPN_PLUGIN_ENABLE_PF){
    /* unfortunately, at this stage we dont know anything about the client
     * yet. Let assume it is enabled, we will define default somewhere
     */
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
  }else if( type == OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ){
    /* on client connect, we return conf options through return list
     */
    const char *username = get_env ("username", envp);
    client_context_t *cc = per_client_context;
    char *ccd_options = NULL;
    /* sanity check */
    if (!username){
      LOGERROR("No username supplied to OpenVPN plugin");
      return OPENVPN_PLUGIN_FUNC_ERROR;
    }
    if (!cc || !cc->profile){
      LOGERROR("No profile found for user");
      return OPENVPN_PLUGIN_FUNC_ERROR;
    }
#ifdef ENABLE_LDAPUSERCONF
    ccd_options = ldap_account_get_options_to_string( cc->ldap_account );
#endif
    if( cc->profile->redirect_gateway_prefix && strlen( cc->profile->redirect_gateway_prefix ) > 0 ){
      /* do the username start with prefix? */
      if( strncmp( cc->profile->redirect_gateway_prefix, username, strlen( cc->profile->redirect_gateway_prefix ) ) == 0 ){
        char *tmp_ccd = ccd_options;
        ccd_options = strdupf("push \"redirect-gateway %s\"\n%s",
                            cc->profile->redirect_gateway_flags ? cc->profile->redirect_gateway_flags : DFT_REDIRECT_GATEWAY_FLAGS,
                            tmp_ccd ? tmp_ccd : "");
        if( tmp_ccd ) la_free( tmp_ccd );
      }
    }
    if( ccd_options ){
      *return_list = la_malloc( sizeof( struct openvpn_plugin_string_list ) );
      if( *return_list != NULL){
        (*return_list)->next = NULL;
        (*return_list)->name = strdup( "config" );
        (*return_list)->value = ccd_options;
      }
    }
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
  }
#ifdef ENABLE_LDAPUSERCONF
  else if( type == OPENVPN_PLUGIN_CLIENT_DISCONNECT ){
    /* nothing done for now
     * potentially, session could be logged
     */
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
  }
#endif
  return res;
}