Skip to content

feat: resolve overrideServerUrl and overrideLocalDir via managed sett… - #11043

Open
cw-nvdael wants to merge 3 commits into
nextcloud:masterfrom
cw-nvdael:feat/managed-override-server-url
Open

cw-nvdael wants to merge 3 commits into
nextcloud:masterfrom
cw-nvdael:feat/managed-override-server-url

Conversation

@cw-nvdael

@cw-nvdael cw-nvdael commented Oct 9, 2026 •

Copy link
Copy Markdown

Resolves

Part of #5497.

overrideServerUrl and overrideLocalDir now resolve through the managed settings framework (ConfigFile::getConfig). They can be set by device policy (registry / managed plist) or as a device default, in addition to the existing --overrideserverurl / --overridelocaldir command-line options.

Summary

Wizard behaviour per source

Source Wizard behaviour
Device default Prefilled and editable; applies to every new account setup
Device policy Locked; login flow starts automatically
Command line Locked; login flow starts automatically, one-shot (removed after the account is added)

Details

  • The server cannot set these keys, since they are needed before an account exists.
  • Values are validated against the schema: http(s) URL or JSON list of {name, url} for overrideServerUrl, absolute path for overrideLocalDir. Empty or invalid values are skipped, including empty user values that older clients wrote after account setup.
  • A JSON server list offers a choice only when the URL is locked. This is existing upstream behaviour (initialiseOverrideServerChoices).
  • New ConfigFile::clearConfig() removes a user value so the next source applies again.
  • Legacy account migration (restoreLegacyAccount, nextcloudcmd) is skipped only for an override from the user config.
  • Docs: doc/settings/managed-settings.md.

Deliberate choices

  • The wizard never sets forceOverrideServerUrl to false. Otherwise branded builds with APPLICATION_SERVER_URL_ENFORCE would lose their lock.
  • Test names follow the camelCase style of the existing test files, not the testUnit_state_expected pattern from the Coding Style wiki.
  • Out of scope: overrideServerUrl parameter not cleared from running client after account setup #10640. The Theme keeps the override in memory, so "Add account" in the same session uses the old value.

Testing

Linux CI container (client-qt6:client-sid-6.10.2-4, -Werror):

  • ManagedSettingsTest 84/84
  • AccountWizardControllerTest 39/39
  • MigrationTest 21/21
  • UriSchemeHandlerTest 16/16

The new tests fail without the fix: the wizard default test fails without the lock change, and 10 value-check cases fail without the validator.

Manual test on Windows (Craft build), six scenarios: device default, policy, policy with server list, invalid policy value, empty legacy user value, command line.

macOS and Linux were not tested manually.

TODO

  • Building ADMX Templates

Checklist

AI (if applicable)

…ings

Signed-off-by: Nathan van Dael <n.vandael@cloudwise.nl>
Comment thread src/gui/application.cpp
Comment thread src/gui/application.cpp
Comment thread src/libsync/configfile.cpp
Comment on lines +1375 to +1376
cfg.clearOverrideServerUrl();
cfg.clearOverrideLocalDir();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only clears the user value. A device default or policy overrideLocalDir stays e.g. Nextcloud, so it applies to every account added later. For a second account, initialiseLocalSyncFolder() gets the first account folder, findGoodPathForNewSyncFolder() rejects it and falls back to e.g Nextcloud2.
However, with a policy enforced URL, the auto finish skips the sync options step, so the user never sees this. Should a overrideLocalDir only apply to the first account, or should this be handled explicitly?

Assisted-by: Claude:claude-opus-5-5

Comment thread src/libsync/settings/managedsettingsschema.cpp
- Return whether setOverrideServerUrl() and setOverrideLocalDir() wrote
  the value, and show a hint when a policy blocks --overrideserverurl or
  --overridelocaldir.
- Reject a --overridelocaldir path that is not absolute while parsing the
  command line, using the schema validator.
- Add ConfigFile::isOverrideServerUrlLocked(), shared by the wizard and
  the nc:// URI scheme handler, so only a policy or command line value
  locks the server URL and restricts login links. Builds enable
  APPLICATION_SERVER_URL_ENFORCE by default, so the wizard now clears the
  lock for a device default.
- Apply an overrideLocalDir from device default or policy only to the
  first account, in the wizard and for account setup from the command
  line. A command line value still applies to the next account. Skip the
  sync options step only for a locked folder.
- Update the docs and add tests.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Nathan van Dael <n.vandael@cloudwise.nl>
Theme::instance()->setForceOverrideServerUrl(true);
Theme::instance()->setStartLoginFlowAutomatically(true);
} else {
Theme::instance()->setForceOverrideServerUrl(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the false in this line should depend on the boolean set in APPLICATION_SERVER_URL_ENFORCE.
the way this is now, a branded client with APPLICATION_SERVER_URL_ENFORCE set to true will not enforce the server url as expected.

Comment thread src/gui/application.cpp Outdated
_overrideLocalDir = overrideLocalDir;
}
} else {
showHint("Invalid URL passed to --overridelocaldir");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
showHint("Invalid URL passed to --overridelocaldir");
showHint("Invalid path passed to --overridelocaldir");

@camilasan camilasan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After this round, I think it will be good enough to merge it.
thanks for the contribution!

@camilasan camilasan self-assigned this Oct 19, 2026
- A device default no longer unlocks the server URL in a build that sets
  APPLICATION_SERVER_URL together with APPLICATION_SERVER_URL_ENFORCE.
  Standard builds enable APPLICATION_SERVER_URL_ENFORCE without a URL, so
  a device default stays editable there.
- Say "Invalid path" when --overridelocaldir is given without a path.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Nathan van Dael <n.vandael@cloudwise.nl>
@cw-nvdael

Copy link
Copy Markdown
Author

Hi @camilasan . I've implemented your feedback, thanks for giving this to me.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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.

2 participants