Commit Graph
348 Commits
Author SHA1 Message Date
J Logan dadfdcefae Adds opt-in precommit hook to check formatting. (#483) 2026-01-21 11:34:16 -08:00
J Logan ce0963f693 Devcontainer for vminitd development. (#482) 2026-01-21 01:51:56 -08:00
J Logan d40650f1fb Update workflow label to select macOS 26 builder. (#485) 2026-01-21 00:38:54 -08:00
Danny Canter 863380c5e1 Interface: Support custom mtu (#484)
We started the legwork awhile ago, but never exposed it to be
configurable by the container types.
2026-01-20 17:32:28 -08:00
Saehej Kang 53017de9c2 [docs]: Updates to contribution guidelines (#426)
## Type of Change
- [ ] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [x] Documentation update

## Motivation and Context

- Added an index to the doc for easily accessing important sections
- Added two new main sections to help first time contributors with tips
on how to get started with issues, how to ask for help, and who to ask
for help.
- Made all headings sentence case for consistency

Closes https://github.com/apple/container/issues/880, as it was
preferred to not add a `CODEOWNERS` file, but instead add notes to where
contributors can find a list of maintainers to ping.

## Testing
- [ ] Tested locally
- [ ] Added/updated tests
- [x] Added/updated docs
2026-01-20 10:08:26 -08:00
Danny Canter 552d4ce759 Integration: Add simple test filtering (#479)
Just does simple string contains logic
2026-01-17 20:15:54 -08:00
Danny Canter 26f3dcc796 LinuxProcess: Start stdin relay after process start (#478)
Fixes #477

Because we start piping stdin before process launch we can fill up the
guest pipe buffer before the process even starts. We'd need some
backpressure mechanism to handle this and slow consumers (register the
other end with epoll and buffer some data etc.), but we should probably
just start piping after the process is up and running. This change does
exactly that, as well as stops holding the process mutex while draining
stdin in the guest for `CloseStdin()`.

This fixes issues where we try and write > pipe_buf bytes through stdin.
Today this hangs.
2026-01-16 14:14:08 -08:00
Danny Canter 0e91de6124 vmexec: Use FoundationEssentials (#475)
Start the journey to try and remove the 30MiB ICU blob in this binary...
2026-01-16 10:11:45 -08:00
J Logan f570b8734e Fix formatting. (#476) 2026-01-15 11:29:34 -08:00
J Logan 3e93416b9a Merge commit from fork
* Admit only valid OCI layout files when loading image.

- Adds `AdmissionMapper` protocol for validating archive
  member paths and normalizing them to relative paths
  under the extraction root directory.
- Renames `Reader.swift` to `ArchiveReader.swift` to
  match type name.
- Rework `TempDir` to address `NSString.utf8String`
  deprecation warning in Swift 6.2.3.
- Rework `ArchiveReader.extractContent()` to use an
  `AdmissionMapper` to validate and remap archive
   members before extracting.
- Adds `IdentityAdmissionWrapper` for naive extraction.
- Adds `NoSymlinkAdmissionWrapper` that only extracts
  regular files and directories under the extraction root.
- Adds `OCIImageAdmissionWrapper` that only extracts
  valid OCI image layout paths.
- Use `OCIImageAdmissionWrapper` for `cctl image load`
  and print rejected paths.

* PR feedback.

* Adds public init() for TrustedAdmissionMapper.

* Replace AdmissionMapper with more secure extraction.

- Adds FileDescriptor.mkdirSecure() to prevent
  root escapes on member pathnames, and to prevent
  symlink traversal.
- Adds FileDescriptor.unlinkRecursive() to
  facilitate overwrites when there are multiple
  archive entries with the same member path.
- Adds FileDescriptor.validateSymlinkTargetInRoot()
  to validate that extracted symlink targets do
  not escape the root.
- Rewrite ArchiveReader.extractContents() to use
  secure path functions.

* Remove unneeded symlink check, rename files.

* Simplify the lexical normalizer workaround.

* Reject member paths containing parent traversal components.

* Remove unused lexical normalization workaround.

* Fix leaking fds, extract absolute members as relative.
2026-01-15 12:52:02 -06:00
Danny Canter bbe4159649 LinuxContainer: Give a bit of overhead memory (#472)
The guest agent isn't free, and today we were sizing the VMs memory
allotment and the containers cgroup to the same value. This change gives
some overhead memory to the VM (50MB for now) for the guest agent.
2026-01-14 13:31:34 -08:00
Danny Canter 8446f895ee Allow filtering container statistics (#471)
It's possible a user doesn't want the full stats list, and only wants
cpu/mem etc. This plumbs through the ability to filter to only what is
requested. This, while we're already here, adds in memory.event output
to the stats list. For that specifically, I think eventually we may want
a streaming variant of this so you can get alerted of changes in the
file immediately instead of polling/one off reads, but this is useful
for now.
2026-01-13 13:35:00 -08:00
박성근 cbc03d7040 Fix: resolve relative executable paths against workingDirectory in vmexec (#473)
- Fixes the root cause for apple/container#962.

Signed-off-by: ParkSeongGeun <phd0801@naver.com>
2026-01-11 18:15:18 -08:00
Danny Canter fc5399e77e vmexec: Remove the logger setup (#469)
We can't write to stderr because it may be the containers stderr, so
this is mostly dead code. We should think about how to do logging from
here as there's a couple spots it'd be nice.
2026-01-05 13:48:43 -08:00
Kathryn Baldauf ec2ee3e94d Update license header on all files to include the current year (#470)
Related to https://github.com/apple/container/pull/1024

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-01-05 13:08:48 -08:00
J Logan 452f354bac Adds MACAddress type. (#468)
- Simplifies processing and validation of MAC addresses for
apple/container#1005, where we need to create MAC addresses and
corresponding link local IPv6 addresses.
- Adds Codable for IPAddress and CIDR for apple/container#1006, so we
can parse and relay IP addresses regardless of address family for port
forwards.
2026-01-05 11:31:23 -08:00
Danny Canter 2f55d75fec Support read only rootfs (#461) 2026-01-02 13:28:44 -08:00
Danny Canter 44ecb87f8d Agent: Add single file copying (#463)
Add a streaming rpc to copy single files in and out. This can easily be
extended to support copying directories, but we need the guest agent to
be able to tar/untar, and we'll need to figure out what that model is.
2026-01-02 08:57:40 -08:00
Danny Canter fb95398fb5 ci: Build for release (#465) 2026-01-01 17:40:30 -08:00
Danny Canter cbb48bc0fd vminitd: Strip binaries (#464) 2026-01-01 17:07:14 -08:00
J Logan 9f2742abf4 Handle multiple messages in netlink responses. (#460)
- Closes #459.
- Loop in `parseResponse()` until all data is consumed.
- Add properties to LinkResponse for `isEthernet`, `isLoopback`,
`address`.
2025-12-29 08:06:34 -08:00
Sebastian Moßburger 02bd878212 feat(registry): Add custom ca certificate override (#402)
Closely related to https://github.com/apple/container/issues/305 I would
like to override the used SSL TrustRoots via standard env variables.

This here would add this configuration and would give an entrypoint for
an implementation of 305 to provide CLI flags or similar.


This has no tests yet, as this would require setting up something like a
MITM proxy when testing against a registry.
As I am unfamiliar with the codebase, I would be willing to do this, but
would require a first nudge on where to best implement this.

To actually use this, we would need to add the allowed env variables to
the `container system start` command env filter.
2025-12-23 07:14:32 -05:00
Yibo Zhuang dcbc7bf71d Use string representation for CIDR and IPAddress types (#458)
This change adds extension to the CIDR and IPAddress types to implement
custom encode/decode functions for `Codable` conformance to use their
string representation as the output from encode and input to decode.
This would make the output from encoding this type (e.g. JSON) more
human-readable rather than using the internal integer representation.
2025-12-20 17:11:36 -08:00
J Logan 528f635521 Make IPv6 integer representation public. (#456)
- We did this for IPv4 so we could bit bash addresses, but forgot to
make the corresponding change for IPv6.
2025-12-19 13:06:09 -08:00
Yibo Zhuang 5ac406601e Add custom decoder to Linux struct for optional fields (#455)
Allows decoding of minimal OCI specs with empty linux objects by
providing default values for missing fields. Also added unit test to
ensure that empty Linux struct {} works correctly with the fix.
2025-12-19 01:28:02 -08:00
Yibo Zhuang 8865bc95f2 Make IP/CIDR types conform to Codable (#454)
These types can benefit from swift's automatic
synthesis as the properties already conform to Codable. This will give
some flexibility for clients using these types to not have to add
extension and implement the encoding / decoding separately.
2025-12-19 11:07:07 +05:30
Salman Chishti 57d6e0b499 Upgrade GitHub Actions to latest versions (#451)
## Summary

Upgrade GitHub Actions to their latest versions for improved features,
bug fixes, and security updates.

## Changes

| Action | Old Version(s) | New Version | Release | Files |
|--------|---------------|-------------|---------|-------|
| `actions/upload-pages-artifact` |
[`v3`](https://github.com/actions/upload-pages-artifact/releases/tag/v3)
|
[`v4`](https://github.com/actions/upload-pages-artifact/releases/tag/v4)
|
[Release](https://github.com/actions/upload-pages-artifact/releases/tag/v4)
| containerization-build-template.yml |

## Why upgrade?

Keeping GitHub Actions up to date ensures:
- **Security**: Latest security patches and fixes
- **Features**: Access to new functionality and improvements
- **Compatibility**: Better support for current GitHub features
- **Performance**: Optimizations and efficiency improvements

### Security Note

Actions that were previously pinned to commit SHAs remain pinned to SHAs
(updated to the latest release SHA) to maintain the security benefits of
immutable references.

### Testing

These changes only affect CI/CD workflow configurations and should not
impact application functionality. The workflows should be tested by
running them on a branch before merging.
2025-12-16 23:19:18 -08:00
Salman Chishti d6109d70cf Upgrade GitHub Actions for Node 24 compatibility (#452)
## Summary

Upgrade GitHub Actions to their latest versions to ensure compatibility
with Node 24, as Node 20 will reach end-of-life in April 2026.

## Changes

| Action | New Version | Release |
|--------|-------------|---------|
| `actions/checkout` |
[`8e8c483`](https://github.com/actions/checkout/commit/8e8c483db84b4bee98b60c0593521ed34d9990e8)
(v6) | [Release](https://github.com/actions/checkout/releases/tag/v6) |
| `actions/upload-artifact` |
[`b7c566a`](https://github.com/actions/upload-artifact/commit/b7c566a772e6b6bfb58ed0dc250532a479d7789f)
(v6) |
[Release](https://github.com/actions/upload-artifact/releases/tag/v6) |
| `actions/download-artifact` |
[`37930b1`](https://github.com/actions/download-artifact/commit/37930b1c2abaa49bbe596cd826c3c89aef350131)
(v7) |
[Release](https://github.com/actions/download-artifact/releases/tag/v7)
|

## Context

Per [GitHub's
announcement](https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/),
Node 20 is being deprecated and runners will begin using Node 24 by
default starting March 4th, 2026.

### Why this matters

- **Node 20 EOL**: April 2026
- **Node 24 default**: March 4th, 2026
- **Action**: Update to latest action versions that support Node 24

### Security Note

All actions are pinned to commit SHAs for security, with version tags
noted in comments for reference.

### Testing

These changes only affect CI/CD workflow configurations and should not
impact application functionality.
2025-12-16 23:18:58 -08:00
J LoganandAgam Dua 9ba8267afb Use typesafe IP/CIDR parameters everywhere. (#448)
- Closes #445.
- Adopts refined IPv4 and IPv6 types developed
  by Agam Dua <agamdua@users.noreply.github.com>.
- For type safety and clarity, use IP and CIDR types
  where we were previously using String.

Co-authored-by: Agam Dua <agamdua@users.noreply.github.com>
2025-12-16 09:58:44 -03:00
Danny Canter 68694942ec Command: Pass the right flags to /dev/null (#449) 2025-12-12 11:55:01 -08:00
J Logan 6d548a0e49 Match Mount default cache/sync to container defaults. (#446)
- Use `cache=auto`, `sync=fsync` as default everywhere.
2025-12-11 19:47:02 -03:00
Danny Canter 7962dae643 Add capabilities support (#444)
Closes https://github.com/apple/containerization/issues/442

This adds capabilities support to LinuxContainer via a new surface in
ContainerizationOS + some C wrappers.
2025-12-11 15:07:17 -05:00
Dmitry Kovba 96d37e2e21 Fix multi-sentence error messages (#443)
Fixes multi-sentence error messages, where they start from a lowercased
letter.
2025-12-09 12:32:09 -08:00
Danny Canter e8aff29be3 Cgroup2Manager: Fix cgroup deletions (#439)
If there's any nested cgroups in the one we made for the container
(commonly seen for systemd images) removeItem didn't seem to be having a
grand time, even though it states it should do recursive removals. Lets
roll our own, and have a small EBUSY/EAGAIN retry loop as well. This
fixes LinuxContainer.stop() for any containers with nested cgs.

Context: https://github.com/apple/container/issues/928
2025-12-09 14:47:38 -03:00
Dmitry Kovba bb0cd39177 Lowercase error messages (#440)
For consistency, all error messages are lowercased.
2025-12-09 05:38:48 -08:00
Kathryn Baldauf d473f89ccb Rename CONTRIBUTORS to MAINTAINERS and update list to current state (#435)
We'd like a way for people to know who they can ping for help on PRs and
issues, but we want to avoid being automatically assigned to PRs via
something like CODEOWNERS. Instead, we've opted to list the maintainers
of the project in a new MAINTAINERS file.

We opted to change from CONTRIBUTORS to MAINTAINERS since we believe
that contributors are already acknowledged via the `Contributors` tab on
GitHub and in the release notes we make for each new release.

In the future, the MAINTAINERS file can be extended to include
additional maintainers and past maintainers can continue to be
recognized for their work.
2025-12-06 17:54:17 -08:00
Danny Canter d0b43df9b5 EXT4: Remove advertising inline data (#438) 2025-12-06 13:45:36 -08:00
Danny Canter 2d27ef6deb LinuxPod: Wire up pid namespace sharing (#434)
In a prior change I'd added a way for vminitd to double as a simple
pause container. This change wires this up by adding a new bool to the
pod config to ask for pid ns sharing.
2025-12-05 10:42:50 -05:00
Danny Canter c45fef7278 Vminitd: Add pause command (#418)
Due to us supporting a pod type now, and pid ns sharing being quite a
common thing for pods, lets add a pause container like command to
vminitd to eventually enable pid ns sharing between containers in our
variant of a pod.

This changes vminitd slightly to have pause and init (default) commands
as it seemed simpler than creating a whole new binary to include in the
guest image.
2025-12-02 15:52:32 -05:00
Danny Canter 5c190dc4a8 Integration: multipleConcurrentProcesses adjustments (#424)
Remove the prints (To me they're just noise) and stop SIGKILL'ing
the init process and just stop the container.
2025-12-02 10:59:13 -05:00
Danny Canter 1254352d68 vminitd: Turn ProcessSupervisor into a class (#433)
Really no reason for this to be an actor, and we're seeing runtime
errors seemingly because of it.
2025-12-02 10:43:14 -05:00
Danny Canter 27947cda9c VirtualMachineInstance: Remove stopListen (#412) 2025-12-01 09:40:20 -08:00
Danny Canter 0e8a779f03 README: Adjust required version numbers (#432)
macOS and Xcode 26 are both released now, no need to still list beta.
2025-12-01 11:15:39 -05:00
GAUTAM RAJU 031cd72e2a Implement pdeathSignal handling in Runc (#431)
Add support for parent death signal (pdeathSignal) to ensure child
processes receive a signal when the parent process dies. This addresses
the FIXME comment in Runc.execute().

## Changes
- Add pdeathSignal field to exec_command_attrs C struct
- Implement prctl(PR_SET_PDEATHSIG) in child process handler (Linux
only)
- Expose pdeathSignal through Command.Attrs Swift API
- Wire up pdeathSignal in Runc.execute() to remove FIXME

## Implementation Details
The implementation uses Linux-specific prctl() to set the parent death
signal, ensuring proper cleanup when parent processes terminate. The
feature is conditionally compiled for Linux only, maintaining
compatibility with other platforms.
2025-12-01 02:35:09 -08:00
Danny Canter 4a8f945f87 vminitd: Add memory threshold monitoring (#427)
Add a small bit of logic to monitor if vminitd goes over a (somewhat
arbitrary) memory threshold. On average, when running one container it
seems to hover around 25MiB, so this is mostly to catch cases where it's
exceeding a limit we don't deem normal.
2025-11-21 14:54:13 -08:00
Raj 35ebe365ba Add calculateOrphanedBlobsSize() to calculate the size of orphaned blobs (#428)
Adds `calculateOrphanedBlobsSize()` to calculate the size of orphaned
blobs, will need this to include them under size and reclaimable space
for images in the `container system df` command so it matches up with
what `container image prune` frees up on disk.
2025-11-21 14:50:28 -08:00
Danny Canter 836b699a91 Wire up experimental OCI runtime support (#416) 2025-11-21 12:16:58 -08:00
Raj 860139bd1a Fix ImageStore.prune() behavior to actually remove images (#420)
- Fixes #417.

Rename `_prune()` to `cleanupOrphanedBlobs()` to clarify what it
actually does, and remove `prune()` method as we'll do all that logic in
container directly.
2025-11-20 15:22:54 -08:00
Danny Canter 14f56e4a53 Scripts: Add a script to find kernel panics (#422)
Adds a simple script to find kernel panics in the integration serial
console logs. We're tracking down one related to Swift's Mutex.
2025-11-20 12:02:57 -08:00
Danny Canter 79d7e398c1 vminitd client: Remove connection backoff (#423)
For the constructor we're using where we pass an already connected
socket, I'm not sure this even does anything, and if it does that's a
bug I'd rather just avoid altogether.

Also gets rid of the unused constructor we have to pass in a UDS.
2025-11-20 12:00:56 -08:00