| 900 | #define config_set_else } else |
| 901 | |
| 902 | void configSetCommand(client *c) { |
| 903 | robj *o; |
| 904 | long long ll; |
| 905 | int err; |
| 906 | const char *errstr = NULL; |
| 907 | serverAssertWithInfo(c,c->argv[2],sdsEncodedObject(c->argv[2])); |
| 908 | |
| 909 | if (c->argc < 4 || c->argc > 4) { |
| 910 | o = nullptr; |
| 911 | // Variadic set is only supported for tls-allowlist |
| 912 | if (strcasecmp(szFromObj(c->argv[2]), "tls-allowlist")) { |
| 913 | addReplySubcommandSyntaxError(c); |
| 914 | return; |
| 915 | } |
| 916 | } else { |
| 917 | o = c->argv[3]; |
| 918 | serverAssertWithInfo(c,c->argv[3],sdsEncodedObject(c->argv[3])); |
| 919 | } |
| 920 | |
| 921 | /* Iterate the configs that are standard */ |
| 922 | for (standardConfig *config = configs; config->name != NULL; config++) { |
| 923 | if (!(config->flags & IMMUTABLE_CONFIG) && |
| 924 | (!strcasecmp(szFromObj(c->argv[2]),config->name) || |
| 925 | (config->alias && !strcasecmp(szFromObj(c->argv[2]),config->alias)))) |
| 926 | { |
| 927 | if (config->flags & SENSITIVE_CONFIG) { |
| 928 | redactClientCommandArgument(c,3); |
| 929 | } |
| 930 | if (!config->interface.set(config->data,szFromObj(o),1,&errstr)) { |
| 931 | goto badfmt; |
| 932 | } |
| 933 | addReply(c,shared.ok); |
| 934 | return; |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | if (0) { /* this starts the config_set macros else-if chain. */ |
| 939 | |
| 940 | /* Special fields that can't be handled with general macros. */ |
| 941 | config_set_special_field("bind") { |
| 942 | int vlen; |
| 943 | sds *v = sdssplitlen(szFromObj(o),sdslen(szFromObj(o))," ",1,&vlen); |
| 944 | |
| 945 | if (vlen < 1 || vlen > CONFIG_BINDADDR_MAX) { |
| 946 | addReplyError(c, "Too many bind addresses specified."); |
| 947 | sdsfreesplitres(v, vlen); |
| 948 | return; |
| 949 | } |
| 950 | |
| 951 | if (changeBindAddr(v, vlen, true) == C_ERR) { |
| 952 | addReplyError(c, "Failed to bind to specified addresses."); |
| 953 | sdsfreesplitres(v, vlen); |
| 954 | return; |
| 955 | } |
| 956 | // Now run the config change on the other threads |
| 957 | for (int ithread = 0; ithread < cserver.cthreads; ++ithread) { |
| 958 | if (&g_pserver->rgthreadvar[ithread] != serverTL) { |
| 959 | incrRefCount(o); |
no test coverage detected