Esempio n. 1
0
def getent_shadow(database, keys=None):
    if not keys:
        write_shadow(NslcdClient(constants.NSLCD_ACTION_SHADOW_ALL))
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_BYNAME)
        con.write_string(key)
        write_shadow(con)
Esempio n. 2
0
def getent_shadow(database, keys=None):
    if not keys:
        write_shadow(NslcdClient(constants.NSLCD_ACTION_SHADOW_ALL))
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_BYNAME)
        con.write_string(key)
        write_shadow(con)
Esempio n. 3
0
def getent_aliases(database, keys=None):
    if not keys:
        write_aliases(NslcdClient(constants.NSLCD_ACTION_ALIAS_ALL))
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_BYNAME)
        con.write_string(key)
        write_aliases(con)
Esempio n. 4
0
def getent_aliases(database, keys=None):
    if not keys:
        write_aliases(NslcdClient(constants.NSLCD_ACTION_ALIAS_ALL))
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_BYNAME)
        con.write_string(key)
        write_aliases(con)
Esempio n. 5
0
def getent_netgroup(database, keys=None):
    recurse = database == 'netgroup'
    if not keys:
        write_netgroup(NslcdClient(constants.NSLCD_ACTION_NETGROUP_ALL),
                       recurse)
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
        con.write_string(key)
        write_netgroup(con, recurse)
Esempio n. 6
0
def getent_netgroup(database, keys=None):
    recurse = database == 'netgroup'
    if not keys:
        write_netgroup(
            NslcdClient(constants.NSLCD_ACTION_NETGROUP_ALL), recurse)
        return
    for key in keys:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
        con.write_string(key)
        write_netgroup(con, recurse)
Esempio n. 7
0
def getent_netgroup(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
        con.write_string(key)
    for name, members, tripples in _get_getgroups(con, database == 'netgroup'):
        print '%-15s %s' % (name, ' '.join(
                members +
                ['(%s, %s, %s)' % (host, user, domain)
                 for host, user, domain in tripples]
            ))
Esempio n. 8
0
def getent_ethers(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_ALL)
    elif re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key):
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER)
        con.write_ether(key)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        ether = con.read_ether()
        print '%s %s' % (ether, name)
Esempio n. 9
0
def getent_aliases(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%-16s%s' % (
            con.read_string() + ': ',
            ', '.join(con.read_stringlist()),
        )
Esempio n. 10
0
def getent_passwd(database, keys=None):
    if not keys:
        write_passwd(NslcdClient(constants.NSLCD_ACTION_PASSWD_ALL))
        return
    for key in keys:
        if re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYUID)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYNAME)
            con.write_string(key)
        write_passwd(con)
Esempio n. 11
0
def getent_protocols(database, keys=None):
    if not keys:
        write_protocols(NslcdClient(constants.NSLCD_ACTION_PROTOCOL_ALL))
        return
    for key in keys:
        if re.match(r'^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_PROTOCOL_BYNUMBER)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_PROTOCOL_BYNAME)
            con.write_string(key)
        write_protocols(con)
Esempio n. 12
0
def getent_ethers(database, keys=None):
    if not keys:
        write_ethers(NslcdClient(constants.NSLCD_ACTION_ETHER_ALL))
        return
    for key in keys:
        if re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key):
            con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER)
            con.write_ether(key)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME)
            con.write_string(key)
        write_ethers(con)
Esempio n. 13
0
def getent_rpc(database, keys=None):
    if not keys:
        write_rpc(NslcdClient(constants.NSLCD_ACTION_RPC_ALL))
        return
    for key in keys:
        if re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNUMBER)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNAME)
            con.write_string(key)
        write_rpc(con)
Esempio n. 14
0
def getent_services(database, keys=None):
    if not keys:
        write_services(NslcdClient(constants.NSLCD_ACTION_SERVICE_ALL))
        return
    for key in keys:
        value = key
        protocol = ''
        if '/' in value:
            value, protocol = value.split('/', 1)
        if re.match('^\d+$', value):
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNUMBER)
            con.write_int32(int(value))
            con.write_string(protocol)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNAME)
            con.write_string(value)
            con.write_string(protocol)
        write_services(con)
Esempio n. 15
0
def _get_getgroups(con, recurse, netgroups=None):
    if netgroups is None:
        netgroups = {}
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name, members, tripples = _read_netgroup(con)
        if not recurse:
            yield (name, members, tripples)
        else:
            netgroups[name] = None
            for netgroup in members:
                if netgroup not in netgroups:
                    con2 = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
                    con2.write_string(netgroup)
                    all(_get_getgroups(con2, recurse, netgroups))
                if netgroups.get(netgroup, None) is not None:
                    tripples += netgroups[netgroup][1]
            netgroups[name] = (members, tripples)
            yield (name, [], tripples)
