Skip to content

Parse @(owner,group,mode) plist fields positionally again - #198

Merged
laffer1 merged 1 commit into
mainfrom
fix-plist-owner-mode-empty-fields
Sep 25, 2026
Merged

laffer1 merged 1 commit into
mainfrom
fix-plist-owner-mode-empty-fields

Conversation

@laffer1

@laffer1 laffer1 commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Problem

Since 0c5f815 (2026-06-06), parse_file_owner_mode() has skipped empty tokens. As a result, @(,,755) bin/npm stores 755 as the owner and leaves the mode unset. mport then never applies the requested mode, and the file keeps whatever mode it had in the fake root.

36 mports plists use this form. The visible breakage is www/npm-node24: npm-cli.js installs as 0444 (from COPYTREE_SHARE), so every port with an npm dependency fails with env: npm: Permission denied or depends on executable: npm - not found. On magus run 648 this hits claude-code-legacy, gemini-cli, clawhub and grok-cli.

Fix

Skip the leading ( and split on ,) so an empty field keeps its position. @(,,755) again means owner="", group="", mode="755". An empty owner or group already means "use the default" at install time.

Tests

  • New plist_owner_mode_mode_only and plist_owner_mode_all_fields cases in mport_util_test, covering @(,,mode), @(owner,group,mode), @dir(,group,) and @sample(,,mode).
  • The new tests fail on the old parser ("" != e->owner ( != 755)).
  • kyua test mport_util_test mport_install_test: 38/38 passed.

Follow-up

  • Merge into src contrib/mport and rebuild mport on the build boxes.
  • Rebuild www/npm-node22/npm-node24 packages (or bump PORTREVISION) so the installed files get the correct modes.

🤖 Generated with Claude Code

Summary by Sourcery

Preserve empty plist owner and group fields so positional file ownership and mode specifications are parsed and applied correctly.

Bug Fixes:

  • Restore positional parsing of empty owner, group, and mode fields in plist asset specifications so mode-only entries apply the requested file permissions correctly.

Tests:

  • Add coverage for mode-only, fully populated, directory, and sample plist owner/group/mode specifications.

parse_file_owner_mode() skipped empty tokens, so "@(,,755) bin/npm"
stored "755" as the owner and left the mode unset. mport then never
applied the requested mode, and files kept whatever mode they had in the
fake root. npm-node24 shipped npm-cli.js as 0444, and every port with an
npm build dependency failed with "env: npm: Permission denied". That
includes claude-code-legacy, gemini-cli, clawhub and grok-cli.

Skip the leading '(' and split on ",)" so an empty field keeps its slot.
Add tests covering @(,,mode), @(owner,group,mode), @dir(,group,) and
@sample(,,mode).

AI-Assisted-By: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Lucas Holt <luke@foolishgames.com>
@sourcery-ai

sourcery-ai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The parser now treats owner, group, and mode as positional fields, so empty values no longer shift later values into the wrong slot; focused tests cover file, directory, and sample plist forms.

Flow diagram for positional plist owner, group, and mode parsing

flowchart LR
    Input["@(owner,group,mode) plist entry"] --> Strip["Skip leading ("]
    Strip --> Split["Split on , and )"]
    Split --> Assign["Assign tokens to owner, group, mode by position"]
    Assign --> Install["mport install uses empty owner or group as default"]
    Assign --> Apply["mport applies requested mode"]
Loading

File-Level Changes

Change Details Files
Restore positional parsing for owner/group/mode fields, preserving empty fields.
  • Strip the leading ( before tokenization.
  • Split only on commas and the closing ), allowing empty tokens to consume their positional slots.
  • Continue parsing up to the three expected fields for file, directory, and sample entries.
libmport/plist.c
Add regression coverage for mode-only and mixed owner/mode plist entries.
  • Add a helper to parse and inspect a single plist line.
  • Verify @(,,755) leaves owner and group empty while setting the mode.
  • Verify populated, partially empty, and sample-entry fields retain their positions.
  • Register the new tests in the utility test suite.
tests/mport_util_test.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@laffer1
laffer1 merged commit 69f420c into main Sep 25, 2026
5 of 6 checks passed
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