SASL Enabled Memcached LIST_MECH return 空支持机制

SASL Enabled Memcached LIST_MECH return empty supported mechanisms

我正在编写自己的 memcachedClient 实现,我想在其中添加身份验证。我刚开始使用普通身份验证但失败了。简而言之,LIST_MECH 命令总是 returns 一个空结果,如果我继续发出 PLAIN AUTH 命令,它说,

mech:  ``PLAIN'' with 34 bytes of data
SASL (severity 2): Couldn't find mech PLAIN

以下是我的配置:

% cat memcached.conf
mech_list: plain
log_level: 5
sasldb_path: /tmp/memcached-sasl-db
% cat memcached-sasl-db
myname:mypass
export MEMCACHED_SASL_PWDB=/tmp/memcached-sasl-db
export SASL_CONF_PATH=`pwd`/memcached.conf

启动后:

./memcached -m 32 -S -B binary -vvvv
Reading configuration from: </MemcachedBuildDirection/build/bin/>
Initialized SASL.

LIST_MECH 正在显示:

<29 Read binary protocol data:
<29    0x80 0x20 0x00 0x00
<29    0x00 0x00 0x00 0x00
<29    0x00 0x00 0x00 0x00
<29    0x00 0x00 0x00 0x01
<29    0x00 0x00 0x00 0x00
<29    0x00 0x00 0x00 0x00
authenticated() in cmd 0x20 is true
>29 Writing bin response:
>29   0x81 0x20 0x00 0x00
>29   0x00 0x00 0x00 0x00
>29   0x00 0x00 0x00 0x00
>29   0x00 0x00 0x00 0x01
>29   0x00 0x00 0x00 0x00
>29   0x00 0x00 0x00 0x00

表明响应的总长度为零。因此,我正在从输出中读取一个空列表。

以及 AUTH 命令:

<29 Read binary protocol data:
<29    0x80 0x21 0x00 0x05
<29    0x00 0x00 0x00 0x00
<29    0x00 0x00 0x00 0x27
<29    0x00 0x00 0x00 0x01
<29    0x00 0x00 0x00 0x00
<29    0x00 0x00 0x00 0x00
authenticated() in cmd 0x21 is true
29: going from conn_parse_cmd to conn_nread
mech:  ``PLAIN'' with 34 bytes of data
SASL (severity 2): Couldn't find mech PLAIN
sasl result code:  -4
Unknown sasl response:  -4
>29 Writing an error: Auth failure.
>29 Writing bin response:
>29   0x81 0x21 0x00 0x00
>29   0x00 0x00 0x00 0x20
>29   0x00 0x00 0x00 0x0d
>29   0x00 0x00 0x00 0x01
>29   0x00 0x00 0x00 0x00
>29   0x00 0x00 0x00 0x00

我预计 LIST_MECH 会返回支持的身份验证机制列表。

这里的任何人都可以指出可以使它起作用的方向吗?

这是我自己想出来的。 Cyrus-SASL 未在我的工作区中正确安装。

通常你可以通过 sudo yum install cyrus-sasl-devel 安装 sasl 这对我有用。

有时,您正在使用的包管理框架不允许您使用 yum 安装依赖项,而是通过某些特定的依赖项管理工具。然后你必须从那里弄清楚。在我的例子中,我必须将 SASL_PATH 指定为环境变量,并将其指向我的依赖管理工具安装 SASL 共享库的位置。