Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
polkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zbigniew Jędrzejewski-Szmek
polkit
Commits
5dabca21
Commit
5dabca21
authored
Mar 28, 2007
by
David Zeuthen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement the classes carrying data
parent
a2974bda
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
323 additions
and
113 deletions
+323
-113
libpolkit/libpolkit-caller.c
libpolkit/libpolkit-caller.c
+80
-28
libpolkit/libpolkit-caller.h
libpolkit/libpolkit-caller.h
+2
-2
libpolkit/libpolkit-context.c
libpolkit/libpolkit-context.c
+30
-15
libpolkit/libpolkit-privilege.c
libpolkit/libpolkit-privilege.c
+37
-15
libpolkit/libpolkit-resource.c
libpolkit/libpolkit-resource.c
+58
-15
libpolkit/libpolkit-seat.c
libpolkit/libpolkit-seat.c
+35
-15
libpolkit/libpolkit-session.c
libpolkit/libpolkit-session.c
+80
-22
libpolkit/libpolkit-session.h
libpolkit/libpolkit-session.h
+1
-1
No files found.
libpolkit/libpolkit-caller.c
View file @
5dabca21
...
...
@@ -54,6 +54,12 @@
**/
struct
PolKitCaller
{
int
refcount
;
char
*
dbus_name
;
pid_t
uid
;
pid_t
pid
;
char
*
selinux_context
;
PolKitSession
*
session
;
};
/**
...
...
@@ -66,7 +72,10 @@ struct PolKitCaller
PolKitCaller
*
libpolkit_caller_new
(
void
)
{
return
NULL
;
PolKitCaller
*
caller
;
caller
=
g_new0
(
PolKitCaller
,
1
);
caller
->
refcount
=
1
;
return
caller
;
}
/**
...
...
@@ -80,9 +89,34 @@ libpolkit_caller_new (void)
PolKitCaller
*
libpolkit_caller_ref
(
PolKitCaller
*
caller
)
{
g_return_val_if_fail
(
caller
!=
NULL
,
caller
);
caller
->
refcount
++
;
return
caller
;
}
/**
* libpolkit_caller_unref:
* @caller: The caller object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_caller_unref
(
PolKitCaller
*
caller
)
{
g_return_if_fail
(
caller
!=
NULL
);
caller
->
refcount
--
;
if
(
caller
->
refcount
>
0
)
return
;
g_free
(
caller
->
dbus_name
);
g_free
(
caller
->
selinux_context
);
if
(
caller
->
session
!=
NULL
)
libpolkit_session_unref
(
caller
->
session
);
g_free
(
caller
);
}
/**
* libpolkit_caller_set_dbus_name:
* @caller: The caller object
...
...
@@ -93,18 +127,24 @@ libpolkit_caller_ref (PolKitCaller *caller)
void
libpolkit_caller_set_dbus_name
(
PolKitCaller
*
caller
,
const
char
*
dbus_name
)
{
g_return_if_fail
(
caller
!=
NULL
);
if
(
caller
->
dbus_name
==
NULL
)
g_free
(
caller
->
dbus_name
);
caller
->
dbus_name
=
g_strdup
(
dbus_name
);
}
/**
* libpolkit_caller_set_
u
id:
* @caller: The caller object
* @
uid: UNIX user
id
* libpolkit_caller_set_
p
id:
* @caller: The caller object
* @
pid: UNIX process
id
*
* Set the callers UNIX
user
id.
* Set the callers UNIX
process
id.
**/
void
libpolkit_caller_set_uid
(
PolKitCaller
*
caller
,
uid_t
uid
)
{
g_return_if_fail
(
caller
!=
NULL
);
caller
->
uid
=
uid
;
}
/**
...
...
@@ -117,6 +157,8 @@ libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
void
libpolkit_caller_set_pid
(
PolKitCaller
*
caller
,
pid_t
pid
)
{
g_return_if_fail
(
caller
!=
NULL
);
caller
->
pid
=
pid
;
}
/**
...
...
@@ -129,6 +171,10 @@ libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid)
void
libpolkit_caller_set_selinux_context
(
PolKitCaller
*
caller
,
const
char
*
selinux_context
)
{
g_return_if_fail
(
caller
!=
NULL
);
if
(
caller
->
selinux_context
==
NULL
)
g_free
(
caller
->
selinux_context
);
caller
->
selinux_context
=
g_strdup
(
selinux_context
);
}
/**
...
...
@@ -143,6 +189,10 @@ libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_
void
libpolkit_caller_set_ck_session
(
PolKitCaller
*
caller
,
PolKitSession
*
session
)
{
g_return_if_fail
(
caller
!=
NULL
);
if
(
caller
->
session
==
NULL
)
libpolkit_session_unref
(
caller
->
session
);
caller
->
session
=
session
!=
NULL
?
libpolkit_session_ref
(
session
)
:
NULL
;
}
/**
...
...
@@ -157,22 +207,28 @@ libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
gboolean
libpolkit_caller_get_dbus_name
(
PolKitCaller
*
caller
,
char
**
out_dbus_name
)
{
return
FALSE
;
g_return_val_if_fail
(
caller
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_dbus_name
!=
NULL
,
FALSE
);
*
out_dbus_name
=
caller
->
dbus_name
;
return
TRUE
;
}
/**
* libpolkit_caller_get_
u
id:
* libpolkit_caller_get_
p
id:
* @caller: The caller object
* @out_
uid: Returns the UNIX user
id
* @out_
pid: Returns the UNIX process
id
*
* Get the callers UNIX
user
id.
* Get the callers UNIX
process
id.
*
* Returns: TRUE iff the value is returned
**/
gboolean
libpolkit_caller_get_uid
(
PolKitCaller
*
caller
,
uid_t
*
out_uid
)
{
return
FALSE
;
g_return_val_if_fail
(
caller
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_uid
!=
NULL
,
FALSE
);
*
out_uid
=
caller
->
uid
;
return
TRUE
;
}
/**
...
...
@@ -185,9 +241,12 @@ libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
* Returns: TRUE iff the value is returned
**/
gboolean
libpolkit_caller_get_pid
(
PolKitCaller
*
caller
,
u
id_t
*
out_pid
)
libpolkit_caller_get_pid
(
PolKitCaller
*
caller
,
p
id_t
*
out_pid
)
{
return
FALSE
;
g_return_val_if_fail
(
caller
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_pid
!=
NULL
,
FALSE
);
*
out_pid
=
caller
->
pid
;
return
TRUE
;
}
/**
...
...
@@ -200,9 +259,12 @@ libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
* Returns: TRUE iff the value is returned
**/
gboolean
libpolkit_caller_get_selinux_context
(
PolKitCaller
*
caller
,
char
*
out_selinux_context
)
libpolkit_caller_get_selinux_context
(
PolKitCaller
*
caller
,
char
*
*
out_selinux_context
)
{
return
FALSE
;
g_return_val_if_fail
(
caller
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_selinux_context
!=
NULL
,
FALSE
);
*
out_selinux_context
=
caller
->
selinux_context
;
return
TRUE
;
}
/**
...
...
@@ -217,18 +279,8 @@ libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_co
gboolean
libpolkit_caller_get_ck_session
(
PolKitCaller
*
caller
,
PolKitSession
**
out_session
)
{
return
FALSE
;
}
/**
* libpolkit_caller_unref:
* @caller: The caller object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_caller_unref
(
PolKitCaller
*
caller
)
{
g_return_val_if_fail
(
caller
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_session
!=
NULL
,
FALSE
);
*
out_session
=
caller
->
session
;
return
TRUE
;
}
libpolkit/libpolkit-caller.h
View file @
5dabca21
...
...
@@ -46,8 +46,8 @@ void libpolkit_caller_set_selinux_context (PolKitCaller *caller, co
void
libpolkit_caller_set_ck_session
(
PolKitCaller
*
caller
,
PolKitSession
*
session
);
gboolean
libpolkit_caller_get_dbus_name
(
PolKitCaller
*
caller
,
char
**
out_dbus_name
);
gboolean
libpolkit_caller_get_uid
(
PolKitCaller
*
caller
,
uid_t
*
out_uid
);
gboolean
libpolkit_caller_get_pid
(
PolKitCaller
*
caller
,
u
id_t
*
out_pid
);
gboolean
libpolkit_caller_get_selinux_context
(
PolKitCaller
*
caller
,
char
*
out_selinux_context
);
gboolean
libpolkit_caller_get_pid
(
PolKitCaller
*
caller
,
p
id_t
*
out_pid
);
gboolean
libpolkit_caller_get_selinux_context
(
PolKitCaller
*
caller
,
char
*
*
out_selinux_context
);
gboolean
libpolkit_caller_get_ck_session
(
PolKitCaller
*
caller
,
PolKitSession
**
out_session
);
#endif
/* LIBPOLKIT_H */
...
...
libpolkit/libpolkit-context.c
View file @
5dabca21
...
...
@@ -53,6 +53,9 @@
**/
struct
PolKitContext
{
int
refcount
;
PolKitContextConfigChangedCB
config_changed_cb
;
gpointer
config_changed_user_data
;
};
/**
...
...
@@ -65,7 +68,10 @@ struct PolKitContext
PolKitContext
*
libpolkit_context_new
(
void
)
{
return
FALSE
;
PolKitContext
*
pk_context
;
pk_context
=
g_new0
(
PolKitContext
,
1
);
pk_context
->
refcount
=
1
;
return
pk_context
;
}
/**
...
...
@@ -79,9 +85,29 @@ libpolkit_context_new (void)
PolKitContext
*
libpolkit_context_ref
(
PolKitContext
*
pk_context
)
{
g_return_val_if_fail
(
pk_context
!=
NULL
,
pk_context
);
pk_context
->
refcount
++
;
return
pk_context
;
}
/**
* libpolkit_context_unref:
* @pk_context: the context object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_context_unref
(
PolKitContext
*
pk_context
)
{
g_return_if_fail
(
pk_context
!=
NULL
);
pk_context
->
refcount
--
;
if
(
pk_context
->
refcount
>
0
)
return
;
g_free
(
pk_context
);
}
/**
* libpolkit_context_set_config_changed:
* @pk_context: the context object
...
...
@@ -98,18 +124,7 @@ libpolkit_context_set_config_changed (PolKitContext *pk_context,
PolKitContextConfigChangedCB
cb
,
gpointer
user_data
)
{
g_return_if_fail
(
pk_context
!=
NULL
);
pk_context
->
config_changed_cb
=
cb
;
pk_context
->
config_changed_user_data
=
user_data
;
}
/**
* libpolkit_context_unref:
* @pk_context: the context object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_context_unref
(
PolKitContext
*
pk_context
)
{
}
libpolkit/libpolkit-privilege.c
View file @
5dabca21
...
...
@@ -54,6 +54,8 @@
**/
struct
PolKitPrivilege
{
int
refcount
;
char
*
id
;
};
/**
...
...
@@ -66,7 +68,10 @@ struct PolKitPrivilege
PolKitPrivilege
*
libpolkit_privilege_new
(
void
)
{
return
NULL
;
PolKitPrivilege
*
privilege
;
privilege
=
g_new0
(
PolKitPrivilege
,
1
);
privilege
->
refcount
=
1
;
return
privilege
;
}
/**
...
...
@@ -80,9 +85,30 @@ libpolkit_privilege_new (void)
PolKitPrivilege
*
libpolkit_privilege_ref
(
PolKitPrivilege
*
privilege
)
{
g_return_val_if_fail
(
privilege
!=
NULL
,
privilege
);
privilege
->
refcount
++
;
return
privilege
;
}
/**
* libpolkit_privilege_unref:
* @privilege: the privilege object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_privilege_unref
(
PolKitPrivilege
*
privilege
)
{
g_return_if_fail
(
privilege
!=
NULL
);
privilege
->
refcount
--
;
if
(
privilege
->
refcount
>
0
)
return
;
g_free
(
privilege
->
id
);
g_free
(
privilege
);
}
/**
* libpolkit_privilege_set_privilege_id:
* @privilege: the privilege object
...
...
@@ -93,6 +119,10 @@ libpolkit_privilege_ref (PolKitPrivilege *privilege)
void
libpolkit_privilege_set_privilege_id
(
PolKitPrivilege
*
privilege
,
const
char
*
privilege_id
)
{
g_return_if_fail
(
privilege
!=
NULL
);
if
(
privilege
->
id
==
NULL
)
g_free
(
privilege
->
id
);
privilege
->
id
=
g_strdup
(
privilege_id
);
}
/**
...
...
@@ -107,18 +137,10 @@ libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char *p
gboolean
libpolkit_privilege_get_privilege_id
(
PolKitPrivilege
*
privilege
,
char
**
out_privilege_id
)
{
return
FALSE
;
}
/**
* libpolkit_privilege_unref:
* @privilege: the privilege object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_privilege_unref
(
PolKitPrivilege
*
privilege
)
{
g_return_val_if_fail
(
privilege
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_privilege_id
!=
NULL
,
FALSE
);
if
(
privilege
->
id
==
NULL
)
return
FALSE
;
*
out_privilege_id
=
privilege
->
id
;
return
TRUE
;
}
libpolkit/libpolkit-resource.c
View file @
5dabca21
...
...
@@ -54,6 +54,9 @@
**/
struct
PolKitResource
{
int
refcount
;
char
*
type
;
char
*
id
;
};
/**
...
...
@@ -66,7 +69,10 @@ struct PolKitResource
PolKitResource
*
libpolkit_resource_new
(
void
)
{
return
NULL
;
PolKitResource
*
resource
;
resource
=
g_new0
(
PolKitResource
,
1
);
resource
->
refcount
=
1
;
return
resource
;
}
/**
...
...
@@ -80,9 +86,35 @@ libpolkit_resource_new (void)
PolKitResource
*
libpolkit_resource_ref
(
PolKitResource
*
resource
)
{
g_return_val_if_fail
(
resource
!=
NULL
,
resource
);
resource
->
refcount
++
;
return
resource
;
}
/**
* libpolkit_resource_unref:
* @resource: the resource object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_resource_unref
(
PolKitResource
*
resource
)
{
g_return_if_fail
(
resource
!=
NULL
);
resource
->
refcount
--
;
if
(
resource
->
refcount
>
0
)
return
;
g_free
(
resource
->
type
);
g_free
(
resource
->
id
);
g_free
(
resource
);
}
/**
* libpolkit_resource_set_resource_type:
* @resource: the resource object
...
...
@@ -93,6 +125,11 @@ libpolkit_resource_ref (PolKitResource *resource)
void
libpolkit_resource_set_resource_type
(
PolKitResource
*
resource
,
const
char
*
resource_type
)
{
g_return_if_fail
(
resource
!=
NULL
);
if
(
resource
->
type
==
NULL
)
g_free
(
resource
->
type
);
resource
->
type
=
g_strdup
(
resource_type
);
}
/**
...
...
@@ -105,6 +142,11 @@ libpolkit_resource_set_resource_type (PolKitResource *resource, const char *res
void
libpolkit_resource_set_resource_id
(
PolKitResource
*
resource
,
const
char
*
resource_id
)
{
g_return_if_fail
(
resource
!=
NULL
);
if
(
resource
->
id
==
NULL
)
g_free
(
resource
->
id
);
resource
->
id
=
g_strdup
(
resource_id
);
}
/**
...
...
@@ -119,7 +161,14 @@ libpolkit_resource_set_resource_id (PolKitResource *resource, const char *resou
gboolean
libpolkit_resource_get_resource_type
(
PolKitResource
*
resource
,
char
**
out_resource_type
)
{
return
FALSE
;
g_return_val_if_fail
(
resource
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_resource_type
!=
NULL
,
FALSE
);
if
(
resource
->
type
==
NULL
)
return
FALSE
;
*
out_resource_type
=
resource
->
type
;
return
TRUE
;
}
/**
...
...
@@ -134,18 +183,12 @@ libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resou
gboolean
libpolkit_resource_get_resource_id
(
PolKitResource
*
resource
,
char
**
out_resource_id
)
{
return
FALSE
;
}
g_return_val_if_fail
(
resource
!=
NULL
,
FALSE
)
;
g_return_val_if_fail
(
out_resource_id
!=
NULL
,
FALSE
);
/**
* libpolkit_resource_unref:
* @resource: the resource object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_resource_unref
(
PolKitResource
*
resource
)
{
if
(
resource
->
id
==
NULL
)
return
FALSE
;
*
out_resource_id
=
resource
->
id
;
return
TRUE
;
}
libpolkit/libpolkit-seat.c
View file @
5dabca21
...
...
@@ -54,6 +54,8 @@
**/
struct
PolKitSeat
{
int
refcount
;
char
*
ck_objref
;
};
/**
...
...
@@ -66,7 +68,10 @@ struct PolKitSeat
PolKitSeat
*
libpolkit_seat_new
(
void
)
{
return
NULL
;
PolKitSeat
*
seat
;
seat
=
g_new0
(
PolKitSeat
,
1
);
seat
->
refcount
=
1
;
return
seat
;
}
/**
...
...
@@ -80,9 +85,30 @@ libpolkit_seat_new (void)
PolKitSeat
*
libpolkit_seat_ref
(
PolKitSeat
*
seat
)
{
g_return_val_if_fail
(
seat
!=
NULL
,
seat
);
seat
->
refcount
++
;
return
seat
;
}
/**
* libpolkit_seat_unref:
* @seat: the seat object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_seat_unref
(
PolKitSeat
*
seat
)
{
g_return_if_fail
(
seat
!=
NULL
);
seat
->
refcount
--
;
if
(
seat
->
refcount
>
0
)
return
;
g_free
(
seat
->
ck_objref
);
g_free
(
seat
);
}
/**
* libpolkit_seat_set_ck_objref:
* @seat: the seat object
...
...
@@ -93,6 +119,10 @@ libpolkit_seat_ref (PolKitSeat *seat)
void
libpolkit_seat_set_ck_objref
(
PolKitSeat
*
seat
,
const
char
*
ck_objref
)
{
g_return_if_fail
(
seat
!=
NULL
);
if
(
seat
->
ck_objref
==
NULL
)
g_free
(
seat
->
ck_objref
);
seat
->
ck_objref
=
g_strdup
(
ck_objref
);
}
/**
...
...
@@ -107,18 +137,8 @@ libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
gboolean
libpolkit_seat_get_ck_objref
(
PolKitSeat
*
seat
,
char
**
out_ck_objref
)
{
return
FALSE
;
}
/**
* libpolkit_seat_unref:
* @seat: the seat object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_seat_unref
(
PolKitSeat
*
seat
)
{
g_return_val_if_fail
(
seat
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
out_ck_objref
!=
NULL
,
FALSE
);
*
out_ck_objref
=
seat
->
ck_objref
;
return
TRUE
;
}
libpolkit/libpolkit-session.c
View file @
5dabca21
...
...
@@ -55,6 +55,13 @@
**/
struct
PolKitSession
{
int
refcount
;
uid_t
uid
;
PolKitSeat
*
seat
;
char
*
ck_objref
;
gboolean
is_active
;
gboolean
is_local
;
char
*
remote_host
;
};
/**
...
...
@@ -67,7 +74,10 @@ struct PolKitSession
PolKitSession
*
libpolkit_session_new
(
void
)
{
return
NULL
;
PolKitSession
*
session
;
session
=
g_new0
(
PolKitSession
,
1
);
session
->
refcount
=
1
;
return
session
;
}
/**
...
...
@@ -81,7 +91,32 @@ libpolkit_session_new (void)
PolKitSession
*
libpolkit_session_ref
(
PolKitSession
*
session
)
{
return
NULL
;
g_return_val_if_fail
(
session
!=
NULL
,
session
);
session
->
refcount
++
;
return
session
;
}
/**
* libpolkit_session_unref:
* @session: The session object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_session_unref
(
PolKitSession
*
session
)
{
g_return_if_fail
(
session
!=
NULL
);
session
->
refcount
--
;
if
(
session
->
refcount
>
0
)
return
;
g_free
(
session
->
ck_objref
);
g_free
(
session
->
remote_host
);
if
(
session
->
seat
!=
NULL
)
libpolkit_seat_unref
(
session
->
seat
);
g_free
(
session
);
}
/**
...
...
@@ -94,6 +129,8 @@ libpolkit_session_ref (PolKitSession *session)
void
libpolkit_session_set_uid
(
PolKitSession
*
session
,
uid_t
uid
)