Is there a way to remove the authorization prompt from command-line instances of Instruments (Xcode)?
Asked Answered
P

11

30

I am currently using Instruments via a bash script to initiate the command-line interface to start up runs of the Automation plug-in.

With 4.2, this worked well enough, however with the upgrade to Xcode 4.3, I am now being prompted for an authorized user to 'analyze other processes'. No user is ever actually authenticated, even if the correct credentials are granted. I get the following error:

Failed to authorize rights (0x20) with status: -60007.
2012-02-27 19:30:37.232 instruments[54151:1c03] Failed to connect to local pid watcher     service: (os/kern) failure

Even with the authentication failure, the Automation plug-in executes, however this requires my script to have a physical babysitter enter credentials, which in many ways defeats the purpose of these command-line runs. Is it possible to add the user details as arguments? Or is there some other way to skip over this prompt without requiring a person at the keys?

-- EDIT --

This authorization dialog appears when you try to run UIAutomation tests from the GUI for the first time.

enter image description here

Filed a radar rdar://10945962.

-- EDIT --

Once the authorization dialog has been answered in the GUI, the prompts stop appearing on the command-line. This kind of work-around doesn't seem valid as an 'answer' though.

Pronuba answered 28/2, 2012 at 3:53 Comment(4)
Have you ever solved this problem? Because I am currently running into the same one as well...Analogical
@Analogical Are you also working with Hudson integration ?Run
no currently I am trying it via console directly on the server, but its not working eitherAnalogical
@Analogical Yep. I am on the same boat !Run
R
15

Here's a wonderful command that may work for you:

security unlock-keychain -p [password] "${HOME}/Library/Keychains/login.keychain"

It's the command-line way to gain access to a keychain on the Mac. I haven't tested it with Automation, but it's how I've integrated my iOS builds with Jenkins.

(Replace [password] with the password)

Robinett answered 13/3, 2012 at 5:1 Comment(2)
Adding this line to my bash script prior to the call to Instruments caused the dialog to stop appearing.Pronuba
this seems to have worked for me on Catalina. ThanksTragedian
A
18

Okay I think I got it working.

Here are some more details about how to remove xcode command line authorization prompt

What I did was the following:

  • Mark jenkins user as admin (unfortunately it seems that there is no other way atm)
  • Go to /etc/authorization
  • search for key system.privilige.taskport
  • change value of allow-root to true

    <key>system.privilege.taskport</key>
    <dict>
        <key>allow-root</key>
        <false/> // change to -> <true>
        <key>class</key>
        <string>user</string>
        <key>comment</key>
        <string>Used by task_for_pid(...).
        ...
    </dict>
    

Now I am being able to use jenkins to run my UIAutomation-Tests via Command Line Script

Analogical answered 10/7, 2012 at 14:52 Comment(5)
This is much better than what I did !! :) This should be marked the right answer.Run
Works flawlessly with calabash-ios. Made my dayScourge
I have no /etc/authorization in OS X El Capitan. Has this changed?Corned
@devios I found mine in /System/Library/Security/authorization.plistArteriole
I believe the spelling is system.privilege.taskportRecapture
R
15

Here's a wonderful command that may work for you:

security unlock-keychain -p [password] "${HOME}/Library/Keychains/login.keychain"

It's the command-line way to gain access to a keychain on the Mac. I haven't tested it with Automation, but it's how I've integrated my iOS builds with Jenkins.

(Replace [password] with the password)

Robinett answered 13/3, 2012 at 5:1 Comment(2)
Adding this line to my bash script prior to the call to Instruments caused the dialog to stop appearing.Pronuba
this seems to have worked for me on Catalina. ThanksTragedian
N
10

Adding to Alexander's answer, I found that for Mavericks, because of the way authorizations are handled (source), you should do this:

sudo security authorizationdb write system.privilege.taskport allow

I am running zucchini functional tests through a Jenkins job in a VMWare VM, and the slave couldn't launch properly the simulator and would hang on the splash screen, probably because of incorrect authorisations. This helped me solve this issue, hope it helps others.

Nonchalance answered 7/1, 2014 at 2:58 Comment(2)
This command doesn't set allow-root to true, but completely overwrites the settings. Do sudo security authorizationdb read system.privilege.taskport before and after running your command above command to compare.Kujawa
This (nor any of the other answers) seem to work for YosemiteSniperscope
R
5

