Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to setup sandbox on Windows when game has multiple launch actions #826

Closed
quyse opened this issue Jul 25, 2016 · 17 comments
Closed

Comments

@quyse
Copy link
Contributor

quyse commented Jul 25, 2016

Looks like if a game has multiple launch actions specified in itch manifest, some mistake in itch's logic prevents performing first-time sandbox setup during game launch. Repro:

  1. enable sandbox in settings
  2. install a game with multiple actions, e.g. Sample Evil App
  3. click Launch
  4. choose any action in the action chooser popup
  5. itch says it wants to install sandbox and needs administrator rights, agree
  6. action chooser pops up again (instead of UAC prompt) - WTF
  7. go to 4

Tried only on Windows yet.

@fasterthanlime
Copy link
Collaborator

Ooh, good catch! Experienced it a while ago but forgot to file an issue.

There's a bad fix and good fix and I'd rather do the good fix now.

Currently there's no way to block on a modal's response, so the modal's action (for the action picker) is just queueCave with a few options added. The trick is also used to ask you if you agree to see an UAC prompt for sandbox setup, and apparently those don't combine well.

So the bad fix is making sure they combine (but it'll still be a "workaround"), and the good fix is making it posisble to await the outcome of a modal, just like the Electron API allows (which we used to use, but doesn't offer as much flexibility).

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

Hmm, it doesn't appear to be fixed for me. Now after "Install sandbox" popup itch just does nothing silently. It's neither installing sandbox nor launching Sample Evil App. I'm not sure if it's still the same bug, because I also have some problems with itch I run from git working directory (rather than itch/kitch installed via installers from itch.io) - in particular, it refuses to install some of my apps in the same silent manner. I'll investigate a bit more and report back.

Here's the console output (looks like nothing interesting):

[2016-07-25 @ 23:25:03.495] [reactors/tasks] Have a cave for game 72778, launching
[2016-07-25 @ 23:25:03.496] [reactors/tasks] Starting cave 84fa07b4-f69f-4004-b983-c45415165bcc: stub
[2016-07-25 @ 23:25:03.499] [reactors/tasks] About to start launch (476981ec-e457-48f9-8729-7504eda28dee)
[2016-07-25 @ 23:25:03.500] [reactors/tasks] Starting launch (476981ec-e457-48f9-8729-7504eda28dee)...
[2016-07-25 @ 23:25:03.502] [tasks/launch] itch 18.3.6-canary launching game 72778: Sample Evil App
[2016-07-25 @ 23:25:03.503] [tasks/launch] looking for manifest @ "C:\Users\Quyse\AppData\Roaming\itch\apps\Sample Evil App\.itch.toml"
[2016-07-25 @ 23:25:03.506] [tasks/launch] found manifest, parsing
[2016-07-25 @ 23:25:03.520] [tasks/launch] manifest:
 {
  "actions": [
    {
      "name": "Default",
      "path": "Sample Evil App{{EXT}}",
      "scope": "profile:me"
    },
    {
      "name": "Sandbox opt-in",
      "path": "Sample Evil App{{EXT}}",
      "scope": "profile:me",
      "sandbox": true
    },
    {
      "name": "Args",
      "path": "Sample Evil App{{EXT}}",
      "args": [
        "being",
        "john",
        "malkovich"
      ]
    }
  ]
}
got response from promisedModal: {
  "type": "MODAL_RESPONSE",
  "payload": {
    "manifestActionName": "Default"
  },
  "source": "main_process"
}
[2016-07-25 @ 23:25:06.063] [tasks/launch] Requesting subkey with scope: profile:me
[2016-07-25 @ 23:25:06.264] [api] 0ms wait, 186ms http, post credentials/subkey with {"game_id":72778,"scope":"profile:me"}
[2016-07-25 @ 23:25:06.269] [tasks/launch] Got subkey (169 chars, expires undefined)
[2016-07-25 @ 23:25:06.287] [tasks/launch/native] cave location: "appdata/Sample Evil App"
[2016-07-25 @ 23:25:06.293] [tasks/launch/native] manifest action picked: {
  "name": "Default",
  "path": "Sample Evil App.exe",
  "scope": "profile:me"
}
[2016-07-25 @ 23:25:06.300] [tasks/launch/native] executing 'C:\Users\Quyse\AppData\Roaming\itch\apps\Sample Evil App\Sample Evil App.exe' on 'win32' with args ''
[2016-07-25 @ 23:25:07.807] [reactors/tasks] Checking results for launch (476981ec-e457-48f9-8729-7504eda28dee)...
[2016-07-25 @ 23:25:07.808] [reactors/tasks] Task ended, err: <none>
[2016-07-25 @ 23:25:07.810] [reactors/tasks] game 72778 just exited!
[2016-07-25 @ 23:25:07.818] [reactors/tasks] encouraging generosity!

