| 1 | /* |
| 2 | * Copyright 2021-2022 Endless OS Foundation, LLC |
| 3 | * Copyright 2023 Red Hat, Inc |
| 4 | * |
| 5 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 23 | |
| 24 | #include "xdp-permissions.h"cxx . . $ `<file>/src/xdp-permissions.h`/ |
| 25 | #include "xdp-session-persistence.h"cxx . . $ `<file>/src/xdp-session-persistence.h`/ |
| 26 | |
| 27 | static GMutexcxx . . $ GMutex# transient_permissions_lockcxx . . $ transient_permissions_lock.; |
| 28 | static GHashTablecxx . . $ GHashTable# *transient_permissionscxx . . $ transient_permissions.; |
| 29 | |
| 30 | #define RESTORE_DATA_TYPEcxx . . $ `src/xdp-session-persistence.c:30:9`! "(suv)" |
| 31 | |
| 32 | void |
| 33 | xdp_session_persistence_set_transient_permissionscxx . . $ xdp_session_persistence_set_transient_permissions(39535d30e1370bee). (XdpSessioncxx . . $ XdpSession# *session, |
| 34 | const char *restore_token, |
| 35 | GVariantcxx . . $ GVariant# *restore_data) |
| 36 | { |
| 37 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GMutexLocker) locker = g_mutex_locker_newcxx . . $ g_mutex_locker_new(3c345ff2ce91af48). (&transient_permissions_lockcxx . . $ transient_permissions_lock.); |
| 38 | |
| 39 | if (!transient_permissionscxx . . $ transient_permissions.) |
| 40 | { |
| 41 | transient_permissionscxx . . $ transient_permissions. = |
| 42 | g_hash_table_new_fullcxx . . $ g_hash_table_new_full(e2dd12b570de7430). (g_str_hashcxx . . $ g_str_hash(b11f534102b1ad6)., g_str_equalcxx . . $ g_str_equal(9148c8c3ff42c9d8)., |
| 43 | g_freecxx . . $ g_free(5d22bdacc48458e8)., (GDestroyNotifycxx . . $ GDestroyNotify#) g_variant_unrefcxx . . $ g_variant_unref(86dbca581f53fd84).); |
| 44 | } |
| 45 | |
| 46 | g_hash_table_insertcxx . . $ g_hash_table_insert(6a7c46015dd5ef26). (transient_permissionscxx . . $ transient_permissions., |
| 47 | g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s/%s", session->sendercxx . . $ _XdpSession#sender., restore_token), |
| 48 | g_variant_refcxx . . $ g_variant_ref(3606eab35379b54a). (restore_data)); |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | xdp_session_persistence_delete_transient_permissionscxx . . $ xdp_session_persistence_delete_transient_permissions(81a88252364aabd7). (XdpSessioncxx . . $ XdpSession# *session, |
| 53 | const char *restore_token) |
| 54 | { |
| 55 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GMutexLocker) locker = g_mutex_locker_newcxx . . $ g_mutex_locker_new(3c345ff2ce91af48). (&transient_permissions_lockcxx . . $ transient_permissions_lock.); |
| 56 | g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 57 | |
| 58 | if (!transient_permissionscxx . . $ transient_permissions.) |
| 59 | return; |
| 60 | |
| 61 | id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s/%s", session->sendercxx . . $ _XdpSession#sender., restore_token); |
| 62 | g_hash_table_removecxx . . $ g_hash_table_remove(453ebbf4abdbe50e). (transient_permissionscxx . . $ transient_permissions., id); |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | xdp_session_persistence_delete_transient_permissions_for_sendercxx . . $ xdp_session_persistence_delete_transient_permissions_for_sender(85c52e162fed56f9). (const char *sender_name) |
| 67 | { |
| 68 | |
| 69 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GMutexLocker) locker = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 70 | GHashTableItercxx . . $ GHashTableIter# iter; |
| 71 | const char *key; |
| 72 | |
| 73 | locker = g_mutex_locker_newcxx . . $ g_mutex_locker_new(3c345ff2ce91af48). (&transient_permissions_lockcxx . . $ transient_permissions_lock.); |
| 74 | |
| 75 | if (!transient_permissionscxx . . $ transient_permissions.) |
| 76 | return; |
| 77 | |
| 78 | g_hash_table_iter_initcxx . . $ g_hash_table_iter_init(1fd6bbae530c3b4). (&iter, transient_permissionscxx . . $ transient_permissions.); |
| 79 | while (g_hash_table_iter_nextcxx . . $ g_hash_table_iter_next(1740d3f8cffea03c). (&iter, (gpointercxx . . $ gpointer# *) &key, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 80 | { |
| 81 | g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GStrv) split = g_strsplitcxx . . $ g_strsplit(656a2b498280081). (key, "/", 2); |
| 82 | |
| 83 | if (split && split[0] && g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (split[0], sender_name) == 0) |
| 84 | g_hash_table_iter_removecxx . . $ g_hash_table_iter_remove(9647bc02074e2e65). (&iter); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | GVariantcxx . . $ GVariant# * |
| 89 | xdp_session_persistence_get_transient_permissionscxx . . $ xdp_session_persistence_get_transient_permissions(d0d712aff29b2784). (XdpSessioncxx . . $ XdpSession# *session, |
| 90 | const char *restore_token) |
| 91 | { |
| 92 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GMutexLocker) locker = g_mutex_locker_newcxx . . $ g_mutex_locker_new(3c345ff2ce91af48). (&transient_permissions_lockcxx . . $ transient_permissions_lock.); |
| 93 | g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 94 | GVariantcxx . . $ GVariant# *permissions; |
| 95 | |
| 96 | if (!transient_permissionscxx . . $ transient_permissions.) |
| 97 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 98 | |
| 99 | id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s/%s", session->sendercxx . . $ _XdpSession#sender., restore_token); |
| 100 | permissions = g_hash_table_lookupcxx . . $ g_hash_table_lookup(8183d62c39a6a245). (transient_permissionscxx . . $ transient_permissions., id); |
| 101 | return permissions ? g_variant_refcxx . . $ g_variant_ref(3606eab35379b54a). (permissions) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 102 | } |
| 103 | |
| 104 | void |
| 105 | xdp_session_persistence_set_persistent_permissionscxx . . $ xdp_session_persistence_set_persistent_permissions(715bb496ef4c0a67). (XdpSessioncxx . . $ XdpSession# *session, |
| 106 | const char *table, |
| 107 | const char *restore_token, |
| 108 | GVariantcxx . . $ GVariant# *restore_data) |
| 109 | { |
| 110 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 111 | g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) permissions_builder = |
| 112 | G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPEcxx . . $ `<external>/14064154155447831270/gvarianttype.h:298:10`! ("a{sas}")); |
| 113 | g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GStrv) permission = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 114 | |
| 115 | permission = xdp_permissions_from_tristatecxx . . $ xdp_permissions_from_tristate(742f30fe6dafc281). (XDP_PERMISSION_YEScxx . . $ XDP_PERMISSION_YES.); |
| 116 | |
| 117 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&permissions_builder, "{s^a&s}", session->app_idcxx . . $ _XdpSession#app_id., permission); |
| 118 | |
| 119 | if (!xdp_dbus_impl_permission_store_call_set_synccxx . . $ xdp_dbus_impl_permission_store_call_set_sync(ebbed47b1b8832). (xdp_get_permission_storecxx . . $ xdp_get_permission_store(ac6178aae3a00722). (), |
| 120 | table, |
| 121 | TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!, |
| 122 | restore_token, |
| 123 | g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&permissions_builder), |
| 124 | g_variant_new_variantcxx . . $ g_variant_new_variant(3606eab35379b54a). (restore_data), |
| 125 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 126 | &error)) |
| 127 | { |
| 128 | g_dbus_error_strip_remote_errorcxx . . $ g_dbus_error_strip_remote_error(425e103a815b829). (error); |
| 129 | g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Error setting permission store value: %s", error->message); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void |
| 134 | xdp_session_persistence_delete_persistent_permissionscxx . . $ xdp_session_persistence_delete_persistent_permissions(5d9e194d3a3141c9). (XdpSessioncxx . . $ XdpSession# *session, |
| 135 | const char *table, |
| 136 | const char *restore_token) |
| 137 | { |
| 138 | |
| 139 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 140 | |
| 141 | if (!xdp_dbus_impl_permission_store_call_delete_synccxx . . $ xdp_dbus_impl_permission_store_call_delete_sync(98dc9b18e9d74261). (xdp_get_permission_storecxx . . $ xdp_get_permission_store(ac6178aae3a00722). (), |
| 142 | table, |
| 143 | restore_token, |
| 144 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 145 | &error)) |
| 146 | { |
| 147 | g_dbus_error_strip_remote_errorcxx . . $ g_dbus_error_strip_remote_error(425e103a815b829). (error); |
| 148 | g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Error deleting permission: %s", error->message); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | GVariantcxx . . $ GVariant# * |
| 153 | xdp_session_persistence_get_persistent_permissionscxx . . $ xdp_session_persistence_get_persistent_permissions(10291f328a9f44da). (XdpSessioncxx . . $ XdpSession# *session, |
| 154 | const char *table, |
| 155 | const char *restore_token) |
| 156 | { |
| 157 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) perms = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 158 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 159 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 160 | const char **permissions; |
| 161 | |
| 162 | if (!xdp_dbus_impl_permission_store_call_lookup_synccxx . . $ xdp_dbus_impl_permission_store_call_lookup_sync(b4ce393c2c779376). (xdp_get_permission_storecxx . . $ xdp_get_permission_store(ac6178aae3a00722). (), |
| 163 | table, |
| 164 | restore_token, |
| 165 | &perms, |
| 166 | &data, |
| 167 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 168 | &error)) |
| 169 | { |
| 170 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 171 | } |
| 172 | |
| 173 | if (!perms || !g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (perms, session->app_idcxx . . $ _XdpSession#app_id., "^a&s", &permissions)) |
| 174 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 175 | |
| 176 | if (!data) |
| 177 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 178 | |
| 179 | return g_variant_get_child_valuecxx . . $ g_variant_get_child_value(8aa5a571b04b0b30). (data, 0); |
| 180 | } |
| 181 | |
| 182 | void |
| 183 | xdp_session_persistence_replace_restore_token_with_datacxx . . $ xdp_session_persistence_replace_restore_token_with_data(6fd49f6574b5027b). (XdpSessioncxx . . $ XdpSession# *session, |
| 184 | const char *table, |
| 185 | GVariantcxx . . $ GVariant# **in_out_options, |
| 186 | char **out_restore_token) |
| 187 | { |
| 188 | GVariantItercxx . . $ GVariantIter# options_iter; |
| 189 | g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) options_builder = |
| 190 | G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!); |
| 191 | char *key; |
| 192 | GVariantcxx . . $ GVariant# *value; |
| 193 | |
| 194 | g_variant_iter_initcxx . . $ g_variant_iter_init(83d0c9c646e4f22c). (&options_iter, *in_out_options); |
| 195 | |
| 196 | while (g_variant_iter_nextcxx . . $ g_variant_iter_next(eaf615a8ce2e43df). (&options_iter, "{&sv}", &key, &value)) |
| 197 | { |
| 198 | if (g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (key, "restore_token") == 0) |
| 199 | { |
| 200 | g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *restore_token = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 201 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) restore_data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 202 | |
| 203 | restore_token = g_variant_dup_stringcxx . . $ g_variant_dup_string(99f549e0b90183de). (value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 204 | |
| 205 | /* Lookup permissions in memory first, and fallback to the permission |
| 206 | * store if not found. Immediately delete them now as a safety measure, |
| 207 | * since they'll be stored again when the session is closed. |
| 208 | * |
| 209 | * Notice that transient mode uses the sender name, whereas persistent |
| 210 | * mode uses the app id. |
| 211 | */ |
| 212 | restore_data = |
| 213 | xdp_session_persistence_get_transient_permissionscxx . . $ xdp_session_persistence_get_transient_permissions(d0d712aff29b2784). (session, |
| 214 | restore_token); |
| 215 | if (restore_data) |
| 216 | { |
| 217 | xdp_session_persistence_delete_transient_permissionscxx . . $ xdp_session_persistence_delete_transient_permissions(81a88252364aabd7). (session, |
| 218 | restore_token); |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | restore_data = |
| 223 | xdp_session_persistence_get_persistent_permissionscxx . . $ xdp_session_persistence_get_persistent_permissions(10291f328a9f44da). (session, |
| 224 | table, |
| 225 | restore_token); |
| 226 | if (restore_data) |
| 227 | { |
| 228 | xdp_session_persistence_delete_persistent_permissionscxx . . $ xdp_session_persistence_delete_persistent_permissions(5d9e194d3a3141c9). (session, |
| 229 | table, |
| 230 | restore_token); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if (restore_data && |
| 235 | g_variant_check_format_stringcxx . . $ g_variant_check_format_string(a76104a983d13bdd). (restore_data, RESTORE_DATA_TYPEcxx . . $ `src/xdp-session-persistence.c:30:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!)) |
| 236 | { |
| 237 | g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Replacing 'restore_token' with portal-specific data"); |
| 238 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&options_builder, "{sv}", |
| 239 | "restore_data", restore_data); |
| 240 | *out_restore_token = g_steal_pointercxx . . $ `<external>/1123956534522462559/gmem.h:250:9`! (&restore_token); |
| 241 | } |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&options_builder, "{sv}", |
| 246 | key, value); |
| 247 | } |
| 248 | |
| 249 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&value, g_variant_unref); |
| 250 | } |
| 251 | |
| 252 | *in_out_options = g_variant_ref_sinkcxx . . $ g_variant_ref_sink(3606eab35379b54a). (g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&options_builder)); |
| 253 | } |
| 254 | |
| 255 | void |
| 256 | xdp_session_persistence_generate_and_save_restore_tokencxx . . $ xdp_session_persistence_generate_and_save_restore_token(2087e7161d3dc2ca). (XdpSessioncxx . . $ XdpSession# *session, |
| 257 | const char *table, |
| 258 | XdpSessionPersistenceModecxx . . $ XdpSessionPersistenceMode# persist_mode, |
| 259 | char **in_out_restore_token, |
| 260 | GVariantcxx . . $ GVariant# **in_out_restore_data) |
| 261 | { |
| 262 | if (!*in_out_restore_data) |
| 263 | { |
| 264 | if (*in_out_restore_token) |
| 265 | { |
| 266 | xdp_session_persistence_delete_persistent_permissionscxx . . $ xdp_session_persistence_delete_persistent_permissions(5d9e194d3a3141c9). (session, |
| 267 | table, |
| 268 | *in_out_restore_token); |
| 269 | xdp_session_persistence_delete_transient_permissionscxx . . $ xdp_session_persistence_delete_transient_permissions(81a88252364aabd7). (session, |
| 270 | *in_out_restore_token); |
| 271 | } |
| 272 | |
| 273 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (in_out_restore_token, g_free); |
| 274 | return; |
| 275 | } |
| 276 | |
| 277 | switch (persist_mode) |
| 278 | { |
| 279 | case XDP_SESSION_PERSISTENCE_MODE_NONEcxx . . $ XDP_SESSION_PERSISTENCE_MODE_NONE.: |
| 280 | if (*in_out_restore_token) |
| 281 | { |
| 282 | xdp_session_persistence_delete_persistent_permissionscxx . . $ xdp_session_persistence_delete_persistent_permissions(5d9e194d3a3141c9). (session, |
| 283 | table, |
| 284 | *in_out_restore_token); |
| 285 | xdp_session_persistence_delete_transient_permissionscxx . . $ xdp_session_persistence_delete_transient_permissions(81a88252364aabd7). (session, |
| 286 | *in_out_restore_token); |
| 287 | } |
| 288 | |
| 289 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (in_out_restore_token, g_free); |
| 290 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (in_out_restore_data, g_variant_unref); |
| 291 | break; |
| 292 | |
| 293 | case XDP_SESSION_PERSISTENCE_MODE_TRANSIENTcxx . . $ XDP_SESSION_PERSISTENCE_MODE_TRANSIENT.: |
| 294 | if (!*in_out_restore_token) |
| 295 | *in_out_restore_token = g_uuid_string_randomcxx . . $ g_uuid_string_random(41208ce6ca65dd58). (); |
| 296 | |
| 297 | xdp_session_persistence_set_transient_permissionscxx . . $ xdp_session_persistence_set_transient_permissions(39535d30e1370bee). (session, |
| 298 | *in_out_restore_token, |
| 299 | *in_out_restore_data); |
| 300 | break; |
| 301 | |
| 302 | case XDP_SESSION_PERSISTENCE_MODE_PERSISTENTcxx . . $ XDP_SESSION_PERSISTENCE_MODE_PERSISTENT.: |
| 303 | if (!*in_out_restore_token) |
| 304 | *in_out_restore_token = g_uuid_string_randomcxx . . $ g_uuid_string_random(41208ce6ca65dd58). (); |
| 305 | |
| 306 | xdp_session_persistence_set_persistent_permissionscxx . . $ xdp_session_persistence_set_persistent_permissions(715bb496ef4c0a67). (session, |
| 307 | table, |
| 308 | *in_out_restore_token, |
| 309 | *in_out_restore_data); |
| 310 | |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | void |
| 316 | xdp_session_persistence_replace_restore_data_with_tokencxx . . $ xdp_session_persistence_replace_restore_data_with_token(97c9ce3fc2c5d9dc). (XdpSessioncxx . . $ XdpSession# *session, |
| 317 | const char *table, |
| 318 | GVariantcxx . . $ GVariant# **in_out_results, |
| 319 | XdpSessionPersistenceModecxx . . $ XdpSessionPersistenceMode# *in_out_persist_mode, |
| 320 | char **in_out_restore_token, |
| 321 | GVariantcxx . . $ GVariant# **in_out_restore_data) |
| 322 | { |
| 323 | g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) results = *in_out_results; |
| 324 | g_autocxx . . $ `<external>/12741050725406041920/gmacros.h:1428:9`!(GVariantBuilder) results_builder = |
| 325 | G_VARIANT_BUILDER_INITcxx . . $ `<external>/10279604295420929244/gvariant.h:369:9`! (G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!); |
| 326 | GVariantItercxx . . $ GVariantIter# iter; |
| 327 | const char *key; |
| 328 | GVariantcxx . . $ GVariant# *value; |
| 329 | gbooleancxx . . $ gboolean# found_restore_data = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 330 | |
| 331 | g_variant_iter_initcxx . . $ g_variant_iter_init(83d0c9c646e4f22c). (&iter, results); |
| 332 | while (g_variant_iter_nextcxx . . $ g_variant_iter_next(eaf615a8ce2e43df). (&iter, "{&sv}", &key, &value)) |
| 333 | { |
| 334 | if (g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (key, "restore_data") == 0) |
| 335 | { |
| 336 | if (g_variant_check_format_stringcxx . . $ g_variant_check_format_string(a76104a983d13bdd). (value, RESTORE_DATA_TYPEcxx . . $ `src/xdp-session-persistence.c:30:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!)) |
| 337 | { |
| 338 | *in_out_restore_data = g_variant_refcxx . . $ g_variant_ref(3606eab35379b54a). (value); |
| 339 | found_restore_data = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 340 | } |
| 341 | else |
| 342 | { |
| 343 | g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Received restore data in invalid variant format ('%s'; expected '%s')", |
| 344 | g_variant_get_type_string (value), |
| 345 | RESTORE_DATA_TYPEcxx . . $ `src/xdp-session-persistence.c:30:9`!); |
| 346 | } |
| 347 | } |
| 348 | else if (g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (key, "persist_mode") == 0) |
| 349 | { |
| 350 | *in_out_persist_mode = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (*in_out_persist_mode, |
| 351 | g_variant_get_uint32 (value)); |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&results_builder, "{sv}", key, value); |
| 356 | } |
| 357 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&value, g_variant_unref); |
| 358 | } |
| 359 | |
| 360 | if (found_restore_data) |
| 361 | { |
| 362 | g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Replacing restore data received from portal impl with a token"); |
| 363 | |
| 364 | xdp_session_persistence_generate_and_save_restore_tokencxx . . $ xdp_session_persistence_generate_and_save_restore_token(2087e7161d3dc2ca). (session, |
| 365 | table, |
| 366 | *in_out_persist_mode, |
| 367 | in_out_restore_token, |
| 368 | in_out_restore_data); |
| 369 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&results_builder, "{sv}", "restore_token", |
| 370 | g_variant_new_stringcxx . . $ g_variant_new_string(8d35775da1697fc2). (*in_out_restore_token)); |
| 371 | } |
| 372 | else |
| 373 | { |
| 374 | *in_out_persist_mode = XDP_SESSION_PERSISTENCE_MODE_NONEcxx . . $ XDP_SESSION_PERSISTENCE_MODE_NONE.; |
| 375 | } |
| 376 | |
| 377 | *in_out_results = g_variant_ref_sinkcxx . . $ g_variant_ref_sink(3606eab35379b54a). (g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&results_builder)); |
| 378 | } |