aboutsummaryrefslogtreecommitdiffstats
path: root/src/main-afb-daemon.c
AgeCommit message (Collapse)AuthorFilesLines
2019-12-12afb-daemon: Fix optionnal portJosé Bollo1-55/+60
Since: - introduction of interface to set the listening port(s) and address(es) - use of nss-localuser for discriminating binders there is no more strict need for exporting the port and substituting it. So the substitution is make only if needed. Since removal of token generation, there is no more need to propoagate any token. The two possibilities are kept for being used whene needed and to ensure sweet transition. Bug-AGL: SPEC-2968 Signed-off-by: José Bollo <jose.bollo@iot.bzh> Change-Id: I1d2b4d765f244e46de3071baddd8b3d0817b9436
2019-12-03main-afb-daemon: manage listening interfacesicefish_8.99.3icefish_8.99.2icefish/8.99.3icefish/8.99.28.99.38.99.2Jose Bollo1-8/+35
This change allows to specify interfaces to serve explicitely. By default the option --port=PORT lead to serving interface of specification "tcp:*:PORT". Meaning that all interfaces are listened. This is intended to be used with localuser family of hostnames. Bug-AGL: SPEC-2968 Signed-off-by: José Bollo <jose.bollo@iot.bzh> Change-Id: I3fb2a77a5c03dd4c2118ebe3267794f79bfc0262
2019-12-03Relax constraint on aliasesJose Bollo1-1/+1
Without relaxing constraint, it is impossible to alias 2 directory contents for the same prefix. Relaxing it is needed for implementing ".well-known" interface. Bug-AGL: SPEC-2968 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh> Change-Id: I339699bbe66ed3df74ed4ac92344646339e5f2ad
2019-12-03afb-context: Move credentials to contextJosé Bollo1-1/+1
The split between context and credentials in requests was somehow artificial and awkward. This change move the credentials to the context and removes as many references to credentials as possible in favor of working on contexts. Change the value returned by afb_auth_check to be 1 if validated, 0 or less than zero if not validated. Bug-AGL: SPEC-2968 Signed-off-by: José Bollo <jose.bollo@iot.bzh> Change-Id: I979dc841e03247e126e3fa8433a1cc0d4108adf0
2019-11-29afb-session: remove initial tokenJose Bollo1-5/+8
Tokens are no more managed by the binder. Bug-AGL: SPEC-2968 Change-Id: Idf1c38105f8ede82cd0ed43aeae3e8e69b9845a3 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-11-20Introduce object for tokensicefish_8.99.1icefish/8.99.18.99.1Jose Bollo1-2/+1
For further optimizations, the token is represented by a specific structure. Bug-AGL: SPEC-2968 Change-Id: I3d46a12c8c16809c6cc1d543fa2e6309927ed84d Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-08-09Avoid lock when child diesJose Bollo1-7/+17
Interaction between pthread_cond_wait, pthread_broadcast and signal may lead to lock when the child of afb-daemon dies. To avoid that sad behavior, this commit defers the call to "job_exit" using lazy job queueing. Bug-AGL: SPEC-2720 Change-Id: Ifd1a56f4a439e1704f79a1291fa01f39b1640f29 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-07-12afb-evt: send events in separate jobJose Bollo1-1/+1
Sending events in the context of the calling process had the consequence that the ordering of the messages had to be removed (see SPEC-2215 & SPEC-2219). This was not good by nature and lead to issues SPEC-2542 and SPEC-2599. Sending events in the context of the calling process also implies to delay the calling process. For this reasons, sending events is now done in an other jobs. For that reason, the count of allowed pending jobs is increased to 100 (was 50). Bug-AGL: SPEC-2215 Bug-AGL: SPEC-2219 Bug-AGL: SPEC-2542 Bug-AGL: SPEC-2599 Change-Id: I5b56d952cc187b65ad6eb9344ad74e5e8d3b7540 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-05-29afb-daemon: Add /tmp has fallback for uploadshalibut_7.99.1halibut/7.99.17.99.1José Bollo1-2/+6
During its start, when implementing HTTP server, afb-daemon checked that the upload directory was accessible and writable and afb-daemon refused to start when it was not the case. When trying to use systemd's DynamicUser for platform services, it had the effect to forbid service to run. That commit add the directory /tmp as a fallback upload directory. Bug-AGL: SPEC-2446 Signed-off-by: José Bollo <jose.bollo@iot.bzh> Change-Id: Ib4ee456d71cb1aefa19e8eed6774ef5f77919366
2019-04-02Add conditionnal support of dynamic bindingsJose Bollo1-0/+2
The load of dynamic bindings becomes removable. This is a step in direction of a tiny binder library. Also refactor AGL_DEVEL Signed-off-by: Jose Bollo <jose.bollo@iot.bzh> Change-Id: If283f431fd8a831429e717b2770464cb54476dc7
2019-04-02Improve setting of optionsJose Bollo1-5/+5
Change-Id: Idbadb9b7b801cb61d527addb5d3137aeb4cf6311 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-04-02jobs: Refactor exiting jobsJosé Bollo1-5/+14
The new termination function can allow the restart because it doesn't abort the waiting jobs. So after calling 'jobs_exit', all threads stop. The function 'job_start' returns. The threads that are in blocking state, i.e. in a call to 'jobs_enter' or 'jobs_call' are stopped. An error status -1 with errno=EINTR is returned in that case. But before returning, that function calls the exit handler if any. Change-Id: I85a4b1976b09b18804eb681af940531ae5ace6c3 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2019-03-29Rename afb-config to afb-argsJosé Bollo1-2/+2
With the introduction of more compilation flags, it becomes interesting to use a configuration file. The configuration file is usually "config.h". So that renaming avoids future ambiguity. It also reflects better what the module does. Change-Id: I952adc1e1bf469132dc224900bd9140ccc51c58b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2019-03-29hooks: Allow to remove hooking (and/or trace)Jose Bollo1-6/+19
This change allows to downsize the binder by removing its internal hooking and tracing features. Change-Id: Ifb080a7426216f6c6b1c8f8e5bf8ddd52df40a3e Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2019-03-27watchdog: Isolate the watchdog from jobsJosé Bollo1-0/+8
Change-Id: Iaa7f71dc7e5d8d525463619b4da980c827722909 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2019-02-06Update copyright datehalibut_7.90.0halibut/7.90.07.90.0José Bollo1-1/+1
Change-Id: I3aaa92b2bfb01699ee8ae609272e93032b6f1a9d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-12-13afb-hsrv: Prepare selection of listening interfacesJose Bollo1-1/+12
The listening socket will no more be the default one but will be the selected ones, with ability to select more than just one listening interface. Nevertheless, the behavior is not changed at the moment. The default interface (0.0.0.0) is still used. A further change will add the ability to select the listening interfaces. That evolution depends on a fix of libmicrohttpd to enable at the same time epoll and no-listen-fd. Bug-AGL: SPEC-1833 Bug-AGL: SPEC-1016 Change-Id: Ia78671cbee90a243ba7b2c724b6155cffbde6920 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-11-08main-afb-daemon: Export variables to connect to binderJosé Bollo1-12/+42
Two new variables are exported that will allow to connect to the binder: - AFB_PORT: the HTTP port that the binder listen - AFB_TOKEN: the initial token that the binder expects These variables are defined only if the HTTP server is started. They are available during initialisation of bindings, even if it is before the real start of the HTTP server. Change-Id: I1b7c8572e3d77b7036a32af47b2a2f1d95803a41 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-10-12APIv3: Allow to write application bindingJosé Bollo1-3/+6
This enable a binding version 3 to declare no API. This is used to start a job that will will run after initialisation. The tutorial tuto-app1 shows how. Run it with: afb-daemon --binding tuto-app1.so A further option could be add to close stdin even if running in foreground, as it was the case before. Change-Id: I2b384d125accb4642eed8e004642ba959326878f Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-09-05main-afb-daemon: Export API after initializationJose Bollo1-3/+7
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é Bollo1-8/+18
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 Bollo1-1/+46
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-02Fix warnings and false errorsJosé Bollo1-1/+1
Change-Id: I434a0bd6be2758fd7964bc272d63dc280d400f47 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-08-02Add ability to provide binding settingsJosé Bollo1-0/+6
Change-Id: Iab93a26340fa9743a58ca43cd903bbf31c783e5b Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-08-02Improve parsing of json stringJose Bollo1-2/+3
Change-Id: I7100961ef8f8a75d623a0667178f191dd4cfb9d3 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
2018-07-27coverage: Improve coverage testJosé Bollo1-2/+1
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-25afb-config: Rewrite the config as JSON objectJosé Bollo1-137/+243
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-16Simplify starting of servicesJosé Bollo1-1/+1
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-13main-afb-daemon: Kill child instead of itJosé Bollo1-1/+1
Killing afb-daemon when exit is called has bad side effects. Because there is no need to do it now, remove it. Change-Id: I18903bb168b1722a522cb4a78c5c8c2508483996 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-supervision: Remove dependency to externalJosé Bollo1-1/+1
Also some cleaning in use of extern to allow accurate grep. Removing extern is better for linking and for structuration. Change-Id: I8121c4b9b34fa2737bffd2ecbe170d04d1d60ad1 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-09main-afb-daemon: Remove call to "nice"José Bollo1-3/+0
Instead of setting the priority in the binder, delegate that responsibility of setting the priority of the process to the launcher. Bug-AGL: SPEC-1578 Change-Id: Ia6bdbdda72ce76fabc19c6448deeb62e2861dce0 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-05supervision: Exclude conditionaly the supervisionJosé Bollo1-1/+5
Exclude from the binder the part related to the supervision when the supervisor is excluded from the build. Change-Id: I41193122d63e47b9f0db7f113f88d2d63b783027 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-06-22Improve documentation of api v3José Bollo1-2/+1
The documentation is improved to reflect the new version. Tune the options Change-Id: I894c3db3bc0c10e89db66a9a51a9ad049bb8c0c4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-06-15api-v3: First draftJosé Bollo1-0/+698
This commit introduces the bindings v3 API for bindings. The documentation has still to be improved and will come very soon. Change-Id: I8f9007370e29f671fdfd1da87fff7372a17db7af Signed-off-by: José Bollo <jose.bollo@iot.bzh>