我已经在 linux 服务器(ubuntu 16.04)上设置了 pam 和 nss,以从远程 postgresql 数据库获取用户和组。在服务器上登录没问题,但是无法从数据库中加载组。
如果表 group_table 中存在条目,则 getent 组失败并显示消息“column number 3 is out of range 0..2”。nss-pgsql.conf 中使用的所有 sql 似乎都很好。
我使用以下数据库表:
nss-pgsql.conf 的内容:
connectionstring = hostaddr=123.456.789.10 dbname=nobodyexpects user=the password=spanishinquisition connect_timeout=1
getgroupmembersbygid = SELECT username FROM passwd_table WHERE gid = $1
getpwnam = SELECT username, passwd, gecos, homedir, shell, uid, gid FROM passwd_table WHERE username = $1
getpwuid = SELECT username, passwd, gecos, homedir, shell, uid, gid FROM passwd_table WHERE uid = $1
allusers = SELECT username, passwd, gecos, homedir, shell, uid, gid FROM passwd_table
getgrnam = SELECT groupname, passwd, gid FROM group_table WHERE groupname = $1
getgrgid = SELECT groupname, passwd, gid FROM group_table WHERE gid = $1
groups_dyn = SELECT ug.gid FROM passwd_table JOIN usergroups ug USING (uid) where username = $1 and ug.gid <> $2
allgroups = SELECT groupname, passwd, gid FROM group_table
如果表 group_table 不包含数据,我会收到无法找到组名称的消息,并且 getent 组与本地组一起工作。希望有人能帮忙。