2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2014-08-14 13:34:57 +02:00
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NM_AUTH_MANAGER_H
|
|
|
|
|
#define NM_AUTH_MANAGER_H
|
|
|
|
|
|
2021-02-12 15:01:09 +01:00
|
|
|
#include "libnm-core-aux-intern/nm-auth-subject.h"
|
2019-12-10 08:51:03 +01:00
|
|
|
#include "nm-config-data.h"
|
2014-08-14 13:34:57 +02:00
|
|
|
|
2018-04-09 17:03:58 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2019-12-05 15:20:18 +01:00
|
|
|
NM_AUTH_CALL_RESULT_UNKNOWN = NM_CLIENT_PERMISSION_RESULT_UNKNOWN,
|
|
|
|
|
NM_AUTH_CALL_RESULT_YES = NM_CLIENT_PERMISSION_RESULT_YES,
|
|
|
|
|
NM_AUTH_CALL_RESULT_AUTH = NM_CLIENT_PERMISSION_RESULT_AUTH,
|
|
|
|
|
NM_AUTH_CALL_RESULT_NO = NM_CLIENT_PERMISSION_RESULT_NO,
|
2018-04-09 17:03:58 +02:00
|
|
|
} NMAuthCallResult;
|
|
|
|
|
|
2019-12-05 15:20:18 +01:00
|
|
|
static inline NMClientPermissionResult
|
|
|
|
|
nm_auth_call_result_to_client(NMAuthCallResult result)
|
|
|
|
|
{
|
|
|
|
|
return (NMClientPermissionResult) result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 17:03:58 +02:00
|
|
|
static inline NMAuthCallResult
|
|
|
|
|
nm_auth_call_result_eval(gboolean is_authorized, gboolean is_challenge, GError *error)
|
|
|
|
|
{
|
|
|
|
|
if (error)
|
|
|
|
|
return NM_AUTH_CALL_RESULT_UNKNOWN;
|
|
|
|
|
if (is_authorized)
|
|
|
|
|
return NM_AUTH_CALL_RESULT_YES;
|
|
|
|
|
if (is_challenge)
|
|
|
|
|
return NM_AUTH_CALL_RESULT_AUTH;
|
|
|
|
|
return NM_AUTH_CALL_RESULT_NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-08-14 13:34:57 +02:00
|
|
|
#define NM_TYPE_AUTH_MANAGER (nm_auth_manager_get_type())
|
|
|
|
|
#define NM_AUTH_MANAGER(obj) \
|
2022-12-14 16:21:48 +01:00
|
|
|
(_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_AUTH_MANAGER, NMAuthManager))
|
2014-08-14 13:34:57 +02:00
|
|
|
#define NM_AUTH_MANAGER_CLASS(klass) \
|
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_AUTH_MANAGER, NMAuthManagerClass))
|
|
|
|
|
#define NM_IS_AUTH_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_AUTH_MANAGER))
|
|
|
|
|
#define NM_IS_AUTH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_AUTH_MANAGER))
|
|
|
|
|
#define NM_AUTH_MANAGER_GET_CLASS(obj) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_AUTH_MANAGER, NMAuthManagerClass))
|
|
|
|
|
|
|
|
|
|
#define NM_AUTH_MANAGER_POLKIT_ENABLED "polkit-enabled"
|
|
|
|
|
|
|
|
|
|
#define NM_AUTH_MANAGER_SIGNAL_CHANGED "changed"
|
|
|
|
|
|
2016-09-29 13:49:01 +02:00
|
|
|
typedef struct _NMAuthManager NMAuthManager;
|
|
|
|
|
typedef struct _NMAuthManagerClass NMAuthManagerClass;
|
2014-08-14 13:34:57 +02:00
|
|
|
|
|
|
|
|
GType nm_auth_manager_get_type(void);
|
|
|
|
|
|
2019-12-10 08:51:03 +01:00
|
|
|
NMAuthManager *nm_auth_manager_setup(NMAuthPolkitMode auth_polkit_mode);
|
2014-08-14 13:34:57 +02:00
|
|
|
NMAuthManager *nm_auth_manager_get(void);
|
|
|
|
|
|
2018-04-09 13:27:03 +02:00
|
|
|
void nm_auth_manager_force_shutdown(NMAuthManager *self);
|
|
|
|
|
|
2014-08-14 13:34:57 +02:00
|
|
|
gboolean nm_auth_manager_get_polkit_enabled(NMAuthManager *self);
|
|
|
|
|
|
2018-04-09 13:27:03 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
typedef struct _NMAuthManagerCallId NMAuthManagerCallId;
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
typedef void (*NMAuthManagerCheckAuthorizationCallback)(NMAuthManager *self,
|
2018-04-09 13:27:03 +02:00
|
|
|
NMAuthManagerCallId *call_id,
|
|
|
|
|
gboolean is_authorized,
|
|
|
|
|
gboolean is_challenge,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError *error,
|
2018-04-09 13:27:03 +02:00
|
|
|
gpointer user_data);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2018-04-09 13:27:03 +02:00
|
|
|
NMAuthManagerCallId *
|
2021-11-09 13:28:54 +01:00
|
|
|
nm_auth_manager_check_authorization(NMAuthManager *self,
|
|
|
|
|
NMAuthSubject *subject,
|
|
|
|
|
const char *action_id,
|
2018-04-09 13:27:03 +02:00
|
|
|
gboolean allow_user_interaction,
|
|
|
|
|
NMAuthManagerCheckAuthorizationCallback callback,
|
|
|
|
|
gpointer user_data);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2018-04-09 13:27:03 +02:00
|
|
|
void nm_auth_manager_check_authorization_cancel(NMAuthManagerCallId *call_id);
|
2014-08-14 13:34:57 +02:00
|
|
|
|
|
|
|
|
#endif /* NM_AUTH_MANAGER_H */
|