{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/9683","labels_url":"https://api.github.com/repos/golang/go/issues/9683/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/9683/comments","events_url":"https://api.github.com/repos/golang/go/issues/9683/events","html_url":"https://github.com/golang/go/issues/9683","id":55409886,"number":9683,"title":"archive/tar: ustar-style long filenames not understood by GNU tar / BSD tar / star","user":{"login":"lyonel","id":741087,"avatar_url":"https://avatars.githubusercontent.com/u/741087?v=3","gravatar_id":"","url":"https://api.github.com/users/lyonel","html_url":"https://github.com/lyonel","followers_url":"https://api.github.com/users/lyonel/followers","following_url":"https://api.github.com/users/lyonel/following{/other_user}","gists_url":"https://api.github.com/users/lyonel/gists{/gist_id}","starred_url":"https://api.github.com/users/lyonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyonel/subscriptions","organizations_url":"https://api.github.com/users/lyonel/orgs","repos_url":"https://api.github.com/users/lyonel/repos","events_url":"https://api.github.com/users/lyonel/events{/privacy}","received_events_url":"https://api.github.com/users/lyonel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-25T10:49:33Z","updated_at":"2015-01-27T01:42:54Z","closed_at":null,"body":"Go version: go1.3.3 linux/amd64 on Fedora 20\r\n\r\nWhen creating an archive (with `tar.NewWriter`), long names (> 100 chars) that don't fit into standard tar headers need to be encoded differently.\r\nAn optimisation in `archive/tar/writer.go: writeHeader()` tries to use a ustar header when only the name is too long creates files that are misinterpretated by other tar implementations (but read correctly by archive/tar)\r\n\r\nFor example, `/home/support/.openoffice.org/3/user/uno_packages/cache/registry/com.sun.star.comp.deployment.executable.PackageRegistryBackend` becomes `com.sun.star.comp.deployment.executable.PackageRegistryBackend` for external `tar` commands (tested with GNU tar, BSD tar and star)\r\n\r\nModifying `archive/tar/writer.go` and forcing `preferPax` to `true` in `NewWriter` fixes the issue"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/71575643","html_url":"https://github.com/golang/go/issues/9683#issuecomment-71575643","issue_url":"https://api.github.com/repos/golang/go/issues/9683","id":71575643,"user":{"login":"minux","id":135652,"avatar_url":"https://avatars.githubusercontent.com/u/135652?v=3","gravatar_id":"","url":"https://api.github.com/users/minux","html_url":"https://github.com/minux","followers_url":"https://api.github.com/users/minux/followers","following_url":"https://api.github.com/users/minux/following{/other_user}","gists_url":"https://api.github.com/users/minux/gists{/gist_id}","starred_url":"https://api.github.com/users/minux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minux/subscriptions","organizations_url":"https://api.github.com/users/minux/orgs","repos_url":"https://api.github.com/users/minux/repos","events_url":"https://api.github.com/users/minux/events{/privacy}","received_events_url":"https://api.github.com/users/minux/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T01:42:54Z","updated_at":"2015-01-27T01:42:54Z","body":"The problem is that if the uid/gid is bigger than 2^21-1 (that is, can't be\nepresented in 8 octal digits), archive/tar will use binary representation\nin the tar header.\n\nWhen using that extension, it uses \"ushar\\x20\\x20\" as header magic,\ninstead of the normal \"ushar\". However, according to GNU tar source,\nthe long file name will only be considered if it's TMAGIC (\"ushar\").\n\nBy always using \"ushar\" fixed the problem, and both GNU tar and BSD\ntar read the tar file correctly. I'm not sure why we're using\n\"ushar\\x20\\x20\"\n(OLDGNU_MAGIC) in the first place. It seems all tar readers can handle\nbinary-encoded uid/gid just fine with TMAGIC."}}