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 */
| 1891 | * exist, NULL is returned and errno is set to ENOENT. If the client isn't |
| 1892 | * using an ACL user, NULL is returned and errno is set to ENOTSUP */ |
| 1893 | RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { |
| 1894 | client *client = lookupClientByID(id); |
| 1895 | if (client == NULL) { |
| 1896 | errno = ENOENT; |
| 1897 | return NULL; |
| 1898 | } |
| 1899 | |
| 1900 | if (client->user == NULL) { |
| 1901 | errno = ENOTSUP; |
| 1902 | return NULL; |
| 1903 | } |
| 1904 | |
| 1905 | sds name = sdsnew(client->user->name); |
| 1906 | robj *str = createObject(OBJ_STRING, name); |
| 1907 | autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str); |
| 1908 | return str; |
| 1909 | } |
| 1910 | |
| 1911 | /* This is an helper for RM_GetClientInfoById() and other functions: given |
| 1912 | * a client, it populates the client info structure with the appropriate |
nothing calls this directly
no test coverage detected