Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

User did not grant permission. error even after permission has been granted #88

Closed
samuela opened this issue Feb 25, 2019 · 2 comments
Closed

Comments

@samuela
Copy link

samuela commented Feb 25, 2019

I have a bit of code:

  sudo.exec(
    `umount ${mountPath}`,
    { name: "nuvemfs" },
    (err: any, stdout: any, stderr: any) => {
      console.log("sudo complete");
      console.log("err");
      console.log(err);
      console.log("stdout");
      console.log(stdout);
      console.log("stderr");
      console.log(stderr);
    },
  );

that tries to unmount a drive. It throws up the prompt as expected and then prints the following:

sudo complete
err
Error: User did not grant permission.
    at /opt/nu-links/cli-node_modules/node_modules/sudo-prompt/index.js:111:23
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
stdout

stderr
umount: /home/darthvader/nu/skainswo: target is busy.

which doesn't make any sense since permission was in fact granted. It's just that the command returned a non-zero exit code.

@jorangreef
Copy link
Owner

jorangreef commented Feb 25, 2019

Thanks @samuela , this is only on Linux and should be fixed.

It's tricky to distinguish between sudo's exit code and that of the command. sudo also translates its error messages depending on the locale (we used to inspect stderr for sudo errors until we found they can be translated).

@samuela
Copy link
Author

samuela commented Feb 25, 2019

@jorangreef Ah gotcha, I see how that could get messy.

FWIW my hack is to execute ./my-actual-command.sh && echo "__UNIQUE_SUCCESS_MARKER__" and check that __UNIQUE_SUCCESS_MARKER__ shows up in stdout.

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

No branches or pull requests

2 participants