Revert "Update mozjs38 patch"

This reverts commit 52aeecd450.

The updated patch is still not correct enough, namely it processes cases
where the JS .rules do not provide an answer and the “implicit” value
should be returned incorrectly.
This commit is contained in:
Miloslav Trmač 2017-04-04 21:56:55 +02:00
parent 52aeecd450
commit 45d9d07563
3 changed files with 72 additions and 58 deletions

29
.gitignore vendored
View File

@ -1,2 +1,27 @@
/polkit-*.tar.gz /.project
/polkit-*.sign polkit-0.92.tar.gz
polkit-0.93.tar.gz
polkit-0.94.tar.gz
polkit-0.95.git20090913.tar.gz
polkit-0.95.tar.gz
polkit-0.96.tar.gz
polkit-0.97.tar.gz
polkit-0.98.tar.gz
/polkit-0.100.tar.gz
/polkit-0.101.tar.gz
/polkit-0.102.tar.gz
/polkit-0.103.tar.gz
/polkit-0.104.tar.gz
/polkit-0.105.tar.gz
/polkit-0.106.tar.gz
/polkit-0.107.tar.gz
/polkit-0.108.tar.gz
/polkit-0.109.tar.gz
/polkit-0.110.tar.gz
/polkit-0.111.tar.gz
/polkit-0.111.tar.gz.sign
/polkit-0.112.tar.gz
/polkit-0.112.tar.gz.sign
/polkit-0.113.tar.gz
/polkit-0.113.tar.gz.sign
/polkit-0.113-2919920.tar.gz

View File

