Commit a1814068 authored by Pascal Chevrel's avatar Pascal Chevrel
Browse files

Backed out 1 changesets (bug 1830071) for causing build bustage on esr115 a=backout

Backed out changeset eb8c2d5bd1aa (bug 1830071)
parent ff19f0d4
Loading
Loading
Loading
Loading
+10 −53
Original line number Diff line number Diff line
@@ -77,40 +77,32 @@ export var TaskScheduler = {
   * @param intervalSeconds
   *        Interval at which to run the command, in seconds. Minimum 1800 (30 minutes).
   *
   * @param {Object} options
   * @param options
   *        Optional, as are all of its properties:
   *        {
   *          options.args
   *          args
   *            Array of arguments to pass on the command line. Does not include the command
   *            itself even if that is considered part of the command line. If missing, no
   *            argument list is generated.
   *
   *          options.workingDirectory
   *          workingDirectory
   *            Working directory for the command. If missing, no working directory is set.
   *
   *          options.description
   *          description
   *            A description string that will be visible to system administrators. This should
   *            be localized. If missing, no description is set.
   *
   *          options.disabled
   *          disabled
   *            If true the task will be created disabled, so that it will not be run.
   *            Ignored on macOS: see comments in TaskSchedulerMacOSImpl.jsm.
   *            Default false, intended for tests.
   *
   *          options.executionTimeoutSec
   *          executionTimeoutSec
   *            Specifies how long (in seconds) the scheduled task can execute for before it is
   *            automatically stopped by the task scheduler. If a value <= 0 is given, it will be
   *            ignored.
   *            This is not currently implemented on macOS.
   *            On Windows, the default timeout is 72 hours.
   *
   *          options.nameVersion
   *            Over time, we have needed to change the name format that tasks are registered with.
   *            When interacting with an up-to-date task, this value can be unspecified and the
   *            current version of the name format will be used by default. When interacting with
   *            an out-of-date task using an old naming format, this can be used to specify what
   *            version of the name should be used. Since the precise naming format is platform
   *            specific, these version numbers are also platform-specific.
   *        }
   * }
   */
