summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-23 03:56:32 +0100
committerThomas Haller <thaller@redhat.com>2018-04-16 16:36:43 +0200
commite7d586a6505b4a8daf82514e4c181c7a1599215d (patch)
treec3fdf54b96085bc5d8148acfbbf8c034aaf1c0eb
parent41e0ca68243f1342b38572c888c758f8d20b62cf (diff)
downloadNetworkManager-th/no-polkit-agent.tar.gz
-rw-r--r--Makefile.am10
-rw-r--r--clients/cli/meson.build7
-rw-r--r--clients/cli/polkit-agent.c22
-rw-r--r--clients/common/meson.build2
-rw-r--r--clients/common/nm-polkit-listener.c29
-rw-r--r--clients/common/nm-polkit-listener.h60
-rw-r--r--config.h.meson3
-rw-r--r--configure.ac15
-rw-r--r--meson.build6
-rw-r--r--meson_options.txt1
10 files changed, 22 insertions, 133 deletions
diff --git a/Makefile.am b/Makefile.am
index 61b89bd9f8..2b5a20f2f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3462,6 +3462,8 @@ if BUILD_NMCLI
bin_PROGRAMS += clients/cli/nmcli
clients_cli_nmcli_SOURCES = \
+ clients/common/nm-polkit-listener.c \
+ clients/common/nm-polkit-listener.h \
clients/cli/common.c \
clients/cli/common.h \
clients/cli/utils.c \
@@ -3497,14 +3499,6 @@ clients_cli_nmcli_LDADD = \
$(GLIB_LIBS) \
$(READLINE_LIBS)
-if WITH_POLKIT_AGENT
-clients_cli_nmcli_CPPFLAGS += $(POLKIT_CFLAGS)
-clients_cli_nmcli_SOURCES += \
- clients/common/nm-polkit-listener.c \
- clients/common/nm-polkit-listener.h
-clients_cli_nmcli_LDADD += $(POLKIT_LIBS)
-endif
-
clients_cli_nmcli_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-binary.ver" \
$(SANITIZER_EXEC_LDFLAGS)
diff --git a/clients/cli/meson.build b/clients/cli/meson.build
index 65317a0ac9..d23f74b6d6 100644
--- a/clients/cli/meson.build
+++ b/clients/cli/meson.build
@@ -7,6 +7,7 @@ install_data(
)
sources = files(
+ '../common/nm-polkit-listener.h',
'agent.c',
'common.c',
'connections.c',
@@ -31,12 +32,6 @@ cflags = clients_cflags + [
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
]
-if enable_polkit_agent
- sources += nm_polkit_listener
-
- deps += polkit_agent_dep
-endif
-
executable(
name,
sources,
diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c
index 338f0b15e9..b2482efb0c 100644
--- a/clients/cli/polkit-agent.c
+++ b/clients/cli/polkit-agent.c
@@ -14,22 +14,16 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright 2014 Red Hat, Inc.
+ * Copyright 2014, 2018 Red Hat, Inc.
*/
#include "nm-default.h"
#include "polkit-agent.h"
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "nm-polkit-listener.h"
#include "common.h"
+#include "nm-polkit-listener.h"
-#if WITH_POLKIT_AGENT
static char *
polkit_request (NMPolkitListener *listener,
const char *request,
@@ -84,12 +78,10 @@ polkit_completed (NMPolkitListener *listener,
/* We don't print anything here. The outcome will be evident from
* the operation result anyway. */
}
-#endif
gboolean
nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
{
-#if WITH_POLKIT_AGENT
static const NMPolkitListenVtable vtable = {
.on_request = polkit_request,
.on_show_info = polkit_show_info,
@@ -98,8 +90,6 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
};
NMPolkitListener *listener;
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
listener = nm_polkit_listener_new (for_session, error);
if (!listener)
return FALSE;
@@ -107,26 +97,22 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
nm_polkit_listener_set_vtable (listener, &vtable, nmc);
nmc->pk_listener = listener;
-#endif
return TRUE;
}
void
nmc_polkit_agent_fini (NmCli* nmc)
{
-#if WITH_POLKIT_AGENT
if (nmc->pk_listener) {
nm_polkit_listener_set_vtable (nmc->pk_listener, NULL, NULL);
g_clear_object (&nmc->pk_listener);
}
-#endif
}
gboolean
nmc_start_polkit_agent_start_try (NmCli *nmc)
{
-#if WITH_POLKIT_AGENT
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
/* We don't register polkit agent at all when running non-interactively */
if (!nmc->ask)
@@ -135,9 +121,7 @@ nmc_start_polkit_agent_start_try (NmCli *nmc)
if (!nmc_polkit_agent_init (nmc, FALSE, &error)) {
g_printerr (_("Warning: polkit agent initialization failed: %s\n"),
error->message);
- g_error_free (error);
return FALSE;
}
-#endif
return TRUE;
}
diff --git a/clients/common/meson.build b/clients/common/meson.build
index ea26bccfb4..fb9cf8ca31 100644
--- a/clients/common/meson.build
+++ b/clients/common/meson.build
@@ -1,7 +1,5 @@
common_inc = include_directories('.')
-nm_polkit_listener = files('nm-polkit-listener.c')
-
deps = [
libnm_dep,
nm_core_dep
diff --git a/clients/common/nm-polkit-listener.c b/clients/common/nm-polkit-listener.c
index 300cf11e8d..6cf7771eca 100644
--- a/clients/common/nm-polkit-listener.c
+++ b/clients/common/nm-polkit-listener.c
@@ -39,15 +39,13 @@
#include <stdio.h>
#include <stdlib.h>
-#if WITH_POLKIT_AGENT
-
/*****************************************************************************/
typedef struct {
gpointer reg_handle; /* handle of polkit agent registration */
GSimpleAsyncResult *simple;
- PolkitAgentSession *active_session;
+ //PolkitAgentSession *active_session;
gulong cancel_id;
GCancellable *cancellable;
@@ -60,9 +58,18 @@ typedef struct {
gpointer vtable_user_data;
} NMPolkitListenerPrivate;
-G_DEFINE_TYPE (NMPolkitListener, nm_polkit_listener, POLKIT_AGENT_TYPE_LISTENER)
+struct _NMPolkitListener {
+ GObject parent;
+ NMPolkitListenerPrivate _priv;
+};
+
+struct _NMPolkitListenerClass {
+ GObjectClass parent;
+};
+
+G_DEFINE_TYPE (NMPolkitListener, nm_polkit_listener, G_TYPE_OBJECT)
-#define NM_POLKIT_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_POLKIT_LISTENER, NMPolkitListenerPrivate))
+#define NM_POLKIT_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPolkitListener, NM_IS_POLKIT_LISTENER)
/*****************************************************************************/
@@ -79,6 +86,7 @@ nm_polkit_listener_set_vtable (NMPolkitListener *self,
/*****************************************************************************/
+#if 0
static void
on_request (PolkitAgentSession *session,
const char *request,
@@ -288,6 +296,7 @@ initiate_authentication_finish (PolkitAgentListener *listener,
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
}
+#endif
/*****************************************************************************/
@@ -313,7 +322,7 @@ nm_polkit_listener_new (gboolean for_session,
GError **error)
{
NMPolkitListener *listener;
- PolkitSubject* session;
+ PolkitSubject *session;
NMPolkitListenerPrivate *priv;
g_return_val_if_fail (!error || !*error, NULL);
@@ -361,14 +370,6 @@ static void
nm_polkit_listener_class_init (NMPolkitListenerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- PolkitAgentListenerClass *pkal_class = POLKIT_AGENT_LISTENER_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (NMPolkitListenerPrivate));
gobject_class->finalize = nm_polkit_listener_finalize;
-
- pkal_class->initiate_authentication = initiate_authentication;
- pkal_class->initiate_authentication_finish = initiate_authentication_finish;
}
-
-#endif /* WITH_POLKIT_AGENT */
diff --git a/clients/common/nm-polkit-listener.h b/clients/common/nm-polkit-listener.h
index ea13acddad..bdb2bbacc1 100644
--- a/clients/common/nm-polkit-listener.h
+++ b/clients/common/nm-polkit-listener.h
@@ -13,14 +13,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * Copyright 2014 Red Hat, Inc.
+ * Copyright 2014 - 2018 Red Hat, Inc.
*/
#ifndef __NM_POLKIT_LISTENER_H__
#define __NM_POLKIT_LISTENER_H__
-#if WITH_POLKIT_AGENT
-
typedef struct _NMPolkitListener NMPolkitListener;
typedef struct _NMPolkitListenerClass NMPolkitListenerClass;
@@ -77,9 +75,6 @@ typedef struct {
/*****************************************************************************/
-#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE
-#include <polkitagent/polkitagent.h>
-
#define NM_TYPE_POLKIT_LISTENER (nm_polkit_listener_get_type ())
#define NM_POLKIT_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_POLKIT_LISTENER, NMPolkitListener))
#define NM_POLKIT_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_POLKIT_LISTENER, NMPolkitListenerClass))
@@ -87,57 +82,6 @@ typedef struct {
#define NM_IS_POLKIT_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_POLKIT_LISTENER))
#define NM_POLKIT_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_POLKIT_LISTENER, NMPolkitListenerClass))
-/**
- * NMPolkitListenerOnRequestFunc:
- * @request: the request asked by polkit agent
- * @action_id: the action_id of the polkit request
- * @message: the message of the polkit request
- * @icon_name: the icon name of the polkit request
- * @user: user name
- * @echo_on: whether the response to the request should be echoed to the screen
- * @user_data: user data for the callback
- *
- * Called as a result of a request by polkit. The function should obtain response
- * to the request from user, i.e. get the password required.
- */
-typedef char * (*NMPolkitListenerOnRequestFunc) (const char *request,
- const char *action_id,
- const char *message,
- const char *icon_name,
- const char *user,
- gboolean echo_on,
- gpointer user_data);
-/**
- * NMPolkitListenerOnShowInfoFunc:
- * @text: the info text from polkit
- *
- * Called as a result of show-info signal by polkit.
- */
-typedef void (*NMPolkitListenerOnShowInfoFunc) (const char *text);
-/**
- * NMPolkitListenerOnShowErrorFunc:
- * @text: the error text from polkit
- *
- * Called as a result of show-error signal by polkit.
- */
-typedef void (*NMPolkitListenerOnShowErrorFunc) (const char *text);
-/**
- * NMPolkitListenerCompletedFunc:
- * @gained_authorization: whether the autorization was successful
- *
- * Called as a result of completed signal by polkit.
- */
-typedef void (*NMPolkitListenerOnCompletedFunc) (gboolean gained_authorization);
-
-
-struct _NMPolkitListener {
- PolkitAgentListener parent;
-};
-
-struct _NMPolkitListenerClass {
- PolkitAgentListenerClass parent;
-};
-
GType nm_polkit_listener_get_type (void);
NMPolkitListener *nm_polkit_listener_new (gboolean for_session,
@@ -147,6 +91,4 @@ void nm_polkit_listener_set_vtable (NMPolkitListener *self,
const NMPolkitListenVtable *vtable,
gpointer user_data);
-#endif
-
#endif /* __NM_POLKIT_LISTENER_H__ */
diff --git a/config.h.meson b/config.h.meson
index 06190aae11..c939e4ff36 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -214,9 +214,6 @@
/* Define if you have oFono support (experimental) */
#mesondefine WITH_OFONO
-/* Define if you have polkit agent */
-#mesondefine WITH_POLKIT_AGENT
-
/* Define if you have PPP support */
#mesondefine WITH_PPP
diff --git a/configure.ac b/configure.ac
index c703890e1c..d9773b1476 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,20 +644,6 @@ else
AC_SUBST(NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT, false)
fi
-PKG_CHECK_MODULES(POLKIT, [polkit-agent-1 >= 0.97], [have_pk_agent=yes],[have_pk_agent=no])
-AC_ARG_ENABLE(polkit-agent,
- AS_HELP_STRING([--enable-polkit-agent], [enable polkit agent for clients]),
- [enable_polkit_agent=${enableval}], [enable_polkit_agent=${have_pk_agent}])
-if (test "${enable_polkit_agent}" = "yes"); then
- if test x"$have_pk_agent" = x"no"; then
- AC_MSG_ERROR(Polkit agent is required)
- fi
- AC_DEFINE(WITH_POLKIT_AGENT, 1, [Define if you have polkit agent])
-else
- AC_DEFINE(WITH_POLKIT_AGENT, 0, [Define if you have polkit agent])
-fi
-AM_CONDITIONAL(WITH_POLKIT_AGENT, test "${enable_polkit_agent}" = "yes")
-
AC_ARG_ENABLE(modify-system, AS_HELP_STRING([--enable-modify-system], [Allow users to modify system connections]))
if test "${enable_modify_system}" = "yes"; then
NM_MODIFY_SYSTEM_POLICY="yes"
@@ -1340,7 +1326,6 @@ if test "${enable_modify_system}" = "yes"; then
else
echo " policykit: main.auth-polkit=${enable_polkit} (restrictive modify.system)"
fi
-echo " polkit agent: ${enable_polkit_agent}"
echo " selinux: $have_selinux"
echo " systemd-journald: $have_systemd_journal (default: logging.backend=${nm_config_logging_backend_default})"
echo " hostname persist: ${hostname_persist}"
diff --git a/meson.build b/meson.build
index 17ddbc4a57..77bc6e95c6 100644
--- a/meson.build
+++ b/meson.build
@@ -451,12 +451,6 @@ config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT', config_default_main_au
enable_modify_system = get_option('modify_system')
-enable_polkit_agent = get_option('polkit_agent')
-if enable_polkit_agent
- polkit_agent_dep = dependency('polkit-agent-1', version: '>= 0.97')
-endif
-config_h.set10('WITH_POLKIT_AGENT', enable_polkit_agent)
-
# crypto
crypto = get_option('crypto')
if crypto == 'nss'
diff --git a/meson_options.txt b/meson_options.txt
index f22eb28a4f..6174593ae5 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -18,7 +18,6 @@ option('session_tracking', type: 'combo', choices: ['systemd', 'elogind', 'no'],
option('suspend_resume', type: 'boolean', value: true, description: 'Build NetworkManager with specific suspend/resume support')
option('polkit', type: 'combo', choices: ['yes', 'no', 'disabled'], value: 'yes', description: 'set default value for auth-polkit configuration option. This value can be overwritten by NM configuration. \'disabled\' compiles NM without any support')
option('modify_system', type: 'boolean', value: false, description: 'Allow users to modify system connections')
-option('polkit_agent', type: 'boolean', value: false, description: 'enable polkit agent for clients')
option('selinux', type: 'boolean', value: true, description: 'Build with SELinux')
option('systemd_journal', type: 'boolean', value: true, description: 'Use systemd journal for logging')
option('config_logging_backend_default', type: 'combo', choices: ['default', 'debug', 'syslog', 'journal', 'journal-syslog-style'], value: 'default', description: 'Default value for logging.backend')