Comments (5)
Thanks, I tried your example on OS X 10.10.4 and it worked fine.
Could the password prompt possibly be hidden by other windows?
Once you enter your password the first time using the prompt, or via a sudo command in the console, your user will have sudo privileges for a few minutes, which is why the programmatic version would not require a password prompt the second time.
It is designed to only prompt if sudo privileges are necessary, so it may look like it is silently failing by not showing a prompt each time, but it might actually be working fine.
Are you removing the /etc/test.txt
file each time before you test, and what is the title of your process?
from sudo-prompt.
Thanks Joran for your response it is much appreciated. I checked and didn't locate the password prompt behind any other windows. My process.title is "/Users/guest/Desktop/yeti-launch/node_modules/electron-prebuilt/dist/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper"
My process was to launch the application (with no sudo timestamp). Before I attempted the sudo command, I checked in an external terminal that /etc/test.txt did not exist using stat '/etc/test.txt'
. After executing the sudo code, the prompt for sudo did not pop up, and the file did not exist using the same check in the external terminal stat '/etc/test.txt'
. However, when I have a sudo timestamp available (by running anything that requires sudo in the external terminal, and entering the password), sudo execute will be able to create the /etc/test.txt
file (albeit with no dialog prompt). I have been careful to ensure that the file does not already exist in doing these tests. It appears to be having some sort of issue pulling up the dialog box.
Hope that helps, I will continue testing for now!
from sudo-prompt.
Could you try and run sudo.setName('test')
before you call sudo.exec
?
If you could also please let me know the following:
- What does
os.tmpdir()
return when called from your Electron app and is that path writable by your user? - What does
process.env['USER']
contain when checked from your Electron app? - What do you get when running
which osascript
in the terminal? - What version of OS X are you running?
- Are you sure that you are checking for errors when calling sudo.exec?
from sudo-prompt.
Running sudo.setName('test')
fixed the issue. I told myself that the title couldn't possibly be the problem in my debugging, which was quite shortsighted. I should have tested that myself. I will be testing it on another computer tomorrow to verify that it is completely solved. I suspect that it is, and I will close the issue for now. Thanks for your assistance. The package is quite useful in my electron application.
from sudo-prompt.
That's great to hear.
sudo-prompt works without native dependencies by creating a copy of the osascript binary using the title of your process as the binary name. It does this so that the password prompt shows as being from your application.
I think the reason your process.title didn't work is because it contained slashes which are not valid in a pathname. sudo-prompt should definitely have given you an error in the callback if your process title was invalid:
[Error: Please use sudo.setName(string) to set your app name (process.title contains invalid characters).]
from sudo-prompt.
Related Issues (20)
- 'Command failed' in Electron app HOT 1
- Not possible in Mac App Store, aka app-sandbox HOT 5
- macOS Catalina Operation not permitted HOT 1
- OS dialog prompt is not being prompted in Windows 10 HOT 1
- Operation not permitted in macOS with sudo-prompt
- Prompt shows but name and icon are not visible on macOS HOT 8
- "User did not grant permissions" if I click "Yes" too quickly on Windows? HOT 1
- `sudo-prompt` fails to detect `pkexec` or `kdesudo` in "strictly" confined snap
- Special characters handling on Linux
- Strange behaviour with Electron 9 on Win10 HOT 1
- in Eelectron app Rendering process, sudo run cp not work
- Hello, why option.name just support [a-z0-9 ] ?
- How to get elevated shell and run a command without sudo prefix HOT 1
- macOS: Application cannot be opened because the developer cannot be verified
- BigSur 11.1 issue: The authorization was denied since no user interaction was possible HOT 1
- Linux: option.env not used
- Unexpected behaviour with linux - electron.js HOT 1
- electron exe with root system privileges in linux, It's possible to do ?
- How to run multiple commands without requiring password every time HOT 6
- Any pkg similar to this, but without root/admin?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sudo-prompt.