Commit Graph

171 Commits

Author SHA1 Message Date
Milan Crha
523fe32b65 secret-file-backend: Fix use-after-free in flatpak
The on_portal_retrieve_secret() can connect a GCancellable, but it
doesn't disconnect from it (only when the cancellable is cancelled),
which means when the cancellable is cancelled later, when the GTask
is gone, the callback is called with already freed data.
2020-03-19 09:24:52 +01:00
Niels De Graef
af389ad6f8 Prefer g_info() over g_message()
Libraries shouldn't really use `g_message()` as it will show up in
consumer application outputs. Let's use `g_info()` instead.

Fixes https://gitlab.gnome.org/GNOME/libsecret/issues/40
2020-03-11 05:35:33 +00:00
Niels De Graef
692e7244be meson: Don't specify shared_library()
Some people might want to statically link to libsecret, so use the more
general `library()` target to build libsecret.
2020-03-10 13:36:33 +00:00
Daiki Ueno
a54f5011fc secret-file-collection: force little-endian in GVariant
As the GVariant serialization format does not record the original
endianness of integer values, we need to ensure that it doesn't change
between write and load.
2020-03-10 13:20:31 +00:00
Daiki Ueno
e6881d4ff1 build: Suppress compiler warning if compiled with G_DISABLE_ASSERT
This is similar to 0be63575ff but for
test-file-collection.c.

Fixes #36.
2020-01-14 10:13:16 +01:00
Daiki Ueno
cf21ad50b6 secret-file-collection: Rename internal functions to avoid conflicts
As encrypt() is a standard POSIX function, its declaration had
conflict with our own.  Let's be more verbose about naming of the
internal crypto functions.

Fixes #35.
2020-01-14 10:09:29 +01:00
Niels De Graef
abb4448ca7 item: Port to GTask
`GSimpleAsyncResult` is deprecated in favor of `GTask`.
2020-01-13 13:21:31 +00:00
Daiki Ueno
06d803c478 meson: Point to the base directory of header files in pkgconfig
Fixes commit 22d11f8b22
2019-10-15 10:33:28 +02:00
Daiki Ueno
fb7368f9fe meson: Use "Requires" instead of "Requires.private" in pkgconfig
Also drop libgcrypt dependency for now.
2019-10-14 18:00:39 +02:00
Abderrahim Kitouni
22d11f8b22 meson: add include directory to the generated pkg-config file
Fixes 300ddc702e
2019-10-14 10:14:45 +01:00
Daiki Ueno
a278adc208 secret-backend: Check if portal is available
Before decising to use the file backend, check if the necessary portal
interface is available on the D-Bus.

Suggested by Patrick Griffis.
2019-10-13 06:21:38 +00:00
Daiki Ueno
8f886f0797 secret-file-backend: Retrieve master password from flatpak portal 2019-10-13 06:21:38 +00:00
Daiki Ueno
2d642b5b7d secret-file-backend: New backend for storing secrets in file
This adds a new backend based on locally stored file.
2019-10-13 06:21:38 +00:00
Fabrice Fontaine
93b7043b5f libsecret.pc: add Libs.private field for libgcrypt
When libgcrypt is available, libsecret links with it. When dynamic
linking is used, there is no problem: libsecret.so has a NEEDED
pointing to libgcrypt, so linking an application with -lsecret works
fine. However, when doing static linking, you must specify the entire
chain of libraries, otherwise you get unresolved symbols errors, such
as:

host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libsecret-1.a(libsecret_1_la-secret-session.o): In function `request_open_session_aes':
build/libsecret-0.18.3/libsecret/secret-session.c:99: undefined reference to `gcry_mpi_release'
build/libsecret-0.18.3/libsecret/secret-session.c:101: undefined reference to `gcry_mpi_aprint'
build/libsecret-0.18.3/libsecret/secret-session.c:107: undefined reference to `gcry_free'

In order to solve this, we simply need to indicate in the Libs.private
field of the .pc file that we depend on libgcrypt.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/libsecret/0001-libsecret.pc-add-Libs.private-field-for-libgcrypt.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-10-12 16:16:11 +00:00
Daiki Ueno
300ddc702e meson: Use pkgconfig module instead of substitution 2019-10-12 02:46:06 +02:00
Rico Tzschichholz
a6317352e8 build: Properly expose backend vfuncs to vapi 2019-10-08 07:55:55 +00:00
Daiki Ueno
060061905a secret-password: Add necessary gir annotations 2019-10-08 07:55:55 +00:00
Daiki Ueno
49e6e0cf60 secret-password: Port to SecretBackend interface 2019-10-08 07:55:55 +00:00
Daiki Ueno
b37d2b8d20 secret-backend: Add a way to uncache singleton instance
This is ugly, but necessary to handle instance uncaching in
SecretBackend when the backend instance is gone.
2019-10-08 07:55:55 +00:00
Daiki Ueno
71a19a95ae secret-service: Implement SecretBackendInterface 2019-10-08 07:55:55 +00:00
Daiki Ueno
a0d10597ee secret-backend: New interface to represent password storage backend
This interface provides a separation between the
frontend (secret_password*) and the backend (SecretService).  That
makes it easier to replace SecretService with a custom backend
implementation.
2019-10-08 07:55:55 +00:00
Daiki Ueno
e6456698ec secret-service: Move parent property setting to constructor
This makes it possible to instantiate a SecretService instance
directly through g_initable_new() or g_async_initable_new_async().
2019-10-08 07:55:55 +00:00
Jan Alexander Steffens (heftig)
aae0329ba3
service: Fix secret_service_ensure_session_finish error propagation
The condition checking g_task_is_valid was inverted, resulting in errors
being ignored.

