Commit Graph

42 Commits

Author SHA1 Message Date
Sophie Herold
0d268c4825 Remove all nicks and blurbs from param specs
Nicks and blurbs don't have any practical use for gio/gobject libraries.
Leaving tests untouched since this features is still used by other libraries.

Closes #2991
2023-11-29 13:41:34 +00:00
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1415
2022-05-18 09:18:52 +01:00
Emmanuel Fleury
401ff06614 Fix signedness warning in gio/gkeyfilesettingsbackend.c
gio/gkeyfilesettingsbackend.c: In function ‘convert_path’:
gio/gkeyfilesettingsbackend.c:155:15: warning: comparison of integer
expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’}
and ‘gint’ {aka ‘int’}
  155 |   if (key_len < kfsb->prefix_len ||
      |               ^
2021-04-23 10:42:52 +02:00
Michael Catanzaro
26f6e3db9e gkeyfilesettingsbackend: check for errors when creating file monitors
File monitor creation may fail. We should check for this, rather than
ignoring it and then spewing criticals upon improperly assuming that we
have a valid GFileMonitor rather than NULL.

In practice, creating the GFileMonitors here fail when opening a large
number of tabs in Epiphany. I'm still investigating to see why, but it
doesn't matter for the purposes of this commit.
2021-02-23 16:31:26 -06:00
Philip Withnall
a59247608f gkeyfilesettingsbackend: Disallow empty key or group names
These should never have been allowed; they will result in precondition
failures from the `GKeyFile` later on in the code.

A test will be added for this shortly.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:20:11 +00:00
Philip Withnall
9d27c57f70 gkeyfilesettingsbackend: Fix basename handling when group is unset
Fix an effective regression in commit
7781a9cbd2, which happens when
`convert_path()` is called with a `key` which contains no slashes. In
that case, the `key` is entirely the `basename`.

Prior to commit 7781a9cb, the code worked through a fluke of `i == -1`
cancelling out with the various additions in the `g_memdup()` call, and
effectively resulting in `g_strdup (key)`.

Spotted by Guido Berhoerster.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:16:39 +00:00
Philip Withnall
7781a9cbd2 gkeyfilesettingsbackend: Handle long keys when converting paths
Previously, the code in `convert_path()` could not handle keys longer
than `G_MAXINT`, and would overflow if that was exceeded.

Convert the code to use `gsize` and `g_memdup2()` throughout, and
change from identifying the position of the final slash in the string
using a signed offset `i`, to using a pointer to the character (and
`strrchr()`). This allows the slash to be at any position in a
`G_MAXSIZE`-long string, without sacrificing a bit of the offset for
indicating whether a slash was found.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Helps: #2319
2021-02-04 16:17:21 +00:00
Emmanuel Fleury
579e9e49c5 Fix several warnings in gio/gapplicationimpl-dbus.c:g_application_impl_command_line()
gio/gapplicationimpl-dbus.c: In function ‘g_application_impl_command_line’:
gio/gapplicationimpl-dbus.c:772:3: error: ‘static’ is not at beginning of declaration
  772 |   const static GDBusInterfaceVTable vtable = {
      |   ^~~~~
gio/gapplicationimpl-dbus.c:774:3: error: missing initializer for field ‘get_property’ of ‘GDBusInterfaceVTable’ {aka ‘const struct _GDBusInterfaceVTable’}
  774 |   };
      |   ^
2021-01-21 11:59:09 +01:00
Michael Catanzaro
00e8064137 gkeyfilesettingsbackend: improve error checking
Coverity noticed that we are ignoring return values in a couple places
here. We should print warnings when appropriate.
2020-11-24 10:09:02 +00:00
Philip Withnall
2ac44f3111 Merge branch 'key-file-no-file' into 'master'
key file: Handle filename being NULL

Closes #1825

See merge request GNOME/glib!984
2019-07-15 12:50:45 +00:00
Matthias Clasen
addb8c158a settings: Tweak priorities for keyfile backend
We want to use the keyfile backend in sandboxes,
but we want to avoid people losing their existing
settings that are stored in dconf. Flatpak does
a migration from dconf to keyfile, but only if
the app explictly requests it.

From an app perspective, there are two steps to
the dconf->keyfile migration:
1. Request that flatpak do the migration, by adding
   the migrate-path key to the metadata
2. Stop adding the 'dconf hole' to the sandbox

To keep us from switching to the keyfile backend
prematurely, look at whether the app has stopped
requesting a 'dconf hole' in the sandbox.
2019-07-15 13:01:56 +01:00
Matthias Clasen
953f23f13c key file: Handle filename being NULL
This happens when we are default-constructed
without explicit arguments.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1825
2019-07-10 11:14:03 -04:00
Philip Withnall
1b50643c99 gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1708
2019-03-08 19:46:21 +00:00
Matthias Clasen
5e4da714f0 keyfile settings: Use tighter permissions
When creating directories, create them with 700 permissions,
instead of 777.

Closes: #1658
2019-03-04 12:28:37 +00:00
Philip Withnall
9d89ed0c54 gkeyfilesettingsbackend: Add a code comment to clarify things
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Matthias Clasen
e6574b228e keyfile settings: Accept unquoted strings
It is hard for users to remember that strings have to be explicitly
quoted in the keyfile. Be lenient and accept strings that lack those
quotes.
2019-01-22 11:11:24 -05:00
Matthias Clasen
2854522379 settings: Prefer the keyfile backend when sandboxed
When we are in a sandboxed situation, bump the priority
of the keyfile settings backend above the dconf one,
so we use a keyfile inside the sandbox instead of requiring
holes in the sandbox for dconf.
2019-01-20 21:03:35 -05:00
Matthias Clasen
c63e3a4ada settings: Add support for defaults to keyfile backend
Stacked databases and locks are dconf features that allow
management software like Fleet Commander to set system-wide
defaults and overrides centrally for applications.

This patch adds minimal support for the same to the keyfile
backend. We look for a keyfile named 'defaults' and a
lock-list named 'locks'.

Suitable files can be produced from a dconf database with
dconf dump and dconf list-locks, respectively.

The default location for these files is /etc/glib-2.0/settings/.
For test purposes, this can be overwritten with the
GSETTINGS_DEFAULTS_DIR environment variable.

Writes always go to the per-user keyfile.
2019-01-20 21:03:35 -05:00
Matthias Clasen
5357a23321 settings: Register the keyfile backend as extension
This was not done previously because the backend
could not be instantiated without parameters.
2019-01-20 21:03:35 -05:00
Matthias Clasen
26c8b29ee1 settings: Make the keyfile backend parameterless
Make it possible to instantiate a keyfile settings backend
without specifying parameters, by turning the arguments to
the new() function into construct-only properties. If no
filename is specified, default to
$XDG_CONFIG_HOME/glib-2.0/settings/keyfile
2019-01-20 21:03:35 -05:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Christian Hergert
18a33f72db introspection: use (nullable) or (optional) instead of (allow-none)
If we have an input parameter (or return value) we need to use (nullable).
However, if it is an (inout) or (out) parameter, (optional) is sufficient.

It looks like (nullable) could be used for everything according to the
Annotation documentation, but (optional) is more specific.
2016-11-22 14:14:37 -08:00
Colin Walters
8ebd287fe6 gkeyfilesettingsbackend: Add assertion for known-true condition
We know the group exists since we enumerated it.  Should silence a
static analysis warning.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Matthias Clasen
41a8296e11 GKeyfileSettingsBackend: Use a directory monitor
GKeyfileSettingsBackend was using a file monitor to monitor
the parent directory of its keyfile.
2013-12-22 00:43:44 -05:00
Matthew Barnes
1fba61981a GKeyFileSettingsBackend: ignore file deletions
Ignore the keyfile being deleted (ie: by the user) instead of reporting
it to the application as all values being reverted back to their
originals.

https://bugzilla.gnome.org/show_bug.cgi?id=637956
2013-10-27 17:27:44 -07:00
Ryan Lortie
a795e563df Drop last uses of @returns: 2011-11-21 12:02:02 -05:00
Ryan Lortie
09429e2c82 gio static fixups 2011-10-16 21:41:15 -04:00
Johan Dahlin
30132c44c1 Add a lot of missing annotations 2010-09-24 18:24:41 -03:00
Ryan Lortie
d5bd531d96 Cleanup the GSettingsBackend API
This is a substantial ABI break.  Rebuild dconf.
2010-07-22 18:39:50 -04:00
Ryan Lortie
5344c22810 gio/ docs fixup 2010-07-12 18:30:14 -04:00
Ryan Lortie
5b946e0504 gio/: fully remove gioalias hacks 2010-07-07 19:53:22 -04:00
Ryan Lortie
a16128655f Bug 623407 - g_keyfile_settings_backend_new crash
The keyfile backend forms paths like this:

  prefix + group_name + '/' + keyname

If the prefix is '/apps/yelp/' and the group name is '/' then this means
that we end up with a key name of (for example):

  '/apps/yelp/' + '/' + '/' + 'font-adjustment'

= '/apps/yelp///font-adjustment'

which is obviously not a valid key name.

This patch rejects group names starting or ending with '/' or containing
'//' and also rejects keys containing '/'.  This should make it
impossible for invalid keys to be formed.
2010-07-02 11:35:43 -04:00
Ryan Lortie
887d9d83aa g_keyfile_settings_backend_new doc improvement 2010-06-24 02:21:58 -04:00
Ryan Lortie
726e4dd6e7 KeyfileSettingsBackend: fix symbol visibility leak 2010-06-24 02:17:22 -04:00
Ryan Lortie
65fc931fb9 Rework the GSettings keyfile backend 2010-06-24 01:39:12 -04:00
Ryan Lortie
6c3ae976e6 Bug 621266 - GSettings "context" clarification
Remove the concept of "context" in favour of dealing with
GSettingsBackend directly.
2010-06-17 14:05:40 -04:00
Ryan Lortie
61f3f45cb9 add get_permission API to GSettingsBackend
implement it in the various in-tree backends

also, lots of whitespace changes to realign the vtable members
2010-06-05 00:10:05 +02:00
Ryan Lortie
8dddf6499e GSettingsBackend API/ABI change
- add list() virtual method
  - add 'default_value' flag to read() call
2010-04-28 14:41:42 -05:00
Matthias Clasen
32de7d6905 Fix up docs for backend setup functions 2010-04-18 15:57:11 -04:00
Ryan Lortie
eaaa4d14aa add backend setup APIs 2010-04-17 10:26:51 -04:00
Matthias Clasen
a2716ad020 Merge the keyfile settings backend. 2010-04-16 23:57:26 -04:00