Skip to content

Fix logic bug in file mode calculation in sdk container builds - #55656

Open
lbussell wants to merge 1 commit into
mainfrom
lbussell/fix-container-file-mode
Open

Fix logic bug in file mode calculation in sdk container builds#55656
lbussell wants to merge 1 commit into
mainfrom
lbussell/fix-container-file-mode

Conversation

@lbussell

@lbussell lbussell commented Aug 6, 2026

Copy link
Copy Markdown
Member

The bitwise or here always produced a nonzero value, marking every Unix file as 755 when some should be 644.

Copilot AI review requested due to automatic review settings August 6, 2026 22:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

Fixes Unix file permission classification when generating container layers so non-executable files are not incorrectly marked as executable (and thus not always emitted as 0755).

Changes:

  • Corrects the execute-bit detection logic in Layer tar entry creation by using a bitwise AND rather than OR when checking permissions.

Comment on lines 192 to +194
// On Unix, we can determine the x-bit based on the filesystem permission.
// On Windows, we use executable permissions for all entries.
return (OperatingSystem.IsWindows() || ((file.UnixFileMode | UnixFileMode.UserExecute) != 0)) ? executeMode : nonExecuteMode;
return (OperatingSystem.IsWindows() || ((file.UnixFileMode & UnixFileMode.UserExecute) != 0)) ? executeMode : nonExecuteMode;
// On Unix, we can determine the x-bit based on the filesystem permission.
// On Windows, we use executable permissions for all entries.
return (OperatingSystem.IsWindows() || ((file.UnixFileMode | UnixFileMode.UserExecute) != 0)) ? executeMode : nonExecuteMode;
return (OperatingSystem.IsWindows() || ((file.UnixFileMode & UnixFileMode.UserExecute) != 0)) ? executeMode : nonExecuteMode;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm sorry for ruining your 1 character PR but I do think a regression test would be nice

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.

3 participants