Commit Graph

48 Commits (jtr/fix-public-exceptions-http-codes)

Author SHA1 Message Date
Côme Chilliet e757b649b7
fix: Fix psalm taint false-positives by small refactorings
Mostly make it clear that we trust admin input or that we correctly
 escape strings.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-02-17 18:08:23 +07:00
Côme Chilliet aac79bad9b
fix: Move config.php taint trust upstream directly in OC\Config class
This solves some false-positive psalm taint errors

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-02-17 15:26:20 +07:00
Josh ce51cecb44
fix(config): Suppress error at install time
Signed-off-by: Josh <josh.t.richards@gmail.com>
2024-09-27 17:28:14 +07:00
provokateurin 9836e9b164
chore(deps): Update nextcloud/coding-standard to v1.3.1
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-09-19 14:21:20 +07:00
Robin Appelman 13088b745a
Merge branch 'master' into fix-nc-env-inclusion
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-09-16 15:13:29 +07:00
Josh 3e434bcebf
fix(config): Avoid error messages for restricted opcache API
Make changes recently added via #44230 match #8188 to avoid failures in restricted hosting environments.

Fixes #47562

Signed-off-by: Josh <josh.t.richards@gmail.com>
2024-08-28 08:20:25 +07:00
Daniel Kesselberg af6de04e9e
style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-08-25 19:34:58 +07:00
Josh Richards 34a9e48827 fix: switch from explode to substr (faster)
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
2024-07-08 16:41:58 +07:00
Josh Richards 62192ca57a fix(config): Add missing handling for envCache in getKeys()
NC_ env variable overrides were not appearing in
the output of `occ config:list system` nor `occ
config:system:get xxx`. This was creating nearly
impossible to diagnose configuration/ behavior
disprepancies.

- Refactored readData() so that we aren't saving
  the entire environment in the envCache anymore
  (only those prefixed "NC_") and so that we save
  NC_ provided config values under their real
  key.
- Refactored getValue() to accommodate readData()
  refactor
- Fixed getKeys() to properly return
  envCache keys too

Environment provided config variables now appear
in `occ config:list system` as expected.

Environment provided config variables now appear
when queried via `occ config:system:get KEY`

envCache is now free of non-NC stuff.

Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
2024-07-08 16:41:58 +07:00
Andy Scherzinger dae7c159f7
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-24 13:11:22 +07:00
Sam Bull b6ade7c8e4 fix: regression with updating read-only config
Signed-off-by: Sam Bull <git@sambull.org>
2024-04-18 18:40:51 +07:00
Varun Patil 158558763d fix(config): correctness issues in reading
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
2024-03-25 12:07:17 +07:00
Simon L e87d968c24 add a check for disk_free_space in Config.php
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-03-07 09:43:14 +07:00
Sergei Golovan 1cb50c5afa Fix integer overflow on 32-bit systems when testing free space for writing a config file. 2023-02-20 10:05:45 +07:00
Simon L 3757b345bc address review by Joas
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-02-15 13:43:54 +07:00
Simon L 9b6e5c6674 add a disk_free_space check before writing config
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-02-13 16:26:19 +07:00
Joas Schilling 3236619e99
Revert "Make config file saving safe against write failures" 2022-09-19 14:02:07 +07:00
Côme Chilliet 1013c3bf66
Merge pull request #34009 from andrey-utkin/safe-config-update
Make config file saving safe against write failures
2022-09-15 15:00:40 +07:00
Andriy Utkin 807c53b2ab Make config file saving safe against write failures
In case of disk space depletion, writing a new version of config fails,
leaving the config file empty.

This patch improves safety of updates to config.php by saving the new
version of the config into a randomly-named temporary file in the same
directory, and then renaming it to config.php, which renaming is atomic
in POSIX-compliant filesystems and shouldn't involve disk space
allocation. If writing the new config version is impossible, the current
config remains unchanged.

This patch drops the use of file locking as unnecessary. File locking
merely established order in which the concurrent independent processes
attempted file writing. In the end, the process which was last to update
the file "wins" - their changes persist and the changes of previous
writers are dropped as there's no conflict detection or change merging
mechanism anyway. With the current change, there is still some resulting
ordering, and the last writer still wins in the same way. Readers don't
need file locking as well, as opening config.php for reading always
provides a certain consistent version of the file.

