Commit Graph

49 Commits

Author SHA1 Message Date
som
1e08f9ca2c mm-log: hiding personal info while logging
During mm logging, some of the information like simIccId, Telephone
numbers need to be hidden from displaying in the logs to protect
some of the user information.

Implemented for MBIM requiring libmbim 1.27.6, which is the
development version that includes the needed API.
2022-04-20 15:20:34 +02:00
Aleksander Morgado
89bbc2ccb8 core: dump fatal initialization errors to stderr 2021-06-16 11:59:51 +02:00
Dylan Van Assche
38740e9d11 base-manager: add quick suspend/resume base
Quick suspend/resume infrastructure for
synchronizing the interfaces when resuming.
2021-05-26 13:14:52 +00:00
Aleksander Morgado
ff45d292ee libmm-glib: setup common helper to register DBus errors 2021-05-22 22:58:37 +00:00
Aleksander Morgado
4a06a02765 charsets: detect iconv() support in runtime
The only purpose of this is to log what we found, nothing else, as a
quick way to detect platform support for the charsets we need.
2021-02-23 11:35:11 +00:00
Dylan Van Assche
7159b8e27a context: add test-no-suspend-resume cli parameter
Disables suspend/resume support at runtime.
This is useful for modems which are never turned off
or suspended when the host suspends.
2021-02-14 12:27:42 +00:00
Aleksander Morgado
6f82ea3732 log: force using the object logging API
Unless the generic API is explicitly allowed, as in the main.c source
file.
2020-04-09 07:35:56 +02:00
Aleksander Morgado
f1e930d574 core: consolidate logging format in main daemon logic 2020-04-08 16:35:10 +02:00
Aleksander Morgado
3f15293a0b daemon: register G_IO_ERROR_CANCELLED as "Cancelled" in DBus
We have deprecated the use of MM_CORE_ERROR_CANCELLED inside the
daemon in favor of using G_IO_ERROR_CANCELLED right away, and so, we
will now register G_IO_ERROR_CANCELLED as the error mapped to the
"Cancelled" error in the ModemManager error domain in DBus.

We therefore avoid sending unknown/unmapped errors via DBus, as in
this case:

    $ sudo ./test.sh
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    error: couldn't connect the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Cancelled: Connection attempt cancelled'
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    error: couldn't connect the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Cancelled: Connection attempt cancelled'
    successfully disconnected all bearers in the modem
    error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled'
    successfully disconnected all bearers in the modem
2019-10-11 07:27:59 +00:00
Aleksander Morgado
c4bf785d67 filter: allow selection of filter policy on startup
Added a new '--filter-policy=[POLICY]' option in the daemon, which
allows selecting between the supported filter policies. For now, only
two policies are defined:

  * default: the default policy used by ModemManager, where it tries
    to probe and detect as many modem ports as possible.

  * whitelist-only: only devices explicitly tagged via udev (with the
    ID_MM_DEVICE_PROCESS tag) will be probed and used.
2017-12-05 10:58:29 +01:00
Aleksander Morgado
4d6896f0d9 build: rename --with-suspend-resume to --with-systemd-suspend-resume
And only define WITH_SYSTEMD_SUSPEND_RESUME when enabled.

We already have other systemd specific features under the
--with-systemd-* name scheme, so consolidate that, given that we don't
have any other method to support suspend/resume notifications.
2017-06-22 10:51:40 +02:00
Torsten Hilbrich
fd0bed1df9 log: Add support for journal logging
This logging is available if the software was build with the configure
option --with-systemd-journal.

It will be enabled by default if libsystemd is found.

The runtime parameter --log-journal enables to output of log messages
to the systemd journal.

Please note that the journal priority field has the same value as the
syslog level so no conversion is required here.
2017-06-21 13:08:17 +02:00
Aleksander Morgado
57f193bd04 log: remove func loc info unless MM_LOG_FUNC_LOC is defined
The user can build the project passing custom CFLAGS to enable the
function location information, e.g.:

    $ ./configure --prefix=/usr CFLAGS="-DMM_LOG_FUNC_LOC"
2017-05-29 13:42:23 +02:00
Aleksander Morgado
3bb0f7e66d context: rework application options and help output
Group together all options that allow configuring the logging output,
and make them have the same --log-[XXX] prefix.

Also rework the --help output so that all option groups are printed by
default (i.e. there is no longer a --help-all option).
2017-05-29 12:37:36 +02:00
Ben Chan
31655bb5a5 glib: remove invocations of g_type_init()
g_type_init() has been deprecated (and also marked with the attribute
'deprecated') since glib 2.36 as the type system is automatically
initialized. Since the minimum version of glib required by ModemManager
is 2.36, calling g_type_init() isn't necessarily in the ModemManager
code.
2017-02-03 10:05:14 +01:00
Aleksander Morgado
c4a584416a core: allow disabling auto-scan and notifying ports one by one via API
This commit enables a new core ModemManager daemon option, so that automatic
detection of available modems is totally disabled: '--no-auto-scan'. Note that
this option also replaces the previously used '--test-no-auto-scan' option,
which was only used during tests.

