polkit-module-deny-all.c 2.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
 *
 * polkit-module-allow-all.c : PolicyKit module that says NO to everything
 *
 * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
 *
 * Licensed under the Academic Free License version 2.1
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
 *
 **************************************************************************/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

30
#include <stddef.h>
David Zeuthen's avatar
David Zeuthen committed
31
#include <polkit/polkit.h>
32

David Zeuthen's avatar
David Zeuthen committed
33 34
/* The symbol that polkit looks up when loading this module */
polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
35

36
static polkit_bool_t
37 38
_module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
{
39
        return TRUE;
40 41 42 43 44 45 46 47 48 49
}

static void
_module_shutdown (PolKitModuleInterface *module_interface)
{
}

static PolKitResult
_module_can_session_access_resource (PolKitModuleInterface *module_interface,
                                     PolKitContext         *pk_context,
David Zeuthen's avatar
David Zeuthen committed
50
                                     PolKitAction          *action,
51 52 53
                                     PolKitResource        *resource,
                                     PolKitSession         *session)
{
David Zeuthen's avatar
David Zeuthen committed
54
        return POLKIT_RESULT_NO;
55 56 57 58 59
}

static PolKitResult
_module_can_caller_access_resource (PolKitModuleInterface *module_interface,
                                    PolKitContext         *pk_context,
David Zeuthen's avatar
David Zeuthen committed
60
                                    PolKitAction          *action,
61 62 63
                                    PolKitResource        *resource,
                                    PolKitCaller          *caller)
{
David Zeuthen's avatar
David Zeuthen committed
64
        return POLKIT_RESULT_NO;
65 66
}

67
polkit_bool_t
David Zeuthen's avatar
David Zeuthen committed
68
polkit_module_set_functions (PolKitModuleInterface *module_interface)
69
{
70
        polkit_bool_t ret;
71

72
        ret = FALSE;
73 74 75
        if (module_interface == NULL)
                goto out;

David Zeuthen's avatar
David Zeuthen committed
76 77 78 79
        polkit_module_set_func_initialize (module_interface, _module_init);
        polkit_module_set_func_shutdown (module_interface, _module_shutdown);
        polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
        polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
80

81
        ret = TRUE;
82 83 84
out:
        return ret;
}