platform/core/system/faultd.git
6 years agodm: Add configurable 'activation' decision maker sandbox/pszewczyk/master
Paweł Szewczyk [Tue, 29 Jan 2019 16:35:00 +0000 (17:35 +0100)]
dm: Add configurable 'activation' decision maker

This module allows to bind events to specific actions by using a
configuration file.

Change-Id: I4d406f739df4788d03d9ba99bf247e69409564a3
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoaction: Add unit_start action
Paweł Szewczyk [Tue, 29 Jan 2019 12:44:30 +0000 (13:44 +0100)]
action: Add unit_start action

Change-Id: I86ef58114a55e876ebce14ec2c9e8f44ae428677
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoImprove error handling in sqlite adapter 48/193448/2 tizen
Paweł Szewczyk [Tue, 20 Nov 2018 18:03:43 +0000 (19:03 +0100)]
Improve error handling in sqlite adapter

Change-Id: I02be4a093d3d2e7c43e6bb4c2cba63a4117ee916
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agopackaging: Disable ejdb 35/170835/2 accepted/tizen_5.0_unified accepted/tizen_unified tizen_5.0 accepted/tizen/5.0/unified/20181102.022111 accepted/tizen/unified/20180226.142309 submit/tizen/20180222.151354 submit/tizen_5.0/20181101.000004
Karol Lewandowski [Thu, 22 Feb 2018 10:43:42 +0000 (11:43 +0100)]
packaging: Disable ejdb

Database backend is provided by SQLite.

Change-Id: Idb4283fb7e2e8c5493e937197172e97888d6d1f0

7 years agoMake libejdb usage optional 34/170834/2
Karol Lewandowski [Thu, 22 Feb 2018 10:43:15 +0000 (11:43 +0100)]
Make libejdb usage optional

Since introduction of SQLite backend (preferred), there is no need
to require libejdb anymore.

Change-Id: I6c8da5140fccd994e7fe29d1b283942e615b9959

7 years agoAdd posibility to run faultd in faultctl mode 34/166734/11
Konrad Kuchciak [Wed, 10 Jan 2018 12:23:50 +0000 (13:23 +0100)]
Add posibility to run faultd in faultctl mode

faultctl is a symlink to faultd running in ctl mode.
It's main functionality for now is to show all events stored
in database.

Change-Id: Ic47c8f261fc50778a2514b6273885df8a9ca1824
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix vip-generator issues 49/169549/3
Konrad Kuchciak [Wed, 7 Feb 2018 08:27:20 +0000 (09:27 +0100)]
Fix vip-generator issues

* Service overrides were created in invalid directories
* Config under /etc/faultd/services.conf.d was mandatory, but should be
optional

Change-Id: I6e0ae5070f9135082fa7c25a7f47e66e7925218f
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agosqlite: Load objects by simple queries 36/167136/15
Paweł Szewczyk [Fri, 16 Feb 2018 15:41:00 +0000 (16:41 +0100)]
sqlite: Load objects by simple queries

More advanced queries can be used for filtering objects by other fields
than OID. The simple case of this is implemented here, allowing to find
objects by using few operators.

Change-Id: Id20081b38ea0cfb21f1e675bfcd3a45e375e72ce
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agosqlite: Get objects by id 35/167135/13
Paweł Szewczyk [Mon, 29 Jan 2018 13:14:07 +0000 (14:14 +0100)]
sqlite: Get objects by id

Simplest query is to get an object by its id. This requires only finding
one row by key. Only one table can contain specific id.

Returning result of the query requires building an object based on sql
result and object signature. This commit introduce simple signature
parser in order to properly recreate object structure.

Change-Id: I295ed0a33fc67b5e288c8bfacf6ee4a2d33786f7
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agosqlite: Implement storing objects 34/167134/11
Paweł Szewczyk [Mon, 15 Jan 2018 15:55:53 +0000 (16:55 +0100)]
sqlite: Implement storing objects

This commit introduces the form of object signatures. They have similar
structure to json.

Note that the singature building function is re-purposed for building
other object-specific strings, including sql queries.

Change-Id: I9b268fdb46380fa311abc304116808729e5e1b06
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agosqlite: Manage OIDs 33/167133/9
Paweł Szewczyk [Fri, 16 Feb 2018 13:32:38 +0000 (14:32 +0100)]
sqlite: Manage OIDs

OIDs in sqlite adapter are pairs of integers: table id and row id.
Database handles both numbers internaly when table is created and when
row is inserted.

Change-Id: Ifa7d2a4c6ea822d86705494b26b913941e6c1b80
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agosqlite: Add database initialization 32/167132/8
Paweł Szewczyk [Mon, 15 Jan 2018 15:42:12 +0000 (16:42 +0100)]
sqlite: Add database initialization

At initialization the adapter creates 'meta' table with integer id as key
and signature, which contains information about object structure. Also,
several sql statements are prepared to be used in runtime.