Along with the new ModemManager option, a new ReportKernelEvent() method in
the API is defined, which allows notifying the daemon of which interfaces it
should be accessing, as well as the main details of each interface. The only
mandatory parameters in the new method are 'action' (add/remove), 'name' (the
name of the interface) and 'subsystem' (the subsystem of the interface).

The mmcli tool has support for using the new api method via several new options:

 * The '--report-kernel-event' option allows specifying device ports one by
   one, and is a direct mapping of the ReportKernelEvent() method:
     $ sudo mmcli --report-kernel-event="action=add,name=wwan0,subsystem=net"
     $ sudo mmcli --report-kernel-event="action=add,name=cdc-wdm0,subsystem=usbmisc"

 * The '--report-kernel-event-auto-scan' option uses udev monitoring to notify
   events automatically to the daemon. This allows to operate in a way
   equivalent to the default daemon operation (with implicit auto-scan).

Worth noting that the ReportKernelEvent() method is only usable when
'--no-auto-scan' is explicitly used in the daemon. An error will be reported if
the method is tried while standard udev monitoring is enabled (implicit if
auto scan isn't explicitly disabled in the daemon).

If mmcli is going to be used only to report 'real time' events, an optional
'--initial-kernel-events=[PATH]' may be given in the ModemManager call to
automatically process a set of port kernel events one by one on boot. The file
may e.g. contain:
  action=add,name=wwan0,subsystem=net
  action=add,name=cdc-wdm0,subsystem=usbmisc
2016-09-29 15:43:05 +02:00
Aleksander Morgado
b6f8e5f08d suspend: invalidate and remove modems on suspend, reprobe on resume 2015-02-07 12:57:48 +01:00
Jakub Sitnicki
fcfd52df10 core: perform clean-up when terminating due to a Unix signal
Since commit 2d700043ab ("core: use g_unix_signal_add() for more
reliable Unix signal handling") we no longer have to stick to
signal-safe functions in the SIGTERM/SIGINT handler.

Use exit() to terminate so that the clean-up functions are ran and code
coverage data gets written into files.
2015-01-11 19:32:49 +01:00
Aleksander Morgado
c4e7fdf025 core: add --version option to the ModemManager daemon
It was actually included in the man page of the daemon, but we didn't have it.
2014-09-05 11:18:06 +02:00
Aleksander Morgado
ff478e301e manager: rename 'MMManager' to 'MMBaseManager'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 13:23:37 +02:00
Ben Chan
37b0402ee5 core: minor coding style fixes 2014-05-20 09:32:29 +02:00
Aleksander Morgado
f85e345a9e manager: as soon as we know we're going to stop, clear DBus connection
So that the ObjectManager interface doesn't try to signal about e.g. interface
removals; see:

  https://bugzilla.gnome.org/show_bug.cgi?id=715157.
2014-02-13 13:41:52 +01:00
Aleksander Morgado
247a945950 context: new '--test-plugin-dir' to allow specifying where the plugins are 2014-02-13 13:41:50 +01:00
Aleksander Morgado
65f87561c5 context: new '--test-enable' to enable the Test interface 2014-02-13 13:41:25 +01:00
Aleksander Morgado
243720414e context: new '--test-no-auto-scan' to avoid automatic scanning for devices 2014-02-13 13:41:23 +01:00
Aleksander Morgado
bf57da537d context: new '--test-session' allows launching the MM daemon in the session bus 2014-02-13 13:41:20 +01:00
Aleksander Morgado
8450b7b2a3 core: don't automatically probe ports of USB<->serial adapters
We should not automatically probe ports marked as coming from USB to serial
adapters, as we're not sure that a modem is behind the adapter. Still, let the
user request a manual scan and have these devices probed in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=647556
https://bugzilla.gnome.org/show_bug.cgi?id=691076
2013-03-05 19:41:08 +01:00
Dan Williams
2d700043ab core: use g_unix_signal_add() for more reliable Unix signal handling
There were a few problems with MM's existing signal handling, first
of which was that calling g_main_loop_quit() from a signal handler
only works 50% of the time due to severe restrictions on what you
can do from the handler.  This caused INT or TERM to sometimes be
ignored by MM.

Instead, use the glib signal functions which ensure that the handler
is run in the right context, where we can do anything we want.
2013-02-12 15:48:39 -06:00
Aleksander Morgado
88d80935d6 core: second request to terminate does a hard exit() 2012-10-09 16:30:09 +02:00
Aleksander Morgado
41cc66f33a core: log successful shutdown 2012-10-08 09:41:58 +02:00
Aleksander Morgado
c9d22a655a core: don't wait forever to get all modems disabled and removed
Just in case, put a maximum time to wait for all modems to get disabled and
removed, as we don't want to wait forever.
2012-10-08 09:38:46 +02:00
Aleksander Morgado
65c3976cad core: acquire DBus name only after having created the `MMManager'
The `MMManager' is itself also a `GDBusObjectManagerServer'. If we create this
object after having fully acquired the bus name, the client application in the
other side of the bus could be trying to use the ObjectManager interface before
we actually exported it, which is wrong. Therefore, we need to make sure that
the Manager interfaces are all exported before the name is acquired.
2012-09-28 08:42:13 +02:00
Aleksander Morgado
181f9c85f0 log: only include LOC and method name in debug logs if running with --debug
If the modem is started with --log-level=DEBUG, they will not be shown.
2012-03-16 14:53:23 +01:00
Aleksander Morgado
952b9164b9 context: new source files to keep the daemon context 2012-03-16 14:53:18 +01:00
Aleksander Morgado
60c7f7d9ee core: implement the Manager1 DBus interface, based on GDBus
The MMManager object now derives from the gdbus-codegen-generated
MmGdbusOrgFreedesktopModemManager1Skeleton object, and implements the handlers
for the SetLogging() and ScanDevices() DBus methods.

The main program is also modified to be based on GDBus.
2012-03-15 14:14:21 +01:00
Dan Williams
6f08206ac8 core: enable timestamps with legacy --debug option 2011-01-23 23:21:58 -06:00
Dan Williams
16039244bb core: rework logging
Make it more flexible, add logging to a file, and absolute and
relative timestamps.
2011-01-23 20:51:48 -06:00
Dan Williams
5388cf396e core: work around dbus-glib property access bug (CVE-2010-1172) (rh #585394)
More info:
https://bugzilla.redhat.com/show_bug.cgi?id=585394
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-1172

dbus-glib was not properly enforcing the 'access' permissions on
object properties exported using its API.  There were 2 specific bugs:

1) dbus-glib did not enforce the introspection read/write property
permissions, so if the GObject property definition allowed write
access (which is sometimes desirable), D-Bus clients could modify
that value even if the introspection said it was read-only

2) dbus-glib was not filtering out GObject properties that were
not listed in the introspection XML.  Thus, if the GObject defined
more properties than were listed in the introspection XML (which is
also often useful, and MM uses this quite a bit) those properties
would also be exposed to D-Bus clients.

To fix this completely, you need to:

1) get dbus-glib master when the patch is commited, OR grab the
patch from https://bugzilla.redhat.com/show_bug.cgi?id=585394 and
build a new dbus-glib

