Coder Social home page Coder Social logo

Comments (17)

jorangreef avatar jorangreef commented on August 24, 2024

Thanks, I think this is a duplicate of #39

Please see the suggestion there.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef Thanks for fast reply, I have seen that issue, but in my case, I have to run the commands in different stages of the application execution, I mean that they are not in a row.

from sudo-prompt.

jorangreef avatar jorangreef commented on August 24, 2024

Thanks @mahdifani14, it's not possible. Not because of sudo-prompt, but because sudo itself on Linux and Mac uses TTY tickets. Each time sudo-prompt runs it's essentially running in a new TTY (a new child process), so sudo itself thinks it needs to prompt for a password again. If the user does not have TTY tickets enabled for sudo, then sudo-prompt will only prompt the first time.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef
I got it.
I'll check other possibilities to overcome this obstacle.
Anyway, thanks again for your support.

from sudo-prompt.

jorangreef avatar jorangreef commented on August 24, 2024

It's a pleasure, thanks for checking. You could try using sudo-prompt to launch a long-lived process with root privileges which you could then use to launch your commands as and when needed. If there is another way please let me know.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef Grateful for the hint, I'll try it and inform you about the result or any other solution if I found.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef Eventually after a long ride over this issue, I found a solution and decided to share it with you maybe would be useful. Actually, I tried the idea that you stated but, it didn't work due to the Electron and NodeJs limitations and it's not possible to run the whole app using sudo-prompt.
Therefore, after lots of researches, I divided the story into two scenarios w.r.t the platforms Windows and OSX/Linux.
For the first case, I'm using mt.exe as one of the Windows SDK through which I can force the user to accept the application run as Administrator; for more info, check this link: http://layer0.authentise.com/electron-and-uac-on-windows.html
For latter one, I'm using a mixture of the original sudo and sudo-prompt which is working fine through command line but, the graphical functionality is still under construction and whenever I finalized it, I'll let you know.

from sudo-prompt.

jorangreef avatar jorangreef commented on August 24, 2024

Thanks for the link @mahdifani14, that's really helpful.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef You're welcome.
Mac OSX has been tested by sudo-prompt and worked fine. After running the first command, it keeps the session and uses for the others so, the prompt just appears once.
However, for Linux case, I have to execute the application by using 'gksudo' in the terminal (Electron runs the application by executing a command in terminal "start": "gksudo node_modules/.bin/electron .") that's why I cannot use sudo-prompt for this matter.

from sudo-prompt.

jorangreef avatar jorangreef commented on August 24, 2024

Have you tested macOS Sierra? There was a change recently so that macOS Sierra has started using TTY tickets. macOS Sierra should require a password for each separate sudo-prompt call.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@jorangreef Good question, no I didn't. I'll check it and let you know because my application must be cross-platform.
Grateful for the point,

from sudo-prompt.

Muneefm avatar Muneefm commented on August 24, 2024

@mahdifani14 @jorangreef have you found any solution yet?
am new to this electron. I needed to open specific .app file from mac application. so i tried to run "open path/to/the/application.app" it was showing some error. so i used this library and run the same command now it's working. but the only problem is it's showing the password prompt for every exec. is there is any way to ask that only one time? Thank you.

from sudo-prompt.

mahdifani14 avatar mahdifani14 commented on August 24, 2024

@Muneefm I finally used Cocoasudo, it works fine for all OSX versions, check the link below:
http://www.performantdesign.com/2009/10/26/cocoasudo-a-graphical-cocoa-based-alternative-to-sudo/

from sudo-prompt.

jorangreef avatar jorangreef commented on August 24, 2024

@Muneefm TTY tickets are now the default on macOS Sierra onwards.

Each shell session must authenticate as sudo, independently of existing sudo sessions.

You can think of sudo-prompt as launching the equivalent of an authenticated shell session, which is why each session requires a password.

You can either batch up your commands, or disable TTY tickets.

from sudo-prompt.

NargisTahara avatar NargisTahara commented on August 24, 2024

@mahdifani14 How did you use cocoasudo with Electron?

from sudo-prompt.

hb1998 avatar hb1998 commented on August 24, 2024

@jorangreef You're welcome.
Mac OSX has been tested by sudo-prompt and worked fine. After running the first command, it keeps the session and uses for the others so, the prompt just appears once.
However, for Linux case, I have to execute the application by using 'gksudo' in the terminal (Electron runs the application by executing a command in terminal "start": "gksudo node_modules/.bin/electron .") that's why I cannot use sudo-prompt for this matter.

can u explain it in detail for Linux. Thank you.

from sudo-prompt.

toioski avatar toioski commented on August 24, 2024

Did anyone find a solution to this? It would be really helpful. Personally I am interested on a solution for macOS.

from sudo-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.