Move the check to a g_return_val_if_fail to be in line with all other
uses of g_task_is_valid.

Fixes https://bugs.archlinux.org/task/63666
2019-09-05 18:42:26 +02:00
Daiki Ueno
c06c9d2e26 build: Simplify file substitution
Since meson 0.50, configuration_data() can take a dictionary.
2019-07-25 19:59:05 +02:00
Daiki Ueno
a4ea97d6e6 build: Simplify pathname handling
This switches to using relative paths as much as possible, and the "/"
shorthand for join_paths.
2019-07-25 19:59:01 +02:00
Daiki Ueno
e3963efdee secret-password: Mark @schema argument nullable for *v functions
Given these functions take a hash table built from valid attributes,
there is no need to re-validate.  This is also consistent with the
secret_service API.
2019-07-18 13:54:12 +00:00
Daiki Ueno
a5db34dcd5 secret-value: Add secret_value_unref_to_password
This adds the secret_value_unref_to_password function that
unreferences and returns the stored secret in non-pageable memory.
This is supposed to be used with secret_password_lookup_binary*
functions.
2019-07-18 13:54:12 +00:00
Daiki Ueno
2ae6ec89f4 tests: Add tests for binary variant of secret_{lookup,store} 2019-07-18 13:54:12 +00:00
Daiki Ueno
29c1460fd7 secret-password: Add store_binary functions
This adds a set of functions that takes a SecretValue instead of a
text password when storing a secret.  This is useful if the stored
password is not null-terminated.
2019-07-18 13:54:12 +00:00
Daiki Ueno
bac85c00fc secret-password: Add lookup_binary functions
This adds a set of functions that return a SecretValue instead of a
text password when looking up a secret.  This is useful if the stored
password is not null-terminated.
2019-07-18 13:54:12 +00:00
Daiki Ueno
5fedca8ffc secret-password: Add search functions
This adds a set of functions that expose secret_service_search* from
the simple API.
2019-07-18 13:54:12 +00:00
Daiki Ueno
092d4ef47d secret-item: Implement SecretRetrievableInterface 2019-07-18 13:54:12 +00:00
Daiki Ueno
938640ae52 secret-retrievable: New interface to represent read-only item
This is a ground work for adding a local storage backend.  As
SecretItem is derived from GDBusProxy, it cannot be simply exposed to
the application through the secret_password_search() if the item is
not backed by the DBus API.  This adds an abstract interface
representing a read-only view of a secret item for that purpose.
2019-07-18 13:54:12 +00:00
Daiki Ueno
0be63575ff build: Suppress compiler warning if compiled with G_DISABLE_ASSERT 2019-06-29 06:54:40 +02:00
Daiki Ueno
d17e93e696 tests: undef G_DISABLE_ASSERT
Since GLib 2.58, g_test_init started to be no-op if a test is compiled
with G_DISABLE_ASSERT defined.
2019-06-29 06:54:37 +02:00
Daiki Ueno
0e6b542ff5 secret-version: Remove garbage after #endif 2019-06-17 19:32:48 +02:00
Michael Catanzaro
2b4adfb9f4 Fix -Wunknown-pragmas triggered by secret-version.h
In file included from /usr/include/libsecret-1/libsecret/secret.h:33,
                 from ../lib/sync/../ephy-sync-utils.h:24,
                 from ../lib/sync/ephy-history-manager.c:25:
/usr/include/libsecret-1/libsecret/secret-version.h:19: error: ignoring #pragma __once__  [-Werror=unknown-pragmas]
 #pragma __once__

It should be #pragma once, not #pragma __once__.

But let's follow the other public headers here instead.
2019-06-13 15:00:20 +00:00
Sutou Kouhei
c00283ebd0 Add version macros
Added macros:

  * SECRET_VERSION_MAJOR
  * SECRET_VERSION_MINOR
  * SECRET_VERSION_MICRO
  * SECRET_CHECK_VERSION

These macros are widely defined in GLib based library. For example,
GLib, GTK, poppler GLib and so on define them.

These macros are useful to detect libsecret version on build type and
from GObject Introspection based bindings.
2019-06-09 16:38:39 +02:00
Niels De Graef
1f61ecb911 util: Port from GSimpleAsyncResult to GTask 2019-05-18 20:26:20 +02:00
Niels De Graef
9087c668c7 paths: Port from GSimpleAsyncResult to GTask 2019-05-18 19:02:18 +02:00
Niels De Graef
f165f721d8 Port Service and Session to GTask
GSimpleAsyncResult is deprecated in favor of the simpler GTask, so use
that instead. This cuts down on the deprecation warnings.

