Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamic domains in mod_roster #3159

Merged
merged 26 commits into from
Jun 29, 2021

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Jun 18, 2021

Main changes:

  • Update roster-related hooks and their handlers to use host types.
  • Update callbacks in mod_roster to use host types.
  • Update all roster backends to implement the new callbacks and support multiple domains and host types.
  • Enable roster-related tests with dynamic domains.

Side changes:

  • Remove deprecated functions from mod_roster. They started becoming tedious to maintain.
  • Change the templating of mod_roster to make the test type section consistent with the top-level ones by excluding the header from the template. This makes the templating itself a bit inconsistent, but IMO other modules can be converted as well. It makes sense to exclude constant parts from the template.
  • Change handling of unexpected roster IQs directed to other JIDs - return errors.
  • Make IQ handlers always respond with error 500 when they throw exceptions.
  • Fix a bug in ejabberd_local (it caused errors for empty feature lists).
  • Fix a bug in inbox tests (not enough cleanup, it was breaking subsequent tests).
  • Fix and enable shared roster tests, they were always skipped.

Not changed:

  • The roster_groups hook is only used by mod_pubsub and has no handlers. It can be removed, but we should figure out whether it needs a fix, as the resulting config field is always an empty list.
  • Migration guide - needs to be addressed later.

Take a quick look at the commit messages for more information.

@codecov
Copy link

codecov bot commented Jun 18, 2021

Codecov Report

Merging #3159 (9ef55c6) into master (3789a21) will increase coverage by 0.74%.
The diff coverage is 92.99%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3159      +/-   ##
==========================================
+ Coverage   79.56%   80.30%   +0.74%     
==========================================
  Files         396      396              
  Lines       32287    32260      -27     
==========================================
+ Hits        25688    25908     +220     
+ Misses       6599     6352     -247     
Impacted Files Coverage Δ
src/mod_shared_roster_ldap.erl 60.81% <ø> (+60.36%) ⬆️
src/mongoose_iq.erl 100.00% <ø> (+11.11%) ⬆️
src/mongoose_iq_handler.erl 57.50% <25.00%> (-3.62%) ⬇️
src/admin_extra/service_admin_extra_roster.erl 87.41% <66.66%> (+0.16%) ⬆️
src/mod_commands.erl 91.83% <71.42%> (-1.37%) ⬇️
...ngoose_client_api/mongoose_client_api_contacts.erl 73.80% <90.00%> (-0.59%) ⬇️
src/mod_roster.erl 79.66% <94.35%> (+3.04%) ⬆️
src/ejabberd_c2s.erl 89.20% <100.00%> (+0.06%) ⬆️
src/ejabberd_local.erl 77.34% <100.00%> (ø)
src/mod_roster_mnesia.erl 93.93% <100.00%> (+2.04%) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3789a21...9ef55c6. Read the comment docs.

@chrzaszcz chrzaszcz force-pushed the mod_roster_with_dynamic_domains branch 3 times, most recently from cba74c2 to 8a08909 Compare June 23, 2021 14:41
Return "internal server error" for all IQ requests, not only for roster.
This is against RFC 6121 for roster set.
For roster get it is unspecified, but very unexpected as well.

Following commits will change the tests and the implementation.
According to RFC6121, section 2.3.3, it is forbidden to send roster set
to another user's JID.
In the current implementation there was only a check if the domain exists,
which would leak information about other tenants served by the system.

Handling of roster get to another user's JID is unspecified by the RFC,
but it makes most sense to handle it the same way - it is better
to return an error than to accept such stanzas, which are most likely
sent by accident.
@chrzaszcz chrzaszcz force-pushed the mod_roster_with_dynamic_domains branch 2 times, most recently from d3ddd91 to d85befc Compare June 28, 2021 13:29
For 'rosterusers' it was there but it was unused.
Two more unused columns are removed: 'subscribe' and 'type'.
The 'raw_to_record' callback was a no-op for all backends.
Rework the backend callbacks:
  - Add the host type
  - Merge all 'get_roster_entry_*' variants into one function
  - Remove unused 'raw_to_record'
  - Define types for cleaner and shorter type specs

Make 'set_roster_item_t' return an error if a non-existing item is removed.
This allows to reduce the extra check before calling 'set_roster_item'.
@chrzaszcz chrzaszcz force-pushed the mod_roster_with_dynamic_domains branch from d85befc to 765da85 Compare June 28, 2021 13:31
@chrzaszcz chrzaszcz force-pushed the mod_roster_with_dynamic_domains branch from 765da85 to 3e5cd0e Compare June 28, 2021 15:20
@chrzaszcz chrzaszcz marked this pull request as ready for review June 28, 2021 17:55
Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Copy link
Collaborator

@DenysGonchar DenysGonchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@DenysGonchar DenysGonchar merged commit 20480a5 into master Jun 29, 2021
@DenysGonchar DenysGonchar deleted the mod_roster_with_dynamic_domains branch June 29, 2021 13:10
@Premwoik Premwoik added this to the 5.0.0 milestone Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants