Returns config file name if not writable */
| 623 | |
| 624 | /* Returns config file name if not writable */ |
| 625 | static const char *config_not_writable(const tal_t *ctx, |
| 626 | struct command *cmd, |
| 627 | const struct configvar *oldcv) |
| 628 | { |
| 629 | struct lightningd *ld = cmd->ld; |
| 630 | const char *fname; |
| 631 | |
| 632 | /* If it exists before, we will need to replace that file (rename) */ |
| 633 | if (oldcv && oldcv->file) { |
| 634 | /* We will rename */ |
| 635 | if (!dir_writable(oldcv->file)) |
| 636 | return oldcv->file; |
| 637 | } |
| 638 | |
| 639 | /* If we don't have a setconfig file we'll have to create it, and |
| 640 | * amend the config file. */ |
| 641 | if (!ld->setconfig_file) { |
| 642 | fname = base_conf_file(tmpctx, ld, NULL); |
| 643 | if (!dir_writable(fname)) |
| 644 | return tal_steal(ctx, fname); |
| 645 | } else { |
| 646 | /* We will try to append config.setconfig */ |
| 647 | if (!file_writable(ld->setconfig_file)) |
| 648 | return tal_strdup(ctx, ld->setconfig_file); |
| 649 | } |
| 650 | return NULL; |
| 651 | } |
| 652 | |
| 653 | static struct command_result *json_setconfig(struct command *cmd, |
| 654 | const char *buffer, |
no test coverage detected