emqx / emqx/emqx-auth-pgsql

can't load the emq_auth_pgsql when the db user is NOT "root"

Open
#61 10 comments 0 reactions 1 assignee Claimed by @hjianbo View on GitHub
Dominant language
Erlang
Stars
36
Forks
30
PR merge metrics
No merged PRs in 30d

Description

OS: CentOS 6.8 x86_64
EMQTTD: 2.2

my emq_auth_pgsql.conf list below:
`## Postgre Server: 5432, 127.0.0.1:5432, localhost:5432`
`auth.pgsql.server = 127.0.0.1:5432`
`auth.pgsql.pool = 8`
`auth.pgsql.username = mqtt`
`auth.pgsql.password = mqtt`
`auth.pgsql.database = mqtt`
`auth.pgsql.encoding = utf8`
`auth.pgsql.ssl = false`

and i try to load the plugin:
$ emqttd_ctl plugins load emq_auth_pgsql

load plugin error: {emq_auth_pgsql,
{bad_return,
{{emq_auth_pgsql_app,start,[normal,[]]},
{'EXIT',
{{badmatch,
{error,
{shutdown,
{failed_to_start_child,emq_auth_pgsql,
{shutdown,
{failed_to_start_child,worker_sup,
{shutdown,
{failed_to_start_child,
{worker,1},
{error,fatal,<<"28000">>,
invalid_authorization_specification,
<<"role \"root\" does not exist">>,
[{file,<<"miscinit.c">>},
{line,<<"494">>},
{routine,
<<"InitializeSessionUserId">>}]}}}}}}}}},
[{emq_auth_pgsql_app,start,2,
[{file,"src/emq_auth_pgsql_app.erl"},{line,33}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,273}]}]}}}}}

when i check the crash.log, i found this message:
>2017-07-19 15:20:59 =CRASH REPORT====
crasher:
initial call: ecpool_worker:init/1
pid: <0.1794.0>
registered_name: []
exception exit: {{error,fatal,<<"28000">>,invalid_authorization_specification,<<"role \"root\" does not exist">>,[{file,<<"miscinit.c">>},{line,<<"494">>},{routine,<<"InitializeSessionUserId">>}]},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,344}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
ancestors: [<0.1793.0>,<0.1791.0>,emq_auth_pgsql_sup,<0.1789.0>]
messages: [{'EXIT',<0.1795.0>,normal}]
links: [<0.1793.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 376
stack_size: 27
reductions: 181
neighbours:
2017-07-19 15:20:59 =SUPERVISOR REPORT====
Supervisor: {<0.1793.0>,ecpool_worker_sup}
Context: start_error
Reason: {error,fatal,<<"28000">>,invalid_authorization_specification,<<"role \"root\" does not exist">>,[{file,<<"miscinit.c">>},{line,<<"494">>},{routine,<<"InitializeSessionUserId">>}]}
Offender: [{pid,undefined},{id,{worker,1}},{mfargs,{ecpool_worker,start_link,[emq_auth_pgsql,1,emq_auth_pgsql_cli,[{pool_size,8},{auto_reconnect,1},{host,"127.0.0.1"},{port,5432},{username,"root"},{password,[]},{database,"mqtt"},{encoding,utf8},{ssl,false},{ssl_opts,[]}]]}},{restart_type,transient},{shutdown,5000},{child_type,worker}]
>
>2017-07-19 15:20:59 =SUPERVISOR REPORT====
Supervisor: {<0.1791.0>,ecpool_pool_sup}
Context: start_error
Reason: {shutdown,{failed_to_start_child,{worker,1},{error,fatal,<<"28000">>,invalid_authorization_specification,<<"role \"root\" does not exist">>,[{file,<<"miscinit.c">>},{line,<<"494">>},{routine,<<"InitializeSessionUserId">>}]}}}
Offender: [{pid,undefined},{id,worker_sup},{mfargs,{ecpool_worker_sup,start_link,[emq_auth_pgsql,emq_auth_pgsql_cli,[{pool_size,8},{auto_reconnect,1},{host,"127.0.0.1"},{port,5432},{username,"root"},{password,[]},{database,"mqtt"},{encoding,utf8},{ssl,false},{ssl_opts,[]}]]}},{restart_type,transient},{shutdown,infinity},{child_type,supervisor}]
>
>2017-07-19 15:20:59 =SUPERVISOR REPORT====
Supervisor: {local,emq_auth_pgsql_sup}
Context: start_error
Reason: {shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},{error,fatal,<<"28000">>,invalid_authorization_specification,<<"role \"root\" does not exist">>,[{file,<<"miscinit.c">>},{line,<<"494">>},{routine,<<"InitializeSessionUserId">>}]}}}}}
Offender: [{pid,undefined},{id,emq_auth_pgsql},{mfargs,{ecpool,start_pool,[emq_auth_pgsql,emq_auth_pgsql_cli,[{pool_size,8},{auto_reconnect,1},{host,"127.0.0.1"},{port,5432},{username,"root"},{password,[]},{database,"mqtt"},{encoding,utf8},{ssl,false},{ssl_opts,[]}]]}},{restart_type,permanent},{shutdown,5000},{child_type,supervisor}]
>
>2017-07-19 15:20:59 =CRASH REPORT====
crasher:
initial call: application_master:init/4
pid: <0.1788.0>
registered_name: []
exception exit: {{bad_return,{{emq_auth_pgsql_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,emq_auth_pgsql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},{error,fatal,<<"28000">>,invalid_authorization_specification,<<"role \"root\" does not exist">>,[{file,<<"miscinit.c">>},{line,<<"494">>},{routine,<<"InitializeSessionUserId">>}]}}}}}}}}},[{emq_auth_pgsql_app,start,2,[{file,"src/emq_auth_pgsql_app.erl"},{line,33}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,273}]}]}}}},[{application_master,init,4,[{file,"application_master.erl"},{line,134}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
ancestors: [<0.1787.0>]
messages: [{'EXIT',<0.1789.0>,normal}]
links: [<0.1787.0>,<0.935.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 610
stack_size: 27
reductions: 126
neighbours:

i create the user named 'root' in the pg db, and reload the plug, it WORKS!!!
`createuser -sP root`
`emqttd_ctl plugins load emq_auth_pgsql`
> Start apps: [emq_auth_pgsql]
Plugin emq_auth_pgsql loaded successfully.

it does NOT use the conf entry 'auth.pgsql.username'?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.