@ -15,11 +15,9 @@ polkit in step with gnome.
Signed-off-by: Jeremy Linton <jeremy.linton at arm.com> Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>
--- ---
v1->v2: Switch back to using initjs.j rather than init.js
configure.ac | 2 +- configure.ac | 2 +-
src/polkitbackend/polkitbackendjsauthority.cpp | 430 ++++++++++++------------- src/polkitbackend/polkitbackendjsauthority.cpp | 422 +++++++++++++------------
2 files changed, 216 insertions(+), 216 deletions(-) 2 files changed, 213 insertions(+), 211 deletions(-)
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index af2c8dd..093f5ea 100644 index af2c8dd..093f5ea 100644
@ -35,7 +33,7 @@ index af2c8dd..093f5ea 100644
AC_SUBST(LIBJS_CFLAGS) AC_SUBST(LIBJS_CFLAGS)
AC_SUBST(LIBJS_CXXFLAGS) AC_SUBST(LIBJS_CXXFLAGS)
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 6a0b4ab..292e344 100644 index 6a0b4ab..68bc147 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp --- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
@ -260,10 +258,6 @@ index 6a0b4ab..292e344 100644
- if (!JS_EvaluateScript (authority->priv->cx, - if (!JS_EvaluateScript (authority->priv->cx,
- authority->priv->js_global, - authority->priv->js_global,
- init_js, strlen (init_js), /* init.js */ - init_js, strlen (init_js), /* init.js */
- "init.js", /* filename */
- 0, /* lineno */
- NULL)) /* rval */
- {
+ JS::CompileOptions options(authority->priv->cx); + JS::CompileOptions options(authority->priv->cx);
+ options.setUTF8(true); + options.setUTF8(true);
+ JS::RootedValue result(authority->priv->cx); + JS::RootedValue result(authority->priv->cx);
@ -271,7 +265,10 @@ index 6a0b4ab..292e344 100644
+ if (!JS::Evaluate(authority->priv->cx, + if (!JS::Evaluate(authority->priv->cx,
+ *authority->priv->js_global, + *authority->priv->js_global,
+ options, + options,
+ init_js, strlen(init_js), "init.js", /* filename */
- 0, /* lineno */
- NULL)) /* rval */
- {
+ &result + &result
+ )) + ))
goto fail; goto fail;
@ -383,7 +380,7 @@ index 6a0b4ab..292e344 100644
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@@ -732,13 +725,11 @@ subject_to_jsval (PolkitBackendJsAuthority *authority, @@ -732,11 +725,10 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
PolkitIdentity *user_for_subject, PolkitIdentity *user_for_subject,
gboolean subject_is_local, gboolean subject_is_local,
gboolean subject_is_active, gboolean subject_is_active,
@ -394,11 +391,9 @@ index 6a0b4ab..292e344 100644
gboolean ret = FALSE; gboolean ret = FALSE;
- jsval ret_jsval; - jsval ret_jsval;
const char *src; const char *src;
- JSObject *obj; JSObject *obj;
pid_t pid; pid_t pid;
uid_t uid; @@ -747,19 +739,21 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
gchar *user_name = NULL;
@@ -747,19 +738,21 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
char *seat_str = NULL; char *seat_str = NULL;
char *session_str = NULL; char *session_str = NULL;
@ -427,7 +422,7 @@ index 6a0b4ab..292e344 100644
if (POLKIT_IS_UNIX_PROCESS (subject)) if (POLKIT_IS_UNIX_PROCESS (subject))
{ {
pid = polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject)); pid = polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject));
@@ -832,14 +825,17 @@ subject_to_jsval (PolkitBackendJsAuthority *authority, @@ -832,14 +826,17 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
} }
} }
@ -453,7 +448,7 @@ index 6a0b4ab..292e344 100644
ret = TRUE; ret = TRUE;
out: out:
@@ -849,9 +845,6 @@ subject_to_jsval (PolkitBackendJsAuthority *authority, @@ -849,9 +846,6 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
if (groups != NULL) if (groups != NULL)
g_ptr_array_unref (groups); g_ptr_array_unref (groups);
@ -463,7 +458,7 @@ index 6a0b4ab..292e344 100644
return ret; return ret;
} }
@@ -862,48 +855,49 @@ static gboolean @@ -862,48 +856,50 @@ static gboolean
action_and_details_to_jsval (PolkitBackendJsAuthority *authority, action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
const gchar *action_id, const gchar *action_id,
PolkitDetails *details, PolkitDetails *details,
@ -474,7 +469,7 @@ index 6a0b4ab..292e344 100644
gboolean ret = FALSE; gboolean ret = FALSE;
- jsval ret_jsval; - jsval ret_jsval;
const char *src; const char *src;
- JSObject *obj; JSObject *obj;
gchar **keys; gchar **keys;
guint n; guint n;
@ -536,7 +531,7 @@ index 6a0b4ab..292e344 100644
return ret; return ret;
} }
@@ -939,7 +933,7 @@ runaway_killer_thread_func (gpointer user_data) @@ -939,7 +935,7 @@ runaway_killer_thread_func (gpointer user_data)
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@ -545,7 +540,7 @@ index 6a0b4ab..292e344 100644
js_operation_callback (JSContext *cx) js_operation_callback (JSContext *cx)
{ {
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
@@ -953,7 +947,7 @@ js_operation_callback (JSContext *cx) @@ -953,7 +949,7 @@ js_operation_callback (JSContext *cx)
if (!authority->priv->rkt_timeout_pending) if (!authority->priv->rkt_timeout_pending)
{ {
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
@ -554,7 +549,7 @@ index 6a0b4ab..292e344 100644
} }
authority->priv->rkt_timeout_pending = FALSE; authority->priv->rkt_timeout_pending = FALSE;
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
@@ -962,12 +956,11 @@ js_operation_callback (JSContext *cx) @@ -962,12 +958,11 @@ js_operation_callback (JSContext *cx)
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Terminating runaway 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 */ /* Throw an exception - this way the JS code can ignore the runaway script handling */
@ -570,7 +565,7 @@ index 6a0b4ab..292e344 100644
} }
static gboolean static gboolean
@@ -980,7 +973,7 @@ rkt_on_timeout (gpointer user_data) @@ -980,7 +975,7 @@ rkt_on_timeout (gpointer user_data)
g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
/* Supposedly this is thread-safe... */ /* Supposedly this is thread-safe... */
@ -579,7 +574,7 @@ index 6a0b4ab..292e344 100644
/* keep source around so we keep trying to kill even if the JS bit catches the exception /* keep source around so we keep trying to kill even if the JS bit catches the exception
* thrown in js_operation_callback() * thrown in js_operation_callback()
@@ -1004,49 +997,48 @@ runaway_killer_setup (PolkitBackendJsAuthority *authority) @@ -1004,49 +999,48 @@ runaway_killer_setup (PolkitBackendJsAuthority *authority)
/* ... rkt_on_timeout() will then poke the JSContext so js_operation_callback() is /* ... rkt_on_timeout() will then poke the JSContext so js_operation_callback() is
* called... and from there we throw an exception * called... and from there we throw an exception
*/ */
@ -644,7 +639,7 @@ index 6a0b4ab..292e344 100644
rval); rval);
runaway_killer_teardown (authority); runaway_killer_teardown (authority);
return ret; return ret;
@@ -1066,17 +1058,18 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1066,17 +1060,18 @@ 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;
@ -667,7 +662,7 @@ index 6a0b4ab..292e344 100644
{ {
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",
@@ -1090,7 +1083,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1090,7 +1085,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,
@ -676,7 +671,7 @@ index 6a0b4ab..292e344 100644
&error)) &error))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1099,11 +1092,12 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1099,11 +1094,12 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
g_clear_error (&error); g_clear_error (&error);
goto out; goto out;
} }
@ -692,7 +687,7 @@ index 6a0b4ab..292e344 100644
&rval)) &rval))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1111,14 +1105,17 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1111,14 +1107,17 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
goto out; goto out;
} }
@ -713,7 +708,7 @@ index 6a0b4ab..292e344 100644
if (ret_str == NULL) 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: %s", error->message);
@@ -1136,8 +1133,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1136,8 +1135,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
if (identity == NULL) if (identity == NULL)
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@ -724,7 +719,7 @@ index 6a0b4ab..292e344 100644
} }
else else
{ {
@@ -1148,7 +1145,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA @@ -1148,7 +1147,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
out: out:
g_strfreev (ret_strs); g_strfreev (ret_strs);
@ -733,7 +728,7 @@ index 6a0b4ab..292e344 100644
/* fallback to root password auth */ /* fallback to root password auth */
if (ret == NULL) if (ret == NULL)
ret = g_list_prepend (ret, polkit_unix_user_new (0)); ret = g_list_prepend (ret, polkit_unix_user_new (0));
@@ -1175,17 +1172,18 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1175,17 +1174,18 @@ 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;
@ -757,7 +752,7 @@ index 6a0b4ab..292e344 100644
{ {
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",
@@ -1199,7 +1197,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1199,7 +1199,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,
@ -766,7 +761,7 @@ index 6a0b4ab..292e344 100644
&error)) &error))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1209,10 +1207,13 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1209,10 +1209,13 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
goto out; goto out;
} }
@ -782,7 +777,7 @@ index 6a0b4ab..292e344 100644
&rval)) &rval))
{ {
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1220,22 +1221,17 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1220,22 +1223,17 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
goto out; goto out;
} }
@ -811,7 +806,7 @@ index 6a0b4ab..292e344 100644
if (ret_str == NULL) 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: %s", error->message);
@@ -1257,7 +1253,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1257,7 +1255,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
out: out:
if (!good) if (!good)
ret = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED; ret = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED;
@ -820,7 +815,7 @@ index 6a0b4ab..292e344 100644
JS_MaybeGC (authority->priv->cx); JS_MaybeGC (authority->priv->cx);
@@ -1268,27 +1264,27 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu @@ -1268,26 +1266,26 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@ -847,15 +842,13 @@ index 6a0b4ab..292e344 100644
- ret = JS_TRUE; - ret = JS_TRUE;
+ ret = true; + ret = true;
+
+ args.rval().setUndefined(); //returned undefined
- JS_SET_RVAL (cx, vp, JSVAL_VOID); /* return undefined */ - JS_SET_RVAL (cx, vp, JSVAL_VOID); /* return undefined */
- out: + args.rval().setUndefined(); //returned undefined
out:
return ret; return ret;
} }
@@ -1353,13 +1351,13 @@ spawn_cb (GObject *source_object,
@@ -1353,13 +1349,13 @@ spawn_cb (GObject *source_object,
g_main_loop_quit (data->loop); g_main_loop_quit (data->loop);
} }
@ -872,7 +865,7 @@ index 6a0b4ab..292e344 100644
JSObject *array_object; JSObject *array_object;
gchar *standard_output = NULL; gchar *standard_output = NULL;
gchar *standard_error = NULL; gchar *standard_error = NULL;
@@ -1372,11 +1368,13 @@ js_polkit_spawn (JSContext *cx, @@ -1372,11 +1370,13 @@ js_polkit_spawn (JSContext *cx,
GMainLoop *loop = NULL; GMainLoop *loop = NULL;
SpawnData data = {0}; SpawnData data = {0};
guint n; guint n;
@ -881,15 +874,15 @@ index 6a0b4ab..292e344 100644
- if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object)) - if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object))
- goto out; - goto out;
+ array_object=JS::ToObject(cx, args[0]); + array_object=JS::ToObject(cx, args[0]);
+
+ JS::RootedObject opts(cx, array_object);
- if (!JS_GetArrayLength (cx, array_object, &array_len)) - if (!JS_GetArrayLength (cx, array_object, &array_len))
+ JS::RootedObject opts(cx, array_object);
+
+ if (!JS_GetArrayLength (cx, opts, &array_len)) + if (!JS_GetArrayLength (cx, opts, &array_len))
{ {
JS_ReportError (cx, "Failed to get array length"); JS_ReportError (cx, "Failed to get array length");
goto out; goto out;
@@ -1387,18 +1385,19 @@ js_polkit_spawn (JSContext *cx, @@ -1387,18 +1387,19 @@ js_polkit_spawn (JSContext *cx,
{ {
jsval elem_val; jsval elem_val;
char *s; char *s;
@ -914,7 +907,7 @@ index 6a0b4ab..292e344 100644
argv[n] = g_strdup (s); argv[n] = g_strdup (s);
JS_free (cx, s); JS_free (cx, s);
} }
@@ -1456,10 +1455,10 @@ js_polkit_spawn (JSContext *cx, @@ -1456,10 +1457,10 @@ js_polkit_spawn (JSContext *cx,
goto out; goto out;
} }
@ -927,7 +920,7 @@ index 6a0b4ab..292e344 100644
out: out:
g_strfreev (argv); g_strfreev (argv);
@@ -1476,21 +1475,22 @@ js_polkit_spawn (JSContext *cx, @@ -1476,21 +1477,22 @@ js_polkit_spawn (JSContext *cx,
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@ -955,7 +948,7 @@ index 6a0b4ab..292e344 100644
user = JS_EncodeString (cx, user_str); user = JS_EncodeString (cx, user_str);
netgroup = JS_EncodeString (cx, netgroup_str); netgroup = JS_EncodeString (cx, netgroup_str);
@@ -1500,16 +1500,16 @@ js_polkit_user_is_in_netgroup (JSContext *cx, @@ -1500,15 +1502,15 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
user, user,
NULL)) /* domain */ NULL)) /* domain */
{ {
@ -968,13 +961,11 @@ index 6a0b4ab..292e344 100644
- ret = JS_TRUE; - ret = JS_TRUE;
+ ret = true; + ret = true;
+
+ args.rval().setBoolean(is_in_netgroup);
- JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup)); - JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup));
- out: + args.rval().setBoolean(is_in_netgroup);
out:
return ret; return ret;
} }
-- --
2.11.0 2.11.0

