From 6caade489f8bd15dccdde6c69452d920ead2201e Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 2 Aug 2018 18:48:57 +0200 Subject: Add the external binding feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduce two new features: TODO: manage security by setting correct Smack label to the exported files Bugs-AGL: SPEC-1439 Bugs-AGL: SPEC-1663 Change-Id: I70aad7d523ece7a2ae0058b79708a02ef81144e2 Signed-off-by: José Bollo --- conf/unit/generate-unit-conf/Makefile | 2 +- conf/unit/generate-unit-conf/afm-unit | 6 +- conf/unit/generate-unit-conf/binder.inc | 5 +- conf/unit/generate-unit-conf/provided-api.inc | 72 ++++++++++++++++++++ conf/unit/generate-unit-conf/provided-binding.inc | 33 ++++++++++ conf/unit/generate-unit-conf/provided.inc | 80 ----------------------- conf/unit/generate-unit-conf/service.inc | 10 ++- 7 files changed, 123 insertions(+), 85 deletions(-) create mode 100644 conf/unit/generate-unit-conf/provided-api.inc create mode 100644 conf/unit/generate-unit-conf/provided-binding.inc delete mode 100644 conf/unit/generate-unit-conf/provided.inc (limited to 'conf/unit/generate-unit-conf') diff --git a/conf/unit/generate-unit-conf/Makefile b/conf/unit/generate-unit-conf/Makefile index 5f5346b..562f025 100644 --- a/conf/unit/generate-unit-conf/Makefile +++ b/conf/unit/generate-unit-conf/Makefile @@ -2,7 +2,7 @@ MAIN = afm-unit -FILES = $(MAIN) binder.inc provided.inc service.inc Makefile +FILES = $(MAIN) binder.inc provided-api.inc provided-binding.inc service.inc Makefile DIR = .. diff --git a/conf/unit/generate-unit-conf/afm-unit b/conf/unit/generate-unit-conf/afm-unit index 40a56fc..99d986d 100644 --- a/conf/unit/generate-unit-conf/afm-unit +++ b/conf/unit/generate-unit-conf/afm-unit @@ -53,6 +53,8 @@ define( `UNIT_NAME_SERVICE', `UNIT_NAME_BASE%i.service') define( `UNIT_NAME_API_BASE', `afm-api-$1') define( `UNIT_NAME_API_SERVICE', `UNIT_NAME_API_BASE($1)@$2.service') define( `UNIT_NAME_API_SOCKET', `UNIT_NAME_API_BASE($1)@$2.socket') +define( `UNIT_NAME_BINDING_BASE', `afm-link-$1') +define( `UNIT_NAME_BINDING_SERVICE', `UNIT_NAME_BINDING_BASE($1)@$2.service') define( `APP_DATA_DIR', `/home/%i/app-data') define( `USER_RUN_DIR', `@afm_users_rundir@/%i') define( `DEBUGGING_DIR', `@afm_platform_rundir@/debug') @@ -144,7 +146,9 @@ divert(0)dnl include(service.inc) -include(provided.inc) +include(provided-api.inc) + +include(provided-binding.inc) {{/targets}} ;--------------------------------------------------------------------------------- diff --git a/conf/unit/generate-unit-conf/binder.inc b/conf/unit/generate-unit-conf/binder.inc index 98efd4e..57f4166 100644 --- a/conf/unit/generate-unit-conf/binder.inc +++ b/conf/unit/generate-unit-conf/binder.inc @@ -33,10 +33,13 @@ ENDIF \ {{#required-api}} \ ON_VALUE(auto|ws, --ws-client=unix:USER_RUN_DIR/apis/ws/{{name}}) \ ON_VALUE(dbus, --dbus-client={{name}}) \ - ON_VALUE(link, --binding=USER_RUN_DIR/apis/lib/{{name}}) \ ON_VALUE(cloud, --cloud-client={{name}}) \ ON_VALUE(local, --binding={{:#metadata.install-dir}}/{{name}}) \ {{/required-api}} \ + {{#required-binding}} \ + ON_VALUE(local, --binding={{:#metadata.install-dir}}/{{name}}) \ + ON_VALUE(extern, --binding=USER_RUN_DIR/apis/link/{{name}}) \ + {{/required-binding}} \ {{#provided-api}} \ ON_VALUE(auto|ws, --ws-server=sd:{{name}}) \ ON_VALUE(dbus, --dbus-server={{name}}) \ diff --git a/conf/unit/generate-unit-conf/provided-api.inc b/conf/unit/generate-unit-conf/provided-api.inc new file mode 100644 index 0000000..8a667a9 --- /dev/null +++ b/conf/unit/generate-unit-conf/provided-api.inc @@ -0,0 +1,72 @@ +dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4: +;------------------------------------------------------------------------------- +;---- P R O V I D E D A P I S ---- +;------------------------------------------------------------------------------- + +{{#provided-api}} + +;------------------------------------------------------------------------------- +;---- T H E S E R V I C E O F T H E A P I ---- +;------------------------------------------------------------------------------- +%begin systemd-unit + +# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}} + +%systemd-unit system +%systemd-unit service UNIT_NAME_API_BASE({{name}})@ + +[Unit] +Description=Provides api {{name}} for user %i +X-AFM-API-TYPE={{value}} + +Requires=afm-user-setup@%i.service +After=afm-user-setup@%i.service + +{{#value=ws|auto}} +Requires=UNIT_NAME_API_BASE({{name}})@%i.socket +After=UNIT_NAME_API_BASE({{name}})@%i.socket +{{/value=ws|auto}} + +[Service] +Type=oneshot +RemainAfterExit=yes +{{#value=ws|auto}} +ExecStart=/bin/true +{{/value=ws|auto}} + +%end systemd-unit + + +;------------------------------------------------------------------------------- +;---- T H E S O C K E T O F T H E A P I ---- +;------------------------------------------------------------------------------- +{{#value=ws|auto}} + +%begin systemd-unit + +# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}} + +%systemd-unit system +%systemd-unit socket UNIT_NAME_API_BASE({{name}})@ +[Unit] +Description=Provides websocket api {{name}} for user %i +Requires=afm-user-setup@%i.service +After=afm-user-setup@%i.service +DefaultDependencies=no + +[Socket] +SmackLabel=* +SmackLabelIPIn=System +SmackLabelIPOut=System +ListenStream=USER_RUN_DIR/apis/ws/{{name}} +FileDescriptorName={{name}} +Service=UNIT_NAME_SERVICE + +%end systemd-unit + + +{{/value=ws|auto}} + +{{/provided-api}} + + diff --git a/conf/unit/generate-unit-conf/provided-binding.inc b/conf/unit/generate-unit-conf/provided-binding.inc new file mode 100644 index 0000000..a5636ee --- /dev/null +++ b/conf/unit/generate-unit-conf/provided-binding.inc @@ -0,0 +1,33 @@ +dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4: +;------------------------------------------------------------------------------- +;---- P R O V I D E D B I N D I N G ---- +;------------------------------------------------------------------------------- + +{{#provided-binding}} + +;------------------------------------------------------------------------------- +;---- T H E S E R V I C E O F T H E B I N D I N G ---- +;------------------------------------------------------------------------------- +%begin systemd-unit + +# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}} + +%systemd-unit system +%systemd-unit service UNIT_NAME_BINDING_BASE({{name}})@ + +[Unit] +Description=Provides binding {{name}} for user %i + +Requires=afm-user-setup@%i.service +After=afm-user-setup@%i.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/ln -s {{:#metadata.install-dir}}/{{value}} USER_RUN_DIR/apis/link/{{name}} + +%end systemd-unit + +{{/provided-binding}} + + diff --git a/conf/unit/generate-unit-conf/provided.inc b/conf/unit/generate-unit-conf/provided.inc deleted file mode 100644 index 267e2ed..0000000 --- a/conf/unit/generate-unit-conf/provided.inc +++ /dev/null @@ -1,80 +0,0 @@ -dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4: -;------------------------------------------------------------------------------- -;---- P R O V I D E D A P I S ---- -;------------------------------------------------------------------------------- - -{{#provided-api}} - -;------------------------------------------------------------------------------- -;---- T H E S E R V I C E O F T H E A P I ---- -;------------------------------------------------------------------------------- -%begin systemd-unit - -# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}} - -%systemd-unit system -%systemd-unit service UNIT_NAME_API_BASE({{name}})@ - -[Unit] -Description=Provides api {{name}} for user %i -X-AFM-API-TYPE={{value}} - -Requires=afm-user-setup@%i.service -After=afm-user-setup@%i.service - -{{#value=ws|auto}} -Requires=UNIT_NAME_API_BASE({{name}})@%i.socket -After=UNIT_NAME_API_BASE({{name}})@%i.socket -{{/value=ws|auto}} - -[Service] -Type=oneshot -RemainAfterExit=yes -{{#value=ws|auto}} -ExecStart=/bin/true -{{/value=ws|auto}} -dnl {{#value=link}} -dnl ExecStart=/bin/ln -s {{:#metadata.install-dir}}/ USER_RUN_DIR/apis/link/{{name}} -dnl {{/value=link}} - -dnl %nl -dnl [Install] -dnl WantedBy=afm-user-session@.target -dnl %systemd-unit wanted-by afm-user-session@.target - -%end systemd-unit - - -;------------------------------------------------------------------------------- -;---- T H E S O C K E T O F T H E A P I ---- -;------------------------------------------------------------------------------- -{{#value=ws|auto}} - -%begin systemd-unit - -# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}} - -%systemd-unit system -%systemd-unit socket UNIT_NAME_API_BASE({{name}})@ -[Unit] -Description=Provides websocket api {{name}} for user %i -Requires=afm-user-setup@%i.service -After=afm-user-setup@%i.service -DefaultDependencies=no - -[Socket] -SmackLabel=* -SmackLabelIPIn=System -SmackLabelIPOut=System -ListenStream=USER_RUN_DIR/apis/ws/{{name}} -FileDescriptorName={{name}} -Service=UNIT_NAME_SERVICE - -%end systemd-unit - - -{{/value=ws|auto}} - -{{/provided-api}} - - diff --git a/conf/unit/generate-unit-conf/service.inc b/conf/unit/generate-unit-conf/service.inc index 3efa975..1df4210 100644 --- a/conf/unit/generate-unit-conf/service.inc +++ b/conf/unit/generate-unit-conf/service.inc @@ -40,6 +40,12 @@ ConditionSecurity=smack %nl # Automatic bound to required api +{{#required-binding}} +{{#value=extern}} +BindsTo=UNIT_NAME_BINDING_SERVICE({{name}},%i) +After=UNIT_NAME_BINDING_SERVICE({{name}},%i) +{{/value=extern}} +{{/required-binding}} {{#required-api}} {{#value=auto|ws}} BindsTo=UNIT_NAME_API_SERVICE({{name}},%i) @@ -48,8 +54,8 @@ After=UNIT_NAME_API_SERVICE({{name}},%i) {{/required-api}} {{#provided-api}} {{#value=ws|auto}} -Requires=UNIT_NAME_API_SERVICE({{name}},%i) -After=UNIT_NAME_API_SERVICE({{name}},%i) +Requires=UNIT_NAME_API_SOCKET({{name}},%i) +After=UNIT_NAME_API_SOCKET({{name}},%i) {{/value=ws|auto}} {{/provided-api}} -- cgit 1.2.3-korg