diff options
| author | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
| commit | 33491bc4279481db8ae47213e34a6d695a0e8830 (patch) | |
| tree | 097d2b0fdff3fae6885381ae5e57a182cd8cbbba /src/ppp-manager | |
| parent | 59c3714a494c3b3765657c0551ad82842d98a7d2 (diff) | |
Imported Upstream version 0.9.10.0 upstream/0.9.10.0
Diffstat (limited to 'src/ppp-manager')
| -rw-r--r-- | src/ppp-manager/Makefile.am | 46 | ||||
| -rw-r--r-- | src/ppp-manager/Makefile.in | 134 | ||||
| -rw-r--r-- | src/ppp-manager/nm-ppp-manager.c | 296 | ||||
| -rw-r--r-- | src/ppp-manager/nm-pppd-plugin.c | 24 |
4 files changed, 215 insertions, 285 deletions
diff --git a/src/ppp-manager/Makefile.am b/src/ppp-manager/Makefile.am index 4ad4ff81..46fc9138 100644 --- a/src/ppp-manager/Makefile.am +++ b/src/ppp-manager/Makefile.am @@ -1,46 +1,13 @@ +if WITH_PPP + AM_CPPFLAGS = \ - -I${top_srcdir} \ -I${top_builddir}/include \ -I${top_srcdir}/include \ - -I${top_builddir}/libnm-util \ - -I${top_srcdir}/libnm-util \ - -I${top_srcdir}/src \ - -I${top_builddir}/src/generated \ - -I${top_srcdir}/src/generated \ - -I${top_srcdir}/src/logging \ - -I${top_srcdir}/src/posix-signals \ + -DG_LOG_DOMAIN=\""nm-pppd-plugin"\" \ + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(DBUS_CFLAGS) \ $(GLIB_CFLAGS) -noinst_LTLIBRARIES = libppp-manager.la - -libppp_manager_la_SOURCES = \ - nm-ppp-manager.c \ - nm-ppp-manager.h \ - nm-ppp-status.h - -nm-ppp-manager-glue.h: $(top_srcdir)/introspection/nm-ppp-manager.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ppp_manager --mode=glib-server --output=$@ $< - -built_sources = nm-ppp-manager-glue.h - -$(libppp_manager_la_OBJECTS): $(built_sources) - -libppp_manager_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBDIR=\"$(libdir)\" \ - -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\" - -libppp_manager_la_LIBADD = \ - $(top_builddir)/src/generated/libnm-generated.la \ - $(top_builddir)/src/logging/libnm-logging.la \ - $(top_builddir)/src/posix-signals/libnm-posix-signals.la \ - $(DBUS_LIBS) \ - $(GLIB_LIBS) - -if WITH_PPP - pppd_plugindir = $(PPPD_PLUGIN_DIR) pppd_plugin_LTLIBRARIES = nm-pppd-plugin.la @@ -57,8 +24,3 @@ nm_pppd_plugin_la_LIBADD = \ $(GLIB_LIBS) endif - -BUILT_SOURCES = nm-ppp-manager-glue.h - -CLEANFILES = $(BUILT_SOURCES) - diff --git a/src/ppp-manager/Makefile.in b/src/ppp-manager/Makefile.in index 97465f0c..731a9459 100644 --- a/src/ppp-manager/Makefile.in +++ b/src/ppp-manager/Makefile.in @@ -82,7 +82,8 @@ subdir = src/ppp-manager DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -128,19 +129,8 @@ am__uninstall_files_from_dir = { \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pppd_plugindir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pppd_plugin_LTLIBRARIES) +LTLIBRARIES = $(pppd_plugin_LTLIBRARIES) am__DEPENDENCIES_1 = -libppp_manager_la_DEPENDENCIES = \ - $(top_builddir)/src/generated/libnm-generated.la \ - $(top_builddir)/src/logging/libnm-logging.la \ - $(top_builddir)/src/posix-signals/libnm-posix-signals.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_libppp_manager_la_OBJECTS = libppp_manager_la-nm-ppp-manager.lo -libppp_manager_la_OBJECTS = $(am_libppp_manager_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = @WITH_PPP_TRUE@nm_pppd_plugin_la_DEPENDENCIES = \ @WITH_PPP_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ @WITH_PPP_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) @@ -148,6 +138,10 @@ am__nm_pppd_plugin_la_SOURCES_DIST = nm-pppd-plugin.c nm-pppd-plugin.h \ nm-ppp-status.h @WITH_PPP_TRUE@am_nm_pppd_plugin_la_OBJECTS = nm-pppd-plugin.lo nm_pppd_plugin_la_OBJECTS = $(am_nm_pppd_plugin_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = nm_pppd_plugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(nm_pppd_plugin_la_LDFLAGS) $(LDFLAGS) \ @@ -187,9 +181,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libppp_manager_la_SOURCES) $(nm_pppd_plugin_la_SOURCES) -DIST_SOURCES = $(libppp_manager_la_SOURCES) \ - $(am__nm_pppd_plugin_la_SOURCES_DIST) +SOURCES = $(nm_pppd_plugin_la_SOURCES) +DIST_SOURCES = $(am__nm_pppd_plugin_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -240,12 +233,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -270,7 +266,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -315,12 +310,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -337,6 +336,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -364,11 +365,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -383,6 +389,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -445,6 +452,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -455,39 +463,14 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ -AM_CPPFLAGS = \ - -I${top_srcdir} \ - -I${top_builddir}/include \ - -I${top_srcdir}/include \ - -I${top_builddir}/libnm-util \ - -I${top_srcdir}/libnm-util \ - -I${top_srcdir}/src \ - -I${top_builddir}/src/generated \ - -I${top_srcdir}/src/generated \ - -I${top_srcdir}/src/logging \ - -I${top_srcdir}/src/posix-signals \ - $(DBUS_CFLAGS) \ - $(GLIB_CFLAGS) - -noinst_LTLIBRARIES = libppp-manager.la -libppp_manager_la_SOURCES = \ - nm-ppp-manager.c \ - nm-ppp-manager.h \ - nm-ppp-status.h - -built_sources = nm-ppp-manager-glue.h -libppp_manager_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBDIR=\"$(libdir)\" \ - -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\" - -libppp_manager_la_LIBADD = \ - $(top_builddir)/src/generated/libnm-generated.la \ - $(top_builddir)/src/logging/libnm-logging.la \ - $(top_builddir)/src/posix-signals/libnm-posix-signals.la \ - $(DBUS_LIBS) \ - $(GLIB_LIBS) +with_valgrind = @with_valgrind@ +@WITH_PPP_TRUE@AM_CPPFLAGS = \ +@WITH_PPP_TRUE@ -I${top_builddir}/include \ +@WITH_PPP_TRUE@ -I${top_srcdir}/include \ +@WITH_PPP_TRUE@ -DG_LOG_DOMAIN=\""nm-pppd-plugin"\" \ +@WITH_PPP_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ +@WITH_PPP_TRUE@ $(DBUS_CFLAGS) \ +@WITH_PPP_TRUE@ $(GLIB_CFLAGS) @WITH_PPP_TRUE@pppd_plugindir = $(PPPD_PLUGIN_DIR) @WITH_PPP_TRUE@pppd_plugin_LTLIBRARIES = nm-pppd-plugin.la @@ -502,10 +485,7 @@ libppp_manager_la_LIBADD = \ @WITH_PPP_TRUE@ $(DBUS_LIBS) \ @WITH_PPP_TRUE@ $(GLIB_LIBS) -BUILT_SOURCES = nm-ppp-manager-glue.h -CLEANFILES = $(BUILT_SOURCES) -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am +all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -540,17 +520,6 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - install-pppd_pluginLTLIBRARIES: $(pppd_plugin_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pppd_plugin_LTLIBRARIES)'; test -n "$(pppd_plugindir)" || list=; \ @@ -586,9 +555,6 @@ clean-pppd_pluginLTLIBRARIES: rm -f $${locs}; \ } -libppp-manager.la: $(libppp_manager_la_OBJECTS) $(libppp_manager_la_DEPENDENCIES) $(EXTRA_libppp_manager_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libppp_manager_la_OBJECTS) $(libppp_manager_la_LIBADD) $(LIBS) - nm-pppd-plugin.la: $(nm_pppd_plugin_la_OBJECTS) $(nm_pppd_plugin_la_DEPENDENCIES) $(EXTRA_nm_pppd_plugin_la_DEPENDENCIES) $(AM_V_CCLD)$(nm_pppd_plugin_la_LINK) $(am_nm_pppd_plugin_la_rpath) $(nm_pppd_plugin_la_OBJECTS) $(nm_pppd_plugin_la_LIBADD) $(LIBS) @@ -598,7 +564,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libppp_manager_la-nm-ppp-manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-pppd-plugin.Plo@am__quote@ .c.o: @@ -622,13 +587,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -libppp_manager_la-nm-ppp-manager.lo: nm-ppp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libppp_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libppp_manager_la-nm-ppp-manager.lo -MD -MP -MF $(DEPDIR)/libppp_manager_la-nm-ppp-manager.Tpo -c -o libppp_manager_la-nm-ppp-manager.lo `test -f 'nm-ppp-manager.c' || echo '$(srcdir)/'`nm-ppp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libppp_manager_la-nm-ppp-manager.Tpo $(DEPDIR)/libppp_manager_la-nm-ppp-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nm-ppp-manager.c' object='libppp_manager_la-nm-ppp-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libppp_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libppp_manager_la-nm-ppp-manager.lo `test -f 'nm-ppp-manager.c' || echo '$(srcdir)/'`nm-ppp-manager.c - mostlyclean-libtool: -rm -f *.lo @@ -718,15 +676,13 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am +check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pppd_plugindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am +install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -748,7 +704,6 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -757,11 +712,10 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pppd_pluginLTLIBRARIES mostlyclean-am +clean-am: clean-generic clean-libtool clean-pppd_pluginLTLIBRARIES \ + mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -829,12 +783,11 @@ ps-am: uninstall-am: uninstall-pppd_pluginLTLIBRARIES -.MAKE: all check install install-am install-strip +.MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES \ - clean-pppd_pluginLTLIBRARIES cscopelist-am ctags ctags-am \ - distclean distclean-compile distclean-generic \ + clean-libtool clean-pppd_pluginLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ @@ -848,11 +801,6 @@ uninstall-am: uninstall-pppd_pluginLTLIBRARIES uninstall-pppd_pluginLTLIBRARIES -nm-ppp-manager-glue.h: $(top_srcdir)/introspection/nm-ppp-manager.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ppp_manager --mode=glib-server --output=$@ $< - -$(libppp_manager_la_OBJECTS): $(built_sources) - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index aa03c82a..e856fc19 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -52,32 +52,28 @@ #include "nm-setting-cdma.h" #include "nm-dbus-manager.h" #include "nm-logging.h" -#include "nm-marshal.h" #include "nm-posix-signals.h" static void impl_ppp_manager_need_secrets (NMPPPManager *manager, DBusGMethodInvocation *context); static gboolean impl_ppp_manager_set_state (NMPPPManager *manager, - guint32 state, - GError **err); + guint32 state, + GError **err); static gboolean impl_ppp_manager_set_ip4_config (NMPPPManager *manager, - GHashTable *config, - GError **err); + GHashTable *config, + GError **err); #include "nm-ppp-manager-glue.h" static void _ppp_cleanup (NMPPPManager *manager); -#define NM_PPPD_PLUGIN PLUGINDIR "/nm-pppd-plugin.so" +#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so" #define PPP_MANAGER_SECRET_TRIES "ppp-manager-secret-tries" typedef struct { - gboolean disposed; - GPid pid; - NMDBusManager *dbus_manager; char *dbus_path; char *parent_iface; @@ -85,6 +81,7 @@ typedef struct { NMActRequest *act_req; DBusGMethodInvocation *pending_secrets_context; guint32 secrets_id; + const char *secrets_setting_name; guint32 ppp_watch_id; guint32 ppp_timeout_handler; @@ -135,34 +132,18 @@ nm_ppp_manager_init (NMPPPManager *manager) { } -static GObject * -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) +static void +constructed (GObject *object) { - GObject *object; - NMPPPManagerPrivate *priv; + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); DBusGConnection *connection; static guint32 counter = 0; - object = G_OBJECT_CLASS (nm_ppp_manager_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_PPP_MANAGER_GET_PRIVATE (object); - priv->dbus_manager = nm_dbus_manager_get (); - if (!priv->dbus_manager) { - g_object_unref (object); - return NULL; - } - - connection = nm_dbus_manager_get_connection (priv->dbus_manager); priv->dbus_path = g_strdup_printf (NM_DBUS_PATH "/PPP/%d", counter++); + connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ()); dbus_g_connection_register_g_object (connection, priv->dbus_path, object); - return object; + G_OBJECT_CLASS (nm_ppp_manager_parent_class)->constructed (object); } static void @@ -170,19 +151,9 @@ dispose (GObject *object) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); - if (priv->disposed == FALSE) { - priv->disposed = TRUE; + _ppp_cleanup (NM_PPP_MANAGER (object)); - _ppp_cleanup (NM_PPP_MANAGER (object)); - - if (priv->act_req) { - g_object_unref (priv->act_req); - priv->act_req = NULL; - } - - g_object_unref (priv->dbus_manager); - priv->dbus_manager = NULL; - } + g_clear_object (&priv->act_req); G_OBJECT_CLASS (nm_ppp_manager_parent_class)->dispose (object); } @@ -200,7 +171,7 @@ finalize (GObject *object) static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); @@ -217,7 +188,7 @@ set_property (GObject *object, guint prop_id, static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) + GValue *value, GParamSpec *pspec) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); @@ -238,7 +209,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) g_type_class_add_private (manager_class, sizeof (NMPPPManagerPrivate)); - object_class->constructor = constructor; + object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; @@ -248,45 +219,42 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) g_object_class_install_property (object_class, PROP_PARENT_IFACE, g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, - "ParentIface", - "Parent interface", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + "ParentIface", + "Parent interface", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); /* signals */ signals[STATE_CHANGED] = g_signal_new ("state-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, state_changed), - NULL, NULL, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, - G_TYPE_UINT); + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMPPPManagerClass, state_changed), + NULL, NULL, NULL, + G_TYPE_NONE, 1, + G_TYPE_UINT); signals[IP4_CONFIG] = g_signal_new ("ip4-config", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, ip4_config), - NULL, NULL, - _nm_marshal_VOID__STRING_OBJECT, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_OBJECT); + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMPPPManagerClass, ip4_config), + NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_STRING, + G_TYPE_OBJECT); signals[STATS] = g_signal_new ("stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, stats), - NULL, NULL, - _nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMPPPManagerClass, stats), + NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), - &dbus_glib_nm_ppp_manager_object_info); + &dbus_glib_nm_ppp_manager_object_info); } NMPPPManager * @@ -363,36 +331,50 @@ cancel_get_secrets (NMPPPManager *self) nm_act_request_cancel_secrets (priv->act_req, priv->secrets_id); priv->secrets_id = 0; } + priv->secrets_setting_name = NULL; } static gboolean extract_details_from_connection (NMConnection *connection, + const char *secrets_setting_name, const char **username, const char **password, GError **error) { NMSettingConnection *s_con; NMSetting *setting; - const char *connection_type; + const char *setting_name; g_return_val_if_fail (connection != NULL, FALSE); g_return_val_if_fail (username != NULL, FALSE); g_return_val_if_fail (password != NULL, FALSE); - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - connection_type = nm_setting_connection_get_connection_type (s_con); - g_assert (connection_type); + if (secrets_setting_name) + setting_name = secrets_setting_name; + else { + /* Get the setting matching the connection type */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + setting_name = nm_setting_connection_get_connection_type (s_con); + g_assert (setting_name); + + /* In case of bluetooth connection, use GSM or CDMA setting */ + if (strcmp (setting_name, NM_SETTING_BLUETOOTH_SETTING_NAME) == 0) { + if (nm_connection_get_setting_gsm (connection)) + setting_name = NM_SETTING_GSM_SETTING_NAME; + else + setting_name = NM_SETTING_CDMA_SETTING_NAME; + } + } - setting = nm_connection_get_setting_by_name (connection, connection_type); + setting = nm_connection_get_setting_by_name (connection, setting_name); if (!setting) { g_set_error_literal (error, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, "Missing type-specific setting; no secrets could be found."); return FALSE; } - /* FIXME: push this down to the settings and keep PPP manager generic */ if (NM_IS_SETTING_PPPOE (setting)) { *username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting)); *password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting)); @@ -433,7 +415,7 @@ ppp_secrets_cb (NMActRequest *req, goto out; } - if (!extract_details_from_connection (connection, &username, &password, &local)) { + if (!extract_details_from_connection (connection, priv->secrets_setting_name, &username, &password, &local)) { nm_log_warn (LOGD_PPP, "%s", local->message); dbus_g_method_return_error (priv->pending_secrets_context, local); g_clear_error (&local); @@ -448,9 +430,10 @@ ppp_secrets_cb (NMActRequest *req, */ dbus_g_method_return (priv->pending_secrets_context, username, password); -out: + out: priv->pending_secrets_context = NULL; priv->secrets_id = 0; + priv->secrets_setting_name = NULL; } static void @@ -459,7 +442,6 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMConnection *connection; - const char *setting_name; const char *username = NULL; const char *password = NULL; guint32 tries; @@ -470,10 +452,10 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, connection = nm_act_request_get_connection (priv->act_req); nm_connection_clear_secrets (connection); - setting_name = nm_connection_need_secrets (connection, &hints); - if (!setting_name) { + priv->secrets_setting_name = nm_connection_need_secrets (connection, &hints); + if (!priv->secrets_setting_name) { /* Use existing secrets from the connection */ - if (extract_details_from_connection (connection, &username, &password, &error)) { + if (extract_details_from_connection (connection, NULL, &username, &password, &error)) { /* Send existing secrets to the PPP plugin */ priv->pending_secrets_context = context; ppp_secrets_cb (priv->act_req, priv->secrets_id, connection, NULL, manager); @@ -494,7 +476,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, flags |= NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW; priv->secrets_id = nm_act_request_get_secrets (priv->act_req, - setting_name, + priv->secrets_setting_name, flags, hints ? g_ptr_array_index (hints, 0) : NULL, ppp_secrets_cb, @@ -507,8 +489,8 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, } static gboolean impl_ppp_manager_set_state (NMPPPManager *manager, - guint32 state, - GError **err) + guint32 state, + GError **err) { g_signal_emit (manager, signals[STATE_CHANGED], 0, state); @@ -517,14 +499,14 @@ static gboolean impl_ppp_manager_set_state (NMPPPManager *manager, static gboolean impl_ppp_manager_set_ip4_config (NMPPPManager *manager, - GHashTable *config_hash, - GError **err) + GHashTable *config_hash, + GError **err) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMConnection *connection; NMSettingPPP *s_ppp; NMIP4Config *config; - NMIP4Address *addr; + NMPlatformIP4Address address; GValue *val; int i; @@ -533,28 +515,28 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, remove_timeout_handler (manager); config = nm_ip4_config_new (); - addr = nm_ip4_address_new (); - nm_ip4_address_set_prefix (addr, 32); + memset (&address, 0, sizeof (address)); + address.plen = 32; val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_GATEWAY); if (val) { - nm_ip4_address_set_gateway (addr, g_value_get_uint (val)); - nm_ip4_config_set_ptp_address (config, g_value_get_uint (val)); + nm_ip4_config_set_gateway (config, g_value_get_uint (val)); + address.peer_address = g_value_get_uint (val); } val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_ADDRESS); if (val) - nm_ip4_address_set_address (addr, g_value_get_uint (val)); + address.address = g_value_get_uint (val); val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_PREFIX); if (val) - nm_ip4_address_set_prefix (addr, g_value_get_uint (val)); + address.plen = g_value_get_uint (val); - if (nm_ip4_address_get_address (addr) && nm_ip4_address_get_prefix (addr)) { - nm_ip4_config_take_address (config, addr); + if (address.address && address.plen) { + address.source = NM_PLATFORM_SOURCE_PPP; + nm_ip4_config_add_address (config, &address); } else { nm_log_err (LOGD_PPP, "invalid IPv4 address received!"); - nm_ip4_address_unref (addr); goto out; } @@ -665,25 +647,34 @@ nm_cmd_line_add_int (NMCmdLine *cmd, int i) /*******************************************/ +static const char *pppd_binary_paths[] = { + PPPD_PATH, + "/usr/local/sbin/pppd", + "/usr/sbin/pppd", + "/sbin/pppd", + NULL +}; + +static const char *pppoe_binary_paths[] = { + PPPOE_PATH, + "/usr/local/sbin/pppoe", + "/usr/sbin/pppoe", + "/sbin/pppoe", + NULL +}; + static inline const char * -nm_find_pppd (void) +nm_find_binary (const char *paths[]) { - static const char *pppd_binary_paths[] = { - "/usr/local/sbin/pppd", - "/usr/sbin/pppd", - "/sbin/pppd", - NULL - }; - - const char **pppd_binary = pppd_binary_paths; + const char **binary = paths; - while (*pppd_binary != NULL) { - if (g_file_test (*pppd_binary, G_FILE_TEST_EXISTS)) + while (*binary != NULL) { + if (**binary && g_file_test (*binary, G_FILE_TEST_EXISTS)) break; - pppd_binary++; + binary++; } - return *pppd_binary; + return *binary; } static void @@ -805,22 +796,32 @@ create_pppd_cmd_line (NMPPPManager *self, GError **err) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); - const char *ppp_binary; + const char *pppd_binary, *pppoe_binary = NULL; NMCmdLine *cmd; gboolean ppp_debug; g_return_val_if_fail (setting != NULL, NULL); - ppp_binary = nm_find_pppd (); - if (!ppp_binary) { + pppd_binary = nm_find_binary (pppd_binary_paths); + if (!pppd_binary) { g_set_error (err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR, - "Could not find ppp binary."); + "Could not find pppd binary."); return NULL; } + if ( pppoe + || (adsl && strcmp (nm_setting_adsl_get_protocol (adsl), NM_SETTING_ADSL_PROTOCOL_PPPOE))) { + pppoe_binary = nm_find_binary (pppoe_binary_paths); + if (!pppoe_binary) { + g_set_error (err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR, + "Could not find pppoe binary."); + return NULL; + } + } + /* Create pppd command line */ cmd = nm_cmd_line_new (); - nm_cmd_line_add_string (cmd, ppp_binary); + nm_cmd_line_add_string (cmd, pppd_binary); nm_cmd_line_add_string (cmd, "nodetach"); nm_cmd_line_add_string (cmd, "lock"); @@ -833,8 +834,7 @@ create_pppd_cmd_line (NMPPPManager *self, nm_cmd_line_add_string (cmd, ","); ppp_debug = !!getenv ("NM_PPP_DEBUG"); - if ( nm_logging_level_enabled (LOGL_DEBUG) - && nm_logging_domain_enabled (LOGD_PPP)) + if (nm_logging_enabled (LOGL_DEBUG, LOGD_PPP)) ppp_debug = TRUE; if (ppp_debug) @@ -846,21 +846,30 @@ create_pppd_cmd_line (NMPPPManager *self, } if (pppoe) { - char *dev_str; + GString *pppoe_arg; const char *pppoe_service; + char *quoted; - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, "rp-pppoe.so"); + g_assert (pppoe_binary != NULL); + pppoe_arg = g_string_new (pppoe_binary); - dev_str = g_strdup_printf ("nic-%s", priv->parent_iface); - nm_cmd_line_add_string (cmd, dev_str); - g_free (dev_str); + g_string_append (pppoe_arg, " -I "); + quoted = g_shell_quote (priv->parent_iface); + g_string_append (pppoe_arg, quoted); + g_free (quoted); pppoe_service = nm_setting_pppoe_get_service (pppoe); if (pppoe_service) { - nm_cmd_line_add_string (cmd, "rp_pppoe_service"); - nm_cmd_line_add_string (cmd, pppoe_service); + g_string_append (pppoe_arg, " -S "); + quoted = g_shell_quote (pppoe_service); + g_string_append (pppoe_arg, quoted); + g_free (quoted); } + + nm_cmd_line_add_string (cmd, "pty"); + nm_cmd_line_add_string (cmd, pppoe_arg->str); + + g_string_free (pppoe_arg, TRUE); } else if (adsl) { const gchar *protocol = nm_setting_adsl_get_protocol (adsl); @@ -883,9 +892,14 @@ create_pppd_cmd_line (NMPPPManager *self, nm_cmd_line_add_string (cmd, "vc-encaps"); } else if (!strcmp (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, "rp-pppoe.so"); - nm_cmd_line_add_string (cmd, priv->parent_iface); + char *pppoe_arg; + + g_assert (pppoe_binary != NULL); + + pppoe_arg = g_strdup_printf ("%s -I %s", pppoe_binary, priv->parent_iface); + nm_cmd_line_add_string (cmd, "pty"); + nm_cmd_line_add_string (cmd, pppoe_arg); + g_free (pppoe_arg); } nm_cmd_line_add_string (cmd, "noipdefault"); @@ -950,6 +964,10 @@ create_pppd_cmd_line (NMPPPManager *self, nm_cmd_line_add_string (cmd, "lcp-echo-interval"); nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_interval (setting)); + /* Avoid pppd to exit if no traffic going through */ + nm_cmd_line_add_string (cmd, "idle"); + nm_cmd_line_add_int (cmd, 0); + nm_cmd_line_add_string (cmd, "ipparam"); nm_cmd_line_add_string (cmd, priv->dbus_path); @@ -983,9 +1001,9 @@ pppoe_fill_defaults (NMSettingPPP *setting) g_object_set (setting, NM_SETTING_PPP_MRU, (guint32) 1492, NULL); g_object_set (setting, - NM_SETTING_PPP_NOAUTH, TRUE, - NM_SETTING_PPP_NODEFLATE, TRUE, - NULL); + NM_SETTING_PPP_NOAUTH, TRUE, + NM_SETTING_PPP_NODEFLATE, TRUE, + NULL); /* FIXME: These commented settings should be set as well, update NMSettingPPP first. */ #if 0 @@ -1070,9 +1088,9 @@ nm_ppp_manager_start (NMPPPManager *manager, priv->pid = 0; if (!g_spawn_async (NULL, (char **) ppp_cmd->array->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - pppd_child_setup, - NULL, &priv->pid, err)) { + G_SPAWN_DO_NOT_REAP_CHILD, + pppd_child_setup, + NULL, &priv->pid, err)) { goto out; } @@ -1082,7 +1100,7 @@ nm_ppp_manager_start (NMPPPManager *manager, priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager); priv->act_req = g_object_ref (req); - out: +out: if (s_ppp_created) g_object_unref (s_ppp); diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c index e2e5c709..e6ee86f7 100644 --- a/src/ppp-manager/nm-pppd-plugin.c +++ b/src/ppp-manager/nm-pppd-plugin.c @@ -174,13 +174,13 @@ nm_ip_up (void *data, int arg) } hash = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, value_destroy); + NULL, value_destroy); g_hash_table_insert (hash, NM_PPP_IP4_CONFIG_INTERFACE, - str_to_gvalue (ifname)); + str_to_gvalue (ifname)); g_hash_table_insert (hash, NM_PPP_IP4_CONFIG_ADDRESS, - uint_to_gvalue (opts.ouraddr)); + uint_to_gvalue (opts.ouraddr)); /* Prefer the peer options remote address first, _unless_ pppd made the * address up, at which point prefer the local options remote address, @@ -259,22 +259,22 @@ get_credentials (char *username, char *password) size_t len; GError *err = NULL; - if (username && !password) { + if (!password) { /* pppd is checking pap support; return 1 for supported */ + g_return_val_if_fail (username, -1); return 1; } + g_return_val_if_fail (username, -1); g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1); g_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__); - dbus_g_proxy_call (proxy, "NeedSecrets", &err, - G_TYPE_INVALID, - G_TYPE_STRING, &my_username, - G_TYPE_STRING, &my_password, - G_TYPE_INVALID); - - if (err) { + if (!dbus_g_proxy_call (proxy, "NeedSecrets", &err, + G_TYPE_INVALID, + G_TYPE_STRING, &my_username, + G_TYPE_STRING, &my_password, + G_TYPE_INVALID)) { g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s", __func__, err ? err->code : -1, @@ -325,7 +325,9 @@ plugin_init (void) DBusGConnection *bus; GError *err = NULL; +#if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); +#endif g_message ("nm-ppp-plugin: (%s): initializing", __func__); |