@@ -131,37 +123,14 @@ export var TaskScheduler = {
  /**
   * Delete a scheduled task previously created with registerTask.
   *
   * @param {Object} options
   *        Optional, as are all of its properties:
   *        {
   *            options.nameVersion
   *              Over time, we have needed to change the name format that tasks are registered with.
   *              When interacting with an up-to-date task, this value can be unspecified and the
   *              current version of the name format will be used by default. When interacting with
   *              an out-of-date task using an old naming format, this can be used to specify what
   *              version of the name should be used. Since the precise naming format is platform
   *              specific, these version numbers are also platform-specific.
   *        }
   * @throws NS_ERROR_FILE_NOT_FOUND if the task does not exist.
   */
  async deleteTask(id, options) {
    return lazy.gImpl.deleteTask(id, options);
  async deleteTask(id) {
    return lazy.gImpl.deleteTask(id);
  },

  /**
   * Delete all tasks registered by this application.
   *
   * @param {Object} options
   *        Optional, as are all of its properties:
   *        {
   *            options.nameVersion
   *              Over time, we have needed to change the name format that tasks are registered with.
   *              When interacting with an up-to-date task, this value can be unspecified and the
   *              current version of the name format will be used by default. When interacting with
   *              an out-of-date task using an old naming format, this can be used to specify what
   *              version of the name should be used. Since the precise naming format is platform
   *              specific, these version numbers are also platform-specific.
   *        }
   */
  async deleteAllTasks() {
    return lazy.gImpl.deleteAllTasks();
@@ -173,22 +142,10 @@ export var TaskScheduler = {
   * @param id
   *        A string representing the identifier of the task to look for.
   *
   * @param {Object} options
   *        Optional, as are all of its properties:
   *        {
   *            options.nameVersion
   *              Over time, we have needed to change the name format that tasks are registered with.
   *              When interacting with an up-to-date task, this value can be unspecified and the
   *              current version of the name format will be used by default. When interacting with
   *              an out-of-date task using an old naming format, this can be used to specify what
   *              version of the name should be used. Since the precise naming format is platform
   *              specific, these version numbers are also platform-specific.
   *        }
   *
   * @return
   *        true if the task exists, otherwise false.
   */
  async taskExists(id, options) {
    return lazy.gImpl.taskExists(id, options);
  async taskExists(id) {
    return lazy.gImpl.taskExists(id);
  },
};
+7 −7
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ export var MacOSImpl = {
    let uid = await this._uid();
    lazy.log.debug(`registerTask: uid=${uid}`);

    let label = this._formatLabelForThisApp(id, options);
    let label = this._formatLabelForThisApp(id);

    // We ignore `options.disabled`, which is test only.
    //
@@ -126,10 +126,10 @@ export var MacOSImpl = {
    return true;
  },

  async deleteTask(id, options) {
  async deleteTask(id) {
    lazy.log.info(`deleteTask(${id})`);

    let label = this._formatLabelForThisApp(id, options);
    let label = this._formatLabelForThisApp(id);
    return this._deleteTaskByLabel(label);
  },

@@ -207,8 +207,8 @@ export var MacOSImpl = {
    lazy.log.debug(`deleteAllTasks: returning ${JSON.stringify(result)}`);
  },

  async taskExists(id, options) {
    const label = this._formatLabelForThisApp(id, options);
  async taskExists(id) {
    const label = this._formatLabelForThisApp(id);
    const path = this._formatPlistPath(label);
    return IOUtils.exists(path);
  },
@@ -292,12 +292,12 @@ export var MacOSImpl = {
    return serializer.serializeToString(doc);
  },

  _formatLabelForThisApp(id, options) {
  _formatLabelForThisApp(id) {
    let installHash = lazy.XreDirProvider.getInstallHash();
    return `${AppConstants.MOZ_MACBUNDLE_ID}.${installHash}.${id}`;
  },

  _labelMatchesThisApp(label, options) {
  _labelMatchesThisApp(label) {
    let installHash = lazy.XreDirProvider.getInstallHash();
    return (
      label &&
+7 −41
Original line number Diff line number Diff line
@@ -40,16 +40,16 @@ export var WinImpl = {

    lazy.WinTaskSvc.registerTask(
      this._taskFolderName(),
      this._formatTaskName(id, options),
      this._formatTaskName(id),
      xml,
      updateExisting
    );
  },

  deleteTask(id, options) {
  deleteTask(id) {
    lazy.WinTaskSvc.deleteTask(
      this._taskFolderName(),
      this._formatTaskName(id, options)
      this._formatTaskName(id)
    );
  },

@@ -112,7 +112,7 @@ export var WinImpl = {
    }
  },

  taskExists(id, options) {
  taskExists(id) {
    const taskFolderName = this._taskFolderName();

    let allTasks;
@@ -126,7 +126,7 @@ export var WinImpl = {
      throw ex;
    }

    return allTasks.includes(this._formatTaskName(id, options));
    return allTasks.includes(this._formatTaskName(id));
  },

  _formatTaskDefinitionXML(command, intervalSeconds, options) {
@@ -270,47 +270,13 @@ export var WinImpl = {
    };
  },

  /**
   * Formats a given task id according to one of two formats.
   *
   * @param id
   *        A string representing the identifier of the task to format
   *
   * @param {Object} options
   *        Optional, as are all of its properties:
   *        {
   *            options.nameVersion
   *              Specifies whether to search for tasks using nameVersion 1
   *              which is `${taskID} ${installHash}` or nameVersion 2 which is
   *              `${taskID} ${currentUserSid} ${installHash}`. Defaults to nameVersion 2.
   *        }
   *
   * @return
   *        Formatted task name.
   */
  _formatTaskName(id, options) {
  _formatTaskName(id) {
    const installHash = lazy.XreDirProvider.getInstallHash();
    if (options?.nameVersion == 1) {
    return `${id} ${installHash}`;
    }
    const currentUserSid = lazy.WinTaskSvc.getCurrentUserSid();
    return `${id} ${currentUserSid} ${installHash}`;
  },

  _matchAppTaskName(name) {
    const installHash = lazy.XreDirProvider.getInstallHash();
    return name.endsWith(` ${installHash}`);
  },

  _updateTaskNameFormat(id) {
    const taskFolderName = this._taskFolderName();
    const allTasks = lazy.WinTaskSvc.getFolderTasks(taskFolderName);
    const taskNameV1 = this._formatTaskName(id, { nameVersion: 1 });
    const taskNameV2 = this._formatTaskName(id, { nameVersion: 2 });
    if (allTasks.includes(taskNameV1)) {
      const taskXML = lazy.WinTaskSvc.getTaskXML(taskFolderName, taskNameV1);
      lazy.WinTaskSvc.registerTask(taskFolderName, taskNameV2, taskXML, true);
      lazy.WinTaskSvc.deleteTask(taskFolderName, taskNameV1);
    }
  },
};
+0 −11
Original line number Diff line number Diff line
@@ -59,17 +59,6 @@ interface nsIWinTaskSchedulerService : nsISupports
   */
  AString getTaskXML(in wstring aFolderName, in wstring aTaskName);

  /**
   * Gets the sid of the current user.
   *
   * @throws NS_ERROR_NOT_IMPLEMENTED If called on a non-Windows OS.
   * @throws NS_ERROR_FAILURE         If the user token cannot be found.
   * @throws NS_ERROR_ABORT           If converting the sid to a string fails.
   *
   * @returns                         The sid of the current user.
   */
  AString getCurrentUserSid();

  /**
   * Delete a task.
   *
+0 −26
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@

#include <windows.h>
#include <comdef.h>
#include <sddl.h>
#include <securitybaseapi.h>
#include <taskschd.h>

#include "nsString.h"
@@ -116,30 +114,6 @@ nsWinTaskSchedulerService::GetTaskXML(const char16_t* aFolderName,
  return NS_OK;
}

NS_IMETHODIMP
nsWinTaskSchedulerService::GetCurrentUserSid(nsAString& aUserSid) {
#ifndef XP_WIN
  return NS_ERROR_NOT_IMPLEMENTED;
#else  // !XP_WIN
  DWORD tokenLen;
  LPWSTR stringSid;
  BYTE tokenBuf[TOKEN_USER_MAX_SIZE];
  PTOKEN_USER tokenInfo = reinterpret_cast<PTOKEN_USER>(tokenBuf);
  BOOL success = GetTokenInformation(GetCurrentProcessToken(), TokenUser,
                                     tokenInfo, sizeof(tokenBuf), &tokenLen);
  if (!success) {
    return NS_ERROR_FAILURE;
  }
  success = ConvertSidToStringSidW(tokenInfo->User.Sid, &stringSid);
  if (!success) {
    return NS_ERROR_ABORT;
  }
  aUserSid.Assign(stringSid);
  LocalFree(stringSid);
  return NS_OK;
#endif
}

NS_IMETHODIMP
nsWinTaskSchedulerService::RegisterTask(const char16_t* aFolderName,
                                        const char16_t* aTaskName,
Loading