Change-Id: Ib9380d6899601477195390e7fd77483c8dffe4b3
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agosqlite: Add sqlite-based database adapter 88/165888/9
Paweł Szewczyk [Fri, 19 Jan 2018 13:28:58 +0000 (14:28 +0100)]
sqlite: Add sqlite-based database adapter

The skeleton of new module is added and the module added to building
system.

Change-Id: Iee2431c20dcf26cc1b85af530cba085167235463
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agocore: fix possible null pointer dereference 14/169714/1
Paweł Szewczyk [Thu, 8 Feb 2018 12:45:15 +0000 (13:45 +0100)]
core: fix possible null pointer dereference

Change-Id: Ie680786c77848079f31a4f43ba003ca1954f606b
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agostandard_reboot_dm: Change order in db query 31/167131/2
Paweł Szewczyk [Mon, 15 Jan 2018 16:37:57 +0000 (17:37 +0100)]
standard_reboot_dm: Change order in db query

This change fixes the existing queries to the same order as object they
are searching for, however it probably should be handled in more general
way (e.g. sorting fields in queries).

Change-Id: I1e856fd6c714d9e121bc7e9ba2948519a4065aa1
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agodatabase: Remove get_event from ejdb adapter 47/167447/1
Paweł Szewczyk [Wed, 17 Jan 2018 16:21:20 +0000 (17:21 +0100)]
database: Remove get_event from ejdb adapter

This function is only a helper, which can be implemented on higher
abstraction level. For the sake of testing framework, the function is
left as optional in adapter structure for now.

Change-Id: I335b6ffd8572b350573f417847070c06ee8e362d
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agodatabase: Remove new_oid from database adapter 46/167446/1
Paweł Szewczyk [Wed, 17 Jan 2018 14:38:19 +0000 (15:38 +0100)]
database: Remove new_oid from database adapter

Instead of separate mechanism for generating OIDs, we delegate this
task to database_store function.

This removes the requirement to have id field present in stored objects. This
change is essential for database adapters internal handling of objects
IDs, as they are still required to be included in results of queries.

Change-Id: I56478e0ebb2992f46712e99f311ebbf5827de862
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoRework faultd_event_to_string() 46/166346/4
Konrad Kuchciak [Fri, 22 Dec 2017 15:23:29 +0000 (16:23 +0100)]
Rework faultd_event_to_string()

Function to_string() is removed from event's ops, because it was very
simillar to serialization. Printing events is now done by one generic
function faultd_event_to_string(), which serializes an event and prints
faultd_object structure.

Change-Id: Ice3f95480560a1a8306ef49a35a5731090b68ddf
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix recursive str freeing on error 47/166647/2
Konrad Kuchciak [Thu, 11 Jan 2018 09:09:31 +0000 (10:09 +0100)]
Fix recursive str freeing on error

Change-Id: Ib90021823e310f7a2ace329a8269382d01678334

7 years agoAdd function to print faultd_object structure 45/166345/8
Konrad Kuchciak [Mon, 4 Dec 2017 10:30:57 +0000 (11:30 +0100)]
Add function to print faultd_object structure

Change-Id: I4dae5bc06f5fec7cf44cbaefeb1a099cff3de584
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Fix coding style]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoAdd documentation about faultd internals 39/164739/4
Krzysztof Opasiak [Wed, 20 Dec 2017 21:06:47 +0000 (22:06 +0100)]
Add documentation about faultd internals

Change-Id: I82a04ee89a467bb20bf1268e41b2d25d3669b6ea
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoMerge "Rework faultd's configuration mechanism" into tizen
Krzysztof Opasiak [Tue, 9 Jan 2018 13:00:25 +0000 (13:00 +0000)]
Merge "Rework faultd's configuration mechanism" into tizen

7 years agoRework faultd's configuration mechanism 50/163850/11
Konrad Kuchciak [Tue, 12 Dec 2017 10:50:24 +0000 (11:50 +0100)]
Rework faultd's configuration mechanism

Faultd's configuration consists of two main parts,
modules configuration and service configuration.
Each of these is composed of default configuration
and then is overridden by custom/user configuration.

1. Modules

