From 2f39096f2d819e846e95dfbe4292a2ca0f6236bd Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 22 Mar 2018 13:00:33 -0400 Subject: [PATCH] jsauthority: s/jsval/JS::Value/ The API got renamed in mozjs31. Signed-off-by: Ray Strode https://bugs.freedesktop.org/show_bug.cgi?id=105865 --- src/polkitbackend/polkitbackendjsauthority.cpp | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) 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 @@ -65,61 +65,61 @@ * evalates Javascript files and supports interaction with * authentication agents (virtue of being based on * #PolkitBackendInteractiveAuthority). */ /* ---------------------------------------------------------------------------------------------------- */ struct _PolkitBackendJsAuthorityPrivate { gchar **rules_dirs; GFileMonitor **dir_monitors; /* NULL-terminated array of GFileMonitor instances */ JSContext *cx; JSObject *js_global; JSAutoCompartment *ac; JSObject *js_polkit; GThread *runaway_killer_thread; GMainContext *rkt_context; GMainLoop *rkt_loop; GSource *rkt_source; GMutex rkt_timeout_pending_mutex; gboolean rkt_timeout_pending; /* A list of JSObject instances */ GList *scripts; }; 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, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean utils_spawn_finish (GAsyncResult *res, gint *out_exit_status, gchar **out_standard_output, gchar **out_standard_error, GError **error); static void on_dir_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data); /* ---------------------------------------------------------------------------------------------------- */ enum { PROP_0, PROP_RULES_DIRS, }; /* ---------------------------------------------------------------------------------------------------- */ static gpointer runaway_killer_thread_func (gpointer user_data); @@ -165,63 +165,63 @@ static const struct JSClassOps js_global_class_ops = { }; static JSClass js_global_class = { "global", JSCLASS_GLOBAL_FLAGS, &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_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[] = { 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 }; /* ---------------------------------------------------------------------------------------------------- */ static void report_error (JSContext *cx, JSErrorReport *report) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "%s:%u: %s", report->filename ? report->filename : "", (unsigned int) report->lineno, report->message().c_str()); } static void polkit_backend_js_authority_init (PolkitBackendJsAuthority *authority) { authority->priv = G_TYPE_INSTANCE_GET_PRIVATE (authority, POLKIT_BACKEND_TYPE_JS_AUTHORITY, PolkitBackendJsAuthorityPrivate); } @@ -290,87 +290,87 @@ load_scripts (PolkitBackendJsAuthority *authority) { if (g_str_has_suffix (name, ".rules")) files = g_list_prepend (files, g_strdup_printf ("%s/%s", dir_name, name)); } g_dir_close (dir); } } files = g_list_sort (files, (GCompareFunc) rules_file_name_cmp); for (l = files; l != NULL; l = l->next) { 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) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error compiling script %s", filename); continue; } /* evaluate the script */ - jsval rval; + JS::Value rval; if (!execute_script_with_runaway_killer (authority, script, &rval)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error executing script %s", filename); continue; } //g_print ("Successfully loaded and evaluated script `%s'\n", filename); num_scripts++; } polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Finished loading, compiling and executing %d rules", num_scripts); g_list_free_full (files, g_free); } 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); if (!JS_CallFunctionName(authority->priv->cx, authority->priv->js_polkit, "_deleteRules", 0, argv, &rval)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error deleting old rules, not loading new ones"); goto out; } polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Collecting garbage unconditionally..."); JS_GC (authority->priv->cx); load_scripts (authority); /* Let applications know we have new rules... */ g_signal_emit_by_name (authority, "changed"); out: JS_EndRequest (authority->priv->cx); } static void on_dir_monitor_changed (GFileMonitor *monitor, GFile *file, @@ -641,131 +641,131 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass) authority_class->get_features = polkit_backend_js_authority_get_features; interactive_authority_class = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_CLASS (klass); interactive_authority_class->get_admin_identities = polkit_backend_js_authority_get_admin_auth_identities; interactive_authority_class->check_authorization_sync = polkit_backend_js_authority_check_authorization_sync; g_object_class_install_property (gobject_class, PROP_RULES_DIRS, g_param_spec_boxed ("rules-dirs", NULL, NULL, G_TYPE_STRV, GParamFlags(G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE))); g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate)); JS_Init (); } /* ---------------------------------------------------------------------------------------------------- */ /* authority->priv->cx must be within a request */ static void set_property_str (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, const gchar *value) { JSString *value_jsstr; - 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); } /* authority->priv->cx must be within a request */ static void set_property_strv (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, GPtrArray *value) { - jsval value_jsval; + JS::Value value_jsval; JSObject *array_object; guint n; array_object = JS_NewArrayObject (authority->priv->cx, 0, NULL); for (n = 0; n < value->len; n++) { JSString *jsstr; - jsval val; + JS::Value val; jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n)); val = STRING_TO_JSVAL (jsstr); JS_SetElement (authority->priv->cx, array_object, n, &val); } value_jsval = OBJECT_TO_JSVAL (array_object); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* authority->priv->cx must be within a request */ static void set_property_int32 (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, gint32 value) { - jsval value_jsval; + JS::Value value_jsval; value_jsval = INT_TO_JSVAL ((gint32) value); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* authority->priv->cx must be within a request */ static void set_property_bool (PolkitBackendJsAuthority *authority, JSObject *obj, const gchar *name, gboolean value) { - jsval value_jsval; + JS::Value value_jsval; value_jsval = BOOLEAN_TO_JSVAL ((bool) value); JS_SetProperty (authority->priv->cx, obj, name, &value_jsval); } /* ---------------------------------------------------------------------------------------------------- */ /* authority->priv->cx must be within a request */ static gboolean subject_to_jsval (PolkitBackendJsAuthority *authority, PolkitSubject *subject, 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; uid_t uid; gchar *user_name = NULL; GPtrArray *groups = NULL; struct passwd *passwd; char *seat_str = NULL; char *session_str = NULL; src = "new Subject();"; if (!JS_EvaluateScript (authority->priv->cx, authority->priv->js_global, src, strlen (src), __FILE__, __LINE__, &ret_jsval)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src); goto out; } obj = JSVAL_TO_OBJECT (ret_jsval); if (POLKIT_IS_UNIX_PROCESS (subject)) { pid = polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject)); } else if (POLKIT_IS_SYSTEM_BUS_NAME (subject)) { PolkitSubject *process; @@ -837,65 +837,65 @@ subject_to_jsval (PolkitBackendJsAuthority *authority, set_property_int32 (authority, obj, "pid", pid); set_property_str (authority, obj, "user", user_name); set_property_strv (authority, obj, "groups", groups); set_property_str (authority, obj, "seat", seat_str); set_property_str (authority, obj, "session", session_str); set_property_bool (authority, obj, "local", subject_is_local); set_property_bool (authority, obj, "active", subject_is_active); ret = TRUE; out: free (session_str); free (seat_str); g_free (user_name); if (groups != NULL) g_ptr_array_unref (groups); if (ret && out_jsval != NULL) *out_jsval = ret_jsval; return ret; } /* ---------------------------------------------------------------------------------------------------- */ /* authority->priv->cx must be within a request */ 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; guint n; src = "new Action();"; if (!JS_EvaluateScript (authority->priv->cx, authority->priv->js_global, src, strlen (src), __FILE__, __LINE__, &ret_jsval)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src); goto out; } obj = JSVAL_TO_OBJECT (ret_jsval); set_property_str (authority, obj, "id", action_id); keys = polkit_details_get_keys (details); for (n = 0; keys != NULL && keys[n] != NULL; n++) { gchar *key; const gchar *value; key = g_strdup_printf ("_detail_%s", keys[n]); value = polkit_details_lookup (details, keys[n]); set_property_str (authority, obj, key, value); g_free (key); } @@ -903,61 +903,61 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority, ret = TRUE; out: if (ret && out_jsval != NULL) *out_jsval = ret_jsval; return ret; } /* ---------------------------------------------------------------------------------------------------- */ static gpointer runaway_killer_thread_func (gpointer user_data) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data); g_main_context_push_thread_default (authority->priv->rkt_context); g_main_loop_run (authority->priv->rkt_loop); g_main_context_pop_thread_default (authority->priv->rkt_context); return NULL; } /* ---------------------------------------------------------------------------------------------------- */ static bool 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(). */ g_mutex_lock (&authority->priv->rkt_timeout_pending_mutex); if (!authority->priv->rkt_timeout_pending) { g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); return true; } authority->priv->rkt_timeout_pending = FALSE; g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex); /* Log that we are terminating the script */ polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Terminating runaway script"); /* Throw an exception - this way the JS code can ignore the runaway script handling */ JS_SetOperationCallback (authority->priv->cx, NULL); val_str = JS_NewStringCopyZ (cx, "Terminating runaway script"); val = STRING_TO_JSVAL (val_str); JS_SetPendingException (authority->priv->cx, val); JS_SetOperationCallback (authority->priv->cx, js_operation_callback); return false; } static gboolean rkt_on_timeout (gpointer user_data) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data); @@ -1010,109 +1010,109 @@ runaway_killer_call_g_main_quit (gpointer user_data) return G_SOURCE_REMOVE; } static void runaway_killer_terminate (PolkitBackendJsAuthority *authority) { GSource *source; /* Use a g_idle_source_new () to ensure g_main_loop_quit () is called from * inside a running rkt_loop. This prevents a possible race condition, where * we could be calling g_main_loop_quit () on the main thread before * runaway_killer_thread_func () starts its g_main_loop_run () call; * g_main_loop_quit () before g_main_loop_run () does nothing, so in such * a case we would not terminate the thread and become blocked in * g_thread_join () below. */ g_assert (authority->priv->rkt_loop != NULL); source = g_idle_source_new (); g_source_set_callback (source, runaway_killer_call_g_main_quit, authority, NULL); g_source_attach (source, authority->priv->rkt_context); g_source_unref (source); g_thread_join (authority->priv->runaway_killer_thread); } static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority, JSScript *script, - jsval *rval) + JS::Value *rval) { bool ret; runaway_killer_setup (authority); ret = JS_ExecuteScript (authority->priv->cx, authority->priv->js_global, script, rval); runaway_killer_teardown (authority); return ret; } 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); ret = JS_CallFunctionName(authority->priv->cx, authority->priv->js_polkit, function_name, argc, argv, rval); runaway_killer_teardown (authority); return ret; } /* ---------------------------------------------------------------------------------------------------- */ static GList * polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveAuthority *_authority, PolkitSubject *caller, PolkitSubject *subject, PolkitIdentity *user_for_subject, gboolean subject_is_local, gboolean subject_is_active, const gchar *action_id, PolkitDetails *details) { 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; gchar *ret_str = NULL; gchar **ret_strs = NULL; JS_BeginRequest (authority->priv->cx); if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting action and details to JS object: %s", error->message); g_clear_error (&error); goto out; } if (!subject_to_jsval (authority, subject, user_for_subject, subject_is_local, subject_is_active, &argv[1], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting subject to JS object: %s", error->message); g_clear_error (&error); goto out; @@ -1166,62 +1166,62 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA out: g_strfreev (ret_strs); g_free (ret_str); /* fallback to root password auth */ if (ret == NULL) ret = g_list_prepend (ret, polkit_unix_user_new (0)); JS_MaybeGC (authority->priv->cx); JS_EndRequest (authority->priv->cx); return ret; } /* ---------------------------------------------------------------------------------------------------- */ static PolkitImplicitAuthorization polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAuthority *_authority, PolkitSubject *caller, PolkitSubject *subject, PolkitIdentity *user_for_subject, gboolean subject_is_local, gboolean subject_is_active, const gchar *action_id, PolkitDetails *details, PolkitImplicitAuthorization implicit) { 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; gchar *ret_str = NULL; gboolean good = FALSE; JS_BeginRequest (authority->priv->cx); if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting action and details to JS object: %s", error->message); g_clear_error (&error); goto out; } if (!subject_to_jsval (authority, subject, user_for_subject, subject_is_local, subject_is_active, &argv[1], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting subject to JS object: %s", error->message); g_clear_error (&error); goto out; @@ -1262,61 +1262,61 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu } g_strstrip (ret_str); if (!polkit_implicit_authorization_from_string (ret_str, &ret)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Returned result `%s' is not valid", ret_str); goto out; } good = TRUE; out: if (!good) ret = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED; g_free (ret_str); JS_MaybeGC (authority->priv->cx); JS_EndRequest (authority->priv->cx); return ret; } /* ---------------------------------------------------------------------------------------------------- */ 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; JSString *str; char *s; if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "S", &str)) goto out; s = JS_EncodeString (cx, str); JS_ReportWarningUTF8 (cx, s); JS_free (cx, s); ret = true; JS_SET_RVAL (cx, vp, JSVAL_VOID); /* return undefined */ out: return ret; } /* ---------------------------------------------------------------------------------------------------- */ static const gchar * get_signal_name (gint signal_number) { switch (signal_number) { #define _HANDLE_SIG(sig) case sig: return #sig; _HANDLE_SIG (SIGHUP); _HANDLE_SIG (SIGINT); @@ -1347,90 +1347,90 @@ get_signal_name (gint signal_number) _HANDLE_SIG (SIGURG); _HANDLE_SIG (SIGVTALRM); _HANDLE_SIG (SIGXCPU); _HANDLE_SIG (SIGXFSZ); #undef _HANDLE_SIG default: break; } return "UNKNOWN_SIGNAL"; } typedef struct { GMainLoop *loop; GAsyncResult *res; } SpawnData; static void spawn_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SpawnData *data = (SpawnData *)user_data; data->res = (GAsyncResult*)g_object_ref (res); g_main_loop_quit (data->loop); } 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; JSObject *array_object; gchar *standard_output = NULL; gchar *standard_error = NULL; gint exit_status; GError *error = NULL; JSString *ret_jsstr; guint32 array_len; gchar **argv = NULL; GMainContext *context = NULL; GMainLoop *loop = NULL; SpawnData data = {0}; guint n; if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object)) goto out; if (!JS_GetArrayLength (cx, array_object, &array_len)) { JS_ReportErrorUTF8 (cx, "Failed to get array length"); goto out; } 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)) { JS_ReportErrorUTF8 (cx, "Failed to get element %d", n); goto out; } if (!JSVAL_IS_STRING (elem_val)) { JS_ReportErrorUTF8 (cx, "Element %d is not a string", n); goto out; } s = JS_EncodeString (cx, JSVAL_TO_STRING (elem_val)); argv[n] = g_strdup (s); JS_free (cx, s); } context = g_main_context_new (); loop = g_main_loop_new (context, FALSE); g_main_context_push_thread_default (context); data.loop = loop; utils_spawn ((const gchar *const *) argv, 10, /* timeout_seconds */ NULL, /* cancellable */ spawn_cb, &data); g_main_loop_run (loop); @@ -1470,61 +1470,61 @@ js_polkit_spawn (JSContext *cx, g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'", standard_output, standard_error); JS_ReportErrorUTF8 (cx, "%s", gstr->str); g_string_free (gstr, TRUE); goto out; } ret = true; ret_jsstr = JS_NewStringCopyZ (cx, standard_output); JS_SET_RVAL (cx, vp, STRING_TO_JSVAL (ret_jsstr)); out: g_strfreev (argv); g_free (standard_output); g_free (standard_error); g_clear_object (&data.res); if (loop != NULL) g_main_loop_unref (loop); if (context != NULL) g_main_context_unref (context); return ret; } /* ---------------------------------------------------------------------------------------------------- */ static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, - jsval *vp) + JS::Value *vp) { /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */ bool ret = false; JSString *user_str; JSString *netgroup_str; char *user; char *netgroup; bool is_in_netgroup = false; if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str)) goto out; user = JS_EncodeString (cx, user_str); netgroup = JS_EncodeString (cx, netgroup_str); if (innetgr (netgroup, NULL, /* host */ user, NULL)) /* domain */ { is_in_netgroup = true; } JS_free (cx, netgroup); JS_free (cx, user); ret = true; JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup)); out: -- 2.16.2