when doing ck-list-sessions from a ssh session i noticed that "is-local" is "TRUE", i decided to try to find out why and after some debugging i stumbled on this while loop:
|
while (!is_local && g_variant_iter_next (iter, "{sv}", &prop_name, &value)) { |
|
if (g_strcmp0 (prop_name, "is-local") == 0) { |
|
is_local = TRUE; |
|
} |
|
if (g_strcmp0 (prop_name, "login-session-id") == 0) { |
|
is_local = _verify_login_session_id_is_local (manager, g_variant_get_string (value, 0)); |
|
} |
|
g_free (prop_name); |
|
g_variant_unref (value); |
|
} |
it sets "is_local" to true if it finds the "is-local" prop even if it's value is false.
also when reading the comment above which says "Only allow a local session if originating from an existing local session....", i thought it meant that only allow "is_local" to be true if both "is-local" and "_verify_login_session_id_is_local()" are true; but the while loop terminates if either are true, and "_verify_login_session_id_is_local()" can just override "is-local".
so when you set "is-local" to be false when opening a new session not only does it completely ignore that, but even if it didn't it can still be set to true, this seems to be completely opposite of what the comment instructs.
so i attempted to patch it like this:
diff --git a/src/ck-manager.c b/src/ck-manager.c
index c8a244e..3b183c1 100644
--- a/src/ck-manager.c
+++ b/src/ck-manager.c
@@ -2900,6 +2900,7 @@ verify_and_open_session_for_leader (CkManager *manager,
GDBusMethodInvocation *context)
{
gboolean is_local = FALSE;
+ gboolean is_session_id_local = FALSE;
GVariantIter *iter;
gchar *prop_name;
GVariant *value;
@@ -2911,18 +2912,21 @@ verify_and_open_session_for_leader (CkManager *manager,
g_debug ("CkManager: verifying session for leader");
g_variant_get ((GVariant *)parameters, "a{sv}", &iter);
- while (!is_local && g_variant_iter_next (iter, "{sv}", &prop_name, &value)) {
+ while (g_variant_iter_next (iter, "{sv}", &prop_name, &value)) {
if (g_strcmp0 (prop_name, "is-local") == 0) {
- is_local = TRUE;
+ is_local = g_variant_get_boolean (value);
}
if (g_strcmp0 (prop_name, "login-session-id") == 0) {
- is_local = _verify_login_session_id_is_local (manager, g_variant_get_string (value, 0));
+ is_session_id_local = _verify_login_session_id_is_local (manager, g_variant_get_string (value, 0));
}
g_free (prop_name);
g_variant_unref (value);
}
g_variant_iter_free (iter);
+ if (is_session_id_local == FALSE)
+ is_local = FALSE;
+
g_debug ("CkManager: found is-local=%s", is_local ? "true" : "false");
open_session_for_leader (manager,
but when rebooting it seems that all my sessions are not local, so i have no idea how it is supposed to begin a local session when also verifying that login session id is local.
so ignoring the comment i just decided to only use login-session-id to bootstrap is-local, then when looking at commit history i found that it was also used to only bootstrap in the past, so this is the final patch that works for me:
diff --git a/src/ck-manager.c b/src/ck-manager.c
index c8a244e..3a555b8 100644
--- a/src/ck-manager.c
+++ b/src/ck-manager.c
@@ -2899,7 +2899,8 @@ verify_and_open_session_for_leader (CkManager *manager,
GVariant *parameters,
GDBusMethodInvocation *context)
{
- gboolean is_local = FALSE;
+ gboolean is_local = -1;
+ gboolean is_session_id_local = -1;
GVariantIter *iter;
gchar *prop_name;
GVariant *value;
@@ -2911,18 +2912,23 @@ verify_and_open_session_for_leader (CkManager *manager,
g_debug ("CkManager: verifying session for leader");
g_variant_get ((GVariant *)parameters, "a{sv}", &iter);
- while (!is_local && g_variant_iter_next (iter, "{sv}", &prop_name, &value)) {
+ while (g_variant_iter_next (iter, "{sv}", &prop_name, &value)) {
if (g_strcmp0 (prop_name, "is-local") == 0) {
- is_local = TRUE;
+ is_local = g_variant_get_boolean (value);
}
if (g_strcmp0 (prop_name, "login-session-id") == 0) {
- is_local = _verify_login_session_id_is_local (manager, g_variant_get_string (value, 0));
+ is_session_id_local = _verify_login_session_id_is_local (manager, g_variant_get_string (value, 0));
}
g_free (prop_name);
g_variant_unref (value);
}
g_variant_iter_free (iter);
+ if (is_local == -1 && is_session_id_local == TRUE)
+ is_local = TRUE;
+ else if (is_local == -1)
+ is_local = FALSE;
+
g_debug ("CkManager: found is-local=%s", is_local ? "true" : "false");
open_session_for_leader (manager,
what is the purpose of "_verify_login_session_id_is_local"? how is it meant to work?
when doing ck-list-sessions from a ssh session i noticed that "is-local" is "TRUE", i decided to try to find out why and after some debugging i stumbled on this while loop:
ConsoleKit2/src/ck-manager.c
Lines 2914 to 2923 in 735ae64
it sets "is_local" to true if it finds the "is-local" prop even if it's value is false.
also when reading the comment above which says "Only allow a local session if originating from an existing local session....", i thought it meant that only allow "is_local" to be true if both "is-local" and "_verify_login_session_id_is_local()" are true; but the while loop terminates if either are true, and "_verify_login_session_id_is_local()" can just override "is-local".
so when you set "is-local" to be false when opening a new session not only does it completely ignore that, but even if it didn't it can still be set to true, this seems to be completely opposite of what the comment instructs.
so i attempted to patch it like this:
but when rebooting it seems that all my sessions are not local, so i have no idea how it is supposed to begin a local session when also verifying that login session id is local.
so ignoring the comment i just decided to only use login-session-id to bootstrap is-local, then when looking at commit history i found that it was also used to only bootstrap in the past, so this is the final patch that works for me:
what is the purpose of "_verify_login_session_id_is_local"? how is it meant to work?