The user your script runs as has to be authorized to use the developer tools. You can do this two ways:

  • Add the user to the _developer group: sudo dscl . append /Groups/_developer GroupMembership scriptusername

  • Use the DevToolsSecurity command line tool

Keep in mind that for the UIAutomation instruments to work properly, the user you are invoking Instruments from will also need to be a user that can start a window server (i.e. run the UI) - and will have to be logged in to a window server when UIAutomation runs.

These two things are two of the four or five secrets to using UIAutomation with Jenkins.

Rockefeller answered 15/5, 2012 at 5:6 Comment(2)
Tried both of these and I'm still being prompted.Jessie
DevToolsSecurity --enable is the answer!Conservatism
D
4

I partially solved this issue. I run instruments from command line and have authorization prompt in GUI (once per session) + this in console (each time I run instruments):

Instruments: Instruments wants permission to analyze other processes.
Type your password to allow this.
Name ([my-username]):
Password:

Failed to authorize rights (0x20) with status: -60007.
2012-02-28 10:04:19.607 instruments[60398:1203] Failed to connect to
local pid watcher service: (os/kern) failure

I compared /etc/authorization file before and after upgrading to xCode 4.3. Apple replaced two keys:

<key>com.apple.dt.instruments.process.analysis</key>
<key>com.apple.dt.instruments.process.kill</key>

with

<key>com.apple.instruments.process.analysis</key>

I edited /etc/authorization, added missing keys below new one and issue from console is solved. Unfortunately GUI prompt is still there.

Mising keys:

<key>com.apple.dt.instruments.process.analysis</key>
<dict>
    <key>allow-root</key>
    <true/>
    <key>class</key>
    <string>user</string>
    <key>comment</key>
    <string>Rights for Instruments</string>
    <key>group</key>
    <string>admin</string>
    <key>shared</key>
    <true/>
    <key>timeout</key>
    <integer>36000</integer>
    </dict>
<key>com.apple.dt.instruments.process.kill</key>
<dict>
    <key>allow-root</key>
    <true/>
    <key>class</key>
    <string>user</string>
    <key>comment</key>
    <string>Rights for Instruments</string>
    <key>group</key>
    <string>admin</string>
    <key>shared</key>
    <true/>
    <key>timeout</key>
    <integer>5</integer>
</dict>

Hope this will point you to solve whole issue

Defense answered 14/3, 2012 at 7:58 Comment(4)
The bad thing is, that this seems only to work, if the user running the automation tests has admin privileges. Otherwise it will not workAnalogical
@Analogical In that case , I cannot integrate it with hudson :-/Run
I think I got it working, see my response below, unfortunately jenkins has be be admin :(Analogical
Editing authorization and adding the keys above worked for me. Note: my test user has admin rights, and I have not tried from jenkins yet, just command line.Oconnor
D
3

I also faced with this issue on El Capitan. I found this article very helpful https://www.dssw.co.uk/reference/authorization-rights/. Based on it I changed following rights in order to overcome this issue:

system.privilege.taskport
system.privilege.taskport.debug
system.privilege.taskport.safe
com.apple.dt.instruments.process.analysis
com.apple.dt.instruments.process.kill
Deposal answered 14/6, 2016 at 15:11 Comment(0)
B
1

This is the solution worked for me :

<key>system.privilege.taskport</key>
<dict>
<key>allow-root</key>
<false/> 
<key>class</key>
<string>user</string> // change to -> allow
<key>comment</key>
<string>Used by task_for_pid(...).
...
</dict>
Bespeak answered 24/10, 2013 at 18:35 Comment(0)
D
1
sudo security authorize -u [username]

worked for me.

Directions answered 12/11, 2013 at 9:14 Comment(0)
V
0

I also tried security unlock-keychain and changed the /etc/authorization file, and have DevToolsSecurity enabled, but none of them worked, until I launched the Instruments GUI app and run my script, from which it popped up a dialog and i entered my password, after then when i run the instruments script again it doesn't require password anymore!

Validate answered 9/8, 2013 at 5:33 Comment(0)
A
0

In Xcode - if you load up organizer (Xcode->Window->Organizer)

Then select your machine under devices -> 'Enable Developer Mode'

This should remove the need for prompts with instruments.

Ayn answered 24/5, 2014 at 20:34 Comment(0)
D
-1

I tried security unlock-keychain and editing the /etc/authorization file, but neither of those worked.

In the end the only thing that removed that security prompt was what jacekmigacz suggested in a comment, to run "sudo DevToolsSecurity --enable".

Delorisdelorme answered 18/7, 2013 at 22:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.