Repository navigation
Conversation
User.parse read both files with String(contentsOf:encoding: .ascii), so a single non-ASCII byte (for example an accented GECOS name) made every exec fail with NSCocoaErrorDomain Code=259. Decode leniently instead, so legacy non-UTF-8 bytes are not fatal either. Add regression tests for both cases.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
Closes apple/container#2376.
User.parsereads/etc/passwdand/etc/groupwithString(contentsOf:encoding: .ascii). One non-ASCII byte in either file, for example an accented GECOS name fromuseradd -c 'José Müller', makes the read fail. Every latercontainer execthen fails withNSCocoaErrorDomain Code=259, for every user.This change decodes the files with
String(decoding:as: UTF8.self). That fixes UTF-8 names. It also keeps a legacy non-UTF-8 byte (for example Latin-1) from failing the whole file. The parser only splits on:and newlines, so a replacement character in a GECOS field has no effect.Repro, from the issue:
Before:
container execfails withNSCocoaErrorDomain Code=259 "The file isn’t in the correct format.".After:
User.parsereads the file, so the exec no longer fails at this step.Testing
I ran the unit tests on macOS 26.2 with Swift 6.3.3. I did not run
container execend to end.swift test --filter ContainerizationOSTests.UsersTestswith the oldUser.swift:swift test --filter ContainerizationOSTestswith this change:swift formatleaves both changed files unchanged.I am new to open source, and this pull request was made with AI assistance.