mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8250968: Symlinks attributes not preserved when using jarsigner on zip files
Reviewed-by: lancea, weijun, hchao
This commit is contained in:
parent
8d6d43c33b
commit
7686e87155
10 changed files with 199 additions and 38 deletions
|
@ -57,7 +57,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
|
|||
int flag = 0; // general purpose flag
|
||||
byte[] extra; // optional extra field data for entry
|
||||
String comment; // optional comment string for entry
|
||||
int posixPerms = -1;// posix permissions
|
||||
int extraAttributes = -1; // e.g. POSIX permissions, sym links.
|
||||
/**
|
||||
* Compression method for uncompressed entries.
|
||||
*/
|
||||
|
@ -131,7 +131,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
|
|||
flag = e.flag;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
posixPerms = e.posixPerms;
|
||||
extraAttributes = e.extraAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -658,8 +658,8 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
e.csize = CENSIZ(cen, pos);
|
||||
e.method = CENHOW(cen, pos);
|
||||
if (CENVEM_FA(cen, pos) == FILE_ATTRIBUTES_UNIX) {
|
||||
// 12 bits for setuid, setgid, sticky + perms
|
||||
e.posixPerms = CENATX_PERMS(cen, pos) & 0xFFF;
|
||||
// read all bits in this field, including sym link attributes
|
||||
e.extraAttributes = CENATX_PERMS(cen, pos) & 0xFFFF;
|
||||
}
|
||||
|
||||
if (elen != 0) {
|
||||
|
@ -1096,14 +1096,13 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
public Stream<String> entryNameStream(ZipFile zip) {
|
||||
return zip.entryNameStream();
|
||||
}
|
||||
// only set posix perms value via ZipEntry contructor for now
|
||||
@Override
|
||||
public int getPosixPerms(ZipEntry ze) {
|
||||
return ze.posixPerms;
|
||||
public int getExtraAttributes(ZipEntry ze) {
|
||||
return ze.extraAttributes;
|
||||
}
|
||||
@Override
|
||||
public void setPosixPerms(ZipEntry ze, int perms) {
|
||||
ze.posixPerms = perms;
|
||||
public void setExtraAttributes(ZipEntry ze, int extraAttrs) {
|
||||
ze.extraAttributes = extraAttrs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -511,7 +511,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
|
|||
* to a version value.
|
||||
*/
|
||||
private int versionMadeBy(ZipEntry e, int version) {
|
||||
return (e.posixPerms < 0) ? version :
|
||||
return (e.extraAttributes < 0) ? version :
|
||||
VERSION_MADE_BY_BASE_UNIX | (version & 0xff);
|
||||
}
|
||||
|
||||
|
@ -606,8 +606,8 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
|
|||
}
|
||||
writeShort(0); // starting disk number
|
||||
writeShort(0); // internal file attributes (unused)
|
||||
// external file attributes, used for storing posix permissions
|
||||
writeInt(e.posixPerms > 0 ? e.posixPerms << 16 : 0);
|
||||
// extra file attributes, used for storing posix permissions etc.
|
||||
writeInt(e.extraAttributes > 0 ? e.extraAttributes << 16 : 0);
|
||||
writeInt(offset); // relative offset of local header
|
||||
writeBytes(nameBytes, 0, nameBytes.length);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue