aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2018-09-24afb-socket: API name cares of abstract UDSJose Bollo1-1/+3
Change-Id: Ie485672d8f66ff32ea20cb0eb313690ba380db4a Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-09-14afb-session: Fix an issue in managing sessionsJosé Bollo1-2/+2
Probably an old copy/paste error in the commit d45426257d5149c735e33e3055220625a919e7bc It doesn't affect version EE (Electric Eel). Bug-AGL: SPEC-1735 Change-Id: Ia1536e141ac12275000196a3218eb62d77b36a06 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-09-07afb-apiset: fixed the error message upon api open.flounder_5.99.6flounder/5.99.65.99.6Thierry Bultel1-2/+2
just a typo Change-Id: I2963c2568cffdc89f577e99f2280da6dcb732b04 Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-09-06afb-session: Use ad-hoc pseudo-random uuidJose Bollo1-0/+50
The use of the generator given by the lib uuid implies the use of the system call 'getrandom' without the flag GRND_NONBLOCK. It has a weird effect on boot because many binders require the generation of uuid at the same time but getrandom is subject to starving. This introduced a tiny pseudo-random generation of UUID that does not implies the use of 'getrandom'. Bug-AGL: SPEC-1655 Change-Id: I5131072881d7a53f0edda9e36762985c96a04550 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-09-05main-afb-daemon: Export API after initializationJose Bollo3-5/+9
Exporting API after initialization is a simple technic to avoid interleaving of incoming foreign calls during initialisation. Also a tiny fix in jobs.c and afb-socket.c. Bug-AGL: SPEC-1724 Change-Id: I59596256481c8afcd88755ec303bf7f881b55c12 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-28Allow choice to trap or not program faultsJosé Bollo5-29/+110
The binder traps faults by default to recover as much as possible from unexpected errors. Developers may need to remove that behaviour to get core file. This introduces 2 ways to set or remove the trapping of faults: - the environment variable AFB_TRAP_FAULTS - the command line option --trap-faults Both take a boolean value set using on of the following words: 1 yes true on -- enable trapping of faults (the default) 0 no false off -- disable trapping of faults Bug-AGL: SPEC-1702 Change-Id: I6c6a3b933dbda9922a6079c390a601c533d49e55 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-28main-afb-daemon: Set AFB_ROOTDIR and AFB_WORKDIR in environmentJose Bollo2-3/+48
It may be difficult to retrieve the root directory from bindings and from process spawn by option --exec. In the same way, well identifying the workdir might interest programs or bindings. So, from now, the environment variables below are set: - AFB_ROOTDIR: identify the rootdir as set by --rootdir and in the context of AGL it will be the widget directory - AFB_WORKDIR: identify the workdir as set by --workdir To avoid any confusion, the function realpath is used to export absolute path names. Bug-AGL: SPEC-1694 Change-Id: Id272e009ca975e28aaab8b14fa2a98fbd2216e73 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh> Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-27afb-hook-flags: Fix a compilation warningJose Bollo1-1/+1
Change-Id: Ic9d1cc44ef1bbf6db4afe8eb7016b05f4cddb9a4 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-23jobs: Abort when systemd's event loop lostflounder_5.99.4flounder/5.99.45.99.4José Bollo1-1/+2
When sd_event_prepare returns an error there is currently no way to restore the event loop working. It happens when a callback of an sd_event is faulty (ex: SIGSEGV). In that case the monitoring of signals (sig-monitor) interfer badly with systemd. But at the the application firstly has error. To avoid flooding the journal with messages, aborting is the best solution. Bug-AGL: SPEC-1681 Change-Id: If01295f07b3c3fc8c8ec1ac5bf04840d42ee9774 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-23afb-stub-ws: Add reconnection of ws-clients on needJosé Bollo3-6/+67
This implementation detects deconnections and try to reconnect lazily on need. Bug-AGL: SPEC-1668 Change-Id: Ib2a20a4578f2da80afe1564c42de96c4aa250e64 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-23afb-stub-ws: Safe handling of deconnectionsJose Bollo3-134/+166
This commit also include many comments and improvements in naming of functions. Bug-AGL: SPEC-1668 Change-Id: I1b5dd95678d94e9edfca1c598c5697e90bb9e5bf Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-23afb-stub-ws: Process error on call to remoteJosé Bollo1-2/+6
Change-Id: I8bb96419cfac3da88e75da42c66a5d359ec7c666 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-23Send error replies on disconnectionJose Bollo3-4/+40
The pending calls receive an error notification when the server hang up. Bug-AGL: SPEC-1668 Change-Id: I052dca5e338a7650d7630856e21f1d3a81c6f265 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-23afb-wsj1: Split 'wsj1_on_text' in 2José Bollo1-23/+50
This improves the code and also prepare answering diconnected on server hangup. Bug-AGL: SPEC-1668 Change-Id: I2cf5a75bc2db6e9a0fd0cab88c7ff3cb9fd06242 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-23afb-stub-ws: Clean upJose Bollo1-10/+0
Change-Id: I6fbe737d4986fd18f9675942cd7ad75966125343 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-22afb-api-ws: Use afb-socket featuresJose Bollo1-92/+85
Use the feature of afb-socket to handle the api name. Bug-AGL: SPEC-1668 Change-Id: Ib13891d7948c75bc5d342b45c774f8e6c3ea016e Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-22afb-socket: ImprovementJose Bollo3-69/+194
Allows to either open a 'struct fdev*' or a int. This prepares further integration in afb-api-ws. Bug-AGL: SPEC-1668 Change-Id: I3d61be582bceaab636460b3c7de3ac2f24ed9473 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-22afb-stub-ws: Improve namingJose Bollo4-4/+4
The function afb_stub_ws_on_hangup is now named afb_stub_ws_set_on_hangup. Bug-AGL: SPEC-1668 Change-Id: Ie96c77d4af10ee6b42aea6f57d7c3aadb95e6467 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-08afb-export: Provide the real path of the bindingflounder_5.99.3flounder/5.99.35.99.3José Bollo1-2/+6
The path can be a symbolic link. It must be resolved to be usefull. Change-Id: I5db247fd9925065684e036d8d458c2131006f9db Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-02Fix warnings and false errorsJosé Bollo3-3/+3
Change-Id: I434a0bd6be2758fd7964bc272d63dc280d400f47 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-02afb-export: Manage path of librariesJosé Bollo9-49/+87
This change allows a binding to know its installation path. This path is retrieved using the api function 'afb_api_settings'. The path is returned --if known-- as a string of key "binding-path". Change-Id: Ie1a349dc4936d4ccf173f1f77e118099f7f0599a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-02Add ability to provide binding settingsJosé Bollo8-35/+223
Change-Id: Iab93a26340fa9743a58ca43cd903bbf31c783e5b Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-02Improve parsing of json stringJose Bollo7-25/+46
Change-Id: I7100961ef8f8a75d623a0667178f191dd4cfb9d3 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-02afb-socket: Separate socket creationJosé Bollo6-167/+321
The objective is to have a well identified and possibly reusable internally. Change-Id: Icdb6ce7d85ae26373cfe4f0b492fe97b74ed747c Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-02afb-msg-json: remove obsolete functionJose Bollo3-11/+9
The function afb_msg_json_internal_error was based on the previous reply standard and was not used very much. Removing it seems a good idea. Change-Id: I3dddee9c24ffd8c43c787b9b6a737ab013d757b7 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-02afs-supervisor: Improve commentsJosé Bollo1-0/+16
Change-Id: Ic1954403e3924def8fc9fa395ac54e4c5ee6293a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-27coverage: Improve coverage testJosé Bollo7-21/+212
The test now raise an overall coverage rate: lines......: 75.4% (8356 of 11080 lines) functions..: 80.4% (1094 of 1360 functions) Also Improve the documentation and improve parts of code. Change-Id: Ic2b8bc2f85d4181aa0b358a953f95cb105a0eed9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-27afb-export: Set API context as validatedJosé Bollo1-0/+1
An API is always valid internally to the binder. Change-Id: I3c8eed166c9cfc1bcc47daa30c8f327af777d136 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-26main-afb-client-demo: Exit with a significant codeJosé Bollo1-12/+27
The program afb-client-demo now exits whith one of the following code: 0 - everything went well, no error 1 - last received answer was an error 2 - the remote hung up the connection 3 - stdin either has too long line (16384) or has error 4 - bad argument of the command line 5 - cant connect to remote Bug-AGL: SPEC-1619 Change-Id: Ia979c9ddcdae496ce205882b895cd9742f93f365 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-25Tune dependency to fdev-epollJose Bollo3-22/+21
The dependency to fdev-epoll is not real at the moment because afb-daemon still uses systemd event loop mechanisms. At the end use of it will depend on the conditional compilation flag as REMOVE_SYSTEMD_EVENT here. Change-Id: I46e65cddafef05a9418cd4cf4d5cbf596ebeda49 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-07-25afb-api-v3: Simplify the codeJose Bollo1-11/+8
Having a code more easy to read is better here. Change-Id: I429e82d87729e41ec53d0852daa6f146261443c9 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-07-25fdev: Simplify the codeJosé Bollo2-21/+1
Less code is faster and safer. Change-Id: Ide71fec5ee80f14482e2972a3d0f65ef0b589f12 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-25Fix some more memory leaksJose Bollo2-27/+6
While making coverage test, few leaks appeared. This corrects the last discorvered ones. Change-Id: Id9e508bc9412072b628742971b02dd3d62799f3f Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-07-25afb-config: Rewrite the config as JSON objectJosé Bollo10-1078/+1147
Despite its poor performance, this changes is good at the end because: - it allows to put config in files - it removes dirty code to translate to JSON - it removes dirty code to dump the config - it unifies code for scanning hook's flag's names - it improves unity of naming between option's names and JSON's names Change-Id: I2487c8746d78a0cff80505a12b9fa60e40da9951 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-24main-afb-daemon: Reorder instantiation of APIJosé Bollo1-6/+3
The client API are now instanciated after the server API. This allows to be client of itself but forbids to export (serve) a client API. Change-Id: I9b19180cfb60108344c2f846427e964df8339430 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-24json-c: Remove escaping of slashsJosé Bollo11-54/+89
By default json-c escapes the slashes. This is almost ugly and unuseful. But the resolution (with JSON_C_TO_STRING_NOSLASHESCAPE) was introduced lately by json-c. Integrate it as much as possible. Change-Id: Ia9c4bee78dc11df1ee9640cb04311991bd860e43 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-24coverage and test: Add testsJose Bollo2-0/+354
coverage values: - lines: 70.5 % - functions: 76.3 % Change-Id: Iaf802e84bbfa57502bbbac8c3b567b14c01608b6 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-07-24afb-api: Define the function afb_api_is_publicJosé Bollo3-2/+8
And remove the info line setting that the API . is added. Change-Id: I42e247036b9a1016797bb2674ad95f8a8c30e9be Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-24afb-export: Fix event handler of APIJosé Bollo1-2/+2
Change-Id: Ibadaf6f41e39cce398d33a2a2a73751d68dad34d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-19afb-config: Simplify version printflounder_5.99.2flounder/5.99.25.99.2José Bollo1-52/+45
Change-Id: Ia9fc00fbb04a27a46dd66cb60e9b359645f9dc11 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-19afb-trace: Fix bug on uuid of session's eventsJosé Bollo1-1/+1
Change-Id: I4e4c2f337ae61a3399c7c97cfd028411f1471f98 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-19afb-trace: Fix bug in session handlingJosé Bollo1-1/+1
A copy-paste error! Change-Id: Iaf7bd9f3cbd62cddfbab04fecc685f334f983175 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-16Simplify starting of servicesJosé Bollo9-75/+55
The previous version was confusing and was expecting that onneed and share_session were always true. Removing this parameter simplifies the code. Also handle errors of required classes and apis at initialisation. Change-Id: I7c99aa356cba41f368bd47cab797fa086a5740af Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-trace: Fix compiling error on old json-cJosé Bollo1-3/+4
Versions of json-c older than 0.12 doesn't have the function json_object_new_double_s. Change-Id: If34c36ddcfabb3796aeb6739cd150e2b3e763679 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-hook & afb-trace: Fix usage of readlinkJosé Bollo2-4/+14
The function readlink doesn't add a terminating null. This patch fixes that were needed. Change-Id: Ie15309471fe8203c8e98b97315c4ea30de3ccd75 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-wsj1: Fix json parsing of unterminatedJosé Bollo1-0/+2
When receiving 'false', 'true' or 1, the tokener isn't able to terminate its job without ambiguity. Catch this case to force a terminating character. Change-Id: I5c78f759852060ccf0fac87b3f6fc33a65bf30c9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-api-v3: Fix wrong error messageJosé Bollo1-2/+3
Change-Id: Idc2d85ccf71fb7c88a3bbcf981c316b5ba70f434 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-apiset: Try to initialize all APIsJosé Bollo1-3/+4
Don't stop on the first error when initializing apis. Record the error and return it at the end. Change-Id: I1f0f50ff4e527ca5bf0e78904fccddafe54ba5f2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-export: Monitor calls to API initialisationJosé Bollo1-19/+49
Catching SEGV or other exceptional execution error is better for the whole process. Change-Id: I0ece72abe5e0a7ebd7d29aafa416462e6e5963af Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-api-so-v2: Monitor the preinit to catch SEGVJosé Bollo1-1/+24
Add monitoring of preinitialisation of bindings v2 in the hope to better handle arbitrary code execution. Change-Id: I86354caedb17ef9d4904c1f4f47b1ea3c6dd4c40 Signed-off-by: José Bollo <jose.bollo@iot.bzh>