After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739593 - A pile of kerberos changes
A pile of kerberos changes
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-11-03 21:10 UTC by Ray Strode [halfline]
Modified: 2015-05-22 14:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
identity: destroy alarms from main thread, even on dispose (3.26 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
committed Details | Review
identity: add some locking around expiration time (5.54 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
committed Details | Review
identity: make verify_identity have one exit path (5.95 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
committed Details | Review
identity: don't set expiration_time to 0 intermediately while verifying identity (7.66 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
committed Details | Review
kerberos: maintain one long-lasting object manager client to kerberos service (48.39 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
none Details | Review
identity: separate identity service off into its own process (20.84 KB, patch)
2014-11-03 21:11 UTC, Ray Strode [halfline]
none Details | Review
kerberos: zero initialize operation structure (2.71 KB, patch)
2014-11-03 21:14 UTC, Ray Strode [halfline]
committed Details | Review
kerberos: drop weird, superfluous assignment in query function (2.81 KB, patch)
2014-11-04 14:57 UTC, Ray Strode [halfline]
committed Details | Review
kerberos: fail inquiry if provided buffer is too small for password (16.91 KB, patch)
2014-11-04 14:57 UTC, Ray Strode [halfline]
committed Details | Review
inquiry: fix edge case when answer is full size of reply buffer (2.88 KB, patch)
2014-11-04 14:57 UTC, Ray Strode [halfline]
committed Details | Review
kerberos: Maintain one long-lasting object manager client (42.01 KB, patch)
2015-05-22 13:22 UTC, Debarshi Ray
committed Details | Review
identity: Separate identity service off into its own process (8.41 KB, patch)
2015-05-22 13:22 UTC, Debarshi Ray
committed Details | Review

Description Ray Strode [halfline] 2014-11-03 21:10:59 UTC
I've done few kerberos changes for RHEL.
The most notable changes are:

1) moving the identity service to a separate process so if it leaks or crashes
it won't bring down all of goa

2) fixing a leak in ObjectManager objects by making the ObjectManager be a singleton
(versus adding a finalize method and freeing it there)

3) a crasher fix
Comment 1 Ray Strode [halfline] 2014-11-03 21:11:01 UTC
Created attachment 289940 [details] [review]
identity: destroy alarms from main thread, even on dispose

These days we defer destroying alarms to the main thread when
alarms are reset.  We still dispose of alarms in the current
thread when disposing their identity object, however.

This commit changes the code to always dispose of alarms from
the main thread.
Comment 2 Ray Strode [halfline] 2014-11-03 21:11:04 UTC
Created attachment 289941 [details] [review]
identity: add some locking around expiration time

We don't want the expiration time to get read while it's getting
written.
Comment 3 Ray Strode [halfline] 2014-11-03 21:11:09 UTC
Created attachment 289942 [details] [review]
identity: make verify_identity have one exit path

This makes the control flow easier to follow and lays the way
for a follow up change.
Comment 4 Ray Strode [halfline] 2014-11-03 21:11:13 UTC
Created attachment 289943 [details] [review]
identity: don't set expiration_time to 0 intermediately while verifying identity

The top of verify_identity calls

set_expiration_time(self, 0);

as a way to make sure the expiration time is 0'd if the identity's
credentials are invalidated.  In the case, they are still valid,
set_expiration_time is called again with the new, most up to date
value. The problem is the intermediate 0 isn't invisible, there's a
window where the identity can be read and 0 will get returned, even
when the identity is valid.

This commit defers setting the expiration time until the very end of
the function.
Comment 5 Ray Strode [halfline] 2014-11-03 21:11:17 UTC
Created attachment 289945 [details] [review]
kerberos: maintain one long-lasting object manager client to kerberos service

At the moment, the kerberos backend creates one object manager to the
kerberos identity service per provider object.  Provider objects are actually
fairly transient and get created and destroyed, in some cases, per operation
on an account. The upshot is, object manager clients end up getting created
more frequently than they really should be. To make matters worse, the kerberos
provider has no finalize function, so these object manager clients are getting
leaked.

This commit makes the object manager client get created once at start up,
and get reused by all providers.  Since there's only one object manager,
rooted in the main thread, using the main thread's main loop context
now, the per-thread synchronous codepaths can't call object manager async
functions using a local main loop context. They do this, at the moment, because
there are async, main thread code paths that also need to talk to the
kerberos service. The local main loop context provides a way to call the
async code synchronously, and prevent duplication of logic.

This commit gets rid of all the local main loop contexts, and instead uses
sync functions.  To prevent duplication of logic, the async code now
leverages the sync code, in a thread.
Comment 6 Ray Strode [halfline] 2014-11-03 21:11:21 UTC
Created attachment 289946 [details] [review]
identity: separate identity service off into its own process

This commit segregates the kerberos specific functionality off
into its own helper process.

This has a couple of benefits:

1) It is actually a better fit for how the code was initially designed,
which was first staged in gnome-settings-daemon with g-o-a talking to
it. Right now we have gnome-online-accounts talking to itself,
in-process, through d-bus, which is suboptimal.

2) It keeps any leaks or crashes in the kerberos code from bringing down
the whole online accounts daemon.
Comment 7 Ray Strode [halfline] 2014-11-03 21:14:02 UTC
Created attachment 289947 [details] [review]
kerberos: zero initialize operation structure