I wanted to do both separately, but porting one without the other led to
some faulty casts from GSimpleAsyncResult to GTask (and vice versa).
2019-05-15 18:21:34 +02:00
Niels De Graef
929e5c2a3f Stop using g_assert() in unit tests
Apart from having more developer-friendly messages if the assertions go
wrong, it also prevents the assertions not being run if
`G_DISABLE_ASSERT` is defined (e.g. for performance reasons).
2019-05-12 16:31:37 +02:00
Emmanuele Bassi
15902b70b2 Use proper prefix for SecretCollection flags
Commit f36379af33 added the enumeration
GType for SecretCollectionFlags and SecretCollectionCreateFlags in the
introspection data, but by doing so it broke existing users of the
introspected API.

Additionally, the enumeration nicknames—which are used to generate the
enumeration value from the type name and the namespace—were wrong
before, and are wrong now. The idiomatic way to name enumeration members
is to use the uppercase, snake case version of the type name, and append
the value at the end:

  SecretCollectionFlags → SECRET_COLLECTION_FLAGS_NONE
  SecretCollectionCreateFlags → SECRET_COLLECTION_CREATE_FLAGS_NONE

If this practice is not followed, enumerations should use the
glib-mkenums trigraph and the `prefix` option; this tells glib-mkenums,
and the introspection parser after that, where to cut off the prefix and
which part of the enumeration value should be considered the nickname.

Thus, with `prefix=SECRET_COLLECTION` we can turn:

  SECRET_COLLECTION_NONE

into:

  Secret.CollectionFlags.NONE

which is the idiomatic form of an enumeration value.
2019-05-11 00:15:04 +01:00
Kouhei Sutou
65153a2bf4 Remove a needless tab 2019-05-07 11:10:44 +00:00
Kouhei Sutou
f36379af33 Add missing GType to flags in .gir
Here is a sample diff by this change:

    --- Secret-1.gir.before	2019-05-07 15:20:58.252288010 +0900
    +++ Secret-1.gir.after	2019-05-07 15:26:54.314413832 +0900
    @@ -1141,22 +1140,32 @@
           </field>
         </record>
         <bitfield name="CollectionCreateFlags"
    +              glib:type-name="SecretCollectionCreateFlags"
    +              glib:get-type="secret_collection_create_flags_get_type"
                   c:type="SecretCollectionCreateFlags">
           <doc xml:space="preserve">Flags for secret_collection_create().</doc>
    -      <member name="collection_create_none"
    +      <member name="none"
                   value="0"
    -              c:identifier="SECRET_COLLECTION_CREATE_NONE">
    +              c:identifier="SECRET_COLLECTION_CREATE_NONE"
    +              glib:nick="none">
             <doc xml:space="preserve">no flags</doc>
           </member>
         </bitfield>

Other flags such as SecretServiceFlags also have GType in .gir.
2019-05-07 15:27:21 +09:00
Niels De Graef
6658602b6b secret-paths: Add (nullable) if allowed.
This caused segfaults in Seahorse when someone canceled the "Change
Password" dialog for a keyring.

Related to GNOME/seahorse#204
2019-03-01 10:02:05 +01:00
Rico Tzschichholz
50c1d717ca meson: Pass correct header to generate_gir to fix broken vapi 2019-01-25 22:08:37 +01:00
Rico Tzschichholz
8bf566f265 Drop accidentially committed .dirstamp
See b19c309096
2019-01-25 21:59:04 +01:00
Niels De Graef
950b22bab6 Remove deprecated g_type_class_add_private()
Use `G_ADD_PRIVATE()` or its shorthand when defining a type using
`G_DEFINE_TYPE_WITH_PRIVATE()`
2019-01-24 00:07:33 +01:00
Niels De Graef
b483b15d9d Don't end G_DEFINE_AUTOPTR_CLEANUP_FUNC with a ;
Normally it shouldn't matter too much, but the GIR parser apparently
doesn't like it:

```
/home/niels/gnome/libsecret/libsecret/secret-schema.h:75: syntax error, unexpected ';' in ';' at ';'
/home/niels/gnome/libsecret/libsecret/secret-prompt.h:78: syntax error, unexpected ';' in ';' at ';'
/home/niels/gnome/libsecret/libsecret/secret-value.h:54: syntax error, unexpected ';' in ';' at ';'
/home/niels/gnome/libsecret/libsecret/secret-service.h:307: syntax error, unexpected ';' in ';' at ';'
/home/niels/gnome/libsecret/libsecret/secret-collection.h:176: syntax error, unexpected ';' in ';' at ';'
/home/niels/gnome/libsecret/libsecret/secret-item.h:194: syntax error, unexpected ';' in ';' at ';'
```
2019-01-19 23:59:02 +01:00