Commit f7241fd7 authored by Ray Strode's avatar Ray Strode

jsauthority: Fix up JS_CallFunctionName invocations

The way args are passed in changed.
parent 8b2fd8cf
...@@ -93,8 +93,8 @@ struct _PolkitBackendJsAuthorityPrivate ...@@ -93,8 +93,8 @@ struct _PolkitBackendJsAuthorityPrivate
}; };
static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority, static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script, JS::HandleScript script,
JS::Value *rval); JS::MutableHandleValue rval);
static void utils_spawn (const gchar *const *argv, static void utils_spawn (const gchar *const *argv,
guint timeout_seconds, guint timeout_seconds,
...@@ -343,16 +343,18 @@ load_scripts (PolkitBackendJsAuthority *authority) ...@@ -343,16 +343,18 @@ load_scripts (PolkitBackendJsAuthority *authority)
static void static void
reload_scripts (PolkitBackendJsAuthority *authority) reload_scripts (PolkitBackendJsAuthority *authority)
{ {
JS::Value argv[1] = {JS::NullValue()};
JS::Value rval = JS::NullValue();
JS_BeginRequest (authority->priv->cx); 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, if (!JS_CallFunctionName(authority->priv->cx,
authority->priv->js_polkit, js_polkit,
"_deleteRules", "_deleteRules",
0, args,
argv,
&rval)) &rval))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
...@@ -1031,8 +1033,8 @@ runaway_killer_teardown (PolkitBackendJsAuthority *authority) ...@@ -1031,8 +1033,8 @@ runaway_killer_teardown (PolkitBackendJsAuthority *authority)
static bool static bool
execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority, execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
JSScript *script, JS::HandleScript script,
JS::Value *rval) JS::MutableHandleValue rval)
{ {
bool ret; bool ret;
...@@ -1049,17 +1051,17 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority, ...@@ -1049,17 +1051,17 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
static bool static bool
call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority, call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
const char *function_name, const char *function_name,
unsigned argc, const JS::HandleValueArray &args,
JS::Value *argv, JS::RootedValue *rval)
JS::Value *rval)
{ {
bool ret; bool ret;
JS::RootedObject js_polkit(authority->priv->cx, authority->priv->js_polkit->get ());
runaway_killer_setup (authority); runaway_killer_setup (authority);
ret = JS_CallFunctionName(authority->priv->cx, ret = JS_CallFunctionName(authority->priv->cx,
authority->priv->js_polkit, js_polkit,
function_name, function_name,
argc, args,
argv,
rval); rval);
runaway_killer_teardown (authority); runaway_killer_teardown (authority);
return ret; return ret;
...@@ -1079,8 +1081,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA ...@@ -1079,8 +1081,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
{ {
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority); PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
GList *ret = NULL; GList *ret = NULL;
JS::Value argv[2] = {JS::NullValue(), JS::NullValue()}; JS::AutoValueArray<2> args(authority->priv->cx);
JS::Value rval = JS::NullValue(); JS::RootedValue rval(authority->priv->cx);
guint n; guint n;
GError *error = NULL; GError *error = NULL;
JSString *ret_jsstr; JSString *ret_jsstr;
...@@ -1089,7 +1091,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA ...@@ -1089,7 +1091,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
JS_BeginRequest (authority->priv->cx); 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), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error converting action and details to JS object: %s", "Error converting action and details to JS object: %s",
...@@ -1103,7 +1105,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA ...@@ -1103,7 +1105,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
user_for_subject, user_for_subject,
subject_is_local, subject_is_local,
subject_is_active, subject_is_active,
&argv[1], args[1],
&error)) &error))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
...@@ -1115,8 +1117,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA ...@@ -1115,8 +1117,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
if (!call_js_function_with_runaway_killer (authority, if (!call_js_function_with_runaway_killer (authority,
"_runAdminRules", "_runAdminRules",
G_N_ELEMENTS (argv), args,
argv,
&rval)) &rval))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
...@@ -1188,8 +1189,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu ...@@ -1188,8 +1189,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
{ {
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority); PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
PolkitImplicitAuthorization ret = implicit; PolkitImplicitAuthorization ret = implicit;
JS::Value argv[2] = {JS::NullValue(), JS::NullValue()}; JS::AutoValueArray<2> args(authority->priv->cx);
JS::Value rval = JS::NullValue(); JS::RootedValue rval(authority->priv->cx);
GError *error = NULL; GError *error = NULL;
JSString *ret_jsstr; JSString *ret_jsstr;
const jschar *ret_utf16; const jschar *ret_utf16;
...@@ -1198,7 +1199,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu ...@@ -1198,7 +1199,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
JS_BeginRequest (authority->priv->cx); 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), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error converting action and details to JS object: %s", "Error converting action and details to JS object: %s",
...@@ -1212,7 +1213,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu ...@@ -1212,7 +1213,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
user_for_subject, user_for_subject,
subject_is_local, subject_is_local,
subject_is_active, subject_is_active,
&argv[1], args[1],
&error)) &error))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
...@@ -1224,8 +1225,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu ...@@ -1224,8 +1225,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
if (!call_js_function_with_runaway_killer (authority, if (!call_js_function_with_runaway_killer (authority,
"_runRules", "_runRules",
G_N_ELEMENTS (argv), args,
argv,
&rval)) &rval))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment