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

mod_conversejs: exception error: module_not_loaded,mod_register #3824

Closed
marzzzello opened this issue May 20, 2022 · 3 comments
Closed

mod_conversejs: exception error: module_not_loaded,mod_register #3824

marzzzello opened this issue May 20, 2022 · 3 comments
Assignees
Labels
Packaging:Container Container image from GitHub Packages

Comments

@marzzzello
Copy link

Environment

  • ejabberd version: 22.5.3
  • Erlang version: erl +V
  • OS: Linux (Ubuntu)
  • Installed from: ghcr.io/processone/ejabberd:latest

Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml

Click to expand!
## Logging
loglevel: notice
hide_sensitive_log_data: true

## Language
language: en
hosts:
  - domain0.tld
  - domain1.tld

sql_type: pgsql
sql_server: ejabberd-db
sql_database: ejabberd
sql_username: ejabberd
sql_password: xxxxxxxxxxxxxxxxxx
auth_method:
  - sql
# - anonymous
# anonymous_protocol: both
# allow_multiple_connections: true

default_db: sql
new_sql_schema: true

define_macro:
  ## TLS configuration
  TLS_CIPHERS: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  TLS_OPTIONS:
    - no_sslv3
    - no_tlsv1
    - no_tlsv1_1
    - cipher_server_preference
    - no_compression
  DH_FILE: /opt/ejabberd/conf/dh4096.pem
  DOMAIN0_CERT: /opt/ejabberd/certs/domain0.tld/cert.pem
  DOMAIN0_KEY: /opt/ejabberd/certs/domain0.tld/key.pem
  DOMAIN1_CERT: /opt/ejabberd/certs/domain1.tld/cert.pem
  DOMAIN1_KEY: /opt/ejabberd/certs/domain1.tld/key.pem

certfiles:
  - DOMAIN0_CERT
  - DOMAIN0_KEY
  - DOMAIN1_CERT
  - DOMAIN1_KEY

c2s_ciphers: TLS_CIPHERS
s2s_ciphers: TLS_CIPHERS
c2s_protocol_options: TLS_OPTIONS
s2s_protocol_options: TLS_OPTIONS
c2s_dhfile: DH_FILE
s2s_dhfile: DH_FILE
s2s_use_starttls: required

listen:
  - port: 5222
    ip: "::"
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    starttls_required: true
    protocol_options: TLS_OPTIONS
  - port: 5223
    ip: "::"
    tls: true
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    protocol_options: TLS_OPTIONS
  - port: 443
    ip: "::"
    tls: true
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    protocol_options: TLS_OPTIONS
  - port: 5269
    ip: "::"
    module: ejabberd_s2s_in
    max_stanza_size: 524288
  - port: 5270
    ip: "::"
    module: ejabberd_s2s_in
    max_stanza_size: 524288
    tls: true
    protocol_options: TLS_OPTIONS
  - port: 5080
    ip: "::"
    module: ejabberd_http
    tls: false
    request_handlers:
      /account: mod_register_web
      /admin: ejabberd_web_admin
      /api: mod_http_api
      /bosh: mod_bosh
      /captcha: ejabberd_captcha
      /upload: mod_http_upload
      /ws: ejabberd_http_ws
      /conversejs: mod_conversejs
  # stun for domain0.tld
  - port: 3478
    transport: udp
    module: ejabberd_stun
    use_turn: true
    auth_realm: domain0.tld
    turn_min_port: 65435
    turn_ipv4_address: x.x.x.x
    turn_ipv6_address: "x:x:x::"
  - port: 5349
    transport: tcp
    tls: true
    certfile: DOMAIN0_CERT
    auth_realm: domain0.tld
    module: ejabberd_stun
    use_turn: true
    turn_min_port: 65435
    turn_ipv4_address: x.x.x.x
    turn_ipv6_address: "x:x:x::"
  # stun for domain1.tld
  - port: 3479
    transport: udp
    module: ejabberd_stun
    use_turn: true
    auth_realm: domain1.tld
    turn_min_port: 65435
    turn_ipv4_address: x.x.x.x
    turn_ipv6_address: "x:x:x::"
  - port: 5350
    transport: tcp
    tls: true
    certfile: DOMAIN1_CERT
    auth_realm: domain1.tld
    module: ejabberd_stun
    use_turn: true
    turn_min_port: 65435
    turn_ipv4_address: x.x.x.x
    turn_ipv6_address: "x:x:x::"

## Disabling digest-md5 SASL authentication. digest-md5 requires plain-text
## password storage (see auth_password_format option).
disable_sasl_mechanisms:
  - digest-md5
  - X-OAUTH2

  ## Store the plain passwords or hashed for SCRAM:
auth_password_format: scram

## Full path to a script that generates the image.
captcha_cmd: /opt/ejabberd/captcha/captcha.sh
captcha_url: https://xmpp.domain0.tld/captcha
captcha_limit: 5

## Access Rules
acl:
  admin:
    user:
      - marzzzello@domain0.tld
      - admin@domain1.tld
  local:
    user_regexp: ""
  loopback:
    ip:
      - 127.0.0.0/8
      - ::1/128
      - ::ffff:127.0.0.1/128

access_rules:
  local:
    allow: local
  c2s:
    deny: blocked
    allow: all
  announce:
    allow: admin
  configure:
    allow: admin
  muc_create:
    allow: local
  pubsub_createnode:
    allow: local
  register:
    allow: all
  trusted_network:
    allow: loopback

oauth_access: all

api_permissions:
  console commands:
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  admin access:
    who:
      access:
        allow:
          - acl: admin
      oauth:
        scope: ejabberd:admin
        access:
          allow:
            - acl: admin
    what:
      - "*"
      - "!stop"
      - "!start"
  public commands:
    who: all
    what:
      - status
      - stats
      - connected_users_number
      - incoming_s2s_number
      - outgoing_s2s_number

## Speed in byte/s
shaper:
  normal:
    rate: 3000
    burst_size: 20000
  fast: 100000

shaper_rules:
  max_user_sessions: 10
  max_user_offline_messages:
    5000: admin
    500: all
  c2s_shaper:
    none: admin
    normal: all
  s2s_shaper: fast

modules:
  mod_adhoc: {}
  mod_admin_extra: {}
  mod_announce:
    access: announce
  mod_avatar: {}
  mod_blocking: {}
  mod_bosh: {}
  mod_caps: {}
  mod_carboncopy: {}
  mod_client_state: {}
  mod_configure: {}
  ## mod_delegation: {}   # for xep0356

  mod_fail2ban: {}
  ## mod_http_api: {}
  mod_http_upload:
    put_url: https://xmpp.@HOST@/upload/
    hosts:
      - xmpp.@HOST@
    thumbnail: false # TODO https://github.com/processone/ejabberd/issues/3823
    max_size: 5368709120
    custom_headers:
      Access-Control-Allow-Origin: "*"
      Access-Control-Allow-Methods: GET,HEAD,PUT,OPTIONS
      Access-Control-Allow-Headers: Content-Type
  mod_http_upload_quota:
    max_days: 7
  mod_last: {}
  mod_mam:
    assume_mam_usage: true
    default: always
    request_activates_archiving: true

  ##############################################################################
  # New line that causes error:
  mod_conversejs: {}
  ##############################################################################

  mod_muc:
    access:
      - allow
    access_admin:
      - allow: admin
    access_create: muc_create
    access_persistent: muc_create
    access_mam:
      - allow
    default_room_options:
      mam: true
      persistent: true
      public: false
      public_list: false
    history_size: 100
    max_users: 500
  mod_muc_admin: {}
  mod_offline:
    access_max_user_messages: max_user_offline_messages
  mod_ping: {}
  mod_pres_counter:
    count: 5
    interval: 60
  mod_privacy: {}
  mod_private: {}
  mod_proxy65: {}
  mod_pubsub:
    access_createnode: pubsub_createnode
    plugins:
      - flat
      - pep
    force_node_config:
      "eu.siacs.conversations.axolotl.*":
        access_model: open
      storage:bookmarks:
        access_model: whitelist
  mod_push: {}
  mod_push_keepalive: {}
  mod_register_web: {}
  mod_roster:
    versioning: true
  mod_s2s_dialback: {}
  mod_shared_roster: {}
  mod_sic: {}
  mod_stream_mgmt:
    resend_on_timeout: if_offline
  mod_stun_disco:
    secret: QUutVg65LCiApt72IAtmrq2TwHG927avg6ADkNyfSv
  mod_vcard:
    search: false
  mod_vcard_xupdate: {}
  mod_version:
    show_os: false

