Skip to content

BREAKING(tar/unstable): fix handling of mode, uid, and gid #6440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

BlackAsLight
Copy link
Contributor

Closes: #6376

This pull request makes the changes discussed in the other linked pull request.

It changes mode, uid, and gid to accept and decode numbers in the octal format 0o775 instead of decimal format 775. It also changes slightly the decoding segment of these three to be more compatible with other tar specs.

@BlackAsLight BlackAsLight requested a review from kt3k as a code owner February 22, 2025 08:43
@github-actions github-actions bot added the tar label Feb 22, 2025
@BlackAsLight BlackAsLight changed the title change(tar): mode, uid, and gid to accept octals fix(tar): mode, uid, and gid to accept octals Feb 22, 2025
Copy link

codecov bot commented Feb 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.98%. Comparing base (71c828a) to head (101ba12).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6440      +/-   ##
==========================================
- Coverage   95.98%   95.98%   -0.01%     
==========================================
  Files         564      564              
  Lines       42482    42476       -6     
  Branches     6394     6391       -3     
==========================================
- Hits        40775    40769       -6     
  Misses       1668     1668              
  Partials       39       39              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +226 to +227
options.uid.toString(8).padStart(6, "0") + " \0" + //uid
options.gid.toString(8).padStart(6, "0") + " \0" + // gid
Copy link
Member

Choose a reason for hiding this comment

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

I missed this in #6376, but I don't think UID and GID are generally handled as octals. See docs of Deno.chown for example. https://docs.deno.com/api/deno/~/Deno.chown

Can we do these changes only for 'mode'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can but the spec is only expecting octal digits to be written

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this change should be done for UID and GID as well. Currently, to set the UID to, for example, 501, the user would have to write uid: 765 (the octal representation of 501 disguised as a decimal literal), which doesn't make sense to me.

import { TarStream, type TarStreamInput } from "jsr:@std/[email protected]/tar-stream";

const file = new Blob(["hello world\n"]);
await ReadableStream.from<TarStreamInput>([
  {
    type: "file",
    path: "hello.txt",
    size: file.size,
    readable: file.stream(),
    options: { uid: 765, gid: 24, mtime: 0 },
  },
])
  .pipeThrough(new TarStream())
  .pipeTo(Deno.stdout.writable);
$ deno run a.ts | tar tv
-rw-r--r--  0 501    20         12 Jan  1  1970 hello.txt

Copy link
Member

Choose a reason for hiding this comment

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

@0f-0b Ah, ok. That sounds correct. This part needs to be encoded in octals. Thanks for pointing this!

@kt3k kt3k changed the title fix(tar): mode, uid, and gid to accept octals BREAKING(tar/unstable): fix handling of mode, uid, and gid Feb 27, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the fix!

@kt3k kt3k merged commit e3b4bd7 into denoland:main Feb 27, 2025
19 of 20 checks passed
@BlackAsLight BlackAsLight deleted the tar branch February 27, 2025 03:28
eryue0220 added a commit to eryue0220/deno_std that referenced this pull request Mar 2, 2025
…no_std into feat/fs-unstable-remove-api

* 'feat/fs-unstable-remove-api' of github.com:eryue0220/deno_std:
  test(fs/unstable): remove windows specific paths and fix ci (denoland#6448)
  BREAKING(tar/unstable): fix handling of mode, uid, and gid (denoland#6440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants