summaryrefslogtreecommitdiff
path: root/src/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/script.c')
-rw-r--r--src/script.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/src/script.c b/src/script.c
index d78d9fd6b..990248c45 100644
--- a/src/script.c
+++ b/src/script.c
@@ -312,25 +312,7 @@ static int scriptVerifyACL(client *c, sds *err) {
int acl_retval = ACLCheckAllPerm(c, &acl_errpos);
if (acl_retval != ACL_OK) {
addACLLogEntry(c,acl_retval,ACL_LOG_CTX_LUA,acl_errpos,NULL,NULL);
- switch (acl_retval) {
- case ACL_DENIED_CMD:
- *err = sdsnew("The user executing the script can't run this "
- "command or subcommand");
- break;
- case ACL_DENIED_KEY:
- *err = sdsnew("The user executing the script can't access "
- "at least one of the keys mentioned in the "
- "command arguments");
- break;
- case ACL_DENIED_CHANNEL:
- *err = sdsnew("The user executing the script can't publish "
- "to the channel mentioned in the command");
- break;
- default:
- *err = sdsnew("The user executing the script is lacking the "
- "permissions for the command");
- break;
- }
+ *err = sdscatfmt(sdsempty(), "The user executing the script %s", getAclErrorMessage(acl_retval));
return C_ERR;
}
return C_OK;
@@ -360,14 +342,7 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {
}
if (deny_write_type != DISK_ERROR_TYPE_NONE) {
- if (deny_write_type == DISK_ERROR_TYPE_RDB) {
- *err = sdsdup(shared.bgsaveerr->ptr);
- } else {
- *err = sdsempty();
- *err = sdscatfmt(*err,
- "-MISCONF Errors writing to the AOF file: %s\r\n",
- strerror(server.aof_last_write_errno));
- }
+ *err = writeCommandsGetDiskErrorMessage(deny_write_type);
return C_ERR;
}
@@ -375,11 +350,7 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {
* user configured the min-slaves-to-write option. Note this only reachable
* for Eval scripts that didn't declare flags, see the other check in
* scriptPrepareForRun */
- if (server.masterhost == NULL &&
- server.repl_min_slaves_max_lag &&
- server.repl_min_slaves_to_write &&
- server.repl_good_slaves_count < server.repl_min_slaves_to_write)
- {
+ if (!checkGoodReplicasStatus()) {
*err = sdsdup(shared.noreplicaserr->ptr);
return C_ERR;
}
@@ -387,6 +358,16 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {
return C_OK;
}
+static int scriptVerifyMayReplicate(scriptRunCtx *run_ctx, char **err) {
+ if (run_ctx->c->cmd->flags & CMD_MAY_REPLICATE &&
+ server.client_pause_type == CLIENT_PAUSE_WRITE) {
+ *err = sdsnew("May-replicate commands are not allowed when client pause write.");
+ return C_ERR;
+ }
+
+ return C_OK;
+}
+
static int scriptVerifyOOM(scriptRunCtx *run_ctx, char **err) {
if (run_ctx->flags & SCRIPT_ALLOW_OOM) {
/* Allow running any command even if OOM reached */
@@ -528,6 +509,10 @@ void scriptCall(scriptRunCtx *run_ctx, robj* *argv, int argc, sds *err) {
goto error;
}
+ if (scriptVerifyMayReplicate(run_ctx, err) != C_OK) {
+ goto error;
+ }
+
if (scriptVerifyOOM(run_ctx, err) != C_OK) {
goto error;
}