Jailkit-2.20 patch to support Python3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Jailkit-2.20 patch to support Python3

William Stearns
Good day, all,
     I've made the minimal changes needed to run jailkit 2.20 on Python3 - patch is attached.  I've tried to structure this in a form that will continue to work on python2 as well.
    I'd appreciate it if someone could review the "except .... :" lines.  I've connected all of the errors into a single list, like:

-                       except OSError, (errno,strerror):

+                       except (OSError, errno, strerror):


    but am not sure this matches the original intent.
    Many thanks for your work on jailkit.  Cheers,
    - Bill






_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev

jailkit-2.20-python3-compatibility.patch (30K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Jailkit-2.20 patch to support Python3

William Stearns
Good day, all,
    I did screw up on the except calls, sorry for that.  I've attached a new version that:
- replaces
except one_or_more_error_types, (errno, strerror):
    with
except one_or_more_error_types as e:
errno, strerror = e.args

- Makes all prints as functions (and loads "from __future__ import print_function" for compatibility when running under python2)
- Uses the appropriate values for octal 755 in python 2 and 3
- Loads the configparser library as ConfigParser under python 2 and configparser under python 3.
    I've tried to make these the simplest and clearest replacements so the diff is easy to check.  Please let me know if you find any issues with it.
    Cheers,
    - Bill


On Fri, May 31, 2019 at 5:32 PM William Stearns <[hidden email]> wrote:
Good day, all,
     I've made the minimal changes needed to run jailkit 2.20 on Python3 - patch is attached.  I've tried to structure this in a form that will continue to work on python2 as well.
    I'd appreciate it if someone could review the "except .... :" lines.  I've connected all of the errors into a single list, like:

-                       except OSError, (errno,strerror):

+                       except (OSError, errno, strerror):


    but am not sure this matches the original intent.
    Many thanks for your work on jailkit.  Cheers,
    - Bill






_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev

jailkit-2.20-python3-compatibility.201906032134.patch (73K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Jailkit-2.20 patch to support Python3

William Stearns
Good afternoon, all,
    The attached patch replaced the previous 2 and fixes an error I made trying to force py_compile to write out to {modulename}.pyc for compatibility.
    Cheers,
    - Bill


On Mon, Jun 3, 2019 at 5:50 PM William Stearns <[hidden email]> wrote:
Good day, all,
    I did screw up on the except calls, sorry for that.  I've attached a new version that:
- replaces
except one_or_more_error_types, (errno, strerror):
    with
except one_or_more_error_types as e:
errno, strerror = e.args

- Makes all prints as functions (and loads "from __future__ import print_function" for compatibility when running under python2)
- Uses the appropriate values for octal 755 in python 2 and 3
- Loads the configparser library as ConfigParser under python 2 and configparser under python 3.
    I've tried to make these the simplest and clearest replacements so the diff is easy to check.  Please let me know if you find any issues with it.
    Cheers,
    - Bill


On Fri, May 31, 2019 at 5:32 PM William Stearns <[hidden email]> wrote:
Good day, all,
     I've made the minimal changes needed to run jailkit 2.20 on Python3 - patch is attached.  I've tried to structure this in a form that will continue to work on python2 as well.
    I'd appreciate it if someone could review the "except .... :" lines.  I've connected all of the errors into a single list, like:

-                       except OSError, (errno,strerror):

+                       except (OSError, errno, strerror):


    but am not sure this matches the original intent.
    Many thanks for your work on jailkit.  Cheers,
    - Bill






_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev

jailkit-2.20-python3-compatibility.201906032203.patch (73K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Jailkit-2.20 patch to support Python3

Olivier Sessink-2
thanks!

you're a busy man :)

I've currently little time for actual testing, so I can look at the code and commit. Have you tested the various different python scripts for their functionality?

Olivier


On 04-06-19 00:10, William Stearns wrote:
Good afternoon, all,
    The attached patch replaced the previous 2 and fixes an error I made trying to force py_compile to write out to {modulename}.pyc for compatibility.
    Cheers,
    - Bill


On Mon, Jun 3, 2019 at 5:50 PM William Stearns <[hidden email]> wrote:
Good day, all,
    I did screw up on the except calls, sorry for that.  I've attached a new version that:
- replaces
except one_or_more_error_types, (errno, strerror):
    with
except one_or_more_error_types as e:
errno, strerror = e.args

- Makes all prints as functions (and loads "from __future__ import print_function" for compatibility when running under python2)
- Uses the appropriate values for octal 755 in python 2 and 3
- Loads the configparser library as ConfigParser under python 2 and configparser under python 3.
    I've tried to make these the simplest and clearest replacements so the diff is easy to check.  Please let me know if you find any issues with it.
    Cheers,
    - Bill


On Fri, May 31, 2019 at 5:32 PM William Stearns <[hidden email]> wrote:
Good day, all,
     I've made the minimal changes needed to run jailkit 2.20 on Python3 - patch is attached.  I've tried to structure this in a form that will continue to work on python2 as well.
    I'd appreciate it if someone could review the "except .... :" lines.  I've connected all of the errors into a single list, like:

-                       except OSError, (errno,strerror):

+                       except (OSError, errno, strerror):


    but am not sure this matches the original intent.
    Many thanks for your work on jailkit.  Cheers,
    - Bill






_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev


-- 
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/

_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev
Reply | Threaded
Open this post in threaded view
|

Re: Jailkit-2.20 patch to support Python3

William Stearns
Good evening, Olivier,
    I'm doing that testing now and have found even more that needs attention:
- openvpn section had to "includesections" lines.
- My configparser fix was incomplete.  So was my attempt at getting a portal octal constant.
- File reads were coming in as bytes and need to be converted to strings on python3
- The string.find/string.split/string.strip/string.join calls are deprecated and are replaced with {orig_string}.split() - type calls.
- raw_input() is replaced with input()

    I've run each of the tools to make sure they'll at least successfully load and have built a chroot tree with jk_init , all with /usr/bin/python pointing at python3.5.  I've not tested any of this under python2.  Would someone with python2 be willing to do basic checks with this patch?
    Cheers,
    - Bill


On Tue, Jun 4, 2019 at 10:46 AM Olivier Sessink <[hidden email]> wrote:
thanks!

you're a busy man :)

I've currently little time for actual testing, so I can look at the code and commit. Have you tested the various different python scripts for their functionality?

Olivier


On 04-06-19 00:10, William Stearns wrote:
Good afternoon, all,
    The attached patch replaced the previous 2 and fixes an error I made trying to force py_compile to write out to {modulename}.pyc for compatibility.
    Cheers,
    - Bill


On Mon, Jun 3, 2019 at 5:50 PM William Stearns <[hidden email]> wrote:
Good day, all,
    I did screw up on the except calls, sorry for that.  I've attached a new version that:
- replaces
except one_or_more_error_types, (errno, strerror):
    with
except one_or_more_error_types as e:
errno, strerror = e.args

- Makes all prints as functions (and loads "from __future__ import print_function" for compatibility when running under python2)
- Uses the appropriate values for octal 755 in python 2 and 3
- Loads the configparser library as ConfigParser under python 2 and configparser under python 3.
    I've tried to make these the simplest and clearest replacements so the diff is easy to check.  Please let me know if you find any issues with it.
    Cheers,
    - Bill


On Fri, May 31, 2019 at 5:32 PM William Stearns <[hidden email]> wrote:
Good day, all,
     I've made the minimal changes needed to run jailkit 2.20 on Python3 - patch is attached.  I've tried to structure this in a form that will continue to work on python2 as well.
    I'd appreciate it if someone could review the "except .... :" lines.  I've connected all of the errors into a single list, like:

-                       except OSError, (errno,strerror):

+                       except (OSError, errno, strerror):


    but am not sure this matches the original intent.
    Many thanks for your work on jailkit.  Cheers,
    - Bill






_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev


-- 
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev

_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev

jailkit-2.20-python3-compatibility.201906042043.patch (88K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Jailkit-2.20 patch to support Python3

Olivier Sessink-2
Hi Bill,

sorry it took so long, I finally had enough time to work trough
everything and test it. I did a full code review and testing on both
python2 and python3, and committed your patch to the repository. The
code was 100% OK, so many thanks for that.

One question: you removed netbasics from the openvpn section. Was that
required?

Olivier


On 04-06-19 22:50, William Stearns wrote:

> Good evening, Olivier,
>     I'm doing that testing now and have found even more that needs
> attention:
> - openvpn section had to "includesections" lines.
> - My configparser fix was incomplete.  So was my attempt at getting a
> portal octal constant.
> - File reads were coming in as bytes and need to be converted to strings
> on python3
> - The string.find/string.split/string.strip/string.join calls are
> deprecated and are replaced with {orig_string}.split() - type calls.
> - raw_input() is replaced with input()
>
>     I've run each of the tools to make sure they'll at least
> successfully load and have built a chroot tree with jk_init , all with
> /usr/bin/python pointing at python3.5.  I've not tested any of this
> under python2.  Would someone with python2 be willing to do basic checks
> with this patch?
>     Cheers,
>     - Bill


_______________________________________________
Jailkit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/jailkit-dev