MAC OS, Admin Privileges

Joined
Dec 1, 2009
Messages
4
Reaction score
0
Points
1
Hi All.

We have a program on MAC, and another seperate app which is an updater.

The updater may need to copy/replace/delete some files in the /System/Library/ folders on the MAC.

But these folders need Admin Privileges to be able to edit the files inside them.

Our program is written in Qt, and i run shell commands, such as "cp" and "rm".

If i am able to run "sudo cp" and "sudo rm" then it should be fine. But the problem is that when i run sudo through the Qt app, it doesn't pop up any dialog to allow the user to type in the password.

Is there any function that can pop up the Standard MAC OS X Authentication Dialog and to give my app admin rights? so that when i call "sudo cp", etc, they wont need the password to be keyed in ?

This updater is also called from the main app.. so "sudo open updater" wont work as well ! same problem !

If theres any other ways around it, i'd be glad to hear as well !

THanks a lot!
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I don't have an answer, but if you want any respect from the Mac community, you won't use MAC to mean Mac.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
I think you're doing it the wrong way, using native "cp" and "rm" directly from an application should always be a last resort. You should first attempt to see what facilities the OS provides for doing these things.

I've installed a number of apps that have prompted me for the Admin password in a OS X way to manipulate the system level files, so you might want to dig a bit further into the Mac Cocoa documentation.

Regards
 
Joined
Mar 30, 2004
Messages
4,744
Reaction score
381
Points
83
Location
USA
Your Mac's Specs
12" Apple PowerBook G4 (1.5GHz)
The updater may need to copy/replace/delete some files in the /System/Library/ folders on the MAC.
First of all, think very, very carefully about this. If it is at all possible, don't mess with anything in there, since things in /System/Library/ are used by the OS, its services, and possibly other programs. They may be updated in the future by Software Update, and moving or changing them may cause problems when future updates are released.

That said, Apple does have an API for authentication. See:

Mac Dev Center: Authorization Services Programming Guide: Introduction to Authorization Services Programming Guide

Mac Dev Center: Authorization Services C Reference
 
OP
L
Joined
Dec 1, 2009
Messages
4
Reaction score
0
Points
1
Thanks razoredge and technologist.

Actually we're writing a cross-platform connection manager, using Qt. And I need to update the System/library files etc to update the hardware drivers of the USB WiMAX devices which connects to the internet (i wont touch any of the other OS stuff). No apple programmers here, so I was put in the project, and i'm completely new to Mac.

Thanks for your suggestions! I will look into them and find the best way :)
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
leongyk. What do you mean by ***? You clearly listened to my suggestion in your second post.
 
OP
L
Joined
Dec 1, 2009
Messages
4
Reaction score
0
Points
1
xstep, not everyone has been around Mac's as long as you, so you don't have to be cocky about it.

I will still follow it, (i have no idea if it makes a difference or not), but at least the others were helpful and not cocky.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I wasn't being cocky. I was being direct.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top