8000 Fix installation and tests on current Ubuntu/Debian and Python 3.12+; fix mnexec bugs and test hangs by Mangesh-Bhattacharya · Pull Request #1256 · mininet/mininet · GitHub
[go: up one dir, main page]

Skip to content

Fix installation and tests on current Ubuntu/Debian and Python 3.12+; fix mnexec bugs and test hangs - #1256

Closed
Mangesh-Bhattacharya wants to merge 1 commit into
mininet:masterfrom
Mangesh-Bhattacharya:ci/debian-check
Closed

Mangesh-Bhattacharya wants to merge 1 commit into
mininet:masterfrom
Mangesh-Bhattacharya:ci/debian-check

Conversation

@Mangesh-Bhattacharya
@Mangesh-Bhattacharya Mangesh-Bhattacharya commented Sep 18, 2026 •
Copy link
Copy Markdown

Summary

Mininet 2.3.1b4 no longer installs or tests cleanly on current systems:
util/install.sh fails on Ubuntu 24.04 and Debian 12/13, mn fails on
Python 3.12+ (distutils was removed), scripts start with
#!/usr/bin/env python although there is no python command on
Ubuntu 22.04+/Debian 12+, and CI targets the retired ubuntu-20.04
runners. This PR fixes these without changing Mininet's API or mn
options.

Install and runtime

  • util/install.sh: Ubuntu 22.04/24.04 and Debian 12/13 (PEP 668
    externally-managed Python, renamed/removed packages, /etc/os-release,
    containers without sudo, any checkout directory name).
  • mininet/util.py: version parsing without distutils.
  • mininet/node.py: OVSSwitch falls back to the userspace datapath
    when the openvswitch kernel module is unavailable (Docker, WSL 2, some
    cloud kernels); MININET_OVS_DATAPATH=kernel|user overrides it.
  • Python 3 shebangs everywhere, and 50 regex literals with invalid
    escapes ('\d') made raw strings (SyntaxWarning since 3.12).

mnexec.c (runs as root)

  • -c closed the /proc/self/fd directory it was iterating and never
    freed it.
  • Namespace fds are now O_CLOEXEC and closed instead of leaking into
    the executed command.
  • -a validates the pid; snprintf instead of sprintf; isalnum()
    gets an unsigned char; a NULL working directory is handled.
  • -g also supports cgroup v2 (cgroup.procs), the default today.
  • The Makefile builds it with _FORTIFY_SOURCE, stack protector, PIE and
    full RELRO.

Tests

  • Hang fix: example tests called pexpect's wait() after exit
    without reading the child's output. When stopping the network fills the
    pty buffer, both sides block forever; test_tree1024 hung CI for hours.
    Tests now read to EOF first.
  • sshd.py / baresshd.py create /run/sshd, which OpenSSH requires
    when started by hand and current distributions only create for the ssh
    service (test_sshd/test_baresshd failed on Ubuntu 24.04).
  • CI: run-tests.yaml runs on ubuntu-22.04 and ubuntu-24.04 with
    Python 3 (Python 2 can't be installed on 24.04); code-check.yaml pins
    Python 3.11, since pylint 2.15.7 doesn't run on 3.12+. Actions are
    pinned to commit SHAs.

Packaging and docs

  • debian/ (last updated for 2.1.0 in 2013): Python 3 + pybuild,
    debhelper compat 13, current dependency names, hardening flags, DEP-5
    copyright with the current BSD-3-Clause license.
  • util/doxify.py ported to Python 3; it no longer needs doxypy
    (Python 2 only). doxygen reads the docstrings natively.
  • util/vm/install-mininet-vm.sh works on Ubuntu 22.04/24.04 and
    Debian (it tried to install python2), and uses /etc/sudoers.d.

Testing

Verified in GitHub Actions on Ubuntu 22.04 and 24.04: install.sh -nv,
mn --test pingall (OVS kernel and userspace datapaths, Linux bridge,
TCLink), the core test suite, and every example test (test_nat's
Internet ping is skipped on runners without outbound ICMP). install.sh
was also run from scratch in ubuntu:22.04, ubuntu:24.04, debian:12
and debian:13 containers, and the Debian package was built with
dpkg-buildpackage, installed and used to run a network.

Notes for reviewers

  • Python 2 support in install.sh is left in place; only the CI matrix
    and the VM script stop using it, because it can't be installed on
    current releases. Happy to restore a python2 job on ubuntu-22.04
    if you want to keep testing it.
  • These changes come from a downstream fork
    (Mangesh-Bhattacharya/mininet)
    that also adds Docker images, a browser GUI and other features. Those
    are deliberately not included here. I'm glad to split this PR into
    smaller ones (install, Python 3.12, mnexec, tests, packaging) if that
    is easier to review.

…xec bugs

Mininet no longer installs or tests cleanly on Ubuntu 22.04/24.04,
Debian 12/13 or Python 3.12+. This fixes that without changing how
Mininet works.

Install and runtime:
- util/install.sh: Ubuntu 24.04 and Debian 12/13 (PEP 668, renamed and
  removed packages, /etc/os-release, containers without sudo, any
  checkout directory name)
- mininet/util.py: version parsing without distutils (removed in 3.12)
- mininet/node.py: OVSSwitch falls back to the userspace datapath when
  the openvswitch kernel module is unavailable (containers, WSL, some
  cloud kernels); MININET_OVS_DATAPATH overrides it
- Python 3 shebangs: "#!/usr/bin/env python" fails where there is no
  python command (Ubuntu 22.04+, Debian 12+)
- 50 regex literals with invalid escapes ('\d') are raw strings
  (SyntaxWarning since Python 3.12)

mnexec.c (runs as root):
- -c no longer closes the directory it is iterating, and frees it
- namespace fds are O_CLOEXEC and closed instead of leaking into commands
- -a validates the pid; snprintf instead of sprintf; isalnum() on
  unsigned char; NULL working directory handled
- -g also works with cgroup v2 (cgroup.procs)
- Makefile builds it with FORTIFY_SOURCE, stack protector, PIE and full
  RELRO

Tests:
- example tests read the example's output to EOF before pexpect wait();
  wait() alone deadlocks when the child fills the pty buffer while
  stopping the network (test_tree1024 hung CI for hours)
- sshd.py/baresshd.py create /run/sshd, which OpenSSH needs when started
  by hand and current distributions only create for the ssh service
- example tests spawn python3
- CI: ubuntu-20.04 runners are retired and Python 2 can't be installed
  on 24.04, so run-tests.yaml uses ubuntu-22.04/24.04 with python3;
  code-check pins Python 3.11 for pylint 2.15; actions pinned by SHA

Packaging and docs:
- debian/: Python 3 + pybuild, debhelper compat 13, current dependency
  names, hardening, DEP-5 copyright with the current BSD-3-Clause text
- util/doxify.py ported to Python 3 without doxypy (Python 2 only);
  doxygen reads docstrings natively
- util/vm/install-mininet-vm.sh works on Ubuntu 22.04/24.04 and Debian
  (no python2), uses /etc/sudoers.d
@Mangesh-Bhattacharya Mangesh-Bhattacharya changed the title Ci/debian check Fix installation and tests on current Ubuntu/Debian and Python 3.12+; fix mnexec bugs and test hangs Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0