Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Python bindings #14

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

fabianfreyer
Copy link
Contributor

@fabianfreyer fabianfreyer commented Jul 7, 2018

See #13

Includes (merge these first, then rebase):

Features

  • Jail start/stop
  • StoppedJail parameters
    • getter
    • setter
  • StartedJail parameters
    • getter
    • setter
  • RACCT statistics
  • spawn child wrapper
    • wait, try_wait
    • exit code / signal
    • stdio redirection
      • stdio = subprocess.PIPE, subprocess.DEVNULL, subprocess.STDOUT, as well as custom fds
      • read_stdout(count) -> bytearray, read_stderr(count) -> bytearray
      • write_stdin(bytearray) -> bytes_written
      • readall_stdout_str() -> str, readall_stderr_str() -> str blocking until eof
      • write_stdin_str(str)
      • flush_stdin()
  • iteration over RunningJails (Jls)

@fabianfreyer fabianfreyer added the enhancement New feature or request label Jul 7, 2018
@fabianfreyer fabianfreyer added this to the Future milestone Jul 7, 2018
@fabianfreyer fabianfreyer added the help wanted Extra attention is needed label Jul 7, 2018
@fabianfreyer fabianfreyer added the bindings/python Python language bindings label Jul 7, 2018
@fabianfreyer
Copy link
Contributor Author

fabianfreyer commented Jul 8, 2018

Adding the parameter set logic will require this to be based off #15. This allows us to do stuff like this:

#!/usr/bin/env python3
import jail
config = jail.StoppedJail("/", parameters={"osrelease": "FnordBSD 42.023"})
running = config.start()
print(running.parameters)

Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these types look pretty much the same to me, or am i missing something?

bindings/python/src/lib.rs Outdated Show resolved Hide resolved
@fabianfreyer
Copy link
Contributor Author

@igalic what types?

@igalic
Copy link

igalic commented Dec 29, 2018

the impl StoppedJail and impl RunningJail both looked very similar, but i was also very confused about the lib.rs vs oldlib.rs

@fabianfreyer
Copy link
Contributor Author

@igalic thanks for taking a look!

  • oldlib.rs was a mistake - fixed that. Sorry!
  • StoppedJail and RunningJail are things in libjail-rs that I created to attempt to model the jail lifetime using the rust type system and are therefore distinct types. The python wrapper doesn't necessarily need to model those quirks, but they are kept to more closely wrap the libjail-rs rust library API.

Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

j.stop()

def test_start_stop_jail(benchmark):
s = StoppedJail('/rescue')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a pretty cool "hack"

bindings/python/src/jls.rs Outdated Show resolved Hide resolved
bindings/python/src/jls.rs Outdated Show resolved Hide resolved
@fabianfreyer fabianfreyer force-pushed the python-bindings branch 3 times, most recently from 23b24f6 to ffbfab8 Compare January 2, 2019 15:24
@fabianfreyer fabianfreyer force-pushed the python-bindings branch 2 times, most recently from c02527a to 43f1f8e Compare January 2, 2019 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings/python Python language bindings do-not-merge enhancement New feature or request help wanted Extra attention is needed needs-rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants