Return the ACL user name used by the client with the specified client ID. * Client ID can be obtained with RM_GetClientId() API. If the client does not * exist, NULL is returned and errno is set to ENOENT. If the client isn't * using an ACL user, NULL is returned and errno is set to ENOTSUP */
| 1961 | * exist, NULL is returned and errno is set to ENOENT. If the client isn't |
| 1962 | * using an ACL user, NULL is returned and errno is set to ENOTSUP */ |
| 1963 | RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { |
| 1964 | client *client = lookupClientByID(id); |
| 1965 | if (client == NULL) { |
| 1966 | errno = ENOENT; |
| 1967 | return NULL; |
| 1968 | } |
| 1969 | |
| 1970 | if (client->user == NULL) { |
| 1971 | errno = ENOTSUP; |
| 1972 | return NULL; |
| 1973 | } |
| 1974 | |
| 1975 | sds name = sdsnew(client->user->name); |
| 1976 | robj *str = createObject(OBJ_STRING, name); |
| 1977 | autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str); |
| 1978 | return str; |
| 1979 | } |
| 1980 | |
| 1981 | /* This is an helper for RM_GetClientInfoById() and other functions: given |
| 1982 | * a client, it populates the client info structure with the appropriate |
nothing calls this directly
no test coverage detected