Bug 901757 - Fix mac permissions. r=felipc
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Thu, 08 Aug 2013 13:31:58 -0400
changeset 154803 e50cae680d8c5cd619b6977f547acbb8ffafcff7
parent 154802 e40f8b1eb392ccbcfa264f89e18a4499603e6ff6
child 154804 a51eaf2711ff6350ce16829f9bcc58e2ad8bb76c
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc
bugs901757
milestone26.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
Bug 901757 - Fix mac permissions. r=felipc
toolkit/webapps/WebappsInstaller.jsm
--- a/toolkit/webapps/WebappsInstaller.jsm
+++ b/toolkit/webapps/WebappsInstaller.jsm
@@ -10,16 +10,17 @@ const Cu = Components.utils;
 const Cr = Components.results;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
 Cu.import("resource://gre/modules/WebappOSUtils.jsm");
 Cu.import("resource://gre/modules/AppsUtils.jsm");
+Cu.import("resource://gre/modules/Task.jsm");
 
 this.WebappsInstaller = {
   shell: null,
 
   /**
    * Initializes the app object that takes care of the installation
    * and creates the profile directory for an application
    *
@@ -634,16 +635,17 @@ MacNativeApp.prototype = {
 
     let factory = Cc["@mozilla.org/xpcom/ini-processor-factory;1"]
                     .getService(Ci.nsIINIParserFactory);
 
     let writer = factory.createINIParser(applicationINI).QueryInterface(Ci.nsIINIParserWriter);
     writer.setString("Webapp", "Name", this.appName);
     writer.setString("Webapp", "Profile", this.appProfileDir.leafName);
     writer.writeFile();
+    applicationINI.permissions = FileUtils.PERMS_FILE;
 
     // ${InstallDir}/Contents/Info.plist
     let infoPListContent = '<?xml version="1.0" encoding="UTF-8"?>\n\
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n\
 <plist version="1.0">\n\
   <dict>\n\
     <key>CFBundleDevelopmentRegion</key>\n\
     <string>English</string>\n\
@@ -951,19 +953,22 @@ LinuxNativeApp.prototype = {
 
 /**
  * Async write a data string into a file
  *
  * @param aFile     the nsIFile to write to
  * @param aData     a string with the data to be written
  */
 function writeToFile(aFile, aData) {
-  let path = aFile.path;
-  let data = new TextEncoder().encode(aData);
-  return OS.File.writeAtomic(path, data, { tmpPath: path + ".tmp" });
+  return Task.spawn(function() {
+    let data = new TextEncoder().encode(aData);
+    let file = yield OS.File.open(aFile.path, { truncate: true }, { unixMode: FileUtils.PERMS_FILE });
+    yield file.write(data);
+    yield file.close();
+  });
 }
 
 /**
  * Removes unprintable characters from a string.
  */
 function sanitize(aStr) {
   let unprintableRE = new RegExp("[\\x00-\\x1F\\x7F]" ,"gi");
   return aStr.replace(unprintableRE, "");