2) rebuild ModemManager against the new dbus-glib
2010-08-11 15:59:35 -05:00
Dan Williams
afebde4868 build: print version on startup and add dist-version
Distributions should set dist-version at build time with the
package version and revision, so for RPM-based distros you'd

--with-dist-version=%{version}-%{release}

which will be printed out on MM startup to help debugging.
2010-05-21 09:43:47 -07:00
Dan Williams
76130862ed core: cleanly disable modems on shutdown 2010-03-22 15:41:14 -07:00
Dan Williams
783de3bc10 core: fix SIGTERM before mainloop has started 2010-03-09 09:55:04 -08:00
Dan Williams
983e3c9947 core: gracefully handle SIGTERM and SIGINT by shutting down cleanly 2009-06-18 23:22:07 -04:00
Dan Williams
924814c101 udev: move device probing and detection to udev
Get rid of dependency on HAL, using libgudev instead.  Fix up the plugin API
to no longer use either HAL or udev defines, but let plugins use whatever
mechanism they want for getting more information out of the device given the
subsystem and device node name.

Modems are now defined as "master" devices which "own" a one or more ports.
A port could be a serial tty device or a network device or whatever.  The
plugin figures out whether it supports a given port or not and then assigns
it to a new or existing modem.  Modems now have a 'valid' property that
should be set to TRUE when the modem has enough ports to operate correctly.
For devices (ex. 'hso') that use a network device for data transfer, the
modem would need to grab at least one TTY and the network device associated
with that physical device to be 'valid'.

Also move the generic modem support code to a plugin like other modem plugins,
and change the I-support-this-device mechanism to return a number indicating
the level of support.  For example, the generic plugin would return a quite
low number if the device indicates via probing that it can do GSM or CDMA, but
a more specific plugin can indicate better support for the device, and thus
the more specific plugin would win control.
2009-06-18 14:25:30 -04:00
Tambet Ingo
8eb9fa50b4 Handle cases where HAL is not running/disappears/reappears. 2009-04-14 11:43:26 +03:00
Dan Williams
bef9c48ffc add --enable-more-warnings=yes/no and fix up resulting errors 2009-02-10 06:48:56 -05:00
Tambet Ingo
d4e1d7dc8c Fix a typo in error message when MM couldn't acquire it's DBus service name. 2009-02-04 15:24:39 +02:00
Tambet Ingo
fe4e7ee62b Enable/disable debugging on SIGUSR1. 2008-10-30 15:13:51 +02:00
Tambet Ingo
ac4409e7ce Rewrite serial device communications.
Instead of vague "send something, wait something" the responses are now
analyzed by (overridable) parsers. Makes all the modem implementations much
easier since each caller knows without any code whether the call succeeded
or failed.

Another thing that makes modem code simpler (and the whole thing more robust),
is the queueing of sent commands. Each queued command has a command and a
callback which is quaranteed to get called, even if sending failed.

Define and implement error reporting.
2008-09-11 08:35:32 +03:00
Tambet Ingo
cc31458b18 Initial commit. 2008-07-31 09:43:00 +03:00