Page 1 of 1

Elevated Privileges

Posted: Sat Dec 02, 2023 5:15 pm
by richmond62
Yeah, yeah, yeah: planning to plant viruses all over the place . . .

Nope: sorry to disappoint any would-be nasty pieces of work who might be lurking round these parts.

HOWVER, I would like to know whether it is possible to ask an end-user through a standalone for admin privileges to, say, store a preferences file somewhere a bit more discreet than in a file in the end-user's home folder . . .

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 5:18 pm
by stam
richmond62 wrote:
Sat Dec 02, 2023 5:15 pm
I would like to know whether it is possible to ask an end-user through a standalone for admin privileges to, say, store a preferences file somewhere a bit more discreet than in a file in the end-user's home folder . . .
Why not use specialFolderPath("support")?
On Windows this points to the current user's application-specific data ("AppData") folder and on MacOS the current user's application-specific data folder. Neither of these require escalated privileges or permission, while being more discreet because users tend not to look in these locations...

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 5:20 pm
by richmond62
Now, that is a thought: Thank you.

HOWEVER; let us just suppose that I wish to issue a terminal command from inwith a standalone.

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 5:37 pm
by SparkOut
I never tried it, because I have never made anything for other users that needed special permissions, but in the Standalone Builder settings for Windows there's a drop-down you can choose for the level of privilege the standalone should expect to require. If you set it to highest available then it might require elevated privileges to run, or once run and permission granted, it may stick and remember that it was installed with rights to do what you want. Of course there may be all sorts of different outcomes, especially on different OS and patching levels. I might get a chance to try it myself this weekend but I don't know.

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 5:51 pm
by richmond62
This is the sort of thing I had in mind (and for Linux, Windows, and Macintosh):
-
Screenshot 2023-12-02 at 18.49.43.png

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 6:20 pm
by Klaus
You could use a DOT as the first character of your prefs file, that will make the file invisible for users but not for LC!
-> .el_preffo

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 6:21 pm
by stam
Escalated privileges are required only if you're changing something in sensitive areas or something that may affect other users.
This is of course very different from your initial question of 'save a preference file discreetly'.
I'm also not sure what terminal command you have in mind that would be an issue?

For most common uses associated with user-level actions I found that setting the privilege set to that of the user (ie no escalation required) was more than enough for all my uses. On Windows you do this by setting the UAC execution level to 'same as invoker' in the standalone settings. You do have other options like 'highest available' or 'require administrator' which will bring up the UAC dialog you show above, if you definitely want to show this - again I'm not sure why you'd do this.

On MacOS the process is different if you want the user to grant access - and many have posted on the process in the forums.

Which then brings us to the age-old question: what is it you are actually trying to achieve?

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 6:23 pm
by richmond62
what is it you are actually trying to achieve?
I am asking a question for someone who is too 'shy' to ask it over here themselves. 8)

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 6:24 pm
by stam
richmond62 wrote:
Sat Dec 02, 2023 6:23 pm
what is it you are actually trying to achieve?
I am asking a question for someone who is too 'shy' to ask it over here themselves. 8)
OK - so what exactly is this 'shy' person trying to achieve?

Re: Elevated Privileges

Posted: Sat Dec 02, 2023 6:28 pm
by richmond62
Ha, ha, ha: well at the risk of offending that person:
Here's a strange question, but what's the best way for a standalone to attain administrator privileges on Windows / sudo privileges on MacOS and Linux? I ask, as I'd like to remove the terminal part of my updater, and having it apply the updates seamlessly without having the user jump through that terminal copy-and-paste malarkey

Re: Elevated Privileges

Posted: Sun Dec 03, 2023 4:08 am
by FourthWorld
Would "open elevated process" do what's needed?

https://livecode.com/resources/api-old/ ... en_process

Re: Elevated Privileges

Posted: Sun Dec 03, 2023 4:00 pm
by stam
richmond62 wrote:
Sat Dec 02, 2023 6:28 pm
Ha, ha, ha: well at the risk of offending that person:
Here's a strange question, but what's the best way for a standalone to attain administrator privileges on Windows / sudo privileges on MacOS and Linux? I ask, as I'd like to remove the terminal part of my updater, and having it apply the updates seamlessly without having the user jump through that terminal copy-and-paste malarkey
Well I'm not sure about the logic here.
Why would you need terminal copy-and-paste malarkey [sic] to apply updates 'seamlessly'? And why would this require admin access?

Why not just use the built-in file manipulation commands to remove existing files and update?

Re: Elevated Privileges

Posted: Sun Dec 03, 2023 6:51 pm
by richmond62
Well I'm not sure about the logic here.
Nor am I to be honest as this is only relevant if the end-user installs some software to a root user account.