From 884d22a8a5128291a0601d52860be26396a3fc1d Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 22 Mar 2018 13:00:33 -0400 Subject: [PATCH] jsauthority: s/STRING_TO_JSVAL/JS::StringValue/ Signed-off-by: Ray Strode https://bugs.freedesktop.org/show_bug.cgi?id=105865 --- src/polkitbackend/polkitbackendjsauthority.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp index 5bbf125..7c74d83 100644 --- a/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp @@ -643,84 +643,84 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass) interactive_authority_class = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_CLASS (klass); interactive_authority_class->get_admin_identities = polkit_backend_js_authority_get_admin_auth_identities; interactive_authority_class->check_authorization_sync = polkit_backend_js_authority_check_authorization_sync; g_object_class_install_property (gobject_class, PROP_RULES_DIRS, g_param_spec_boxed ("rules-dirs", NULL, NULL, G_TYPE_STRV, GParamFlags(G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE))); g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate)); JS_Init (); } /* ---------------------------------------------------------------------------------------------------- */ /* authority->priv->cx must be within a request */ static void set_property_str (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, const gchar *value) { JSString *value_jsstr; JS::Value value_jsval; value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value); - value_jsval = STRING_TO_JSVAL (value_jsstr); + value_jsval = JS::StringValue (value_jsstr); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* authority->priv->cx must be within a request */ static void set_property_strv (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, GPtrArray *value) { JS::Value value_jsval; JSObject *array_object; guint n; array_object = JS_NewArrayObject (authority->priv->cx, 0, NULL); for (n = 0; n < value->len; n++) { JSString *jsstr; JS::Value val; jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n)); - val = STRING_TO_JSVAL (jsstr); + val = JS::StringValue (jsstr); JS_SetElement (authority->priv->cx, array_object, n, &val); } value_jsval = JS::ObjectValue (*array_object); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* authority->priv->cx must be within a request */ static void set_property_int32 (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, gint32 value) { JS::Value value_jsval; value_jsval = INT_TO_JSVAL ((gint32) value); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* authority->priv->cx must be within a request */ static void set_property_bool (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, gboolean value) { JS::Value value_jsval; value_jsval = BOOLEAN_TO_JSVAL ((bool) value); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } @@ -923,61 +923,61 @@ runaway_killer_thread_func (gpointer user_data) return NULL; } /* ---------------------------------------------------------------------------------------------------- */ static bool js_operation_callback (JSContext *cx) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); JSString *val_str; JS::Value val; /* This callback can be called by the runtime at any time without us causing * it by JS_TriggerOperationCallback(). */ g_mutex_lock (&authority->priv->rkt_timeout_pending_mutex); if (!authority->priv->rkt_timeout_pending) { g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); return true; } authority->priv->rkt_timeout_pending = FALSE; g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); /* Log that we are terminating the script */ polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Terminating runaway script"); /* Throw an exception - this way the JS code can ignore the runaway script handling */ JS_SetOperationCallback (authority->priv->cx, NULL); val_str = JS_NewStringCopyZ (cx, "Terminating runaway script"); - val = STRING_TO_JSVAL (val_str); + val = JS::StringValue (val_str); JS_SetPendingException (authority->priv->cx, val); JS_SetOperationCallback (authority->priv->cx, js_operation_callback); return false; } static gboolean rkt_on_timeout (gpointer user_data) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data); g_mutex_lock (&authority->priv->rkt_timeout_pending_mutex); authority->priv->rkt_timeout_pending = TRUE; g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); /* Supposedly this is thread-safe... */ JS_TriggerOperationCallback (authority->priv->rt); /* keep source around so we keep trying to kill even if the JS bit catches the exception * thrown in js_operation_callback() */ return TRUE; } static void runaway_killer_setup (PolkitBackendJsAuthority *authority) { g_assert (authority->priv->rkt_source == NULL); /* set-up timer for runaway scripts, will be executed in runaway_killer_thread */ g_mutex_lock (&authority->priv->rkt_timeout_pending_mutex); @@ -1450,61 +1450,61 @@ js_polkit_spawn (JSContext *cx, goto out; } if (!(WIFEXITED (exit_status) && WEXITSTATUS (exit_status) == 0)) { GString *gstr; gstr = g_string_new (NULL); if (WIFEXITED (exit_status)) { g_string_append_printf (gstr, "Helper exited with non-zero exit status %d", WEXITSTATUS (exit_status)); } else if (WIFSIGNALED (exit_status)) { g_string_append_printf (gstr, "Helper was signaled with signal %s (%d)", get_signal_name (WTERMSIG (exit_status)), WTERMSIG (exit_status)); } g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'", standard_output, standard_error); JS_ReportErrorUTF8 (cx, "%s", gstr->str); g_string_free (gstr, TRUE); goto out; } ret = true; ret_jsstr = JS_NewStringCopyZ (cx, standard_output); - JS_SET_RVAL (cx, vp, STRING_TO_JSVAL (ret_jsstr)); + JS_SET_RVAL (cx, vp, JS::StringValue (ret_jsstr)); out: g_strfreev (argv); g_free (standard_output); g_free (standard_error); g_clear_object (&data.res); if (loop != NULL) g_main_loop_unref (loop); if (context != NULL) g_main_context_unref (context); return ret; } /* ---------------------------------------------------------------------------------------------------- */ static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, JS::Value *vp) { /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */ bool ret = false; JSString *user_str; JSString *netgroup_str; char *user; char *netgroup; bool is_in_netgroup = false; if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str)) -- 2.16.2