View File

@ -20,7 +20,6 @@ Patch0: polkit-0.113-agent-leaks.patch
# https://lists.freedesktop.org/archives/polkit-devel/2017-March/000527.html # https://lists.freedesktop.org/archives/polkit-devel/2017-March/000527.html
Patch1: polkit-mozjs38.patch Patch1: polkit-mozjs38.patch
BuildRequires: gcc-c++
BuildRequires: glib2-devel >= 2.30.0 BuildRequires: glib2-devel >= 2.30.0
BuildRequires: expat-devel BuildRequires: expat-devel
BuildRequires: pam-devel BuildRequires: pam-devel
@ -92,14 +91,13 @@ Libraries files for polkit.
%build %build
%if 0%{?enable_autoreconf} %if 0%{?enable_autoreconf}
NOCONFIGURE=1 ./autogen.sh ./autogen.sh
%endif %endif
%configure --enable-gtk-doc \ %configure --enable-gtk-doc \
--disable-static \ --disable-static \
--enable-introspection \ --enable-introspection \
--disable-examples \ --disable-examples \
--enable-libsystemd-login=yes \ --enable-libsystemd-login=yes --with-mozjs=mozjs-38.0
--with-mozjs=mozjs-38.0
make %{?_smp_mflags} V=1 make %{?_smp_mflags} V=1