Elevated Privileges

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Elevated Privileges

Post by richmond62 » Sat Dec 02, 2023 5:15 pm

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 . . .

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Elevated Privileges

Post by stam » Sat Dec 02, 2023 5:18 pm

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...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Elevated Privileges

Post by richmond62 » Sat Dec 02, 2023 5:20 pm

Now, that is a thought: Thank you.

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

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Elevated Privileges

Post by SparkOut » Sat Dec 02, 2023 5:37 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Elevated Privileges

Post by richmond62 » Sat Dec 02, 2023 5:51 pm

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

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Elevated Privileges

Post by Klaus » Sat Dec 02, 2023 6:20 pm

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

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Elevated Privileges

Post by stam » Sat Dec 02, 2023 6:21 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Elevated Privileges

Post by richmond62 » 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)

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Elevated Privileges

Post by stam » Sat Dec 02, 2023 6:24 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Elevated Privileges

Post by richmond62 » 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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Elevated Privileges

Post by FourthWorld » Sun Dec 03, 2023 4:08 am

Would "open elevated process" do what's needed?

https://livecode.com/resources/api-old/ ... en_process
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Elevated Privileges

Post by stam » Sun Dec 03, 2023 4:00 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Elevated Privileges

Post by richmond62 » Sun Dec 03, 2023 6:51 pm

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”