* default config:
/usr/lib/faultd/faultd.conf - main config file
/usr/lib/faultd/modules.conf.d/<mod_name>.conf.d/*.conf -
config pieces for specific module, loaded in lexicographical
order

* custom config:
/etc/faultd/faultd.conf
/etc/faultd/modules.conf.d/<mod_name>.conf.d/*.conf

2. Services

* default config:
/usr/lib/faultd/service.conf.d/<srv_name>.conf.d/*.conf

* custom config:
/etc/faultd/service.conf.d/<srv_name>.conf.d/*.conf

Change-Id: I381ad009221070c5e82f2fbbe4ac896bdf9f189b
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd database adapter as argument to new_oid API 87/165887/2
Paweł Szewczyk [Thu, 4 Jan 2018 15:05:12 +0000 (16:05 +0100)]
Add database adapter as argument to new_oid API

It seems only logical that generating an OID may need information about
database adapter state.

This change does not affect the API used across the code, only existing
adapters. Note it breaks the database modules ABI and render older
database plugins obsolete.

Change-Id: I175b44a8e375914d6c9a1dc8ef8e9271480e0623
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoFix id key used in boot event object 57/166057/1
Paweł Szewczyk [Thu, 4 Jan 2018 11:59:37 +0000 (12:59 +0100)]
Fix id key used in boot event object

This change removes ejdb dependency from startup listener

Change-Id: Ie846ef4eec67790304fd0a021b77313f85497633
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoInitial version of faultd documentation 85/163185/3
Krzysztof Opasiak [Thu, 7 Dec 2017 16:35:02 +0000 (17:35 +0100)]
Initial version of faultd documentation

Change-Id: If93c514d6fe5cf13cdf00be43e81aaaef580f461
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoDisplay test coverage information during building 32/163132/3
Konrad Kuchciak [Thu, 7 Dec 2017 07:13:31 +0000 (08:13 +0100)]
Display test coverage information during building

Change-Id: I380fa6fc614150c6ff6e286a5e791ae1291bcd93
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoMove at_exit global variable to common.c 31/163131/1
Konrad Kuchciak [Thu, 7 Dec 2017 09:47:59 +0000 (10:47 +0100)]
Move at_exit global variable to common.c

This commit removes dependencies to faultd.c. It is needed while
generating test coverage information, as test program will need to have
all sources included except faultd.c

Change-Id: Id8c6cdf8d475021c4c8e86c472deed103de0f920
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoLoad plugins configuration from config file 86/161986/6
Konrad Kuchciak [Tue, 28 Nov 2017 10:39:02 +0000 (11:39 +0100)]
Load plugins configuration from config file

For now, two parameters can be loaded from config:
*n_reboots_before_recovery for standard_reboot_dm
*n_fails_before_reboot for standard_fault_dm

Change-Id: I7422ebeb37cfdab2428e6d708b290cf89229de5b
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoIntegrate mainloop with glib 59/159559/11
Paweł Szewczyk [Wed, 8 Nov 2017 09:52:54 +0000 (10:52 +0100)]
Integrate mainloop with glib

Change-Id: If5079eefdfd3d65638b63c718254cf0878359e2f
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoAdd compile-time option to choose reboot method 52/159252/11
Paweł Szewczyk [Thu, 9 Nov 2017 15:40:41 +0000 (16:40 +0100)]
Add compile-time option to choose reboot method

This commit adds option to reboot system by executing
/sbin/reboot binary. This requires stopping faultd first,
so the exit handler is introduced for postponing
rebooting. It is called just before unloading modules,
which allows it to be implemented by a module, but after
most of the cleanup.

Change-Id: Icb40fe53c158c21412e4c19bd7b655f4e9dfd30d
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix segfault caused by standard_reboot_dm.c 83/159683/2
Konrad Kuchciak [Fri, 10 Nov 2017 13:11:58 +0000 (14:11 +0100)]
Fix segfault caused by standard_reboot_dm.c

Change-Id: Ic85ca0b9e7b0c340c4b5d5624320731bebcfbce3
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Return -ENOENT instead of setting service_name to NULL]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoConfigure faultd to be able to run early 92/159492/5
Karol Lewandowski [Thu, 9 Nov 2017 07:52:20 +0000 (08:52 +0100)]
Configure faultd to be able to run early

This should allow us detecting all the failures from standard
system services (run from multi-user.target)

Change-Id: I1f2c6a01970cd452a4a29b36c2a32fd6c379245b
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
[Squash .service and packaging changes]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agopackaging: Do not try to start when system is started in "factory reset" mode 79/158879/6
Karol Lewandowski [Thu, 9 Nov 2017 14:35:17 +0000 (15:35 +0100)]
packaging: Do not try to start when system is started in "factory reset" mode

"factory reset" procedure might kill daemons and/or replace their data
causing possible failures.  faultd should not try to detect errors when
system is in this mode.

Change-Id: Ibb0bf46780dda57ffa104c1a92ecd10e33c49727
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
[Just dummy rebase]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoAdd new list implementation 49/151049/12
Michal Bloch [Tue, 19 Sep 2017 12:23:09 +0000 (14:23 +0200)]
Add new list implementation

Change-Id: Idb53946d8965faf0f40b270e9c6bf0062c783e82
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
[Reword commit message]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoRemove list implementation 79/151079/2
Krzysztof Opasiak [Tue, 19 Sep 2017 11:12:58 +0000 (13:12 +0200)]
Remove list implementation

Remove current list implementation due to potential
license problems.

Change-Id: I4ce8758d408537c1c4983ce50fb6905d70c91284
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoFix segfault caused by ejdbopen 91/159191/3
Konrad Kuchciak [Tue, 7 Nov 2017 09:58:13 +0000 (10:58 +0100)]
Fix segfault caused by ejdbopen

When power cut occurs or faultd is killed with -9 signal, database
doesn't close properly. In this situation faultd crashes during next
launch. This problem can be solved by removing
/var/db/faultd/faultdb_log.wal file before trying to open database
again.

Change-Id: Ibbc1ac1a618e8df19cf0e63667fe82207fdbb7b5
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix memory leak 20/155520/1
Konrad Kuchciak [Fri, 13 Oct 2017 10:22:13 +0000 (12:22 +0200)]
Fix memory leak

Faultd objects were created in loop, but never unrefed.

Change-Id: I7cd5eeec7c85f7b98555a08be8d819ec9bad0114
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd test services 40/154040/5
Konrad Kuchciak [Tue, 3 Oct 2017 11:28:57 +0000 (13:28 +0200)]
Add test services

This replaces old test programs.
Naming in makefile.am and configure.ac according to unit tests, was also
adjusted to split those two test suites.

Change-Id: I1109e1ab155800e685ae1a5a51a1ff73a94b56e4
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoEnable extra modules by default 16/153916/5
Paweł Szewczyk [Tue, 3 Oct 2017 10:50:15 +0000 (12:50 +0200)]
Enable extra modules by default

Now all extra modules are enabled on installation.

Change-Id: Ia7302637e2a49a7e61067679fcee0b2fb413e8c4
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoAdd standard reboot decision maker 25/151725/7
Konrad Kuchciak [Tue, 19 Sep 2017 11:22:33 +0000 (13:22 +0200)]
Add standard reboot decision maker

This commit adds another scenario to faultd. If three previous reboots
were caused by the same service, reboot system to recovery.

Change-Id: Ia68ed866bbc86f071d320486cf9b278f95a9ffbc
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd support for more advanced querying database 24/151724/8
Konrad Kuchciak [Thu, 21 Sep 2017 15:14:16 +0000 (17:14 +0200)]
Add support for more advanced querying database

Query can now be expanded with another faultd_object called "hints"
which
provides additional querying options like ex. sorting.

Change-Id: I7167e742b16653e37d36a0d310388523c15ab50d
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoRename faultd object type enum 61/153861/5
Konrad Kuchciak [Mon, 2 Oct 2017 09:09:29 +0000 (11:09 +0200)]
Rename faultd object type enum

Change-Id: I2b58fe8a5301ac3315f88fad7979bc6d30a82d32
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoGenerate action executed event when needed 79/137179/10
Krzysztof Opasiak [Tue, 4 Jul 2017 15:10:48 +0000 (17:10 +0200)]
Generate action executed event when needed

Every time when action is executed action executed event should
be generated. To avoid code duplication in each action we put this
into action executor itself.

If some action has to be executed asynchronously it should return
-EPROBE_DEFER from execute() function and then generate event when
execution has been finished.

This commit reworks also all action implementations to make them
compatible with a new interface. A lot of rework has been done esp.
in service_recovery action as it now starts the recovery unit and
delay event generation.

This commit also adds real implementation of recovery action.

Change-Id: I4aeec11e5ffd1bca910fa8a3351d1a6cdad241d8
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix some memory leaks 39/154039/4
Konrad Kuchciak [Thu, 5 Oct 2017 11:24:38 +0000 (13:24 +0200)]
Fix some memory leaks

This commit mainly fixes proper refing/unrefing faultd events, due to
ABI change in event_processor_report_event().

Few other leak fixes and regularities are also included.

Change-Id: I9eeebf8d943cb25414b2e08f999709894c50a9ff
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix cleaning up event queue 24/154524/3
Konrad Kuchciak [Tue, 10 Oct 2017 11:01:13 +0000 (13:01 +0200)]
Fix cleaning up event queue

Unhandled events were poped from the wrong queue, which produced
segfaults during faultd's termination.

Change-Id: I68ed7d61fb65a6f4fda2b8b90f076fd21ebb3348
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd vip-generator program 80/150780/4
Konrad Kuchciak [Wed, 13 Sep 2017 09:56:54 +0000 (11:56 +0200)]
Add vip-generator program

It is meant to be used by systemd to create overrides for VIP
services. The override contains two lines:

[Service]
Restart=no

and prevents service from restarting itself automatically after
failure in order to enter 'failed' state, which is then handled
by faultd.

The override is generated based on config files found
in "/etc/faultd/conf.d/" and placed under
"/run/systemd/generator.early/service_name.service.d/"

Change-Id: I10919964cb8bf0ae304c3771de864c654ee93e93
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoMove parse_service_config() from service.c to new json-config.c file 67/153867/2
Konrad Kuchciak [Mon, 2 Oct 2017 11:39:14 +0000 (13:39 +0200)]
Move parse_service_config() from service.c to new json-config.c file

As other program like vip-generator need access to this functionality,
it should belong to util, not core.

Change-Id: I0b4b5c1e1aeec06720892fad279e808913d0c1a0
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoMerge "Fix variable shadowing" into tizen
Krzysztof Opasiak [Tue, 26 Sep 2017 03:16:01 +0000 (03:16 +0000)]
Merge "Fix variable shadowing" into tizen

7 years agoFix variable shadowing 60/151060/2
Michal Bloch [Tue, 19 Sep 2017 13:20:54 +0000 (15:20 +0200)]
Fix variable shadowing

Change-Id: I523a9b271091fc2e59e04c8fe3c71e00a0dac22c
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
7 years agoFix find_child function 23/151723/1
Konrad Kuchciak [Thu, 21 Sep 2017 15:07:36 +0000 (17:07 +0200)]
Fix find_child function

Recursive searching was not working because of the typo.

Change-Id: I9ea5862c03362237c8067408a32aa9849402efa1
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd log message about performed action 11/149111/4 accepted/tizen/unified/20170922.065535 submit/tizen/20170919.135738 submit/tizen/20170921.100652
Konrad Kuchciak [Mon, 11 Sep 2017 12:16:47 +0000 (14:16 +0200)]
Add log message about performed action

Change-Id: Ib09bdefcf34590d2fc0e30c63ed9bddc5b302874
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd possibility to log to /dev/kmsg 40/149940/4
Konrad Kuchciak [Wed, 13 Sep 2017 14:00:24 +0000 (16:00 +0200)]
Add possibility to log to /dev/kmsg

Change-Id: I531f80e6506f1379b3542abc57801c453daad500
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix faultd cleanup on exit 10/149110/6
Konrad Kuchciak [Mon, 11 Sep 2017 12:08:49 +0000 (14:08 +0200)]
Fix faultd cleanup on exit

Cleanup on exit was performed only when SIGINT received, however during
system reboot systemd is sending SIGTERM to all remaining processes and
faultd was not exitting properly.

Change-Id: I9ab9517ef52790e6c75d10bcf21d4f2fcec87beb
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAllow events to be handled by more than one handler 66/148366/8
Konrad Kuchciak [Wed, 6 Sep 2017 14:51:48 +0000 (16:51 +0200)]
Allow events to be handled by more than one handler

Change-Id: Ie069de32e88bdee7eeacfc19e68bc627b12bfb89
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoRemove semicolon from a macro 39/149939/2
Konrad Kuchciak [Wed, 13 Sep 2017 15:17:48 +0000 (17:17 +0200)]
Remove semicolon from a macro

If macro that ends with semicolon is used inside if else statement,
the else part is ignored and gcc gives an error.

Example:
if (condition)
INIT_QUEUE_HEAD(head);
else

is interpreted as:

if (condition)
                INIT_LIST_HEAD(head);;
        else

Change-Id: I1d1a4e3fdd9115e135c673fe9b771aff607959b2
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix recovering failed services 65/148365/1
Konrad Kuchciak [Thu, 7 Sep 2017 14:24:04 +0000 (16:24 +0200)]
Fix recovering failed services

Change-Id: I57d3a35ef8771a6df778762c2385448f86daf0fb
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFix missing goto finish 15/148015/1
Konrad Kuchciak [Wed, 6 Sep 2017 09:18:03 +0000 (11:18 +0200)]
Fix missing goto finish

Change-Id: I8b4230f251fcf7e0a86a7f4006eb299626a23d5c

7 years agoFix codding style 89/147789/6
Konrad Kuchciak [Tue, 5 Sep 2017 13:54:26 +0000 (15:54 +0200)]
Fix codding style

Change-Id: I9f4c1f7a3a6da62ba4836abf1b8b2c3a8b899e88
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd unit tests for deserialization 27/141427/25
Konrad Kuchciak [Mon, 21 Aug 2017 13:32:46 +0000 (15:32 +0200)]
Add unit tests for deserialization

Change-Id: I896e59f2ce6c140995e4aad1b8010a96f413d8ac
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoFill event's oid when retrieving event from database 90/147790/3
Konrad Kuchciak [Tue, 5 Sep 2017 15:12:03 +0000 (17:12 +0200)]
Fill event's oid when retrieving event from database

Change-Id: I3e6810e69979b81abdbe70175c900a0bea04c874
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd missing deserialization functions 05/147705/7
Konrad Kuchciak [Mon, 4 Sep 2017 14:29:00 +0000 (16:29 +0200)]
Add missing deserialization functions

Change-Id: I8e418657bd8631317ffe96dfe422a51c78e8c39b
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Add missing serialization tests 42/147242/5
Konrad Kuchciak [Fri, 1 Sep 2017 13:38:31 +0000 (15:38 +0200)]
tests: Add missing serialization tests

Added tests for:
* action_executed_event
* faultd_started_event

Change-Id: I2c05bfe580e1ba7355268d0b8c12c49b55f0f1ec

7 years agoStore in database event's oid instead of boot id 15/145515/14
Konrad Kuchciak [Fri, 25 Aug 2017 09:45:45 +0000 (11:45 +0200)]
Store in database event's oid instead of boot id

* database stores event oids so now it is possible to search database
for any event
* implemented function to create event from database
* added static pointer to current boot event
* implemented deserialization of system_booted_event
* adjusted unit tests

Change-Id: I068af4d35193749f0ce008afe2ed942831317e23
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agomodules: Fix segfault in no-modules configuration 01/147001/1
Paweł Szewczyk [Thu, 31 Aug 2017 12:18:06 +0000 (14:18 +0200)]
modules: Fix segfault in no-modules configuration

Change-Id: I2ef4447742c765f8537a8e86f33cf7af773af14b
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoPut modules in shared libraries 50/144950/10
Paweł Szewczyk [Fri, 18 Aug 2017 11:25:50 +0000 (13:25 +0200)]
Put modules in shared libraries

Change-Id: Iec0a3ce3c61390b3080781ca10e4efd5f485a6c9
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agotests: Store pointer to generate_test_attrs() in test data structure 73/145473/5
Konrad Kuchciak [Tue, 22 Aug 2017 10:08:13 +0000 (12:08 +0200)]
tests: Store pointer to generate_test_attrs() in test data structure

Deserialization test will need to call generate_test_attrs more than
once, so the function should be accessed from the setup function as
well as from the test function

Change-Id: I65f8273732f90567920b8d9b82acb05496384953
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Add faultd_object to serialize_test_data structure 72/145472/3
Konrad Kuchciak [Tue, 22 Aug 2017 09:58:15 +0000 (11:58 +0200)]
tests: Add faultd_object to serialize_test_data structure

Every serialization test created it's own faultd_object to serialize to.
Now it is moved to the common test data structure.

Change-Id: I826c95b8dd7868b89de11bcf0eb4fc20ac5f593b
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Add free_test_data function 91/146591/2
Konrad Kuchciak [Mon, 28 Aug 2017 16:17:03 +0000 (18:17 +0200)]
tests: Add free_test_data function

Freeing of the serialize_test_data structure is now done by one function
in helpers.c

Change-Id: I9b0b638e2c7faee461f8b95caa8da8c39a3e5c6c
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Store only pointers to desired variables in tests attrs 97/145197/5
Konrad Kuchciak [Mon, 21 Aug 2017 13:32:08 +0000 (15:32 +0200)]
tests: Store only pointers to desired variables in tests attrs

Desired variables (especially strings) defined by gcc macro #define
cannot be used by generate_test_attrs function, because an address of
the variable is needed.

Change-Id: Ic0aaf99ea388e73f945681a31413efd3e6f8208a
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Rebase onto current head]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agotests: Fix assert_uuid_equal function 90/146590/2
Konrad Kuchciak [Tue, 29 Aug 2017 08:19:23 +0000 (10:19 +0200)]
tests: Fix assert_uuid_equal function

Change-Id: I1e8b50620baf5599528dc77f3e07aeec1a82c1e4
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agodatabase_nop: Return OID on object store attempt 73/145773/6
Paweł Szewczyk [Wed, 23 Aug 2017 15:19:31 +0000 (17:19 +0200)]
database_nop: Return OID on object store attempt

Change-Id: I44b91130f9a389da07dc9d351f1e4c95d8f909b8
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoAdd database API for well-known OIDs 72/145772/5
Paweł Szewczyk [Wed, 23 Aug 2017 13:50:38 +0000 (15:50 +0200)]
Add database API for well-known OIDs

Some well-known objects are stored in database and there should be
universal set of OIDs for them. OIDs however depend on database, so each
database adapter should be able to provide them in its own format.

Change-Id: Ic568dda8e891ba9240f201ecc32a4370a4c51642
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agodatabase: Add oid validation to database abstraction 40/145740/4
Paweł Szewczyk [Wed, 23 Aug 2017 10:32:38 +0000 (12:32 +0200)]
database: Add oid validation to database abstraction

Change-Id: I2657bdb8e2eddc7b5b4cd8d44b35a24f99fb8bd3
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agotests: Add database adapter for testing purposes 39/145739/4
Paweł Szewczyk [Wed, 23 Aug 2017 11:51:58 +0000 (13:51 +0200)]
tests: Add database adapter for testing purposes

Change-Id: I2a8fe6cb432da5120cde1a5133b5fd3c63190157
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoAdd id key to database abstraction layer 38/145738/2
Paweł Szewczyk [Wed, 23 Aug 2017 09:38:18 +0000 (11:38 +0200)]
Add id key to database abstraction layer

Change-Id: I1c1be8bba0aa1c6fb3a3627bc7878c7b38213f47
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoRemove reason's OID checking during serialization 84/145184/2 accepted/tizen_4.0_unified tizen_4.0 accepted/tizen/4.0/unified/20170829.020549 accepted/tizen/unified/20170822.113016 submit/tizen/20170821.133151 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004 tizen_4.0.IoT.p1_release tizen_4.0.IoT.p2_release tizen_4.0.m2_release
Paweł Szewczyk [Mon, 21 Aug 2017 12:49:11 +0000 (14:49 +0200)]
Remove reason's OID checking during serialization

Serialization function should not care about OIDs, because they depend
on database adapter. Reason's OID being zero does not neccessarily mean
the reason is not valid.

Change-Id: Icd792cf20d08099579735edf1362d16256243b44
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoDrop SMACK privilege from System::Privileged to System 56/144956/2 submit/tizen/20170821.012629
Kunhoon Baik [Fri, 18 Aug 2017 12:50:57 +0000 (21:50 +0900)]
Drop SMACK privilege from System::Privileged to System

1) Faultd does not change Smack Label.
2) "System" Privilege has most read/write/access permission for most objects of Tizen.

Thus, Faultd should be executed as "System" Privilege.

Change-Id: I6a8b73995dc71c4181470700462137877eff7182

7 years agoMerge "Fix creating OIDs for database adapters" into tizen accepted/tizen/unified/20170818.000033 submit/tizen/20170817.142242
Karol Lewandowski [Thu, 17 Aug 2017 13:59:33 +0000 (13:59 +0000)]
Merge "Fix creating OIDs for database adapters" into tizen

7 years agoFix creating OIDs for database adapters 18/144718/1
Paweł Szewczyk [Thu, 17 Aug 2017 13:16:31 +0000 (15:16 +0200)]
Fix creating OIDs for database adapters

Different database adapters could have different oid sizes. This commit
fill unused bytes of oid with zeros.

Change-Id: Ida1ec8bd0223c221d12384acbe6bcb0fb78e0018
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
7 years agoAdd CFLAGS/LDFLAGS for ASLR 92/144392/1 submit/tizen/20170816.231957
Łukasz Stelmach [Wed, 16 Aug 2017 10:45:03 +0000 (12:45 +0200)]
Add CFLAGS/LDFLAGS for ASLR

Change-Id: I215a8c004194973c1b54688a91fa806ad71802d7
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
7 years agoAdd unit tests for serialization 07/141207/23
Konrad Kuchciak [Thu, 10 Aug 2017 21:48:24 +0000 (23:48 +0200)]
Add unit tests for serialization

Change-Id: I7a3a22f808b9064ab85bfa1742a0e414539a8758
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Put actual test func into helper, remove copy-paste code]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoAdd unit tests for ejdb module 19/143619/6
Konrad Kuchciak [Wed, 9 Aug 2017 12:13:53 +0000 (14:13 +0200)]
Add unit tests for ejdb module

Testing conversion between faultd_object and bson.

Change-Id: I8f57f4cf1ad005b7a6596112beee49ffab47815e
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Fix found issues]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoImplement conversion between faultd_object and bson 03/142903/9
Konrad Kuchciak [Mon, 7 Aug 2017 14:28:13 +0000 (16:28 +0200)]
Implement conversion between faultd_object and bson

Change-Id: I341da653910f1458b4bb3557b97a2560591b4c28
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Fix helpers.c 18/143618/1
Konrad Kuchciak [Thu, 10 Aug 2017 13:13:40 +0000 (15:13 +0200)]
tests: Fix helpers.c

Get rid of warnings related to pointer casting in
uuid_equal_display_error().
Clear memory before generating UUID in generate_oid().
Generate random uuid in generate_uuid().

Change-Id: I0646b1a4a31da23dbca5411ab659f67c3fca8333
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Add assert functions for missing types 40/143340/4
Konrad Kuchciak [Wed, 9 Aug 2017 09:36:52 +0000 (11:36 +0200)]
tests: Add assert functions for missing types

Change-Id: I6072eca75ba12172d7a7effb379c1e9dc9929492
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Add memory assert in generate_string() 39/143339/3
Konrad Kuchciak [Wed, 9 Aug 2017 09:36:28 +0000 (11:36 +0200)]
tests: Add memory assert in generate_string()

Change-Id: Id95e63e76725e0a09a0689eb049b54236d7f2485
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agoAdd faultd_object_get_oid function 38/143338/1
Konrad Kuchciak [Wed, 9 Aug 2017 09:21:58 +0000 (11:21 +0200)]
Add faultd_object_get_oid function

Change-Id: I371c29be8fc2eff0021e048f811eb8896d394eeb

7 years agoFix serialization/deserialization issues 25/141425/4
Konrad Kuchciak [Mon, 31 Jul 2017 09:22:40 +0000 (11:22 +0200)]
Fix serialization/deserialization issues

Change-Id: Id51a70f7b73c114ae28fbc4740b4275932060569
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotests: Fix TEST_ENTRY_POINT() macro 06/142906/1
Krzysztof Opasiak [Mon, 7 Aug 2017 18:33:30 +0000 (20:33 +0200)]
tests: Fix TEST_ENTRY_POINT() macro

Fix couple of issues:
- remove ptr variable from release builds
- Fix module name used in macro
- Add other macros to help calling this function from test code

Change-Id: If7b35ed4920e1f25121288146df84f8f2946ffb2
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoFix memory leak in faultd_object_new unit test 75/142575/1
Konrad Kuchciak [Fri, 4 Aug 2017 09:43:36 +0000 (11:43 +0200)]
Fix memory leak in faultd_object_new unit test

Change-Id: Iffb32933e15aedfe6ce943f43e0fcc7e7adeddf8
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
7 years agotizen: Disable restarting display-manager.service 91/138991/5
Karol Lewandowski [Mon, 17 Jul 2017 13:52:58 +0000 (15:52 +0200)]
tizen: Disable restarting display-manager.service

display-manager is VIP, meaning its failure has to cause
system reboot.  However, current faultd logic waits for
service to enter failed state before system gets restarted.

Without this patch display-manager never enters failed state
as systemd does not place restartable services in failed state
unless it reaches JobTimeoutSec+StartLimitBurst limits.

This patch disables restart logic in display-manager for above
reason.

Change-Id: I945601caf2b31f0103b09e0d271919b5807e3d6d
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
7 years agopackaging: Disable ejdb module 04/141204/3
Karol Lewandowski [Fri, 28 Jul 2017 12:20:01 +0000 (14:20 +0200)]
packaging: Disable ejdb module

For initial deployment - VIP handling - database support
is not needed.  Compiling-out ejdb support reduces faultd
size by few kb, but more importantly it and drops libejdb.so
library dependency - saving up to 1.3MB of storage.

   text    data     bss     dec     hex filename
  56046    3184     216   59446    e836 db-ejdb/usr/sbin/faultd
  49744    2872     216   52832    ce60 db-nop/usr/sbin/faultd

Change-Id: Ie3bca2f1416b75cd249f138942de92f5632add29
[Rebase onto current HEAD]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoMerge changes Id8957cb4,Iac6be95a into tizen
Krzysztof Opasiak [Thu, 3 Aug 2017 14:53:06 +0000 (14:53 +0000)]
Merge changes Id8957cb4,Iac6be95a into tizen

* changes:
  Drop bson code from core
  Make database backends disableable

7 years agoDisable all modules except for those required for VIP handling 88/141188/2
Karol Lewandowski [Fri, 28 Jul 2017 10:27:57 +0000 (12:27 +0200)]
Disable all modules except for those required for VIP handling

For initial deployment only VIP handling is required, meaning
following modules are left enabled:

 - systemd & startup listeners (for detecting service failures),
 - vip decision maker (triggers system_reboot action)
 - system_reboot action

Disabling rest of modules gives about 20% of .text:

   text    data     bss     dec     hex filename
  63618    5176     208   69002   10d8a before/usr/sbin/faultd
  52423    3248     208   55879    da47 after/usr/sbin/faultd

Change-Id: I49b4d5a0fa605ca0469baef59e7c97078974a550

7 years agoDrop bson code from core 03/141203/2
Karol Lewandowski [Fri, 28 Jul 2017 12:13:09 +0000 (14:13 +0200)]
Drop bson code from core

This commit will cause faultd to be linked to libejdb only
when ejdb module is enabled.

Change-Id: Id8957cb4e95ce7ea48079d53aaad31bceda2cf12
[Rebase to current HEAD]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoMake database backends disableable 02/141202/2
Karol Lewandowski [Fri, 28 Jul 2017 11:53:01 +0000 (13:53 +0200)]
Make database backends disableable

Default to ejdb, if not specified.

Change-Id: Iac6be95a7653ee79802122d80f3c9261ed9ffdfe

7 years agoAdd unit tests for faultd_object type 84/140584/17
Konrad Kuchciak [Tue, 25 Jul 2017 11:54:42 +0000 (13:54 +0200)]
Add unit tests for faultd_object type

Change-Id: I68b144b475979b238dd7f61c2df3dd715506bad6
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Update test to changes in implementation]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoAdd helper sources for unit tests 08/140808/11
Konrad Kuchciak [Wed, 26 Jul 2017 11:07:06 +0000 (13:07 +0200)]
Add helper sources for unit tests

Change-Id: Ie9ebf2ae5bae6e33fde763792e26f416d6834f51
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
[Fix string generation]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agoMake database abstraction layer not depend on ejdb 35/139335/12
Paweł Szewczyk [Tue, 1 Aug 2017 17:28:52 +0000 (19:28 +0200)]
Make database abstraction layer not depend on ejdb

This commit introduces new abstraction layer for databases. Database
logic is separated into independent modules, leaving in core only
generic code.

Change-Id: I6291628b31f96df8d8acae77d659a9da733f2f36
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
[Minor fixes]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>