Esempio n. 16
0
def _get_getgroups(con, recurse, netgroups=None):
    if netgroups is None:
        netgroups = {}
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name, members, tripples = _read_netgroup(con)
        if not recurse:
            yield (name, members, tripples)
        else:
            netgroups[name] = None
            for netgroup in members:
                if netgroup not in netgroups:
                    con2 = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
                    con2.write_string(netgroup)
                    all(_get_getgroups(con2, recurse, netgroups))
                if netgroups.get(netgroup, None) is not None:
                    tripples += netgroups[netgroup][1]
            netgroups[name] = (members, tripples)
            yield (name, [], tripples)
Esempio n. 17
0
def getent_group(database, keys=None):
    if not keys:
        write_group(NslcdClient(constants.NSLCD_ACTION_GROUP_ALL))
        return
    for key in keys:
        if database == 'group.bymember':
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYMEMBER)
            con.write_string(key)
        elif re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYGID)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYNAME)
            con.write_string(key)
        write_group(con)
Esempio n. 18
0
def getent_shadow(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_BYNAME)
        con.write_string(key)
    value2str = lambda x: str(x) if x != -1 else ''
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%s:%s:%s:%s:%s:%s:%s' % (
                con.read_string(),
                con.read_string(),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
                value2str(con.read_int32()),
            )
Esempio n. 19
0
def getent_networks(database, keys=None):
    db_af = _get_af(database)
    if not keys:
        write_networks(NslcdClient(constants.NSLCD_ACTION_NETWORK_ALL), db_af)
        return
    for key in keys:
        ipv4_addr = _get_ipv4(key)
        ipv6_addr = _get_ipv6(key)
        if ipv4_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET, ipv4_addr)
        elif ipv6_addr and db_af in (socket.AF_INET6, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET6, ipv6_addr)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYNAME)
            con.write_string(key)
        write_networks(con, db_af)
Esempio n. 20
0
def getent_aliases(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_ALIAS_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%-16s%s' % (
                con.read_string() + ': ',
                ', '.join(con.read_stringlist()),
            )
Esempio n. 21
0
def getent_netgroup(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_NETGROUP_BYNAME)
        con.write_string(key)
    for name, members, tripples in _get_getgroups(con, database == 'netgroup'):
        print '%-15s %s' % (name, ' '.join(members + [
            '(%s, %s, %s)' % (host, user, domain)
            for host, user, domain in tripples
        ]))
Esempio n. 22
0
def getent_rpc(database, keys=None):
    if not keys:
        write_rpc(NslcdClient(constants.NSLCD_ACTION_RPC_ALL))
        return
    for key in keys:
        if re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNUMBER)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNAME)
            con.write_string(key)
        write_rpc(con)
Esempio n. 23
0
def getent_ethers(database, keys=None):
    if not keys:
        write_ethers(NslcdClient(constants.NSLCD_ACTION_ETHER_ALL))
        return
    for key in keys:
        if re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key):
            con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER)
            con.write_ether(key)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME)
            con.write_string(key)
        write_ethers(con)
Esempio n. 24
0
def getent_passwd(database, keys=None):
    if not keys:
        write_passwd(NslcdClient(constants.NSLCD_ACTION_PASSWD_ALL))
        return
    for key in keys:
        if re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYUID)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYNAME)
            con.write_string(key)
        write_passwd(con)
Esempio n. 25
0
def getent_passwd(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_ALL)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYUID)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%d:%d:%s:%s:%s' % (
            con.read_string(),
            con.read_string(),
            con.read_int32(),
            con.read_int32(),
            con.read_string(),
            con.read_string(),
            con.read_string(),
        )
Esempio n. 26
0
def getent_networks(database, key=None):
    db_af = _get_af(database)
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_NETWORK_ALL)
    else:
        ipv4_addr = _get_ipv4(key)
        ipv6_addr = _get_ipv6(key)
        if ipv4_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET, ipv4_addr)
        elif ipv6_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET6, ipv6_addr)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYNAME)
            con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        names = ' '.join([con.read_string()] + con.read_stringlist())
        for af, address in con.read_addresslist():
            if db_af in (af, None):
                print '%-15s %s' % (address, names)
Esempio n. 27
0
def getent_ethers(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_ALL)
    elif re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key):
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER)
        con.write_ether(key)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        ether = con.read_ether()
        print '%s %s' % (ether, name)
Esempio n. 28
0
def getent_group(database, keys=None):
    if not keys:
        write_group(NslcdClient(constants.NSLCD_ACTION_GROUP_ALL))
        return
    for key in keys:
        if database == 'group.bymember':
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYMEMBER)
            con.write_string(key)
        elif re.match('^\d+$', key):
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYGID)
            con.write_int32(int(key))
        else:
            con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYNAME)
            con.write_string(key)
        write_group(con)
Esempio n. 29
0
def getent_passwd(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_ALL)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYUID)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_PASSWD_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%d:%d:%s:%s:%s' % (
                con.read_string(),
                con.read_string(),
                con.read_int32(),
                con.read_int32(),
                con.read_string(),
                con.read_string(),
                con.read_string(),
            )
