summaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-01-27 03:03:21 +0800
committerGitHub <noreply@github.com>2022-01-26 21:03:21 +0200
commitd6169258351e58ce1c0cfc01ba9c85e2a5b15ffb (patch)
tree77c06611ffe63757f30a24c83005d627c96116e4 /src/server.h
parent795ea011ba8674a9b5e05e79284f6f20a5d0cc03 (diff)
downloadredis-d6169258351e58ce1c0cfc01ba9c85e2a5b15ffb.tar.gz
Allow SET without GET arg on write-only ACL. Allow BITFIELD GET on read-only ACL (#10148)
SET is a R+W command, because it can also do `GET` on the data. SET without GET is a write-only command. SET with GET is a read+write command. In #9974, we added ACL to let users define write-only access. So when the user uses SET with GET option, and the user doesn't have the READ permission on the key, we need to reject it, but we rather not reject users with write-only permissions from using the SET command when they don't use GET. In this commit, we add a `getkeys_proc` function to control key flags in SET command. We also add a new key spec flag (VARIABLE_FLAGS) means that some keys might have different flags depending on arguments. We also handle BITFIELD command, add a `bitfieldGetKeys` function. BITFIELD GET is a READ ONLY command. BITFIELD SET or BITFIELD INCR are READ WRITE commands. Other changes: 1. SET GET was added in 6.2, add the missing since in set.json 2. Added tests to cover the changes in acl-v2.tcl 3. Fix some typos in server.h and cleanups in acl-v2.tcl Co-authored-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server.h b/src/server.h
index f376f620f..06ba54315 100644
--- a/src/server.h
+++ b/src/server.h
@@ -264,6 +264,8 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT];
#define CMD_KEY_CHANNEL (1ULL<<8) /* PUBSUB shard channel */
#define CMD_KEY_INCOMPLETE (1ULL<<9) /* Means that the keyspec might not point
* out to all keys it should cover */
+#define CMD_KEY_VARIABLE_FLAGS (1ULL<<10) /* Means that some keys might have
+ * different flags depending on arguments */
/* AOF states */
#define AOF_OFF 0 /* AOF is off */
@@ -1892,7 +1894,7 @@ struct redisServer {
typedef struct {
int pos; /* The position of the key within the client array */
- int flags; /* The flags associted with the key access, see
+ int flags; /* The flags associated with the key access, see
CMD_KEY_* for more information */
} keyReference;
@@ -1914,7 +1916,7 @@ typedef struct {
* which is limited and doesn't fit many commands.
*
* There are two steps:
- * 1. begin_search (BS): in which index should we start seacrhing for keys?
+ * 1. begin_search (BS): in which index should we start searching for keys?
* 2. find_keys (FK): relative to the output of BS, how can we will which args are keys?
*
* There are two types of BS:
@@ -1956,7 +1958,7 @@ typedef struct {
const char *keyword;
/* An index in argv from which to start searching.
* Can be negative, which means start search from the end, in reverse
- * (Example: -2 means to start in reverse from the panultimate arg) */
+ * (Example: -2 means to start in reverse from the penultimate arg) */
int startfrom;
} keyword;
} bs;
@@ -3019,6 +3021,8 @@ int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
+int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
+int bitfieldGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
unsigned short crc16(const char *buf, int len);