append_host_config:
  domain0.tld:
    modules:
      mod_disco:
        server_info:
          - modules: all
            name: abuse-addresses
            urls:
              - mailto:xmpp@domain0.tld
          - modules: all
            name: support-addresses
            urls:
              - mailto:xmpp@domain0.tld
          - modules: all
            name: admin-addresses
            urls:
              - mailto:xmpp@domain0.tld
      mod_register:
        ip_access: all
        captcha_protected: true
        password_strength: 64
        access: register
        registration_watchers:
          - marzzzello@domain0.tld
        welcome_message:
          subject: Willkommen bei domain0.tld / Welcome to domain0.tld!
          body: |-
            [...]

  domain1.tld:
    modules:
      mod_disco:
        server_info:
          - modules: all
            name: abuse-addresses
            urls:
              - mailto:xmpp@domain1.tld
          - modules: all
            name: support-addresses
            urls:
              - mailto:xmpp@domain1.tld
          - modules: all
            name: admin-addresses
            urls:
              - mailto:xmpp@domain1.tld
      mod_register:
        ip_access: all
        captcha_protected: true
        password_strength: 64
        access: register
        registration_watchers:
          - admin@domain1.tld
        welcome_message:
          subject: Willkommen bei domain1.tld / Welcome to domain1.tld!
          body: |-
            [...]

Errors from error.log

Click to expand!
2022-05-20 23:17:27.226005+00:00 [error] <0.2302.0>@proc_lib:crash_report/4:525 CRASH REPORT:
  crasher:
    initial call: ejabberd_http:init/3
    pid: <0.2302.0>
    registered_name: []
    exception error: {module_not_loaded,mod_register,<<"xmpp.domain0.tld">>}
      in function  gen_mod:get_module_opts/2 (src/gen_mod.erl, line 338)
      in call from gen_mod:get_module_opt/3 (src/gen_mod.erl, line 318)
      in call from mod_conversejs:get_register_options/1 (src/mod_conversejs.erl, line 186)
      in call from mod_conversejs:process/2 (src/mod_conversejs.erl, line 55)
      in call from ejabberd_http:process/2 (src/ejabberd_http.erl, line 373)
      in call from ejabberd_http:process_request/1 (src/ejabberd_http.erl, line 496)
      in call from ejabberd_http:process_header/2 (src/ejabberd_http.erl, line 293)
      in call from ejabberd_http:parse_headers/1 (src/ejabberd_http.erl, line 218)
    ancestors: [ejabberd_http_sup,ejabberd_sup,<0.173.0>]
    message_queue_len: 0
    messages: []
    links: [<0.668.0>,#Port<0.1382>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 2586
    stack_size: 28
    reductions: 24674
  neighbours:

2022-05-20 23:17:27.228231+00:00 [error] <0.668.0>@supervisor:do_restart/3:751 SUPERVISOR REPORT:
    supervisor: {local,ejabberd_http_sup}
    errorContext: child_terminated
    reason: {{module_not_loaded,mod_register,<<"xmpp.domain0.tld">>},
             [{gen_mod,get_module_opts,2,
                       [{file,"src/gen_mod.erl"},{line,338}]},
              {gen_mod,get_module_opt,3,[{file,"src/gen_mod.erl"},{line,318}]},
              {mod_conversejs,get_register_options,1,
                              [{file,"src/mod_conversejs.erl"},{line,186}]},
              {mod_conversejs,process,2,
                              [{file,"src/mod_conversejs.erl"},{line,55}]},
              {ejabberd_http,process,2,
                             [{file,"src/ejabberd_http.erl"},{line,373}]},
              {ejabberd_http,process_request,1,
                             [{file,"src/ejabberd_http.erl"},{line,496}]},
              {ejabberd_http,process_header,2,
                             [{file,"src/ejabberd_http.erl"},{line,293}]},
              {ejabberd_http,parse_headers,1,
                             [{file,"src/ejabberd_http.erl"},{line,218}]}]}
    offender: [{pid,<0.2302.0>},
               {id,undefined},
               {mfargs,{ejabberd_http,start_link,undefined}},
               {restart_type,temporary},
               {significant,false},
               {shutdown,5000},
               {child_type,worker}]

2022-05-20 23:17:27.232597+00:00 [error] <0.2373.0>@proc_lib:crash_report/4:525 CRASH REPORT:
  crasher:
    initial call: ejabberd_http:init/3
    pid: <0.2373.0>
    registered_name: []
    exception error: {module_not_loaded,mod_register,<<"xmpp.domain0.tld">>}
      in function  gen_mod:get_module_opts/2 (src/gen_mod.erl, line 338)
      in call from gen_mod:get_module_opt/3 (src/gen_mod.erl, line 318)
      in call from mod_conversejs:get_register_options/1 (src/mod_conversejs.erl, line 186)
      in call from mod_conversejs:process/2 (src/mod_conversejs.erl, line 55)
      in call from ejabberd_http:process/2 (src/ejabberd_http.erl, line 373)
      in call from ejabberd_http:process_request/1 (src/ejabberd_http.erl, line 496)
      in call from ejabberd_http:process_header/2 (src/ejabberd_http.erl, line 293)
      in call from ejabberd_http:parse_headers/1 (src/ejabberd_http.erl, line 218)
    ancestors: [ejabberd_http_sup,ejabberd_sup,<0.173.0>]
    message_queue_len: 0
    messages: []
    links: [<0.668.0>,#Port<0.1438>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 2586
    stack_size: 28
    reductions: 14053
  neighbours:

2022-05-20 23:17:27.237849+00:00 [error] <0.668.0>@supervisor:do_restart/3:751 SUPERVISOR REPORT:
    supervisor: {local,ejabberd_http_sup}
    errorContext: child_terminated
    reason: {{module_not_loaded,mod_register,<<"xmpp.domain0.tld">>},
             [{gen_mod,get_module_opts,2,
                       [{file,"src/gen_mod.erl"},{line,338}]},
              {gen_mod,get_module_opt,3,[{file,"src/gen_mod.erl"},{line,318}]},
              {mod_conversejs,get_register_options,1,
                              [{file,"src/mod_conversejs.erl"},{line,186}]},
              {mod_conversejs,process,2,
                              [{file,"src/mod_conversejs.erl"},{line,55}]},
              {ejabberd_http,process,2,
                             [{file,"src/ejabberd_http.erl"},{line,373}]},
              {ejabberd_http,process_request,1,
                             [{file,"src/ejabberd_http.erl"},{line,496}]},
              {ejabberd_http,process_header,2,
                             [{file,"src/ejabberd_http.erl"},{line,293}]},
              {ejabberd_http,parse_headers,1,
                             [{file,"src/ejabberd_http.erl"},{line,218}]}]}
    offender: [{pid,<0.2373.0>},
               {id,undefined},
               {mfargs,{ejabberd_http,start_link,undefined}},
               {restart_type,temporary},
               {significant,false},
               {shutdown,5000},
               {child_type,worker}]

Bug description

I wanted to give mod_conversejs a try, so I added it to the request_handlers and I added mod_conversejs: {} to my config.
When I make a request to xmpp.domain0.tld/conversjs the error occurs. It says my mod_register is not loaded. But it is loaded under append_host_config. I tried to put the mod_register in the main config (not in append_host_config). And I tried to put mod_conversejs in append_host_config but the same error occurs.

@badlop badlop self-assigned this May 23, 2022
@badlop badlop added the Packaging:Container Container image from GitHub Packages label May 23, 2022
@badlop
Copy link
Member

badlop commented May 23, 2022

There are two problems here:

A) A bug in mod_conversejs: it expects mod_register to be enabled in the vhost where the HTTP query is handled. Otherwise, it crashes.

I've now solved this in 0e25f8d

B) A problem in your configuration: you don't have "xmpp.domain0.tld" defined in the list of served vhosts in

