bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

Install a packaged app that requests permissions that are not available to this app type results in NS_ERROR_FAILURE - Denied

RESOLVED INVALID

Status

Core Graveyard
DOM: Apps
RESOLVED INVALID
6 years ago
9 months ago

People

(Reporter: jsmith, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
Steps:

1. Go to http://people.mozilla.com/~fdesre/openwebapps/test.html
2. Select install package

Expected:

The packaged app specified in the package.manifest should be installed.

Actual:

The packaged app fails to install without any notification at all. Checking the logcat, I see the following:

10-15 20:03:59.448: E/GeckoConsole(411): [JavaScript Error: "NS_ERROR_FAILURE: Denied" {file: "jar:file:///system/b2g/omni.ja!/components/Webapps.js" line: 667}]
(Reporter)

Comment 1

6 years ago
The error indicated here appears to be thrown if the app does not have sufficient privileges:

  set oninstall(aCallback) {
    if (this.hasPrivileges)
      this._oninstall = aCallback;
    else
      throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
  },

Why is that the case?
(Reporter)

Comment 2

6 years ago
(In reply to Jason Smith [:jsmith] from comment #1)
> The error indicated here appears to be thrown if the app does not have
> sufficient privileges:
> 
>   set oninstall(aCallback) {
>     if (this.hasPrivileges)
>       this._oninstall = aCallback;
>     else
>       throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
>   },
> 
> Why is that the case?

Wait. I know what happened here after looking at the zip file:

  "permissions": [
    "contacts",
    "systemXHR"
  ],

A non-privileged app I don't believe has access to contacts, so this definitely shouldn't be installable. 

The error fired is right, although we could improve on this by throwing an error callback with PERMISSION_DENIED.
Summary: Cannot install a packaged app with a package.manifest - NS_ERROR_FAILURE Denied on line 667 → If I install a packaged app that requests permissions that are not available to this app type, supply a valid error callback with PERMISSION_DENIED
(Reporter)

Comment 3

6 years ago
We really should not be dumping a NS_ERROR_FAILURE and should instead be failing safely with an error callback indicating permission denied.
blocking-basecamp: --- → ?
Not blocking on this specifically. If we don't have error handling that sounds like a separate bug that might be a blocker
blocking-basecamp: ? → -
(Reporter)

Comment 5

6 years ago
(In reply to Jonas Sicking (:sicking) from comment #4)
> Not blocking on this specifically. If we don't have error handling that
> sounds like a separate bug that might be a blocker

I don't follow. Right now, a NS_ERROR_FAILURE is fired if the app does not have permissions as an exception, which is messy from being interpreted from a JS caller's perspective (example: installing web apps from . If the implementation suggestion isn't the way to go, then I'll genericize the bug and mark it for re-triage. But right now, this isn't acceptable if the marketplace guys run into this (specifically in the review process), which is definitely possible.
blocking-basecamp: - → ?
Summary: If I install a packaged app that requests permissions that are not available to this app type, supply a valid error callback with PERMISSION_DENIED → Install a packaged app that requests permissions that are not available to this app type results in NS_ERROR_FAILURE - Denied
(Reporter)

Comment 6

6 years ago
Feel free to morph the bug to whatever is the right acceptable approach for v1. Geo pointed out it was a minus based on the idea I came up with, but feel free to morph to whatever is acceptable for v1.
(In reply to Jason Smith [:jsmith] from comment #1)
> The error indicated here appears to be thrown if the app does not have
> sufficient privileges:
> 
>   set oninstall(aCallback) {
>     if (this.hasPrivileges)
>       this._oninstall = aCallback;
>     else
>       throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
>   },
> 
> Why is that the case?

This is unrelated to app install. The page is trying to use parts of the API that need the webapps-manage permission, and fail to do so. That's fine.
(In reply to Jason Smith [:jsmith] from comment #2)

> 
> Wait. I know what happened here after looking at the zip file:
> 
>   "permissions": [
>     "contacts",
>     "systemXHR"
>   ],
> 
> A non-privileged app I don't believe has access to contacts, so this
> definitely shouldn't be installable. 
> 
> The error fired is right, although we could improve on this by throwing an
> error callback with PERMISSION_DENIED.

This is very possible that we don't bubble an exception from PermissionInstaller.jsm - I'll take a look and update this bug accordingly.
(Reporter)

Updated

6 years ago
Status: NEW → RESOLVED
blocking-basecamp: ? → ---
Last Resolved: 6 years ago
Resolution: --- → INVALID

Updated

9 months ago
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.