如何调试rabbitmq ldap代码?

时间:2014-04-05 21:36:54

标签: erlang rabbitmq

我正在尝试使用openldap for rabbitmq auth。 但是在监视openldap日志时,它总是有错误信息。

计划通过替换ebin文件将调试代码插入rabbitmq的源代码中。

两个问题:

  1. 如何使用shell输入启动rabbitmq-server,因此可以在线调试。默认情况下,ps -ef显示rabbitmq以noshell开头。如何改变?

    yus-iMac:ebin yuchen $ ps -ef | grep erl

    501 16021 16014 0 Thu08AM ttys000 48:49.47 /usr/local/Cellar/erlang/R16B01/lib/erlang/erts-5.10.2/bin/beam.smp - -root / usr / local / Cellar / erlang / R16B01 / lib / erlang -progname erl - -home / Users / yuchen - -newshell -name emacs   501 19097 56527 0 4:56 AM ttys006 0:00:00 grep erl   501 18980 56711 0 4:56 AM ttys007 0:04.09 /usr/local/Cellar/rabbitmq/3.1.5/erts-5.10.2/bin/../../erts-5.10.2/bin/beam.smp - W w -K true -A30 -P 1048576 - -root /usr/local/Cellar/rabbitmq/3.1.5/erts-5.10.2/bin/../ ..-progname erl - -home / Users / yuchen - -pa /usr/local/Cellar/rabbitmq/3.1.5/ebin -noshell -noinput -s rabbit boot -sname rabbit @ localhost -boot /usr/local/Cellar/rabbitmq/3.1 .5 / releases / 3.1.5 / start_sasl -config / usr / local / etc / rabbitmq / rabbitmq -kernel inet_default_connect_options [{nodelay,true}] -rabbit tcp_listeners [{“127.0.0.1”,5672}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,“/ usr / local / var / log / rabbitmq / rabbit @ localhost.log”} -rabbit sasl_error_logger {file,“/ usr / local / var / log / rabbitmq / rabbit @ localhost -sasl.log“} -rabbit enabled_plugins_file”/ usr / local / etc / rabbitmq / enabled_plugins“-rabbit plugins_dir”/usr/local/Cellar/rabbitmq/3.1.5/plugins"-rabbit plugins_expand_dir“/ usr / local / var / LIB / RabbitMQ的/ Mnesia的/兔@本地-插件 - 展开“-os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir”/ usr / local / var / lib / rabbitmq / mnesia / rabbit @ localhost“

  2. 我检查了启动脚本“rabbitmq-server”

    exec ${ERL_DIR}erl \
        -pa ${RABBITMQ_EBIN_ROOT} \
        ${RABBITMQ_START_RABBIT} \
        -sname ${RABBITMQ_NODENAME} \
        -boot "${SASL_BOOT_FILE}" \
        ${RABBITMQ_CONFIG_ARG} \
        +W w \
        ${RABBITMQ_SERVER_ERL_ARGS} \
        ${RABBITMQ_LISTEN_ARG} \
        -sasl errlog_type error \
        -sasl sasl_error_logger false \
        -rabbit error_logger '{file,"'${RABBITMQ_LOGS}'"}' \
        -rabbit sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \
        -rabbit enabled_plugins_file "\"$RABBITMQ_ENABLED_PLUGINS_FILE\"" \
        -rabbit plugins_dir "\"$RABBITMQ_PLUGINS_DIR\"" \
        -rabbit plugins_expand_dir "\"$RABBITMQ_PLUGINS_EXPAND_DIR\"" \
        -os_mon start_cpu_sup false \
        -os_mon start_disksup false \
        -os_mon start_memsup false \
        -mnesia dir "\"${RABBITMQ_MNESIA_DIR}\"" \
        ${RABBITMQ_SERVER_START_ARGS} \
        "$@" 
    

    添加以下调试代码。

    echo "erl dir:" ${ERL_DIR}
    echo "pa:" ${RABBITMQ_EBIN_ROOT} 
    echo "ebin_root:" ${RABBITMQ_EBIN_ROOT}
    echo "boot:" ${SASL_BOOT_FILE}
    echo "start rabbit:"  ${RABBITMQ_START_RABBIT}
    echo "config_args:" ${RABBITMQ_CONFIG_ARG}
    echo "server_erl_args:" ${RABBITMQ_SERVER_ERL_ARGS}
    echo "listen_arg:"  ${RABBITMQ_LISTEN_ARG}
    

    调试结果如下:

    erl dir: /usr/local/Cellar/rabbitmq/3.1.5/erts-5.10.2/bin/
    pa: /usr/local/Cellar/rabbitmq/3.1.5/ebin
    ebin_root: /usr/local/Cellar/rabbitmq/3.1.5/ebin
    boot: /usr/local/Cellar/rabbitmq/3.1.5/releases/3.1.5/start_sasl
    start rabbit: -noinput -s rabbit boot
    config_args: -config /usr/local/etc/rabbitmq/rabbitmq
    server_erl_args: +K true +A30 +P 1048576 -kernel inet_default_connect_options [{nodelay,true}]
    listen_arg: -rabbit tcp_listeners [{"127.0.0.1",5672}]
    

    只有'没有输入',但不存在“noshell”,ps -ef的输出noshell来自何处?

    1. 我用新的替换了“rabbit_auth_backend_ldap.beam”。但重新启动rabbitmq-server后,连接它,但调试信息不​​在rabbitmq日志中。 似乎我的新工作不起作用。

      yus-iMac:ebin yuchen $ pwd /usr/local/Cellar/rabbitmq/3.1.5/plugins/expand/rabbitmq_auth_backend_ldap-3.1.5/ebin

      yus-iMac:ebin yuchen $ ls -li 总计56 20682881 -rw-r - r-- 1 yuchen wheel 9648 4月6日03:54 rabbit_auth_backend_ldap.beam 20682882 -rw-r - r-- 1 yuchen wheel 2100 Aug 15 2013 rabbit_auth_backend_ldap_app.beam 20682883 -rw-r - r-- 1 yuchen wheel 1764 Aug 15 2013 rabbit_auth_backend_ldap_sup.beam 20682884 -rw-r - r-- 1 yuchen wheel 1928年8月15日rabbit_auth_backend_ldap_util.beam 20682885 -rw-r - r-- 1 yuchen wheel 994 Aug 15 2013 rabbitmq_auth_backend_ldap.app

    2. 更改后的文件部分代码如下,我在模板后添加了111:

      log(_Fmt, _Args, #state{log = false}) -> ok;
      log( Fmt,  Args, _State)              -> rabbit_log:info(Fmt ++ "~n", Args).
      
      fill(Fmt, Args, State) ->
          ?L2("filling template111 \"~s\" with~n            ~p", [Fmt, Args], State),
          R = rabbit_auth_backend_ldap_util:fill(Fmt, Args),
          ?L2("template result: \"~s\"", [R], State),
          R.
      

      在rabbitmq-server重启后日志没有变化。

      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
      accepting AMQP connection <0.485.0> (127.0.0.1:62003 -> 127.0.0.1:5672)
      
      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
      LDAP CHECK: login for equipment_serial_001
      
      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
              LDAP filling template "${username}" with
                  [{username,<<"equipment_serial_001">>}]
      
      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
              LDAP template result: "equipment_serial_001"
      
      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
          LDAP bind error: equipment_serial_001 invalidDNSyntax
      
      =INFO REPORT==== 6-Apr-2014::05:25:21 ===
      LDAP DECISION: login for equipment_serial_001: {error,invalidDNSyntax}
      
      =ERROR REPORT==== 6-Apr-2014::05:25:24 ===
      closing AMQP connection <0.485.0> (127.0.0.1:62003 -> 127.0.0.1:5672):
      {handshake_error,starting,0,
                       {amqp_error,access_refused,
                                   "PLAIN login refused: rabbit_auth_backend_ldap failed authenticating equipment_serial_001: invalidDNSyntax\n",
                                   'connection.start_ok'}}
      

1 个答案:

答案 0 :(得分:0)

虽然此错误可能与其他内容有关,但是在RabbitMQ 3.3.5上可能导致此错误的一个条件是包含感叹号的密码用户名:&#34;!&#34;