Commit Graph

224 Commits

Author SHA1 Message Date
Daiki Ueno
3c97587608 secret-file-collection: Improve etag tracking
This resets self->etag only after successful load of the contents, by
using a temporary variable and checking error of
g_file_replace_contents_finish, etc.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2023-10-19 17:23:38 +09:00
Daiki Ueno
f83cd26858 secret-service: Don't unnecessary increase refcount
As the GVariant returned in secret_service_real_prompt_finish should
be already sunk by secret_prompt_perform_finish, calling
g_variant_ref_sink actually increases the refcount and causes a leak.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2023-10-19 13:52:59 +09:00
Daiki Ueno
92705b58a3 secret-paths: Make sure to unref GVariant
The GVariant returned in
secret_service_get_secret{,s}_for_dbus_path{,s}_finish should be
unref'ed after use.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2023-10-19 13:52:59 +09:00
Daiki Ueno
e9818571e3 secret-paths: Fix memleak when unlocking a path
A GPtrArray allocated to temporarily hold (un)locked item paths was
not freed when the collection has a non-empty D-Bus path.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2023-10-18 16:06:23 +09:00
Milan Crha
1f44c81ca4 secret-file-collection: Check for file changes and reload when needed
When some other process changes the underlying file, the collection
should reload its in-memory content, to reflect the changes.

Closes https://gitlab.gnome.org/GNOME/libsecret/-/issues/62
2023-09-18 13:25:38 +02:00
panoplie
7387774263 sync-search: unlock keyring before getting secret attributes
In gnome-keyring, the secret items attributes are not visible until the keyring
is unlocked. But in libsecret, the synchronous secret search function unlocks
the keyring after and not before the attributes dbus pull.

So when the keyring is locked and you run secret_service_search_sync(), you get
hashed or empty attributes because the keyring was locked at the time these
attributes were pulled. If you run this function when the keyring is already
unlocked, there is no problem.

This commit moves the unlock routine before the attributes pull to make the
synchronous search function working correctly when the keyring is locked
initially.

Issues #6 gnome-shell#4780
2023-05-24 07:04:14 +00:00
panoplie
31ea8cb41d Rename secret_search_unlock_load_or_complete()
This function does not unlock the keyring anymore so we remove the "unlock"
term from its name.
2023-05-24 07:04:14 +00:00
panoplie
701a312eb7 async-search: unlock keyring before getting secret attributes
In gnome-keyring, the secret items attributes are not visible until the keyring
is unlocked. But in libsecret, the asynchronous secret search function unlocks
the keyring after and not before the attributes dbus pull.

So when the keyring is locked and you run secret_service_search(), you get
hashed or empty attributes because the keyring was locked at the time these
attributes were pulled. If you run this function when the keyring is already
unlocked, there is no problem.

This commit moves the unlock routine before the attributes pull to make the
asynchronous search function working correctly when the keyring is locked
initially.

The secret_search_unlock_load_or_complete function should be renamed to
secret_service_load_or_complete. To keep this commit readable, it is done in
the next commit.

Issues #6 gnome-shell#4780
2023-05-24 07:04:14 +00:00
Michael Catanzaro
25e1e11c81 file-backend: avoid critical when cancellable is unset
In 0e205fce5f I improperly assumed that
the cancellable would always be valid. Avoid criticals when it is NULL.
2023-05-16 08:14:39 -05:00
Michael Catanzaro
0e205fce5f file-backend: avoid deadlock when portal op is canceled
Calling g_cancellable_disconnect() inside a cancelled handler is a
guaranteed deadlock. Cancellables should only be canceled once, so we
don't need to worry about a second cancellation occurring. I think it's
sufficent to disconnect when the InitClosure is freed.

Fixes #86
2023-04-27 09:20:48 -05:00
Niels De Graef
0f04e5d371 Stop using GSlice
GLib is discussing deprecating/removing it upstream [1] since it has
only limited uses. Next to that, it seems to bork stack traces here when
using ASAN (for which you also have to specify `G_SLICE=always-malloc`
and some other envvars too).

In other words, let's just get rid of using `GSlice` and call the
allocation APIs directly.

[1]: https://gitlab.gnome.org/GNOME/glib/-/issues/1079
2023-01-16 19:17:59 +01:00
Niels De Graef
7d7c1b3430 file-backend: Extract TPM code into separate function
That way, we have a function we can also call in case we want to provide
a synchronous constructor.

This also fixes some cases where the `EggTpm2Context` was not properly
cleaned up in case of some error paths.
2023-01-15 10:12:59 +00:00
Niels De Graef
7b461f5514 file-backend: Extract function to return GFile
A small cleanup
2023-01-15 10:12:59 +00:00
Jens Georg
5183076772 Fix finish function for searchv 2022-11-22 00:03:53 +01:00
Niels De Graef
b9e6394aff secret-paths: Fix a little memory leak 2022-10-25 05:56:56 +00:00
Julian Schmidhuber
921f5f0d2e Fix nullable in secret_collection_for_alias_* 2022-09-19 16:14:47 +02:00
Daiki Ueno
d768ce4efe Properly chain-up GTasks around GDBusProxy::init_async
Our GAsyncInitable implementations in SecretService, SecretCollection,
and SecretItem internally wrap GDBusProxy::init_async and perform
additional error processing. To chain up we used to pass around a
single GTask, which caused an issue in the (additional) error path:
GDBusProxy::init_async may have already called
g_task_return_boolean(task, TRUE) and in that case GLib produces the
following warning:

  g_task_return_error: assertion '!task->ever_returned' failed