Signed-off-by: Andriy Utkin <dev@autkin.net>
2022-09-09 21:46:12 +07:00
Côme Chilliet c2dafb0997
Do not empty config.php file if reading failed for any reason
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-09-06 17:37:34 +07:00
Vincent Petry 89cb450c84
Detect leading spaces in config files
Because those will cause PHP to output to stdout and will cause
unrelated error messages.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2022-08-03 10:51:10 +07:00
Jonas Meurer 241dfef7fb
Don't write to config file if `config_is_read_only` is set
Also don't write to cache in this case to prevent cache and config file
being out of sync.

Fixes: #29901
Signed-off-by: Jonas Meurer <jonas@freesources.org>
2021-12-13 13:14:17 +07:00
Gary Kim b78f3a57d1
Migrate HintException to OCP
Signed-off-by: Gary Kim <gary@garykim.dev>
2021-06-30 15:28:02 +07:00
John Molakvoæ (skjnldsv) 215aef3cbd
Update php licenses
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-06-04 22:02:41 +07:00
Christoph Wurst d89a75be0b
Update all license headers for Nextcloud 21
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-12-16 18:48:22 +07:00
Roeland Jago Douma 17ffe46d0b
Read the env variables only once
We read config.php an awefull lot of times. So it only makes sense to
kill this as much as wel can.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2020-11-02 21:37:09 +07:00
Christoph Wurst cb057829f7
Update license headers for 19
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-29 11:57:22 +07:00
Christoph Wurst 28f8eb5dba
Add visibility to all constants
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-10 16:54:27 +07:00
Christoph Wurst caff1023ea
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.

This also removes and empty lines from method/function bodies at the
beginning and end.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-10 14:19:56 +07:00
Christoph Wurst 42625a46be
Remove spaces after method or function call
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-09 16:05:56 +07:00
Roeland Jago Douma 19ca921676
Merge pull request #20241 from nextcloud/fix/license-headers-19
Update the license headers for Nextcloud 19
2020-04-01 12:44:21 +07:00
Christoph Wurst 1a9330cd69
Update the license headers for Nextcloud 19
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-03-31 14:52:54 +07:00
John Molakvoæ 1b4952bfb2
Update Config.php 2020-03-28 16:16:41 +07:00
Christoph Wurst b80ebc9674
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-03-26 16:34:56 +07:00
Christoph Wurst 5bf3d1bb38
Update license headers
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2019-12-05 15:38:45 +07:00
Roeland Jago Douma 68748d4f85
Some php-cs fixes
* Order the imports
* No leading slash on imports
* Empty line before namespace
* One line per import
* Empty after imports
* Emmpty line at bottom of file

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2019-11-22 20:52:10 +07:00
Daniel Kesselberg 9104e028a3
Remove deleteFromOpcodeCache & clearOpcodeCache
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2019-01-30 17:36:14 +07:00
Morris Jobke 2b73779568
Fix some typos
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2018-03-21 14:30:56 +07:00
Morris Jobke 0eebff152a
Update license headers
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-11-06 16:56:19 +07:00
Morris Jobke 9309217ecb Fix escaped HTML on error pages
* fixes #4655

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-05-08 21:16:08 +07:00
Morris Jobke 95a21e2f2a
Check for boolean false and add tests
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-04-04 15:56:50 +07:00
Morris Jobke 0fcb37adcb
OC_ -> NC_
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-04-04 15:56:50 +07:00
Philipp Schaffrath 695a17804e
Override config.php values through ENV variables (#26570)
* added functionality to override config.php values with 'OC_' prefixed environment variables

* use getenv to read environment variables since apache does not set $_ENV variables, fixed test

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-04-04 15:56:50 +07:00
Joas Schilling 0215b004da
Update with robin 2016-07-21 18:13:58 +07:00
Joas Schilling ba87db3fcc
Fix others 2016-07-21 18:13:57 +07:00
Morris Jobke 191a6c65d9
Show error message if config file is not readable
* when the config file is not writable there is a error message shown
* same happens now if the config file is not readable
* fixes #180
2016-06-21 11:25:38 +07:00
Lukas Reschke aba539703c
Update license headers 2016-05-26 19:57:24 +07:00
Roeland Jago Douma d312051b3d
Moved some files in \OC to PSR-4
* \OC\ActivityManager
* \OC\AllConfig
* \OC\AppConfig
* \OC\AppHelper
* \OC\Avatar
* \OC\AvatarManager
* \OC\CapabilitiesManager
* \OC\Config
* \OC\ContactsManager
* \OC\DatabaseException
* \OC\DatabaseSetupException
2016-04-29 08:00:31 +07:00