connectionstring        = hostaddr=127.0.0.1 dbname=mailsys user=nss password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx connect_timeout=1

# you can use anything postgres accepts as table expression

# Must return "usernames", 1 column, list
getgroupmembersbygid    = SELECT local_part||'%'||domainname AS name FROM users JOIN domain_name USING (gid) WHERE gid = $1 AND is_primary
# Must return passwd_name, passwd_passwd, passwd_gecos, passwd_dir, passwd_shell, passwd_uid, passwd_gid
getpwnam        = SELECT local_part||'%'||domainname AS name, '*' AS passwd, 'vmm virtual user' AS gecos, domaindir ||'/'||uid AS homedir, '/bin/true' AS shell, uid, gid FROM users JOIN domain_data USING (gid) JOIN domain_name USING (gid) WHERE local_part = split_part($1, '%', 1) AND domainname = split_part($1, '%', 2) AND is_primary
# Must return passwd_name, passwd_passwd, passwd_gecos, passwd_dir, passwd_shell, passwd_uid, passwd_gid
getpwuid        = SELECT local_part||'%'||domainname AS name, '*' AS passwd, 'vmm virtual user' AS gecos, domaindir ||'/'||uid AS homedir, '/bin/true' AS shell, uid, gid FROM users JOIN domain_data USING (gid) JOIN domain_name USING (gid) WHERE uid = $1 AND is_primary
# All users
allusers        = SELECT local_part||'%'||domainname AS name, '*' AS passwd, 'vmm virtual user' AS gecos, domaindir ||'/'||uid AS homedir, '/bin/true' AS shell, uid, gid FROM users JOIN domain_data USING (gid) JOIN domain_name USING (gid) WHERE is_primary = 't'
# Must return group_name, group_passwd, group_gid
getgrnam        = SELECT domainname, '*' AS passwd, gid, NULL AS members FROM domain_name WHERE domainname = $1 and is_primary
# Must return group_name, group_passwd, group_gid
getgrgid        = SELECT domainname, '*' AS passwd, gid, NULL AS members FROM domain_name WHERE gid = $1 and is_primary
# Must return gid.  %s MUST appear first for username match in where clause
groups_dyn       = SELECT domainname, '*' AS passwd, n.gid, NULL AS members FROM domain_name n JOIN users u on (n.gid=u.gid) WHERE n.is_primary AND u.local_part||'%'||n.domainname = $1 and n.gid <> $2
allgroups       = SELECT domainname, '*' AS passwd, gid, NULL AS members FROM domain_name WHERE is_primary