This fixes the issue by creating a temporary GTask around
GDBusProxy::init_async call.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2022-05-09 16:27:44 +02:00
Maximiliano Sandoval R
350f987f67
secrets_for_dbus_paths: Improve return doc 2022-02-07 13:02:11 +01:00
Maximiliano Sandoval R
ca80b20042
Fix typos on links 2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
1d1363a780
docs: Merge unused docs for backend & retrievable
Only one doc will appear in gir and gi-docgen docs.
2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
56bf2c8fe9
docs: Remove large indentations
Indentations by more than four spaces make gi-docgen read them as a
quote block.
2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
3f9738bdd4
docs: Document errors 2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
6d5c9782ac
CHECK_VERSION: Document macro
Macros do not use Returns annotation.
2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
8726110219
docs: All docs should have a header line
This line should have a single sentence.
2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
e4ea94621b
secret_value_unref_to_password: Annotate out param 2022-02-07 13:02:10 +01:00
Maximiliano Sandoval R
0457c29dad
docs: Document BACKEND_EXTENSION_POINT_NAME 2022-02-07 13:02:09 +01:00
Maximiliano Sandoval R
868a88ffe8
secret-schema: Add missind docs 2022-02-07 13:02:09 +01:00
Maximiliano
2c3a34cca4 Port documentation to gi-docgen 2022-02-02 12:19:14 +00:00
Dhanuka Warusadura
f882a03f44 Fix deprecated-declarations warnings
These changes fix the existing deprecated-declarations
warnings found during the build process.

Related to: https://gitlab.gnome.org/GNOME/libsecret/-/merge_requests/43
2021-11-21 08:51:32 +05:30
Slava Aseev
d620c79d83
Create default collection after DBus.Error.UnknownObject
Some Secret Service API backend implementations (like keepassxc)
throws UnknownObject (instead of UnknownMethod as gnome-keyring do)
after creating an item in the non-existent
/org/freedesktop/secrets/aliases/default.
2021-08-16 19:25:56 +03:00
Dhanuka Warusadura
ea57d26930 Add TPM2 integration to secret file backend
These changes add TPM2 derived encryption key to secret
file backend.
2021-08-12 21:14:26 +05:30
Evangelos Ribeiro Tzaras
436200b0cb docs: Fix typos 2021-07-09 17:08:29 +02:00
Corentin Noël
0b2844da47 secret-file-backend: Avoid closing the same file descriptor twice
It is already closed a few lines above
2021-06-16 09:05:33 +02:00
Daiki Ueno
86f5afbb10 Remove unnecessary "volatile"
The documentation of g_dbus_error_register_error_domain suggests that
the argument passed to it should not be volatile.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2021-06-12 13:29:36 +02:00
Dhanuka Warusadura
7e713cf65a Fix issues flagged by static analyzers
These changes specifically fix the issues flagged by clang-analyzer.
Fixes: #59
2021-03-31 10:59:04 +00:00
Richard Purdie
b7d4f8cb36 secret-enum-types.c/h.template: Fix reproducibility issue
When full filenames are used in generated sources it makes the resulting
debug packages non-reproducible. Best practise is to use basename instead.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-03-31 09:38:47 +00:00
Niels De Graef
be67deb1c0 methods: Port to GTask
`GSimpleAsyncResult` is deprecated in favor of `GTask`.
2021-02-21 21:44:37 +00:00
Niels De Graef
4266889f33 collection: Port to GTask
`GSimpleAsyncResult` is deprecated in favor of `GTask`.
2021-02-21 21:44:37 +00:00
Sebastien Bacher
1298c7812c Handle snaps the same way as flatpaks 2021-02-19 09:16:23 +01:00
Niels De Graef
82fe5dada1 Mark NULL with appropriate gtk-doc prefix
This looks cleaner for the docs generated by the several bindings.
2021-02-06 16:46:23 +00:00
Niels De Graef
41c8a8282f Mark optional GCancellables as (nullable) 2021-02-06 16:46:23 +00:00
Niels De Graef
402c9fb7fd Get rid of (allow-none) annotations
The `(allow-none)` annotation was deprecated for `(nullable)` and
`(optional)` to solve some ambiguous uses of the tag.
2021-02-06 16:46:23 +00:00
Niels De Graef
7e3c56ba1e Use G_GNUC_NULL_TERMINATED where appropriate
Give our API consumers an extra hint if they're using varargs without an
appropriate `NULL`-sentinel.
2021-02-06 11:47:11 +01:00
Matt Turner
3ad122a633 meson: build test-vala-unstable with -DSECRET_WITH_UNSTABLE
Fixes: https://gitlab.gnome.org/GNOME/libsecret/-/issues/54
2020-12-19 19:29:35 +00:00
Christopher Davis
9d510d5c04 secret-paths.c: Add annotations for paths variable
Fixes an issue with annotations that would cause
Rust bindings to generate incorrectly.
2020-12-10 12:31:13 -08:00
Niels De Graef
fae49c76d4 ci: Fix the coverage build 2020-11-15 21:01:53 +01:00
Niels De Graef
2147b96c9d Drop autotools-based build
Our official instructions only tell how to build with Meson, our CI is
only done with Meson and I wouldn't be surprised if most developers only
used Meson as well.

In other words, the autotools build is outdated. Let's say our goodbye
and drop it in the next stable release.
2020-11-15 20:37:48 +01:00
Daiki Ueno
2f0df81084 secret-file-collection: Make MAC comparison constant time 2020-10-04 17:27:40 +02:00
Mikhail Zabaluev
caf9c0345c Initialize libgcrypt for SecretFileCollection
Make sure libgcrypt is initialized before any SecretFileCollection
instance uses it.
2020-06-18 10:25:36 +03:00
Niels De Graef
bfa66f35cc meson: Add tests for GIR-based languages
Also add a test suite argument to more easily distinguish them.
2020-06-17 22:02:15 +02:00