| 2576 | *----------------------------------------------------------------------------*/ |
| 2577 | |
| 2578 | void configCommand(client *c) { |
| 2579 | /* Only allow CONFIG GET while loading. */ |
| 2580 | if (server.loading && strcasecmp(c->argv[1]->ptr,"get")) { |
| 2581 | addReplyError(c,"Only CONFIG GET is allowed during loading"); |
| 2582 | return; |
| 2583 | } |
| 2584 | |
| 2585 | if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { |
| 2586 | const char *help[] = { |
| 2587 | "GET <pattern>", |
| 2588 | " Return parameters matching the glob-like <pattern> and their values.", |
| 2589 | "SET <directive> <value>", |
| 2590 | " Set the configuration <directive> to <value>.", |
| 2591 | "RESETSTAT", |
| 2592 | " Reset statistics reported by the INFO command.", |
| 2593 | "REWRITE", |
| 2594 | " Rewrite the configuration file.", |
| 2595 | NULL |
| 2596 | }; |
| 2597 | |
| 2598 | addReplyHelp(c, help); |
| 2599 | } else if (!strcasecmp(c->argv[1]->ptr,"set") && c->argc == 4) { |
| 2600 | configSetCommand(c); |
| 2601 | } else if (!strcasecmp(c->argv[1]->ptr,"get") && c->argc == 3) { |
| 2602 | configGetCommand(c); |
| 2603 | } else if (!strcasecmp(c->argv[1]->ptr,"resetstat") && c->argc == 2) { |
| 2604 | resetServerStats(); |
| 2605 | resetCommandTableStats(); |
| 2606 | resetErrorTableStats(); |
| 2607 | addReply(c,shared.ok); |
| 2608 | } else if (!strcasecmp(c->argv[1]->ptr,"rewrite") && c->argc == 2) { |
| 2609 | if (server.configfile == NULL) { |
| 2610 | addReplyError(c,"The server is running without a config file"); |
| 2611 | return; |
| 2612 | } |
| 2613 | if (rewriteConfig(server.configfile, 0) == -1) { |
| 2614 | serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(errno)); |
| 2615 | addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno)); |
| 2616 | } else { |
| 2617 | serverLog(LL_WARNING,"CONFIG REWRITE executed with success."); |
| 2618 | addReply(c,shared.ok); |
| 2619 | } |
| 2620 | } else { |
| 2621 | addReplySubcommandSyntaxError(c); |
| 2622 | return; |
| 2623 | } |
| 2624 | } |
nothing calls this directly
no test coverage detected