vmihalko / t2_polkit

Other
0 stars 0 forks source link

WIP: Add duktape as javascript engine. - [closed] #244

Closed vmihalko closed 1 year ago

vmihalko commented 5 years ago

In GitLab by @yetist on Jul 24, 2019, 17:53

Merges dev-duktape -> master

I don't know if there is a chance to use duktape as the js backend for polkit.

I saw this email on the mailing list.

But some things have changed now:

  1. Duktape can be found in popular distributions.
    • Fedora: 2.2.0
    • Archlinux: 2.3.0
    • Debian / Ubuntu: 2.3.0

https://pkgs.org/download/duktape

  1. This PR provides a new option --with-duktape to enable build with duktape. If you don't add this option, it will still compile with mozjs as before.
  2. Now it uses the system's duktape dynamic library.
  3. This PR migrates the code to duktape-2.0.0+, and when duktape is updated, it will automatically get a new implementation.
vmihalko commented 5 years ago

In GitLab by @yetist on Sep 7, 2019, 08:56

added 3 commits

Compare with previous version

vmihalko commented 4 years ago

In GitLab by @Aduskett on Feb 11, 2020, 21:48

I agree with this. Duktape has two major advantages:

vmihalko commented 4 years ago

In GitLab by @hhoffstaette on Feb 20, 2020, 14:58

This patch is fantastic! I've applied this to my polkit-0.116 package on Gentoo and it immediately got rid of spidermonkey & python-2, and everything still works fine. Thank You! :rocket:

Edit: the ebuild is here.

vmihalko commented 4 years ago

In GitLab by @tpetazzoni on Feb 20, 2020, 18:37

This is definitely something that would be awesome for embedded systems. In the context of the Buildroot project, the mozjs dependency is really annoying, both from a maintenance point of view, but also from a storage/memory consumption point of view.

vmihalko commented 4 years ago

In GitLab by @ross on Feb 20, 2020, 19:05

:thumbsup: from OpenEmbedded for the same reasons as Buildroot (which is why I was wondering if its actually feasible to swap JS for Lua)

vmihalko commented 4 years ago

In GitLab by @tpetazzoni on Feb 20, 2020, 19:17

In this specific case, I believe duktape is an even lighter solution than Lua, and it preserves compatibility with existing polkit installations.

vmihalko commented 4 years ago

In GitLab by @jrybar on Feb 21, 2020, 16:04

added 13 commits

Compare with previous version

vmihalko commented 4 years ago

In GitLab by @ferion11 on Feb 23, 2020, 13:17

Thanks! I am already using the patch on Gentoo Linux (on my ebuilds). And it's working really well. I hope the upstream here merge this PR too.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:02

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 248

Shouldn't there be a retval check here?

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:04

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 386

original spidermonkey code created g_main_loop for authority. Why is it now required here?

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:05

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 408

cast to (g_pointer*) removed here (diff from original code). Many other cases below (at the end) in the code.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:07

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 651

retval check here? I prefer sanity checks in auth software. This entire function presumes TRUE from this line.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:09

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 685

this function returns TRUE only!

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:10

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 694

retval check here, please.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:32

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 1171

typecast missing (as from original).
Also at 1186, 1200, 1214, 1243... you name it.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 16, 2020, 15:56

This MR is awesome! Especially the reduction of code by more than 30%! And duktape seems so simple in comparison to SpiderMonkey!
Thanks, Xiaotian!

I'll be glad to merge it as soon as the polkitbackend tests return to working state. So far it alsays starts looping in polkitbackendjsauthoritytest-wrapper.py. I'm trying to figure out why now.

vmihalko commented 4 years ago

In GitLab by @jrybar on Mar 30, 2020, 17:10

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 688

Actually there used to be entire implementation of runaway_script_killer between the undeleted (!!) comment lines. Without it, the test for infinite loops in uploaded scripts fails, hence entire "make check" fails.

This functionality MUST be returned back, so bad-written (or well-crafted, you name it) user rules do not hang entire polkit!!
@yetist, please, can you take care of it?

vmihalko commented 4 years ago

In GitLab by @danyspin97 on Jun 13, 2020, 21:24

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 1042

From innetgr man page:

These functions are not in POSIX.1-2001, but setnetgrent(), endnetgrent(), getnetgrent(), and innetgr() are available on most UNIX systems. getnetgrent_r() is not widely available on other systems.

innetgr is not POSIX and therefore is not available on musl based systems.

vmihalko commented 4 years ago

In GitLab by @danyspin97 on Jun 13, 2020, 21:30

Any news on this MR?

vmihalko commented 4 years ago

In GitLab by @jrybar on Jun 15, 2020, 17:14

As I wrote in my previous comments related to code review, so far, this MR breaks tests and makes polkit sensitive to incorrect .rules files. I let it sink in so the author had time to revert/reimplement appropriate part of code this MR removes. I may find time to reimplement it myself after finishing !48 which seems greatly anticipated (and which throws segfaults on Fedora vagrantbox for some reason).

vmihalko commented 4 years ago

In GitLab by @jrybar on Jul 23, 2020, 15:22

@yetist Hello and thank you again for your merge request.
Can we please discuss some changes that need to be done so this MR can be merged?
Namely the following things are really required:

