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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* Copyright (C) 2008 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "polkitimplicitauthorization.h"
#include "polkitprivate.h"
/**
* SECTION:polkitimplicitauthorization
* @title: PolkitImplicitAuthorization
* @short_result: Implicit Authorizations
*
* Possible implicit authorizations.
*/
GType
polkit_implicit_authorization_get_type (void)
{
return _polkit_implicit_authorization_get_type ();
}
gboolean
polkit_implicit_authorization_from_string (const gchar *string,
PolkitImplicitAuthorization *out_implicit_authorization)
{
PolkitImplicitAuthorization result;
gboolean ret;
ret = TRUE;
result = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED;
if (strcmp (string, "no") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED;
}
else if (strcmp (string, "auth_self") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED;
}
else if (strcmp (string, "auth_admin") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED;
}
else if (strcmp (string, "auth_self_keep") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED_RETAINED;
}
else if (strcmp (string, "auth_admin_keep") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED_RETAINED;
}
else if (strcmp (string, "yes") == 0)
{
result = POLKIT_IMPLICIT_AUTHORIZATION_AUTHORIZED;
}
else
{
g_warning ("Unknown PolkitImplicitAuthorization string '%s'", string);
ret = FALSE;
}
if (out_implicit_authorization != NULL)
*out_implicit_authorization = result;
return ret;
}
const gchar *
polkit_implicit_authorization_to_string (PolkitImplicitAuthorization implicit_authorization)
{
const gchar *s;
s = "(unknown)";
switch (implicit_authorization)
{
case POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED:
s = "no";
break;
case POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED:
s = "auth_self";
break;
case POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED:
s = "auth_admin";
break;
case POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED_RETAINED:
s = "auth_self_keep";
break;
case POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED_RETAINED:
s = "auth_admin_keep";
break;
case POLKIT_IMPLICIT_AUTHORIZATION_AUTHORIZED:
s = "yes";
break;
}
return s;
}
|