예제 #1
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()),
            )
예제 #2
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()),
        )
예제 #3
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))
예제 #4
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))
예제 #5
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()),
        )
예제 #6
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(),
        )
예제 #7
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()),
            )
예제 #8
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(),
            )
예제 #9
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))
예제 #10
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))