Commit graph

41 commits

Author SHA1 Message Date
Joran Dirk Greef
691c1d7eae Further improve kdesudo message to match macOS 2019-06-01 11:40:35 +02:00
Joran Dirk Greef
8d02007e4b Fix Windows to return PERMISSION_DENIED Error even when Windows' error
messages are internationalized.

Fixes: #96
2019-06-01 10:36:22 +02:00
Joran Dirk Greef
dc0c5f5494 Always return PERMISSION_DENIED as an Error 2019-06-01 10:36:11 +02:00
Joran Dirk Greef
0012c3a905 Remove empty WindowsWriteElevateScript() from control flow 2019-06-01 10:24:49 +02:00
Joran Dirk Greef
da118e99c3 Fix line lengths 2019-06-01 10:22:57 +02:00
Joran Dirk Greef
4da9ecb572 Improve kdesudo arguments to match macOS 2019-06-01 10:19:04 +02:00
Joran Dirk Greef
2ece63fdc1 Improve kdesudo message to match macOS 2019-06-01 10:19:04 +02:00
Joran Dirk Greef
5c743a9658 Revert "Add a fallback to which pkexec on Linux"
This reverts commit 0e933b77c3.
2018-12-12 10:27:28 +02:00
Joran Dirk Greef
0e933b77c3 Add a fallback to which pkexec on Linux
Fixes: https://github.com/jorangreef/sudo-prompt/issues/77
2018-12-10 18:38:50 +02:00
Joran Dirk Greef
8c1a3022f3 Run command idempotently when hostname cannot be resolved 2018-09-11 15:20:05 +02:00
Joran Dirk Greef
f677081dba Windows: Fix cd when cwd is on another drive 2018-03-22 08:48:58 +02:00
Joran Dirk Greef
0ba8cf0b27 Linux: Increase maxBuffer limit to 128 MiB 2018-01-10 15:26:24 +02:00
Joran Dirk Greef
6a0577a387 Breaking: Windows: Set code page of command batch script to UTF-8 2017-11-02 12:43:00 +02:00
Joran Dirk Greef
297b0d17a1 Detect when PowerShell fails to launch command 2017-06-20 10:04:09 +02:00
Joran Dirk Greef
a7338f638c Escape ampersand and other characters special to PowerShell 2017-06-20 10:03:07 +02:00
Joran Dirk Greef
810e87f9ba Add status code to error on Windows and macOS 2017-03-15 16:50:30 +02:00
Juan Cruz Viotti
1acf3d4a70 Yield an error if no polkit authentication agent was found
`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>
2016-08-02 10:22:48 -04:00
Joran Dirk Greef
a57487d444 Add support for Windows 2016-07-15 17:13:03 +02:00
Joran Dirk Greef
3a0aef7b53 Prefer kdesudo to pkexec for a better prompt 2016-06-30 18:19:21 +02:00
Juan Cruz Viotti
17f45ebef3 Pass the --comment option to kdesudo to improve dialog
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>
2016-06-28 17:16:27 -04:00
Juan Cruz Viotti
37996169ed Don't keep parsing command options in sudo
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>
2016-06-07 12:37:43 -04:00
Joran Dirk Greef
1e11485bf4 Remove support for gksudo (gksudo breaks when used concurrently) 2016-06-04 13:17:14 +02:00
Juan Cruz Viotti
3f6c485c4d Don't keep parsing command options in gksudo/kdesudo
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>
2016-05-20 13:15:38 -04:00
Joran Dirk Greef
e428e0b50a Merge branch 'master' of https://github.com/jorangreef/sudo-prompt 2016-05-18 12:52:04 +02:00
Joran Dirk Greef
bd6c099453 Fix applet path to handle spaces 2016-05-18 12:51:54 +02:00
Juan Cruz Viotti
4a5baf5716 Preserve user environment
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>
2016-05-17 13:13:37 -04:00
Joran Dirk Greef
4a118a0c9c Preserve current working directory on OS X
This improves reliability for commands which expect the current working
directory to be preserved. This may not always be the case on Linux as yet.
2016-04-16 12:29:30 +02:00
Joran Dirk Greef
0b5c7d7361 Add support for tty_tickets on OS X (and major breaking changes).
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
2016-04-15 13:11:23 +02:00
Joran Dirk Greef
fe26a8a159 Package applet.app as a base64 zip file within index.js to fix issue with asar files 2016-02-09 09:30:04 +02:00
Joran Dirk Greef
d08ec680f3 Remove dependency on locale language when detecting sudo error 2016-01-01 15:51:58 +02:00
Joran Dirk Greef
f91a0a9b16 Add options.onChildProcess 2015-11-26 12:11:57 +02:00
Joran Dirk Greef
52f07e3526 Update README.md 2015-11-17 15:57:33 +02:00
Joran Dirk Greef
9bc245180a Fix macPrompt to remove hash directory in tmp 2015-11-17 15:54:56 +02:00
Joran Dirk Greef
57a83efd64 Add exec options (support options.icns on OS X), add beta Linux support, improve concurrency 2015-11-17 15:40:53 +02:00
Juan Cruz Viotti
344da8f7b2 Make sure to use the system sudo command
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
2015-10-29 14:56:09 -04:00
Joran Dirk Greef
f07b3679c2 Ensure all errors are an instance of Error to capture the stack 2015-09-07 09:10:39 +02:00
Joran Dirk Greef
2a6642b079 Comment sudo.touch implementation 2015-09-07 08:52:26 +02:00
Joran Dirk Greef
1698b73841 Fix early error check skipping password prompt 2015-09-07 08:51:03 +02:00
Joran Dirk Greef
b3027711ca Clarify implementation of sudo.touch 2015-08-05 09:18:34 +02:00
Joran Dirk Greef
36b303799e Fix setName 2015-06-08 16:29:05 +02:00
Joran Dirk Greef
dcb02caa3c Add code 2015-06-08 15:24:56 +02:00