Skip to content

Add new GET /api/config/_properties endpoint#2356

Open
DL6ER wants to merge 3 commits intodevelopmentfrom
new/config_read_only
Open

Add new GET /api/config/_properties endpoint#2356
DL6ER wants to merge 3 commits intodevelopmentfrom
new/config_read_only

Conversation

@DL6ER
Copy link
Member

@DL6ER DL6ER commented Mar 8, 2025

What does this implement/fix?

Add new GET /api/config/_properties endpoint listing read-only config items. It may be extended to more things later. See #2348

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@github-actions
Copy link

github-actions bot commented Mar 8, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

… items

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER force-pushed the new/config_read_only branch from 2a72ec6 to 60e0793 Compare March 27, 2025 12:55
@github-actions
Copy link

Conflicts have been resolved.

@DL6ER
Copy link
Member Author

DL6ER commented Mar 27, 2025

Rebased on latest development

@DL6ER DL6ER marked this pull request as ready for review March 30, 2025 06:09
@DL6ER DL6ER requested a review from Copilot March 30, 2025 06:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (6)
  • src/api/api.c: Language not supported
  • src/api/api.h: Language not supported
  • src/api/config.c: Language not supported
  • src/api/docs/content/specs/config.yaml: Language not supported
  • src/api/docs/content/specs/main.yaml: Language not supported
  • test/test_suite.bats: Language not supported

@DL6ER DL6ER requested a review from a team March 30, 2025 06:10
Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should users be able to query specific properties directly? Like pihole api config/_properties/read_only ?


Maybe I don't understand misc.readOnly but I would have expected all configuration elements to be returned when misc.readOnly=true

nanopi@nanopi:~$ pihole api config/_properties
API Authentication: Not needed

Requesting: GET https://127.0.0.1:443/api/config/_properties

Status: 200
Data:
{
  "config": {
    "read_only": [
      {
        "key": "misc.readOnly",
        "reason": "read_only",
        "description": "Variable can only be set in pihole.toml, not via API"
      }
    ]
  },
  "took": 0.00019168853759765625
}
API Logout: Success (no valid session)
nanopi@nanopi:~$ pihole-FTL --config misc.readOnly
true

@DL6ER
Copy link
Member Author

DL6ER commented Sep 15, 2025

Should users be able to query specific properties directly? Like pihole api config/_properties/read_only ?

I don't think so. It'd mean adding a lot of code for a feature that is unlikely to be used interactively. This is only meant for the external scripts to have such information available, see #2348 (comment) for the motivation behind this PR.

Maybe I don't understand misc.readOnly but I would have expected all configuration elements to be returned when misc.readOnly=true.

Yes, this makes sense. I will change this.

…config items as read-only

Signed-off-by: Dominik <dl6er@dl6er.de>
reason = "read_only";
description = "Config is in read-only mode";
}
else if(conf_item->f & FLAG_READ_ONLY)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case still needed after you added the case for misc.readOnly. Because I think FLAG_READ_ONLY is only set once misc.readOnly is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a special flag that a dedicated feature on its own. Only misc.readOnly has this flag. It prevents the CLI and/or the API from being able to set this option (and effective lock out itself). It is there to "protect" users. You can set this only by manually editing pihole.toml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch config does not patch non read-only keys while a read-only key is included

4 participants