Return stdout and stderr whenever these are available to assist with
debugging.
Specify 'utf-8' encoding to child_process.exec() as an explicit option
in case Node changes the default in future, and because we sometimes
return stdout and stderr via readFile(), which has a different default.
Fixes: #89
Preserve current working directory.
Support explicit options.env environment variables.
Support multiple commands separated by semicolons.
Distinguish between elevation errors and command errors.
Fixes: #39Fixes: #88Fixes: #91
`pkexec` prints an error to `stderr` if no authentication agent was
found, and if we pass the `--disable-internal-agent` option.
Currently, this module doesn't handle this edge case by yielding a
meaningful error, and therefore causes client applications to usually
miss it.
Fixes: https://github.com/jorangreef/sudo-prompt/issues/28
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
Otherwise, `kdesudo` also displays the command as the dialog title,
making it very ugly and unfriendly.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is very similar to 3f6c485. It implements the fix to the
same problem for `sudo` when the module makes an attempt to determine if
the dialog needs to be shown or not.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
When `gksudo` is detected, this module executes the following command:
```
"/usr/bin/gksudo" --preserve-env --sudo-mode --description="MyApp" <COMMAND>
```
Consider the following command:
```
/home/jviotti/Projects/etcher/node_modules/electron-prebuilt/dist/electron /home/jviotti/Projects/etcher/lib/src/run-child-writer.js lib/start.js /home/jviotti/Downloads/CorePlus-current.iso --robot --drive /dev/sdb --unmount --check
```
Given that the command I'm running contains option arguments, it seems
like `gksudo` tries to interpret the options to my command as `gksudo`
options, failing with errors like this one:
```
/usr/bin/gksudo: unrecognized option '--robot'
```
To prevent this from happening, we can tell `gksudo` to stop parsing
options with the `--` identifier.
The same error happens with `kdesudo`.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
Some child processes executed with this module might benefit from being
able to read their parent process environment variables.
Fixes: https://github.com/jorangreef/sudo-prompt/issues/20
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
Add support for `tty_tickets` on OS X.
Ensure all line lengths are less than 80 characters.
Fix shell commands to use absolute path (e.g. `/bin/rm`, `/usr/bin/defaults`).
Fix `options.icns` to work with asar packages.
Fix internal method names to reduce chance of a clash with local variables.
Remove `options.onChildProcess()` (no longer possible to support).
Remove batching of password prompts on OS X.
Remove deprecated `setName()`.
Remove deprecated `touch()`.
Fixes: https://github.com/jorangreef/sudo-prompt/issues/13
Some modules, like `windosu` expose a binary called `sudo`. By just
calling `sudo`, `sudo-prompt` might accidentally call a `sudo` command
which is not the system one, causing tons of confusions.
Fixes: https://github.com/jorangreef/sudo-prompt/issues/6