Is there a way to remove the authorization prompt

2019-01-10 06:20发布

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.

11条回答
ゆ 、 Hurt°
2楼-- · 2019-01-10 06:30

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>
查看更多
Explosion°爆炸
3楼-- · 2019-01-10 06:31

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.

查看更多
成全新的幸福
4楼-- · 2019-01-10 06:31

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

查看更多
在下西门庆
5楼-- · 2019-01-10 06:33

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.

查看更多
叼着烟拽天下
6楼-- · 2019-01-10 06:37

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

查看更多
Juvenile、少年°
7楼-- · 2019-01-10 06:40

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!

查看更多
登录 后发表回答