We need zero initialize the structure so we don't end up
freeing unused members when cleaning up the operation.
Comment 8 Debarshi Ray 2014-11-04 13:01:47 UTC
Review of attachment 289947 [details] [review]:

Makes sense to me. Is this suitable for older branches?
Comment 9 Debarshi Ray 2014-11-04 13:32:36 UTC
Review of attachment 289940 [details] [review]:

Ok. Suitable for older branches?
Comment 10 Debarshi Ray 2014-11-04 14:11:34 UTC
Review of attachment 289941 [details] [review]:

I hope we continue to be careful to not take the lock recursively while refactoring the code in future. Otherwise looks good to me.
Comment 11 Debarshi Ray 2014-11-04 14:19:55 UTC
Review of attachment 289942 [details] [review]:

Sure, looks good.
Comment 12 Debarshi Ray 2014-11-04 14:42:54 UTC
Review of attachment 289943 [details] [review]:

Makes sense. Suitable for older branches?
Comment 13 Ray Strode [halfline] 2014-11-04 14:54:26 UTC
i'm going to throw another few patches up following our discussion this morning on IRC.
Comment 14 Ray Strode [halfline] 2014-11-04 14:57:43 UTC
Created attachment 289977 [details] [review]
kerberos: drop weird, superfluous assignment in query function

goa_kerberos_identity_inquiry_answer_query has this strange code:

g_return_if_fail (inquiry == kerberos_query->inquiry);
...
inquiry = kerberos_query->inquiry;

It's completely redundant and makes no sense so drop it.
Comment 15 Ray Strode [halfline] 2014-11-04 14:57:47 UTC
Created attachment 289978 [details] [review]
kerberos: fail inquiry if provided buffer is too small for password

Right now we just truncate the user's response if it's too big for
the passed in buffer.  That's wrong on a theoretical level; we
shouldn't ever use a password that the user didn't enter
(even if it's a truncated version of what the user did enter).
In practice, it's not actually a problem. The kerberos library provides
a full 1024 byte buffer, which is much longer than a user would
realistically enter into an entry.

Still, this commit addresses the problem by introducing a mechanism for
failing the inquiry.
Comment 16 Ray Strode [halfline] 2014-11-04 14:57:51 UTC
Created attachment 289979 [details] [review]
inquiry: fix edge case when answer is full size of reply buffer

Right now if the user's answer is 1024 bytes exactly then we'll
call strlen() on an unterminated string.

This commit addresses the issue by avoiding the strlen() call and
instead using the already computed length.
Comment 17 Debarshi Ray 2014-11-04 15:40:00 UTC
Review of attachment 289977 [details] [review]:

Ofcourse
Comment 18 Debarshi Ray 2014-11-04 15:48:00 UTC
Review of attachment 289978 [details] [review]:

Makes sense.

::: src/goaidentity/goakerberosidentityinquiry.c
@@ +34,3 @@
   int number_of_queries;
   int number_of_unanswered_queries;
+  guint is_failed : 1;

Is it really worth doing this instead of using a gboolean?
Comment 19 Debarshi Ray 2014-11-04 15:58:30 UTC
Review of attachment 289979 [details] [review]:

Of course.
Comment 20 Ray Strode [halfline] 2014-11-05 18:54:25 UTC
(In reply to comment #8)
> Review of attachment 289947 [details] [review]:
> 
> Makes sense to me. Is this suitable for older branches?

yea, definitely.
Comment 21 Ray Strode [halfline] 2014-11-05 18:57:18 UTC
(In reply to comment #9)
> Review of attachment 289940 [details] [review]:
> 
> Ok. Suitable for older branches?
at least 3-12. it's sort of a follow up to bug 729718 .
Comment 22 Ray Strode [halfline] 2014-11-05 18:59:48 UTC
(In reply to comment #12)
> Review of attachment 289943 [details] [review]:
> 
> Makes sense. Suitable for older branches?

i think so, but it of course depends on the commit before it that restructures the function, so that would need to go too.
Comment 23 Ray Strode [halfline] 2014-11-05 19:01:47 UTC
(In reply to comment #18)
> Review of attachment 289978 [details] [review]:
> 
> Makes sense.
> 
> ::: src/goaidentity/goakerberosidentityinquiry.c
> @@ +34,3 @@
>    int number_of_queries;
>    int number_of_unanswered_queries;
> +  guint is_failed : 1;
> 
> Is it really worth doing this instead of using a gboolean?
no, not really. it's a question of coding style. If you prefer gboolean, then gboolean is fine with me.
Comment 24 Ray Strode [halfline] 2014-11-05 19:07:34 UTC
Comment on attachment 289979 [details] [review]
inquiry: fix edge case when answer is full size of reply buffer

Attachment 289979 [details] pushed as 524ea19 - inquiry: fix edge case when answer is full size of reply buffer
Comment 25 Debarshi Ray 2015-05-22 13:22:03 UTC
Created attachment 303819 [details] [review]
kerberos: Maintain one long-lasting object manager client
Comment 26 Debarshi Ray 2015-05-22 13:22:33 UTC
Created attachment 303820 [details] [review]
identity: Separate identity service off into its own process
Comment 27 Debarshi Ray 2015-05-22 13:25:06 UTC
The order in which these patches were generated (with respect to bug 739594), was different from the RHEL patches. I rebased these against master in the same order as RHEL since that is what we have been actually shipping so far.

Sorry for having let these slip through the cracks.