Bug 541420: Files extracted from XPI files have their executableness stripped. r=robstrong, a=legneato
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 14 Jul 2010 14:29:23 -0700
changeset 34440 df760e6d4ddc45026cfb00591acbe31035d0935b
parent 34439 b374c411830c837ab1faa6aa9cc17d9cefbc6697
child 34441 5d60b8125b69637e8e139b3449936f15892f9bdf
push id1468
push userdtownsend@mozilla.com
push dateFri, 16 Jul 2010 21:04:59 +0000
reviewersrobstrong, legneato
bugs541420
milestone1.9.2.8pre
Bug 541420: Files extracted from XPI files have their executableness stripped. r=robstrong, a=legneato
toolkit/mozapps/extensions/src/nsExtensionManager.js.in
toolkit/mozapps/extensions/test/unit/data/test_bug541420.xpi
toolkit/mozapps/extensions/test/unit/test_bug541420.js
--- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
+++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
@@ -1789,17 +1789,17 @@ function safeInstallOperation(itemID, in
       entries = zipReader.findEntries(null);
       while (entries.hasMore()) {
         var entryName = entries.getNext();
         target = installLocation.getItemFile(itemID, entryName);
         if (target.exists())
           continue;
 
         zipReader.extract(entryName, target);
-        target.permissions = PERMS_FILE;
+        target.permissions |= PERMS_FILE;
       }
     }
     catch (e) {
       // This means the install operation failed. Remove everything and roll back.
       ERROR("safeInstallOperation: file extraction failed, " +
             "rolling back file moves and aborting installation.");
       try {
         // Us-generated. Safe.
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d5d1e91da9793d1508a422ece91768ee0d632431
GIT binary patch
literal 602
zc$^FHW@Zs#U}E54Sn6YD^ZEtzJS9d31|KE{25tr!hRnR;lEj=Gy`q$~&=5`rX17O?
z-XL6B!Og(P@)f8OsF{JGHRxc_VFiJ`&$SI~gD*+&pS=(=_ttE2{(IYbeP=RGYV7T-
z+uLH6yZGFR-rDzXt9Ku`zBlZNbA)>K<}UHiDske0NA8<NKN5T#_EB)-Ny*o{^6uR|
zpB=sNXwl9T&r_GC-1_8jce&$>m4%xvln!$qih0o)c0E2wlY{q?%E=iQnybXBt(|_j
z?bth&_m>1qS!ws`9b47xR~Kc<GzEn;Ph@|1VKtk&UWwl6r0Ze)H<i36yMLLn`|G1O
zE;}!r-z-*lrJ?uxi$e|@rXE<nEU<`QVuQgol_wFqQ(ny8Yt6OvU#EfA7L)hMlN@$v
z`gC6SuMo$btoKbjBH^Fm3C=x>r{v`3PS`VJ(jKlBUIhWK_1Q)XTtD6kd$Q%m1^p|B
zvVD0iKi^;4v5zqT7|dJ@AmHe0X2XC4*nq*Dl$n=UR0$5@%*T=5AdD8m0p5&Ea?H3Q
zN&;*Wkjt>75yV1?HdaWqVKoq!lO*8mw~gsQEiebNLL7);7AqS_EfWyV1=7nwE@1!w
D_6Ewk
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/unit/test_bug541420.js
@@ -0,0 +1,68 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation.
+ *
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Dave Townsend <dtownsend@oxymoronical.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+function run_test() {
+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+
+  startupEM();
+
+  gEM.installItemFromFile(do_get_file("data/test_bug541420.xpi"),
+                          NS_INSTALL_LOCATION_APPPROFILE);
+
+  restartEM();
+  do_check_neq(gEM.getItemForID("bug541420@tests.mozilla.org"), null);
+
+  var il = gEM.getInstallLocation("bug541420@tests.mozilla.org");
+  var file = il.getItemFile("bug541420@tests.mozilla.org", "binary");
+  do_check_true(file.exists());
+  do_check_true(file.isReadable());
+  do_check_true(file.isWritable());
+
+  // We don't understand executable permissions on Windows since we don't
+  // support NTFS permissions so we don't need to test there. OSX's isExecutable
+  // only tests if the file is an application so it is better to just check the
+  // raw permission bits
+  if (!("nsIWindowsRegKey" in Components.interfaces))
+    do_check_true((file.permissions & 0111) != 0);
+
+  gEM.uninstallItem("bug541420@tests.mozilla.org");
+
+  restartEM();
+  do_check_eq(gEM.getItemForID("bug541420@tests.mozilla.org"), null);
+}