Esempio n. 30
0
def getent_networks(database, keys=None):
    db_af = _get_af(database)
    if not keys:
        write_networks(NslcdClient(constants.NSLCD_ACTION_NETWORK_ALL), db_af)
        return
    for key in keys:
        ipv4_addr = _get_ipv4(key)
        ipv6_addr = _get_ipv6(key)
        if ipv4_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET, ipv4_addr)
        elif ipv6_addr and db_af in (socket.AF_INET6, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET6, ipv6_addr)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYNAME)
            con.write_string(key)
        write_networks(con, db_af)
Esempio n. 31
0
def getent_services(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_SERVICE_ALL)
    else:
        value = key
        protocol = ''
        if '/' in value:
            value, protocol = value.split('/', 1)
        if re.match('^\d+$', value):
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNUMBER)
            con.write_int32(int(value))
            con.write_string(protocol)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNAME)
            con.write_string(value)
            con.write_string(protocol)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        aliases = con.read_stringlist()
        number = con.read_int32()
        protocol = con.read_string()
        print '%-21s %d/%s %s' % (name, number, protocol, ' '.join(aliases))
Esempio n. 32
0
def getent_shadow(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_ALL)
    else:
        con = NslcdClient(constants.NSLCD_ACTION_SHADOW_BYNAME)
        con.write_string(key)
    value2str = lambda x: str(x) if x != -1 else ''
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%s:%s:%s:%s:%s:%s:%s' % (
            con.read_string(),
            con.read_string(),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
            value2str(con.read_int32()),
        )
Esempio n. 33
0
def getent_rpc(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_RPC_ALL)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNUMBER)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        aliases = con.read_stringlist()
        number = con.read_int32()
        print '%-15s %d  %s' % (name, number, ' '.join(aliases))
Esempio n. 34
0
def getent_services(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_SERVICE_ALL)
    else:
        value = key
        protocol = ''
        if '/' in value:
            value, protocol = value.split('/', 1)
        if re.match('^\d+$', value):
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNUMBER)
            con.write_int32(int(value))
            con.write_string(protocol)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNAME)
            con.write_string(value)
            con.write_string(protocol)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        aliases = con.read_stringlist()
        number = con.read_int32()
        protocol = con.read_string()
        print '%-21s %d/%s %s' % (name, number, protocol, ' '.join(aliases))
Esempio n. 35
0
def getent_networks(database, key=None):
    db_af = _get_af(database)
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_NETWORK_ALL)
    else:
        ipv4_addr = _get_ipv4(key)
        ipv6_addr = _get_ipv6(key)
        if ipv4_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET, ipv4_addr)
        elif ipv6_addr and db_af in (socket.AF_INET, None):
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYADDR)
            con.write_address(socket.AF_INET6, ipv6_addr)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_NETWORK_BYNAME)
            con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        names = ' '.join([con.read_string()] + con.read_stringlist())
        for af, address in con.read_addresslist():
            if db_af in (af, None):
                print '%-15s %s' % (address, names)
Esempio n. 36
0
def getent_services(database, keys=None):
    if not keys:
        write_services(NslcdClient(constants.NSLCD_ACTION_SERVICE_ALL))
        return
    for key in keys:
        value = key
        protocol = ''
        if '/' in value:
            value, protocol = value.split('/', 1)
        if re.match('^\d+$', value):
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNUMBER)
            con.write_int32(int(value))
            con.write_string(protocol)
        else:
            con = NslcdClient(constants.NSLCD_ACTION_SERVICE_BYNAME)
            con.write_string(value)
            con.write_string(protocol)
        write_services(con)
Esempio n. 37
0
def getent_rpc(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_RPC_ALL)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNUMBER)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_RPC_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        name = con.read_string()
        aliases = con.read_stringlist()
        number = con.read_int32()
        print '%-15s %d  %s' % (name, number, ' '.join(aliases))
Esempio n. 38
0
def getent_group(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_ALL)
    elif database == 'group.bymember':
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYMEMBER)
        con.write_string(key)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYGID)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%d:%s' % (
            con.read_string(),
            con.read_string(),
            con.read_int32(),
            ','.join(con.read_stringlist()),
        )
Esempio n. 39
0
def getent_group(database, key=None):
    if not key:
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_ALL)
    elif database == 'group.bymember':
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYMEMBER)
        con.write_string(key)
    elif re.match('^\d+$', key):
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYGID)
        con.write_int32(int(key))
    else:
        con = NslcdClient(constants.NSLCD_ACTION_GROUP_BYNAME)
        con.write_string(key)
    while con.get_response() == constants.NSLCD_RESULT_BEGIN:
        print '%s:%s:%d:%s' % (
                con.read_string(),
                con.read_string(),
                con.read_int32(),
                ','.join(con.read_stringlist()),
            )