author | Dave Townsend <dtownsend@oxymoronical.com> |
Fri, 11 Oct 2013 09:47:15 -0700 | |
changeset 150492 | c180e7c60c14cd1923bb3e034d94556142a40623 |
parent 150491 | a5046a3a30eac9a613265824a8d9f2c99a53ee39 |
child 150493 | 0a9e2dd65d142660f5a089f143ddf1eb58a571fc |
push id | 25443 |
push user | ryanvm@gmail.com |
push date | Fri, 11 Oct 2013 19:41:45 +0000 |
treeherder | mozilla-central@1144854a01d6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | taras |
bugs | 921227 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/modules/libjar/nsIZipReader.idl +++ b/modules/libjar/nsIZipReader.idl @@ -6,17 +6,17 @@ #include "nsISupports.idl" interface nsIUTF8StringEnumerator; interface nsIInputStream; interface nsIFile; interface nsICertificatePrincipal; -[scriptable, uuid(e1c028bc-c478-11da-95a8-00e08161165f)] +[scriptable, uuid(fad6f72f-13d8-4e26-9173-53007a4afe71)] interface nsIZipEntry : nsISupports { /** * The type of compression used for the item. The possible values and * their meanings are defined in the zip file specification at * http://www.pkware.com/business_and_developers/developer/appnote/ */ readonly attribute unsigned short compression; @@ -46,16 +46,20 @@ interface nsIZipEntry : nsISupports * entry represents a directory within the zip file which has no * corresponding entry within the zip file. For example, the entry for the * directory foo/ in a zip containing exactly one entry for foo/bar.txt * is synthetic. If the zip file contains an actual entry for a directory, * this attribute will be false for the nsIZipEntry for that directory. * It is impossible for a file to be synthetic. */ readonly attribute boolean isSynthetic; + /** + * The UNIX style file permissions of this item. + */ + readonly attribute unsigned long permissions; }; [scriptable, uuid(38d6d07a-8a58-4fe7-be8b-ef6472fa83ff)] interface nsIZipReader : nsISupports { /** * Opens a zip file for reading. * It is allowed to open with another file,
--- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -906,16 +906,17 @@ nsJAREnumerator::GetNext(nsACString& aRe NS_IMPL_ISUPPORTS1(nsJARItem, nsIZipEntry) nsJARItem::nsJARItem(nsZipItem* aZipItem) : mSize(aZipItem->Size()), mRealsize(aZipItem->RealSize()), mCrc32(aZipItem->CRC32()), mLastModTime(aZipItem->LastModTime()), mCompression(aZipItem->Compression()), + mPermissions(aZipItem->Mode()), mIsDirectory(aZipItem->IsDirectory()), mIsSynthetic(aZipItem->isSynthetic) { } //------------------------------------------ // nsJARItem::GetCompression //------------------------------------------ @@ -995,16 +996,28 @@ NS_IMETHODIMP nsJARItem::GetLastModifiedTime(PRTime* aLastModTime) { NS_ENSURE_ARG_POINTER(aLastModTime); *aLastModTime = mLastModTime; return NS_OK; } +//------------------------------------------ +// nsJARItem::GetPermissions +//------------------------------------------ +NS_IMETHODIMP +nsJARItem::GetPermissions(uint32_t* aPermissions) +{ + NS_ENSURE_ARG_POINTER(aPermissions); + + *aPermissions = mPermissions; + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // nsIZipReaderCache NS_IMPL_ISUPPORTS3(nsZipReaderCache, nsIZipReaderCache, nsIObserver, nsISupportsWeakReference) nsZipReaderCache::nsZipReaderCache() : mLock("nsZipReaderCache.mLock") , mZips(16)
--- a/modules/libjar/nsJAR.h +++ b/modules/libjar/nsJAR.h @@ -137,16 +137,17 @@ public: virtual ~nsJARItem() {} private: uint32_t mSize; /* size in original file */ uint32_t mRealsize; /* inflated size */ uint32_t mCrc32; PRTime mLastModTime; uint16_t mCompression; + uint32_t mPermissions; bool mIsDirectory; bool mIsSynthetic; }; /** * nsJAREnumerator * * Enumerates a list of files in a zip archive
--- a/modules/libjar/zipwriter/src/nsZipHeader.cpp +++ b/modules/libjar/zipwriter/src/nsZipHeader.cpp @@ -122,16 +122,26 @@ NS_IMETHODIMP nsZipHeader::GetLastModifi NS_IMETHODIMP nsZipHeader::GetIsSynthetic(bool *aIsSynthetic) { NS_ASSERTION(mInited, "Not initalised"); *aIsSynthetic = false; return NS_OK; } +/* readonly attribute unsigned long permissions; */ +NS_IMETHODIMP nsZipHeader::GetPermissions(uint32_t *aPermissions) +{ + NS_ASSERTION(mInited, "Not initalised"); + + // Always give user read access at least, this matches nsIZipReader's behaviour + *aPermissions = ((mEAttr >> 16) & 0xfff | 0x100); + return NS_OK; +} + void nsZipHeader::Init(const nsACString & aPath, PRTime aDate, uint32_t aAttr, uint32_t aOffset) { NS_ASSERTION(!mInited, "Already initalised"); PRExplodedTime time; PR_ExplodeTime(aDate, PR_LocalTimeParameters, &time);
--- a/modules/libjar/zipwriter/test/unit/test_zippermissions.js +++ b/modules/libjar/zipwriter/test/unit/test_zippermissions.js @@ -5,17 +5,17 @@ const DATA = "ZIP WRITER TEST DATA"; var TESTS = []; function build_tests() { var id = 0; - // Minimum mode is 0400 + // Minimum mode is 0o400 for (let u = 4; u <= 7; u++) { for (let g = 0; g <= 7; g++) { for (let o = 0; o <= 7; o++) { TESTS[id] = { name: "test" + u + g + o, permission: (u << 6) + (g << 3) + o }; id++; @@ -48,26 +48,36 @@ function run_test() { // This reduces the coverage of the test but there isn't much we can do var perm = file.permissions & 0xfff; if (TESTS[i].permission != perm) { dump("File permissions for " + TESTS[i].name + " were " + perm.toString(8) + "\n"); TESTS[i].permission = perm; } zipW.addEntryFile(TESTS[i].name, Ci.nsIZipWriter.COMPRESSION_NONE, file, false); - file.permissions = 0600; + do_check_eq(zipW.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400); + file.permissions = 0o600; file.remove(true); } zipW.close(); + zipW.open(tmpFile, PR_RDWR); + for (let i = 0; i < TESTS.length; i++) { + dump("Testing zipwriter file permissions for " + TESTS[i].name + "\n"); + do_check_eq(zipW.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400); + } + zipW.close(); + var zipR = new ZipReader(tmpFile); for (let i = 0; i < TESTS.length; i++) { + dump("Testing zipreader file permissions for " + TESTS[i].name + "\n"); + do_check_eq(zipR.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400); + dump("Testing extracted file permissions for " + TESTS[i].name + "\n"); zipR.extract(TESTS[i].name, file); - dump("Testing file permissions for " + TESTS[i].name + "\n"); do_check_eq(file.permissions & 0xfff, TESTS[i].permission); do_check_false(file.isDirectory()); - file.permissions = 0600; + file.permissions = 0o600; file.remove(true); } zipR.close(); tmp.remove(true); }