Thank you for your reply. Looking forward to further discussion.

vmihalko commented 4 years ago

In GitLab by @zx2c4 on Sep 3, 2020, 20:50

Any updates to this? Seems like the original author might have abandoned this, but @jrybar - you expressed some interest in reimplementing it?

vmihalko commented 4 years ago

In GitLab by @XVilka on Sep 4, 2020, 07:49

This work is important for the eliminating Python 2 since the spidermonkey is not in a hurry to switch to Python 3 despite it being out there for more than 10 years.

vmihalko commented 4 years ago

In GitLab by @jrybar on Sep 4, 2020, 12:58

@yetist Hello and thank you again for your merge request.
Can we please discuss some changes that need to be done so this MR can be merged?
Namely the following things are really required:

Thank you for your reply. Looking forward to further discussion.

vmihalko commented 4 years ago

In GitLab by @jrybar on Sep 4, 2020, 13:00

I agree, but this MR is not gonna make it into master in this condition. Some parts must be rewritten and TBH I have tons of other work on polkit before I get to this one.

vmihalko commented 4 years ago

In GitLab by @hhoffstaette on Sep 4, 2020, 15:40

Jan, yetist's profile indicates zero activity since the original posting, and it's reasonable to assume he's gone AWOL.

vmihalko commented 4 years ago

In GitLab by @ferion11 on Sep 4, 2020, 15:53

@hhoffstaette , the Wu Xiaotian (yetist) is active on github, being part of 2 organizations (isoft-linux and mate-desktop). He's probably just out of time too. I wanted to make these corrections too, but I'm also not in a different situation with regard to free time (yet using it now in the form of patch).

vmihalko commented 4 years ago

In GitLab by @Arnaudv6 on Nov 5, 2020, 18:54

I have no idea what would be pros nor what work it'd actually require.
But with recent headlines I'd like to mention https://bellard.org/quickjs/bench.html

vmihalko commented 3 years ago

In GitLab by @fzatlouk on Nov 17, 2020, 23:36

@XVilka SpiderMonkey doesn't require Python 2 since version 78. Take a look at Fedora spec: https://src.fedoraproject.org/rpms/mozjs78/blob/master/f/mozjs78.spec

It's just python3 and python3-six .

vmihalko commented 3 years ago

In GitLab by @mattst88 on Nov 17, 2020, 23:44

Yes, but now it requires Rust and LLVM, each of which is about 3x the size of Python2.7 on my system, for comparison.

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:43

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 248

changed this line in version 4 of the diff

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:43

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 651

changed this line in version 4 of the diff

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:43

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 694

changed this line in version 4 of the diff

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:43

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 1171

changed this line in version 4 of the diff

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:43

added 26 commits

Compare with previous version

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:58

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 248

Return value check added here.

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:58

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 651

Return value check added here

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 04:59

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 1171

fixed

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 05:03

Commented on src/polkitbackend/polkitbackendduktapeauthority.c line 1042

The original master branch code has already used innetgr, so there is no need to modify it here.

https://gitlab.freedesktop.org/polkit/polkit/-/blob/master/src/polkitbackend/polkitbackendjsauthority.cpp#L1530

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 05:48

added 1 commit

Compare with previous version

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 06:19

added 7 commits

Compare with previous version

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 11:18

added 5 commits

Compare with previous version

vmihalko commented 3 years ago

In GitLab by @yetist on Nov 22, 2020, 11:49

added 1 commit

Compare with previous version

vmihalko commented 3 years ago

In GitLab by @corvus on Nov 23, 2020, 03:43

@yetist It's good to see you back! We're all rooting for you and appreciate your work. :-)

vmihalko commented 3 years ago

In GitLab by @asavah on Nov 23, 2020, 12:37

@yetist Yes, this is awesome, please get this merged! Getting rid of bloated mozjs is a must.

vmihalko commented 3 years ago

In GitLab by @karlson2k on Nov 24, 2020, 13:07

@yetist Is code ready to be reviewed? I can't wait for it to be merged as spidermonkey and its dependencies bloat my gentoo installation.

vmihalko commented 3 years ago

In GitLab by @jrybar on Nov 25, 2020, 10:44

Well it sure is desired to remove mozjs from dependencies, yet the two major problems with this MR haven't been fixed. Those are:

Anyway many thanks go to @yetist for his recent commits. I'm glad you haven't abandoned this MR, as this change is really exciting.

vmihalko commented 3 years ago

In GitLab by @mbiebl on Dec 1, 2020, 18:36

  • code duplication

Just curious: Why not switch to duktape wholesale and remove mozjs? Is there a reason why you'd want to keep both, i.e. situations where you would prefer a mozjs-based polkit over a duktape-based polkit?

vmihalko commented 3 years ago

In GitLab by @jrybar on Dec 2, 2020, 08:19

To give distros time to make the change and to give option if there are too many problems with duktape as new technology.

vmihalko commented 3 years ago

In GitLab by @mbiebl on Dec 2, 2020, 13:35

To give distros time to make the change and to give option if there are too many problems with duktape as new technology.

That seems reasonable for a transition period. I'm more interested, what the long term plans are. Do you plan to maintain both backends in parallel in the future or will you eventually remove one of the backends again.