hosts:
  - domain0.tld
  - domain1.tld

But you visit the URL "xmpp.domain0.tld/conversjs" and expect mod_conversejs to know what real vhost xmpp.domain0.tld is associated with?

The error message says it clearly:

{module_not_loaded, mod_register, <<"xmpp.domain0.tld">>}

That module is not loaded for that vhost.

@badlop badlop added this to the ejabberd 22.xx milestone May 23, 2022
@marzzzello
Copy link
Author

Ok, I see. That sounds like it's not possible to have conversejs on a subdomain or other domain, correct?
For the other modules I didn't have a problem to have them on a subdomain.

@badlop
Copy link
Member

badlop commented May 24, 2022

That sounds like it's not possible to have conversejs on a subdomain or other domain, correct?

When mod_conversejs receives an HTTP query addressed to host "xmpp.example.org", and wants to read the module options, it asks ejabberd "What is the mod_conversejs configuration for host xmpp.example.org?"

See:

process([], #request{method = 'GET', host = Host, raw_path = RawPath}) ->
ExtraOptions = get_auth_options(Host)
++ get_register_options(Host)
++ get_extra_options(Host),
DomainRaw = gen_mod:get_module_opt(Host, ?MODULE, default_domain),
Domain = misc:expand_keyword(<<"@HOST@">>, DomainRaw, Host),
Script = get_file_url(Host, conversejs_script,
<<RawPath/binary, "/converse.min.js">>,
<<"https://cdn.conversejs.org/dist/converse.min.js">>),
CSS = get_file_url(Host, conversejs_css,
<<RawPath/binary, "/converse.min.css">>,
<<"https://cdn.conversejs.org/dist/converse.min.css">>),

However, you didn't configure that host at all:

hosts:
  - domain0.tld
  - domain1.tld

When you send a query to somerandomname.example.org, what mod_conversejs configuration should ejabberd use?

@badlop badlop closed this as completed Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Packaging:Container Container image from GitHub Packages
Projects
None yet
Development

No branches or pull requests

2 participants