@fasterthanlime
Copy link
Collaborator

Interesting, I haven't had time to test properly myself yet

@fasterthanlime
Copy link
Collaborator

it refuses to install some of my apps

@quyse can you link me to which apps in particular?

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

@fasterthanlime
Copy link
Collaborator

@quyse I'm able to install&run FLAW flawlessly, will try again with sandbox setup from scratch!

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

@fasterthanlime Yeah, I'm not sure if it's an itch bug at all. I uninstalled release itch (installed via official installer) and deleted AppData...\itch folder completely, because before that I was unable to install any app at all using "git" itch. I thought maybe it's some difference in persistent data format between released and unreleased versions of itch. Now when there's only "git" itch, it seems itch doesn't want to install only FLAW, other apps get installed.

I was hoping you can repro that, but if not here is the full log: https://gist.github.com/quyse/3390495979c2b1872037ca2b57e4344e I'm simply launching itch and immediately clicking Install for FLAW. The only thing I can see is something about undefined installer type and Error: file(1) failed with exit code 1.

Reiterating to be clear, now I have two separate problems. First is that I cannot run Sample Evil App with sandbox (but can install), and second that I cannot install FLAW with "git" itch. The latter doesn't depend on "enable sandbox" setting, and just happened to be mentioned by me here, probably must be separate bug :)

@fasterthanlime
Copy link
Collaborator

First is that I cannot run Sample Evil App with sandbox (but can install),

That was just fixed in 0f47ba0, thanks a lot for catching that.

I cannot install FLAW with "git" itch.

I think the install of file(1) that itch does might be messed up on your system. I don't think the ibrew repo for it ships with SHA1SUMS, which might explain why it could've downloaded an incomplete copy of it?

@fasterthanlime
Copy link
Collaborator

@quyse does removing all file* files from %APPDATA%/itch/bin fix it?

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

That was just fixed in 0f47ba0, thanks a lot for catching that.

Works for me finally, thanks!

does removing all file* files from %APPDATA%/itch/bin fix it?

No, just tried it. itch redownloads file.exe and then fails again with the same error.

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

@fasterthanlime Ok, looks like I found a problem. My git working directory where I type "npm start" is on disk D:, but my Users/AppData folders are on disk C:. It seems that file uses colon as a separator for multiple magic files. From man:

-m, --magic-file magicfiles
Specify an alternate list of files and directories containing magic. This can be a single item, or a colon-separated list.

So that's what I see trying to run file manually:

>"C:\Users\Quyse Lert\AppData\Roaming\itch\bin\file.exe" -m "C:\Users\Quyse Lert\AppData\Roaming\itch\bin\magic.mgc" "C:\Users\Quyse Lert\AppData\Roaming\itch\bin\msys-2.0.dll"
C, 0: Warning: using regular magic file `\Users\Quyse Lert\AppData\Roaming\itch\bin\magic.mgc'
file: could not find any valid magic files!

itch probably uses relative path to bin directory when it specifies magicfile in appsrc/util/file.js, doesn't it? So when current directory (i.e. git working directory) is on disk D:, but bin directory is on disk C:, there's no way to specify relative path!

Well, not sure what's exactly happening yet, but I just tried to make another git clone for itch on disk C:, and it works from there.

@fasterthanlime
Copy link
Collaborator

That's good research! The sad thing about all this is: file doesn't actually return anything useful and then it falls back to naked .exe...

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

Hmm, it seems itch uses the same full path to magic file in both cases. No idea then why it works from disk C:. Both cloned directories are the same except for disk drive they reside at (just did clean git clones and installed npm stuff from scratch).

@fasterthanlime
Copy link
Collaborator

@quyse that's crazy, I was able to reproduce by cloning itch on my own D: disk and trying to uninstall FLAW. 🐙

@quyse
Copy link
Contributor Author

quyse commented Jul 25, 2016

@fasterthanlime Great, at least we know that's not my imaginary problem :)

@fasterthanlime
Copy link
Collaborator

@quyse setting the working directory when launching file fixed it!

@quyse
Copy link
Contributor Author

quyse commented Jul 26, 2016

Ok, full disclosure for the sake of completeness :) Apparently Windows treats paths starting with a backslash, i.e. \a\b\c, as X:\a\b\c where X: is a disk of current directory. So when current directory path starts with D:, path \Users\... from my example above actually means D:\Users\... which obviously points to non-existent file.

It's not properly documented (the only mention of this I've found is here https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247#fully_qualified_vs._relative_paths), but apparently works everywhere in Windows, and not specific to file utility.

Still, since file treats colons as delimiters between multiple magic files, passing full path for -m arg is not correct. It does work now after your fix, but it's better to just use magic file name, as you set current directory anyway - I PR'ed this very simple change in #828.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants