PolicyKit: Branch 'wip/halfline/new-release' - 35 commits
Ray Strode
halfline at kemper.freedesktop.org
Mon Apr 2 19:51:48 UTC 2018
configure.ac | 2
src/polkitbackend/polkitbackendjsauthority.cpp | 450 ++++++++++-----------
test/polkitbackend/test-polkitbackendjsauthority.c | 8
3 files changed, 235 insertions(+), 225 deletions(-)
New commits:
commit a24c192c60edaede8d7b1329f184f3713bf7157d
Merge: fffd12e ffcec36
Author: Ray Strode <rstrode at redhat.com>
Date: Mon Apr 2 15:12:02 2018 -0400
Port JavaScript authority to mozjs52
Currently polkit depends on mozjs24 to provide the JavaScript
support for the JavaScript authority. The problem is, mozjs24
is quite old at this point. Most other parts of the desktop
have moved on.
This patchset updates polkit to target mozjs52, instead.
As a side benefit, we can re-enable the JIT, since it no longer
seems to conflict with the watchdog thread used to detect when
a javascript script is caught in an infinite loop.
Most of the porting work was made by looking at what changes GJS
performed when it retarted mozjs versions, and mimicing them.
I also got some inspiration and a commit from an earlier port to
mozjs38:
https://lists.freedesktop.org/archives/polkit-devel/2017-April/000533.html
commit ffcec363bf63c16308c81f27722d4fc314989e3c
Author: Jeremy Linton <jeremy.linton at arm.com>
Date: Wed Apr 12 22:26:30 2017 -0500
test: Add a test case to handle actions without explicit rules
An implicit authorization parameter is provided to
polkit_backend_js_authority_check_authorization_sync() for actions
without corresponding explicit rules. Assure that is honored rather
than simply being denied.
Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>
diff --git a/test/polkitbackend/test-polkitbackendjsauthority.c b/test/polkitbackend/test-polkitbackendjsauthority.c
index 984110c..b484a26 100644
--- a/test/polkitbackend/test-polkitbackendjsauthority.c
+++ b/test/polkitbackend/test-polkitbackendjsauthority.c
@@ -182,6 +182,14 @@ static const RulesTestCase rules_test_cases[] = {
NULL,
POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED,
},
+ /* actions without explict rules aren't automatically NOT_AUTHORIZED */
+ {
+ "basic2",
+ "net.company.productA.action2",
+ "unix-user:john",
+ NULL,
+ POLKIT_IMPLICIT_AUTHORIZATION_UNKNOWN,
+ },
/* Ordering tests ... we have four rules files, check they are
* evaluated in order by checking the detail set by each rules
commit 79f17c9274a4de9782160a264d658aca88fed800
Author: Ray Strode <rstrode at redhat.com>
Date: Wed Mar 28 15:28:28 2018 -0400
jsauthority: re-enable JIT
seems to work with mozjs52
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index ef1a900..9746c47 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -457,13 +457,10 @@ polkit_backend_js_authority_constructed (GObject *object)
if (!JS::InitSelfHostedCode (authority->priv->cx))
goto fail;
- /* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
- * this is just a SpiderMonkey bug. So disable the JIT for now.
- */
JS::ContextOptionsRef (authority->priv->cx)
- .setIon (FALSE)
- .setBaseline (FALSE)
- .setAsmJS (FALSE);
+ .setIon (TRUE)
+ .setBaseline (TRUE)
+ .setAsmJS (TRUE);
JS::SetWarningReporter(authority->priv->cx, report_error);
JS_SetContextPrivate (authority->priv->cx, authority);
commit b15f0e3e4a9f1fbdc772701fbfd2c00c731866e4
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 15:22:59 2018 -0400
jsauthority: switch from JS_ConvertArguments to JS::CallArgsFromVp
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 686de3f..ef1a900 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1290,20 +1290,18 @@ js_polkit_log (JSContext *cx,
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
- JSString *str;
char *s;
- if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "S", &str))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
- s = JS_EncodeString (cx, str);
+ s = JS_EncodeString (cx, args[0].toString ());
JS_ReportWarningUTF8 (cx, s);
JS_free (cx, s);
ret = true;
- JS_SET_RVAL (cx, vp, JS::UndefinedValue()); /* return undefined */
- out:
+ args.rval ().setUndefined (); /* return undefined */
+
return ret;
}
@@ -1375,7 +1373,7 @@ js_polkit_spawn (JSContext *cx,
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
- JSObject *array_object;
+ JS::RootedObject array_object(cx);
gchar *standard_output = NULL;
gchar *standard_error = NULL;
gint exit_status;
@@ -1388,8 +1386,8 @@ js_polkit_spawn (JSContext *cx,
SpawnData data = {0};
guint n;
- if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (js_argc, vp);
+ array_object = &args[0].toObject();
if (!JS_GetArrayLength (cx, array_object, &array_len))
{
@@ -1400,7 +1398,7 @@ js_polkit_spawn (JSContext *cx,
argv = g_new0 (gchar*, array_len + 1);
for (n = 0; n < array_len; n++)
{
- JS::Value elem_val;
+ JS::RootedValue elem_val(cx);
char *s;
if (!JS_GetElement (cx, array_object, n, &elem_val))
@@ -1474,7 +1472,7 @@ js_polkit_spawn (JSContext *cx,
ret = true;
ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
- JS_SET_RVAL (cx, vp, JS::StringValue (ret_jsstr));
+ args.rval ().setString (ret_jsstr);
out:
g_strfreev (argv);
@@ -1498,17 +1496,14 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
{
/* 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))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
- user = JS_EncodeString (cx, user_str);
- netgroup = JS_EncodeString (cx, netgroup_str);
+ user = JS_EncodeString (cx, args[0].toString());
+ netgroup = JS_EncodeString (cx, args[1].toString());
if (innetgr (netgroup,
NULL, /* host */
@@ -1523,8 +1518,8 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
ret = true;
- JS_SET_RVAL (cx, vp, JS::BooleanValue (is_in_netgroup));
- out:
+ args.rval ().setBoolean (is_in_netgroup);
+
return ret;
}
commit 1fb919e687665b984a35fe62edcef2c5ad4460ba
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 11:03:52 2018 -0400
jsauthority: stop using JS_GetStringCharsZ
it's not around anymore.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 80bf06e..686de3f 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1090,7 +1090,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
JS::RootedValue rval(authority->priv->cx);
guint n;
GError *error = NULL;
- JSString *ret_jsstr;
+ JS::RootedString ret_jsstr (authority->priv->cx);
gchar *ret_str = NULL;
gchar **ret_strs = NULL;
@@ -1137,10 +1137,10 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
}
ret_jsstr = rval.toString();
- ret_str = g_utf16_to_utf8 (JS_GetStringCharsZ (authority->priv->cx, ret_jsstr), -1, NULL, NULL, NULL);
+ ret_str = JS_EncodeStringToUTF8 (authority->priv->cx, ret_jsstr);
if (ret_str == NULL)
{
- g_warning ("Error converting resulting string to UTF-8: %s", error->message);
+ g_warning ("Error converting resulting string to UTF-8");
goto out;
}
@@ -1197,8 +1197,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
JS::AutoValueArray<2> args(authority->priv->cx);
JS::RootedValue rval(authority->priv->cx);
GError *error = NULL;
- JSString *ret_jsstr;
- const jschar *ret_utf16;
+ JS::RootedString ret_jsstr (authority->priv->cx);
gchar *ret_str = NULL;
gboolean good = FALSE;
@@ -1252,12 +1251,10 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
}
ret_jsstr = rval.toString();
- ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr);
- ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error);
+ ret_str = JS_EncodeStringToUTF8 (authority->priv->cx, ret_jsstr);
if (ret_str == NULL)
{
- g_warning ("Error converting resulting string to UTF-8: %s", error->message);
- g_clear_error (&error);
+ g_warning ("Error converting resulting string to UTF-8");
goto out;
}
commit 3049cfb26bfe46ad0667a5559397e1cc1d74e537
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: fix up set_property methods
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 022ba7c..80bf06e 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -660,66 +660,75 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
/* authority->priv->cx must be within a request */
static void
set_property_str (PolkitBackendJsAuthority *authority,
- JSObject *obj,
+ JS::HandleObject obj,
const gchar *name,
const gchar *value)
{
- JSString *value_jsstr;
- JS::Value value_jsval;
- value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value);
- value_jsval = JS::StringValue (value_jsstr);
- JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+ JS::RootedValue value_jsval(authority->priv->cx);
+ if (value)
+ {
+ JS::ConstUTF8CharsZ chars(value, strlen(value));
+ JS::RootedString str(authority->priv->cx, JS_NewStringCopyUTF8Z(authority->priv->cx, chars));
+ value_jsval = JS::StringValue (str);
+ }
+ else
+ value_jsval = JS::NullValue ();
+ 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,
+ JS::HandleObject obj,
const gchar *name,
GPtrArray *value)
{
- JS::Value value_jsval;
- JSObject *array_object;
+ JS::RootedValue value_jsval(authority->priv->cx);
+ JS::AutoValueVector elems(authority->priv->cx);
guint n;
- array_object = JS_NewArrayObject (authority->priv->cx, 0, NULL);
-
+ elems.resize(value->len);
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 = JS::StringValue (jsstr);
- JS_SetElement (authority->priv->cx, array_object, n, &val);
+ const char *c_string = (const char *) g_ptr_array_index(value, n);
+ if (c_string)
+ {
+ JS::ConstUTF8CharsZ chars(c_string, strlen(c_string));
+ JS::RootedString str(authority->priv->cx, JS_NewStringCopyUTF8Z(authority->priv->cx, chars));
+ elems[n].setString(str);
+ }
+ else
+ elems[n].setNull ();
}
+ JS::RootedObject array_object(authority->priv->cx, JS_NewArrayObject (authority->priv->cx, elems));
+
value_jsval = JS::ObjectValue (*array_object);
- JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+ 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,
+ JS::HandleObject 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);
+ JS::RootedValue value_jsval(authority->priv->cx);
+ value_jsval = JS::Int32Value ((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,
+ JS::HandleObject 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);
+ JS::RootedValue value_jsval(authority->priv->cx);
+ value_jsval = JS::BooleanValue ((bool) value);
+ JS_SetProperty (authority->priv->cx, obj, name, value_jsval);
}
/* ---------------------------------------------------------------------------------------------------- */
commit 585a9c5031d153b063964d6994179068ba4b7e8a
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: use JS::Evaluate instead of JS_EvaluateScript
JS_EvaluateScript is no longer in the API set, so use
JS::Evaluate instead.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index a19e926..022ba7c 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -507,12 +507,12 @@ polkit_backend_js_authority_constructed (GObject *object)
js_polkit_functions))
goto fail;
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- init_js, strlen (init_js), /* init.js */
- "init.js", /* filename */
- 0, /* lineno */
- NULL)) /* rval */
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
+ JS::RootedValue rval(authority->priv->cx);
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ init_js, strlen (init_js), /* init.js */
+ &rval)) /* rval */
{
goto fail;
}
@@ -731,11 +731,11 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
PolkitIdentity *user_for_subject,
gboolean subject_is_local,
gboolean subject_is_active,
- JS::Value *out_jsval,
+ JS::MutableHandleValue out_jsval,
GError **error)
{
gboolean ret = FALSE;
- JS::Value ret_jsval;
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
const char *src;
JS::RootedObject obj(authority->priv->cx);
pid_t pid;
@@ -748,17 +748,16 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Subject();";
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- src, strlen (src),
- __FILE__, __LINE__,
- &ret_jsval))
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ src, strlen (src),
+ out_jsval))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
goto out;
}
- obj = ret_jsval.toObjectOrNull();
+ obj = out_jsval.toObjectOrNull();
if (POLKIT_IS_UNIX_PROCESS (subject))
{
@@ -849,9 +848,6 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
if (groups != NULL)
g_ptr_array_unref (groups);
- if (ret && out_jsval != NULL)
- *out_jsval = ret_jsval;
-
return ret;
}
@@ -862,11 +858,11 @@ static gboolean
action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
const gchar *action_id,
PolkitDetails *details,
- JS::Value *out_jsval,
+ JS::MutableHandleValue out_jsval,
GError **error)
{
gboolean ret = FALSE;
- JS::Value ret_jsval;
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
const char *src;
JS::RootedObject obj(authority->priv->cx);
gchar **keys;
@@ -874,17 +870,17 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Action();";
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- src, strlen (src),
- __FILE__, __LINE__,
- &ret_jsval))
+
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ src, strlen (src),
+ out_jsval))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
goto out;
}
- obj = ret_jsval.toObjectOrNull();
+ obj = out_jsval.toObjectOrNull();
set_property_str (authority, obj, "id", action_id);
@@ -903,9 +899,6 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
ret = TRUE;
out:
- if (ret && out_jsval != NULL)
- *out_jsval = ret_jsval;
-
return ret;
}
commit 08129f1bb12d436fc970db4c3e27e36ddc00074c
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:16:17 2018 -0400
jsauthority: adapt arguments for new JS_ExecuteScript API
JS_ExecuteScript no longer takes a global argument.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index f20ec9d..a19e926 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1044,7 +1044,6 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
runaway_killer_setup (authority);
ret = JS_ExecuteScript (authority->priv->cx,
- authority->priv->js_global,
script,
rval);
runaway_killer_teardown (authority);
commit 8ed7f4ffbf6a97515677c46e96a4b82a880347fe
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: adapt arguments for new JS::Compile API
The global object is implicit now and the result is an
out arg.
This commit adapts to the new api.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 9bb6da8..f20ec9d 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -302,13 +302,8 @@ load_scripts (PolkitBackendJsAuthority *authority)
const gchar *filename = (gchar *)l->data;
JS::RootedScript script(authority->priv->cx);
JS::CompileOptions options(authority->priv->cx);
- JS::RootedObject obj(authority->priv->cx,authority->priv->js_global);
options.setUTF8(true);
- script = JS::Compile (authority->priv->cx,
- obj, options,
- filename);
-
- if (script == NULL)
+ if (!JS::Compile (authority->priv->cx, options, filename, &script))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error compiling script %s",
commit 20becbe86ca0347b02094927250214b1d3c65a6a
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:16:17 2018 -0400
jsauthority: root some locals to the context
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index be83df8..9bb6da8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -317,7 +317,7 @@ load_scripts (PolkitBackendJsAuthority *authority)
}
/* evaluate the script */
- JS::Value rval;
+ JS::RootedValue rval(authority->priv->cx);
if (!execute_script_with_runaway_killer (authority,
script,
&rval))
@@ -742,7 +742,7 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
gboolean ret = FALSE;
JS::Value ret_jsval;
const char *src;
- JSObject *obj;
+ JS::RootedObject obj(authority->priv->cx);
pid_t pid;
uid_t uid;
gchar *user_name = NULL;
@@ -873,7 +873,7 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
gboolean ret = FALSE;
JS::Value ret_jsval;
const char *src;
- JSObject *obj;
+ JS::RootedObject obj(authority->priv->cx);
gchar **keys;
guint n;
JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
@@ -934,7 +934,7 @@ js_operation_callback (JSContext *cx)
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
JSString *val_str;
- JS::Value val;
+ JS::RootedValue val(cx);
/* This callback can be called by the runtime at any time without us causing
* it by JS_TriggerOperationCallback().
commit 0c62aeb9c19a488ca6dc3cacfeaa62358a772169
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: redo how global objects are set up
This commit drops usage of JS_AddObjectRoot and switches
the global object over to being wrapped in a JS::Heap
pointer. It stops using JS_DefineObject which no longer
seems to be available, and adds a new JS::FireOnNewGlobalHook
which seems to be required.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 830f5cd..be83df8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -75,9 +75,9 @@ struct _PolkitBackendJsAuthorityPrivate
GFileMonitor **dir_monitors; /* NULL-terminated array of GFileMonitor instances */
JSContext *cx;
- JSObject *js_global;
+ JS::Heap<JSObject*> *js_global;
JSAutoCompartment *ac;
- JSObject *js_polkit;
+ JS::Heap<JSObject*> *js_polkit;
GThread *runaway_killer_thread;
GMainContext *rkt_context;
@@ -478,38 +478,42 @@ polkit_backend_js_authority_constructed (GObject *object)
{
JS::CompartmentOptions compart_opts;
compart_opts.behaviors().setVersion(JSVERSION_LATEST);
- authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
+ JS::RootedObject global(authority->priv->cx);
- if (authority->priv->js_global == NULL)
+ authority->priv->js_global = new JS::Heap<JSObject*> (JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, JS::FireOnNewGlobalHook, compart_opts));
+
+ global = authority->priv->js_global->get ();
+
+ if (global == NULL)
goto fail;
- authority->priv->ac = new JSAutoCompartment(authority->priv->cx, authority->priv->js_global);
+ authority->priv->ac = new JSAutoCompartment(authority->priv->cx, global);
if (authority->priv->ac == NULL)
goto fail;
- JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global);
+ if (!JS_InitStandardClasses (authority->priv->cx, global))
+ goto fail;
+
+ JS::RootedObject polkit(authority->priv->cx);
+
+ authority->priv->js_polkit = new JS::Heap<JSObject *> (JS_NewObject (authority->priv->cx, &js_polkit_class));
- if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global))
+ polkit = authority->priv->js_polkit->get ();
+
+ if (polkit == NULL)
goto fail;
- authority->priv->js_polkit = JS_DefineObject (authority->priv->cx,
- authority->priv->js_global,
- "polkit",
- &js_polkit_class,
- NULL,
- JSPROP_ENUMERATE);
- if (authority->priv->js_polkit == NULL)
+ if (!JS_DefineProperty(authority->priv->cx, global, "polkit", polkit, JSPROP_ENUMERATE))
goto fail;
- JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
if (!JS_DefineFunctions (authority->priv->cx,
- authority->priv->js_polkit,
+ polkit,
js_polkit_functions))
goto fail;
if (!JS_EvaluateScript (authority->priv->cx,
- authority->priv->js_global,
+ global,
init_js, strlen (init_js), /* init.js */
"init.js", /* filename */
0, /* lineno */
@@ -573,11 +577,7 @@ polkit_backend_js_authority_finalize (GObject *object)
g_free (authority->priv->dir_monitors);
g_strfreev (authority->priv->rules_dirs);
- JS_BeginRequest (authority->priv->cx);
- JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
delete authority->priv->ac;
- JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_global);
- JS_EndRequest (authority->priv->cx);
JS_DestroyContext (authority->priv->cx);
/* JS_ShutDown (); */
@@ -750,10 +750,11 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
struct passwd *passwd;
char *seat_str = NULL;
char *session_str = NULL;
+ JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Subject();";
if (!JS_EvaluateScript (authority->priv->cx,
- authority->priv->js_global,
+ global,
src, strlen (src),
__FILE__, __LINE__,
&ret_jsval))
@@ -875,10 +876,11 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
JSObject *obj;
gchar **keys;
guint n;
+ JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Action();";
if (!JS_EvaluateScript (authority->priv->cx,
- authority->priv->js_global,
+ global,
src, strlen (src),
__FILE__, __LINE__,
&ret_jsval))
commit b490a0aa64254e39b45d0eabfe9251ce41ea3296
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: use InterruptCallback api instead of OperationCallback
seems like it got renamed.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 2e26af9..830f5cd 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -950,11 +950,11 @@ js_operation_callback (JSContext *cx)
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);
+ JS_ResetInterruptCallback (authority->priv->cx, TRUE);
val_str = JS_NewStringCopyZ (cx, "Terminating runaway script");
val = JS::StringValue (val_str);
JS_SetPendingException (authority->priv->cx, val);
- JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
+ JS_ResetInterruptCallback (authority->priv->cx, FALSE);
return false;
}
@@ -968,7 +968,7 @@ rkt_on_timeout (gpointer user_data)
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
/* Supposedly this is thread-safe... */
- JS_TriggerOperationCallback (authority->priv->rt);
+ JS_RequestInterruptCallback (authority->priv->cx);
/* keep source around so we keep trying to kill even if the JS bit catches the exception
* thrown in js_operation_callback()
@@ -992,13 +992,15 @@ runaway_killer_setup (PolkitBackendJsAuthority *authority)
/* ... rkt_on_timeout() will then poke the JSContext so js_operation_callback() is
* called... and from there we throw an exception
*/
- JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
+ JS_AddInterruptCallback (authority->priv->cx, js_operation_callback);
+ JS_ResetInterruptCallback (authority->priv->cx, FALSE);
}
static void
runaway_killer_teardown (PolkitBackendJsAuthority *authority)
{
- JS_SetOperationCallback (authority->priv->cx, NULL);
+ JS_ResetInterruptCallback (authority->priv->cx, TRUE);
+
g_source_destroy (authority->priv->rkt_source);
g_source_unref (authority->priv->rkt_source);
authority->priv->rkt_source = NULL;
commit 179337804191b594bc3101bc59a60354d6f7919d
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: Fix up JS_CallFunctionName invocations
The way args are passed in changed.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index e8fff15..2e26af9 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -91,8 +91,8 @@ struct _PolkitBackendJsAuthorityPrivate
};
static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
- JSScript *script,
- JS::Value *rval);
+ JS::HandleScript script,
+ JS::MutableHandleValue rval);
static void utils_spawn (const gchar *const *argv,
guint timeout_seconds,
@@ -342,16 +342,18 @@ load_scripts (PolkitBackendJsAuthority *authority)
static void
reload_scripts (PolkitBackendJsAuthority *authority)
{
- JS::Value argv[1] = {JS::NullValue()};
- JS::Value rval = JS::NullValue();
-
JS_BeginRequest (authority->priv->cx);
+ JS::AutoValueArray<1> args(authority->priv->cx);
+ JS::RootedValue rval(authority->priv->cx);
+
+ JS::RootedObject js_polkit(authority->priv->cx, authority->priv->js_polkit->get ());
+
+ args[0].setUndefined ();
if (!JS_CallFunctionName(authority->priv->cx,
- authority->priv->js_polkit,
+ js_polkit,
"_deleteRules",
- 0,
- argv,
+ args,
&rval))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1036,8 +1038,8 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
static bool
execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
- JSScript *script,
- JS::Value *rval)
+ JS::HandleScript script,
+ JS::MutableHandleValue rval)
{
bool ret;
@@ -1054,17 +1056,17 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
static bool
call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
const char *function_name,
- unsigned argc,
- JS::Value *argv,
- JS::Value *rval)
+ const JS::HandleValueArray &args,
+ JS::RootedValue *rval)
{
bool ret;
+ JS::RootedObject js_polkit(authority->priv->cx, authority->priv->js_polkit->get ());
+
runaway_killer_setup (authority);
ret = JS_CallFunctionName(authority->priv->cx,
- authority->priv->js_polkit,
+ js_polkit,
function_name,
- argc,
- argv,
+ args,
rval);
runaway_killer_teardown (authority);
return ret;
@@ -1084,8 +1086,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
GList *ret = NULL;
- JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
- JS::Value rval = JS::NullValue();
+ JS::AutoValueArray<2> args(authority->priv->cx);
+ JS::RootedValue rval(authority->priv->cx);
guint n;
GError *error = NULL;
JSString *ret_jsstr;
@@ -1094,7 +1096,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
JS_BeginRequest (authority->priv->cx);
- if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
+ if (!action_and_details_to_jsval (authority, action_id, details, args[0], &error))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error converting action and details to JS object: %s",
@@ -1108,7 +1110,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
user_for_subject,
subject_is_local,
subject_is_active,
- &argv[1],
+ args[1],
&error))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1120,8 +1122,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
if (!call_js_function_with_runaway_killer (authority,
"_runAdminRules",
- G_N_ELEMENTS (argv),
- argv,
+ args,
&rval))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1193,8 +1194,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
PolkitImplicitAuthorization ret = implicit;
- JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
- JS::Value rval = JS::NullValue();
+ JS::AutoValueArray<2> args(authority->priv->cx);
+ JS::RootedValue rval(authority->priv->cx);
GError *error = NULL;
JSString *ret_jsstr;
const jschar *ret_utf16;
@@ -1203,7 +1204,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
JS_BeginRequest (authority->priv->cx);
- if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
+ if (!action_and_details_to_jsval (authority, action_id, details, args[0], &error))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error converting action and details to JS object: %s",
@@ -1217,7 +1218,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
user_for_subject,
subject_is_local,
subject_is_active,
- &argv[1],
+ args[1],
&error))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1229,8 +1230,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
if (!call_js_function_with_runaway_killer (authority,
"_runRules",
- G_N_ELEMENTS (argv),
- argv,
+ args,
&rval))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
commit 4f4ebe30a4a674df12e7129af4b661ae1444c975
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:48:44 2018 -0400
jsauthority: JSVAL_IS_NULL (o) to o.isNull()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 71394d7..e8fff15 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1238,7 +1238,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
goto out;
}
- if (JSVAL_IS_NULL (rval))
+ if (rval.isNull())
{
/* this fine, means there was no match, use implicit authorizations */
good = TRUE;
commit 5c5bc8195023179c1dbe5416c76098f2606eaf66
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:48:44 2018 -0400
jsauthority: JSVAL_IS_STRING (s) to s.isString()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index bc33a59..71394d7 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1129,7 +1129,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
goto out;
}
- if (!JSVAL_IS_STRING (rval))
+ if (!rval.isString())
{
g_warning ("Expected a string");
goto out;
@@ -1245,7 +1245,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
goto out;
}
- if (!JSVAL_IS_STRING (rval))
+ if (!rval.isString())
{
g_warning ("Expected a string");
goto out;
@@ -1411,7 +1411,7 @@ js_polkit_spawn (JSContext *cx,
JS_ReportErrorUTF8 (cx, "Failed to get element %d", n);
goto out;
}
- if (!JSVAL_IS_STRING (elem_val))
+ if (!elem_val.isString())
{
JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
goto out;
commit 0ec1eb6d21984b8b913b4a46847819350070b279
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:48:44 2018 -0400
jsauthority: JSVAL_TO_STRING (s) to s.toString()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 1b36703..bc33a59 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1135,7 +1135,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
goto out;
}
- ret_jsstr = JSVAL_TO_STRING (rval);
+ ret_jsstr = rval.toString();
ret_str = g_utf16_to_utf8 (JS_GetStringCharsZ (authority->priv->cx, ret_jsstr), -1, NULL, NULL, NULL);
if (ret_str == NULL)
{
@@ -1251,7 +1251,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
goto out;
}
- ret_jsstr = JSVAL_TO_STRING (rval);
+ ret_jsstr = rval.toString();
ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr);
ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error);
if (ret_str == NULL)
@@ -1416,7 +1416,7 @@ js_polkit_spawn (JSContext *cx,
JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
goto out;
}
- s = JS_EncodeString (cx, JSVAL_TO_STRING (elem_val));
+ s = JS_EncodeString (cx, elem_val.toString());
argv[n] = g_strdup (s);
JS_free (cx, s);
}
commit 085a42634c729ab7884feb8903c05cc6dd3946b1
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: JSVAL_TO_OBJECT (o) to o.toObjectOrNull()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 16d3645..1b36703 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -760,7 +760,7 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
goto out;
}
- obj = JSVAL_TO_OBJECT (ret_jsval);
+ obj = ret_jsval.toObjectOrNull();
if (POLKIT_IS_UNIX_PROCESS (subject))
{
@@ -885,7 +885,7 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
goto out;
}
- obj = JSVAL_TO_OBJECT (ret_jsval);
+ obj = ret_jsval.toObjectOrNull();
set_property_str (authority, obj, "id", action_id);
commit dddf03463e5daaf287c879a842030cff0e5ec689
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/BOOLEAN_TO_JSVAL/JS::BooleanValue/
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7c74d83..16d3645 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1526,7 +1526,7 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
ret = true;
- JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup));
+ JS_SET_RVAL (cx, vp, JS::BooleanValue (is_in_netgroup));
out:
return ret;
}
commit d53b1d17190ed75316a57eca84c4c255ebc6c6a8
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/STRING_TO_JSVAL/JS::StringValue/
Signed-off-by: Ray Strode <rstrode at redhat.com>
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
@@ -670,7 +670,7 @@ set_property_str (PolkitBackendJsAuthority *authority,
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);
}
@@ -693,7 +693,7 @@ set_property_strv (PolkitBackendJsAuthority *authority,
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);
}
@@ -950,7 +950,7 @@ js_operation_callback (JSContext *cx)
/* 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;
@@ -1477,7 +1477,7 @@ js_polkit_spawn (JSContext *cx,
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);
commit ba078b4475351f0e9597b1a07e55ad923f7a92ee
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/OBJECT_TO_JSVAL/JS::ObjectValue/
This commit does a global search and replace
for OBJECT_TO_JSVAL to JS::ObjectValue()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index cef1b1a..5bbf125 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -697,7 +697,7 @@ set_property_strv (PolkitBackendJsAuthority *authority,
JS_SetElement (authority->priv->cx, array_object, n, &val);
}
- value_jsval = OBJECT_TO_JSVAL (array_object);
+ value_jsval = JS::ObjectValue (*array_object);
JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
}
commit dbd4caacbcd54a8b1bb7fc88f5e4f1ce9c0e7150
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/JSVAL_VOID/JS::UndefinedValue()/
This commit does a global search and replace
for JSVAL_VOID to JS::UndefinedValue()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index eb22597..cef1b1a 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1305,7 +1305,7 @@ js_polkit_log (JSContext *cx,
ret = true;
- JS_SET_RVAL (cx, vp, JSVAL_VOID); /* return undefined */
+ JS_SET_RVAL (cx, vp, JS::UndefinedValue()); /* return undefined */
out:
return ret;
}
commit 8ce382413a989fb61822ea81fdfde37bf8e5dda4
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/JSVAL_NULL/JS::NullValue()/
This commit does a global search and replace
for JSVAL_NULL to JS::NullValue()
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 73251a8..eb22597 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -342,8 +342,8 @@ load_scripts (PolkitBackendJsAuthority *authority)
static void
reload_scripts (PolkitBackendJsAuthority *authority)
{
- JS::Value argv[1] = {JSVAL_NULL};
- JS::Value rval = JSVAL_NULL;
+ JS::Value argv[1] = {JS::NullValue()};
+ JS::Value rval = JS::NullValue();
JS_BeginRequest (authority->priv->cx);
@@ -1084,8 +1084,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
GList *ret = NULL;
- JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
- JS::Value rval = JSVAL_NULL;
+ JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
+ JS::Value rval = JS::NullValue();
guint n;
GError *error = NULL;
JSString *ret_jsstr;
@@ -1193,8 +1193,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
PolkitImplicitAuthorization ret = implicit;
- JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
- JS::Value rval = JSVAL_NULL;
+ JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
+ JS::Value rval = JS::NullValue();
GError *error = NULL;
JSString *ret_jsstr;
const jschar *ret_utf16;
commit 88189647097724589fc187884a8007aea9605bc8
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/jsval/JS::Value/
The API got renamed in mozjs31.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 5777dab..73251a8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -92,7 +92,7 @@ struct _PolkitBackendJsAuthorityPrivate
static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script,
- jsval *rval);
+ JS::Value *rval);
static void utils_spawn (const gchar *const *argv,
guint timeout_seconds,
@@ -192,9 +192,9 @@ static JSClass js_polkit_class = {
&js_polkit_class_ops
};
-static bool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
-static bool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
-static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_log (JSContext *cx, unsigned argc, JS::Value *vp);
+static bool js_polkit_spawn (JSContext *cx, unsigned argc, JS::Value *vp);
+static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, JS::Value *vp);
static JSFunctionSpec js_polkit_functions[] =
{
@@ -317,7 +317,7 @@ load_scripts (PolkitBackendJsAuthority *authority)
}
/* evaluate the script */
- jsval rval;
+ JS::Value rval;
if (!execute_script_with_runaway_killer (authority,
script,
&rval))
@@ -342,8 +342,8 @@ load_scripts (PolkitBackendJsAuthority *authority)
static void
reload_scripts (PolkitBackendJsAuthority *authority)
{
- jsval argv[1] = {JSVAL_NULL};
- jsval rval = JSVAL_NULL;
+ JS::Value argv[1] = {JSVAL_NULL};
+ JS::Value rval = JSVAL_NULL;
JS_BeginRequest (authority->priv->cx);
@@ -668,7 +668,7 @@ set_property_str (PolkitBackendJsAuthority *authority,
const gchar *value)
{
JSString *value_jsstr;
- jsval value_jsval;
+ JS::Value value_jsval;
value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value);
value_jsval = STRING_TO_JSVAL (value_jsstr);
JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
@@ -681,7 +681,7 @@ set_property_strv (PolkitBackendJsAuthority *authority,
const gchar *name,
GPtrArray *value)
{
- jsval value_jsval;
+ JS::Value value_jsval;
JSObject *array_object;
guint n;
@@ -690,7 +690,7 @@ set_property_strv (PolkitBackendJsAuthority *authority,
for (n = 0; n < value->len; n++)
{
JSString *jsstr;
- jsval val;
+ JS::Value val;
jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n));
val = STRING_TO_JSVAL (jsstr);
@@ -708,7 +708,7 @@ set_property_int32 (PolkitBackendJsAuthority *authority,
const gchar *name,
gint32 value)
{
- jsval value_jsval;
+ JS::Value value_jsval;
value_jsval = INT_TO_JSVAL ((gint32) value);
JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
}
@@ -720,7 +720,7 @@ set_property_bool (PolkitBackendJsAuthority *authority,
const gchar *name,
gboolean value)
{
- jsval value_jsval;
+ JS::Value value_jsval;
value_jsval = BOOLEAN_TO_JSVAL ((bool) value);
JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
}
@@ -734,11 +734,11 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
PolkitIdentity *user_for_subject,
gboolean subject_is_local,
gboolean subject_is_active,
- jsval *out_jsval,
+ JS::Value *out_jsval,
GError **error)
{
gboolean ret = FALSE;
- jsval ret_jsval;
+ JS::Value ret_jsval;
const char *src;
JSObject *obj;
pid_t pid;
@@ -864,11 +864,11 @@ static gboolean
action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
const gchar *action_id,
PolkitDetails *details,
- jsval *out_jsval,
+ JS::Value *out_jsval,
GError **error)
{
gboolean ret = FALSE;
- jsval ret_jsval;
+ JS::Value ret_jsval;
const char *src;
JSObject *obj;
gchar **keys;
@@ -930,7 +930,7 @@ js_operation_callback (JSContext *cx)
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
JSString *val_str;
- jsval val;
+ JS::Value val;
/* This callback can be called by the runtime at any time without us causing
* it by JS_TriggerOperationCallback().
@@ -1037,7 +1037,7 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
static bool
execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script,
- jsval *rval)
+ JS::Value *rval)
{
bool ret;
@@ -1055,8 +1055,8 @@ static bool
call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
const char *function_name,
unsigned argc,
- jsval *argv,
- jsval *rval)
+ JS::Value *argv,
+ JS::Value *rval)
{
bool ret;
runaway_killer_setup (authority);
@@ -1084,8 +1084,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
GList *ret = NULL;
- jsval argv[2] = {JSVAL_NULL, JSVAL_NULL};
- jsval rval = JSVAL_NULL;
+ JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
+ JS::Value rval = JSVAL_NULL;
guint n;
GError *error = NULL;
JSString *ret_jsstr;
@@ -1193,8 +1193,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
PolkitImplicitAuthorization ret = implicit;
- jsval argv[2] = {JSVAL_NULL, JSVAL_NULL};
- jsval rval = JSVAL_NULL;
+ JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
+ JS::Value rval = JSVAL_NULL;
GError *error = NULL;
JSString *ret_jsstr;
const jschar *ret_utf16;
@@ -1289,7 +1289,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
static bool
js_polkit_log (JSContext *cx,
unsigned argc,
- jsval *vp)
+ JS::Value *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
@@ -1374,7 +1374,7 @@ spawn_cb (GObject *source_object,
static bool
js_polkit_spawn (JSContext *cx,
unsigned js_argc,
- jsval *vp)
+ JS::Value *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
@@ -1403,7 +1403,7 @@ js_polkit_spawn (JSContext *cx,
argv = g_new0 (gchar*, array_len + 1);
for (n = 0; n < array_len; n++)
{
- jsval elem_val;
+ JS::Value elem_val;
char *s;
if (!JS_GetElement (cx, array_object, n, &elem_val))
@@ -1497,7 +1497,7 @@ js_polkit_spawn (JSContext *cx,
static bool
js_polkit_user_is_in_netgroup (JSContext *cx,
unsigned argc,
- jsval *vp)
+ JS::Value *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
commit 1af84ea4f8dc9cd9d9b5313239ba874eefd2e0e7
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: s/JSBool/bool/
It's been gone since mozjs31
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7c2d032..5777dab 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -90,7 +90,7 @@ struct _PolkitBackendJsAuthorityPrivate
GList *scripts;
};
-static JSBool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
+static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script,
jsval *rval);
@@ -192,9 +192,9 @@ static JSClass js_polkit_class = {
&js_polkit_class_ops
};
-static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
-static JSBool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
-static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
static JSFunctionSpec js_polkit_functions[] =
{
@@ -721,7 +721,7 @@ set_property_bool (PolkitBackendJsAuthority *authority,
gboolean value)
{
jsval value_jsval;
- value_jsval = BOOLEAN_TO_JSVAL ((JSBool) value);
+ value_jsval = BOOLEAN_TO_JSVAL ((bool) value);
JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
}
@@ -925,7 +925,7 @@ runaway_killer_thread_func (gpointer user_data)
/* ---------------------------------------------------------------------------------------------------- */
-static JSBool
+static bool
js_operation_callback (JSContext *cx)
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
@@ -939,7 +939,7 @@ js_operation_callback (JSContext *cx)
if (!authority->priv->rkt_timeout_pending)
{
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
- return JS_TRUE;
+ return true;
}
authority->priv->rkt_timeout_pending = FALSE;
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
@@ -953,7 +953,7 @@ js_operation_callback (JSContext *cx)
val = STRING_TO_JSVAL (val_str);
JS_SetPendingException (authority->priv->cx, val);
JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
- return JS_FALSE;
+ return false;
}
static gboolean
@@ -1034,12 +1034,12 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
g_thread_join (authority->priv->runaway_killer_thread);
}
-static JSBool
+static bool
execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script,
jsval *rval)
{
- JSBool ret;
+ bool ret;
runaway_killer_setup (authority);
ret = JS_ExecuteScript (authority->priv->cx,
@@ -1051,14 +1051,14 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
return ret;
}
-static JSBool
+static bool
call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
const char *function_name,
unsigned argc,
jsval *argv,
jsval *rval)
{
- JSBool ret;
+ bool ret;
runaway_killer_setup (authority);
ret = JS_CallFunctionName(authority->priv->cx,
authority->priv->js_polkit,
@@ -1286,13 +1286,13 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
/* ---------------------------------------------------------------------------------------------------- */
-static JSBool
+static bool
js_polkit_log (JSContext *cx,
unsigned argc,
jsval *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
- JSBool ret = JS_FALSE;
+ bool ret = false;
JSString *str;
char *s;
@@ -1303,7 +1303,7 @@ js_polkit_log (JSContext *cx,
JS_ReportWarningUTF8 (cx, s);
JS_free (cx, s);
- ret = JS_TRUE;
+ ret = true;
JS_SET_RVAL (cx, vp, JSVAL_VOID); /* return undefined */
out:
@@ -1371,13 +1371,13 @@ spawn_cb (GObject *source_object,
g_main_loop_quit (data->loop);
}
-static JSBool
+static bool
js_polkit_spawn (JSContext *cx,
unsigned js_argc,
jsval *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
- JSBool ret = JS_FALSE;
+ bool ret = false;
JSObject *array_object;
gchar *standard_output = NULL;
gchar *standard_error = NULL;
@@ -1474,7 +1474,7 @@ js_polkit_spawn (JSContext *cx,
goto out;
}
- ret = JS_TRUE;
+ ret = true;
ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
JS_SET_RVAL (cx, vp, STRING_TO_JSVAL (ret_jsstr));
@@ -1494,18 +1494,18 @@ js_polkit_spawn (JSContext *cx,
/* ---------------------------------------------------------------------------------------------------- */
-static JSBool
+static bool
js_polkit_user_is_in_netgroup (JSContext *cx,
unsigned argc,
jsval *vp)
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
- JSBool ret = JS_FALSE;
+ bool ret = false;
JSString *user_str;
JSString *netgroup_str;
char *user;
char *netgroup;
- JSBool is_in_netgroup = JS_FALSE;
+ bool is_in_netgroup = false;
if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str))
goto out;
@@ -1518,13 +1518,13 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
user,
NULL)) /* domain */
{
- is_in_netgroup = JS_TRUE;
+ is_in_netgroup = true;
}
JS_free (cx, netgroup);
JS_free (cx, user);
- ret = JS_TRUE;
+ ret = true;
JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup));
out:
commit 76b8ad1db47e2f52caa136c9734131c053226cfd
Author: Ray Strode <rstrode at redhat.com>
Date: Wed Mar 28 15:28:28 2018 -0400
jsauthority: pass "%s" format string to report functions
This just avoids the potential for security problems down the line.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index e8714cf..7c2d032 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1469,7 +1469,7 @@ js_polkit_spawn (JSContext *cx,
}
g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'",
standard_output, standard_error);
- JS_ReportErrorUTF8 (cx, gstr->str);
+ JS_ReportErrorUTF8 (cx, "%s", gstr->str);
g_string_free (gstr, TRUE);
goto out;
}
commit a66c6619582a4ab513dbd1ddfcce8f48303900df
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 10:48:44 2018 -0400
jsauthority: add UTF8 suffix to renamed functions
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index a3a21f1..e8714cf 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1300,7 +1300,7 @@ js_polkit_log (JSContext *cx,
goto out;
s = JS_EncodeString (cx, str);
- JS_ReportWarning (cx, s);
+ JS_ReportWarningUTF8 (cx, s);
JS_free (cx, s);
ret = JS_TRUE;
@@ -1396,7 +1396,7 @@ js_polkit_spawn (JSContext *cx,
if (!JS_GetArrayLength (cx, array_object, &array_len))
{
- JS_ReportError (cx, "Failed to get array length");
+ JS_ReportErrorUTF8 (cx, "Failed to get array length");
goto out;
}
@@ -1408,12 +1408,12 @@ js_polkit_spawn (JSContext *cx,
if (!JS_GetElement (cx, array_object, n, &elem_val))
{
- JS_ReportError (cx, "Failed to get element %d", n);
+ JS_ReportErrorUTF8 (cx, "Failed to get element %d", n);
goto out;
}
if (!JSVAL_IS_STRING (elem_val))
{
- JS_ReportError (cx, "Element %d is not a string", n);
+ JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
goto out;
}
s = JS_EncodeString (cx, JSVAL_TO_STRING (elem_val));
@@ -1443,7 +1443,7 @@ js_polkit_spawn (JSContext *cx,
&standard_error,
&error))
{
- JS_ReportError (cx,
+ JS_ReportErrorUTF8 (cx,
"Error spawning helper: %s (%s, %d)",
error->message, g_quark_to_string (error->domain), error->code);
g_clear_error (&error);
@@ -1469,7 +1469,7 @@ js_polkit_spawn (JSContext *cx,
}
g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'",
standard_output, standard_error);
- JS_ReportError (cx, gstr->str);
+ JS_ReportErrorUTF8 (cx, gstr->str);
g_string_free (gstr, TRUE);
goto out;
}
commit 0348879f6fc66e519b1f7fa372448a671edbab2d
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: JS::SetWarningReporter instead of JS_SetErrorReporter
This commit changes the code to use JS::SetWarningReporter instead
of JS_SetErrorReporter. The latter, as far as I can tell, is
just a slightly renamed version of the former with the args moved
around a little bit.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 394e743..a3a21f1 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -207,7 +207,6 @@ static JSFunctionSpec js_polkit_functions[] =
/* ---------------------------------------------------------------------------------------------------- */
static void report_error (JSContext *cx,
- const char *message,
JSErrorReport *report)
{
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
@@ -215,7 +214,7 @@ static void report_error (JSContext *cx,
"%s:%u: %s",
report->filename ? report->filename : "<no filename>",
(unsigned int) report->lineno,
- message);
+ report->message().c_str());
}
static void
@@ -468,7 +467,7 @@ polkit_backend_js_authority_constructed (GObject *object)
.setIon (FALSE)
.setBaseline (FALSE)
.setAsmJS (FALSE);
- JS_SetErrorReporter(authority->priv->cx, report_error);
+ JS::SetWarningReporter(authority->priv->cx, report_error);
JS_SetContextPrivate (authority->priv->cx, authority);
JS_BeginRequest(authority->priv->cx);
commit a4de86fef299dbed29b529f13fc04806a90b25f6
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: change how JIT is disabled
JS_SetOptions seems to be replaced with JS::ContextOptionsRef now.
Also, disabling the JIT seems to be three options now instead of just
one.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 9fe151b..394e743 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -464,9 +464,10 @@ polkit_backend_js_authority_constructed (GObject *object)
/* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
* this is just a SpiderMonkey bug. So disable the JIT for now.
*/
- JS_SetOptions (authority->priv->cx,
- JSOPTION_VAROBJFIX
- /* | JSOPTION_JIT | JSOPTION_METHODJIT*/);
+ JS::ContextOptionsRef (authority->priv->cx)
+ .setIon (FALSE)
+ .setBaseline (FALSE)
+ .setAsmJS (FALSE);
JS_SetErrorReporter(authority->priv->cx, report_error);
JS_SetContextPrivate (authority->priv->cx, authority);
commit f3bb164ec054a56ed06ba04b58c169be781297df
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 15:22:59 2018 -0400
jsauthority: call JS_InitSelfHostedCode
This is now required
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7e98adb..9fe151b 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -458,6 +458,9 @@ polkit_backend_js_authority_constructed (GObject *object)
if (authority->priv->cx == NULL)
goto fail;
+ if (!JS::InitSelfHostedCode (authority->priv->cx))
+ goto fail;
+
/* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
* this is just a SpiderMonkey bug. So disable the JIT for now.
*/
commit 7b41118f4d18955c1de1e86c01b6c0c622c765eb
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 15:22:59 2018 -0400
jsauthority: call JS_Init
This is now required
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 5a5fd5e..7e98adb 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -43,6 +43,7 @@
#include <systemd/sd-login.h>
#endif /* HAVE_LIBSYSTEMD */
+#include <js/Initialization.h>
#include <jsapi.h>
#include "initjs.h" /* init.js */
@@ -650,6 +651,8 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate));
+
+ JS_Init ();
}
/* ---------------------------------------------------------------------------------------------------- */
commit 92ff879060cd5f83e20635416f1a28967913ec9f
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: change how setVersion is called
it's now part of a behaviors method in CompartmentOptions
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7bcfda9..5a5fd5e 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -471,7 +471,7 @@ polkit_backend_js_authority_constructed (GObject *object)
{
JS::CompartmentOptions compart_opts;
- compart_opts.setVersion(JSVERSION_LATEST);
+ compart_opts.behaviors().setVersion(JSVERSION_LATEST);
authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
if (authority->priv->js_global == NULL)
commit 53e5c5d3a45c8ca05950c5e0cb945aa136191b39
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: get rid of JSRuntime
Seems like JSContext is the only thing that matters now.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 3706470..7bcfda9 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -73,7 +73,6 @@ struct _PolkitBackendJsAuthorityPrivate
gchar **rules_dirs;
GFileMonitor **dir_monitors; /* NULL-terminated array of GFileMonitor instances */
- JSRuntime *rt;
JSContext *cx;
JSObject *js_global;
JSAutoCompartment *ac;
@@ -362,7 +361,7 @@ reload_scripts (PolkitBackendJsAuthority *authority)
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Collecting garbage unconditionally...");
- JS_GC (authority->priv->rt);
+ JS_GC (authority->priv->cx);
load_scripts (authority);
@@ -454,11 +453,7 @@ polkit_backend_js_authority_constructed (GObject *object)
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (object);
gboolean entered_request = FALSE;
- authority->priv->rt = JS_NewRuntime (8L * 1024L * 1024L, JS_USE_HELPER_THREADS);
- if (authority->priv->rt == NULL)
- goto fail;
-
- authority->priv->cx = JS_NewContext (authority->priv->rt, 8192);
+ authority->priv->cx = JS_NewContext (8L * 1024L * 1024L);
if (authority->priv->cx == NULL)
goto fail;
@@ -579,7 +574,6 @@ polkit_backend_js_authority_finalize (GObject *object)
JS_EndRequest (authority->priv->cx);
JS_DestroyContext (authority->priv->cx);
- JS_DestroyRuntime (authority->priv->rt);
/* JS_ShutDown (); */
G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->finalize (object);
commit 0db51e97484a573a503483c3b48bc3189cd58569
Author: Ray Strode <rstrode at redhat.com>
Date: Fri Mar 23 16:28:42 2018 -0400
jsauthority: use JS_FN instead of JS_FS
since it doesn't crash if i do that
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 384ea79..3706470 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -198,9 +198,9 @@ static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval
static JSFunctionSpec js_polkit_functions[] =
{
- JS_FS("log", js_polkit_log, 0, 0),
- JS_FS("spawn", js_polkit_spawn, 0, 0),
- JS_FS("_userIsInNetGroup", js_polkit_user_is_in_netgroup, 0, 0),
+ JS_FN("log", js_polkit_log, 0, 0),
+ JS_FN("spawn", js_polkit_spawn, 0, 0),
+ JS_FN("_userIsInNetGroup", js_polkit_user_is_in_netgroup, 0, 0),
JS_FS_END
};
commit 0c2311e3afabb433115c31dfb9a7e48b7d08a840
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 13:00:33 2018 -0400
jsauthority: fix how classes are defined
mozjs no longer has public stub functions that implementers of
JSClass objects are supposed to use. Instead NULL means
to use the default stub implementations.
Furthermore, the structure has been broken out into a JSClassOps
sub structure now.
This commit adapts the code to the new layout.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 0f3761b..384ea79 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -149,34 +149,47 @@ G_DEFINE_TYPE (PolkitBackendJsAuthority, polkit_backend_js_authority, POLKIT_BAC
/* ---------------------------------------------------------------------------------------------------- */
+static const struct JSClassOps js_global_class_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
static JSClass js_global_class = {
"global",
JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub,
- JS_DeletePropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- NULL,
- JSCLASS_NO_OPTIONAL_MEMBERS
+ &js_global_class_ops
};
/* ---------------------------------------------------------------------------------------------------- */
+static const struct JSClassOps js_polkit_class_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
static JSClass js_polkit_class = {
"Polkit",
0,
- JS_PropertyStub,
- JS_DeletePropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- NULL,
- JSCLASS_NO_OPTIONAL_MEMBERS
+ &js_polkit_class_ops
};
static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
commit e28562ae5a06384e76712638278e1a341d1deaa7
Author: Ray Strode <rstrode at redhat.com>
Date: Thu Mar 22 12:59:46 2018 -0400
configure: bump mozjs requirement to 52
This is going to briefly break the build.
Signed-off-by: Ray Strode <rstrode at redhat.com>
diff --git a/configure.ac b/configure.ac
index 8112171..130a482 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
-PKG_CHECK_MODULES(LIBJS, [mozjs-24])
+PKG_CHECK_MODULES(LIBJS, [mozjs-52])
AC_SUBST(LIBJS_CFLAGS)
AC_SUBST(LIBJS_CXXFLAGS)
More information about the hal-commit
mailing list