28

我目前使用儀器通過bash腳本啓動命令行界面來啓動自動化插件的運行。有沒有辦法從Instruments(XCode)的命令行實例中刪除授權提示?

隨着4.2,這個工作得很好,但隨着升級到Xcode 4.3,我現在被提示授權用戶'分析其他進程'。即使授予了正確的憑據,也不會有用戶實際進行身份驗證。我得到以下錯誤:

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 

即使認證失敗,自動化插件執行,但是這需要我的劇本有一個物理保姆輸入憑證,這在許多方面違背了這些命令 - 目的線路運行。是否可以添加用戶詳細信息作爲參數?或者有沒有其他的方式可以跳過這個提示而不需要鑰匙的人?

- 編輯 -

當您嘗試從GUI首次運行UIAutomation測試,會出現此授權對話框。

enter image description here

提起一個radar rdar://10945962

- 編輯 -

一旦授權對話框已在GUI中得到解答,根據提示再出現在命令行。儘管這種解決方法似乎並不適合作爲「答案」。

+0

你有沒有解決過這個問題?因爲我目前也遇到了同樣的問題... – Alexander 2012-07-09 14:26:27

+0

@Alexander你是否也在與Hudson集成? – Legolas 2012-07-09 18:25:00

+0

目前沒有我通過控制檯直接在服務器上嘗試它,但它不工作 – Alexander 2012-07-09 18:36:52

回答

11

這是一個美妙的命令可能會爲你工作:

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

這是命令行的方式來訪問Mac上的鑰匙鏈。我沒有使用自動化測試它,但它是我將我的iOS版本與Jenkins集成的。

+0

在這之後我們做什麼? – Legolas 2012-07-06 18:06:01

+0

在調用Instruments之前將此行添加到我的bash腳本中導致對話框停止顯示。 – Darc 2012-12-27 21:56:20

4

我可以部分地解決這個問題(與密碼替換[密碼])。我運行命令行工具並在GUI(每個會話一次)(每次我運行儀器)授權提示+這在控制檯:

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 

我比較的/ etc /授權文件之前和升級到xcode的4.3後。蘋果取代兩個鍵:

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

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

我編輯的/ etc /授權,添加缺少以下新的,並從控制檯發出鍵就解決了。不幸的是GUI提示仍然存在。

Mising鍵:

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

希望這會爲您解決整個問題

+0

這樣做嗎? – Legolas 2012-07-06 18:05:30

+0

糟糕的是,如果運行自動化測試的用戶具有管理員權限,這似乎只能起作用。否則它將不起作用 – Alexander 2012-07-09 14:27:34

+0

@Alexander在這種情況下,我無法將其與哈德森整合: -/ – Legolas 2012-07-09 18:24:16

5

腳本運行作爲必須被授權使用的開發工具的用戶。你可以這樣做兩種方式:

  • 將用戶添加到_developer組: sudo dscl . append /Groups/_developer GroupMembership scriptusername

  • 使用DevToolsSecurity命令行工具

請記住,對於UIAutomation儀器爲了正常工作,您從中調用Instruments的用戶還需要是可以啓動窗口服務器(即運行UI)的用戶 - 並且必須在UIAutomation時登錄到窗口服務器運行。

這兩件事是與Jenkins一起使用UIAutomation的四個或五個祕密中的兩個。

+0

試過這兩個,我仍然被提示。 – drekka 2012-06-29 01:19:56

+2

DevToolsSecurity - 啓用是答案! – jacekmigacz 2013-01-22 14:46:35

18

好吧,我認爲我得到了它的工作。

以下是有關如何刪除xcode command line authorization prompt

我所做的就是下面的一些細節:

  • 馬克·詹金斯用戶爲管理員(不幸的是,似乎沒有別的辦法ATM)
  • 轉到的/ etc /授權
  • 搜索鍵system.privilige.taskport
  • 允許根的真

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

現在

  • 變化值,我能夠使用詹金斯通過命令行腳本運行我UIAutomation-測試

  • +0

    這比我所做的要好得多!! :)這應該是正確的答案。 – Legolas 2012-07-10 17:57:55

    +0

    完美地與葫蘆 - IOS的​​作品。讓我的一天 – Raul 2014-01-29 09:32:51

    +2

    我在OS X El Capitan沒有'/ etc/authorization'。這有改變嗎? – devios1 2015-11-17 19:38:39

    -1

    我試過安全解鎖鑰匙串和編輯/ etc/authorization文件,但都沒有工作。

    最後,除去安全提示的唯一方法是jacekmigacz在評論中提出的建議,以運行「sudo DevToolsSecurity - 啓用」。

    0

    我也嘗試過安全解鎖鑰匙串,並更改了/ etc/authorization文件,並啓用了DevToolsSecurity,但它們都沒有工作,直到我啓動Instruments GUI應用程序並運行我的腳本,從中彈出一個對話框我輸入了密碼,之後當我再次運行樂器腳本時,它不再需要密碼了!

    1

    這是解決工作對我來說:

    <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> 
    
    1
    sudo security authorize -u [username] 
    

    爲我工作。

    9

    添加到Alexander's answer,我發現,對於小牛隊,因爲這樣的授權進行處理(source),你應該這樣做:通過詹金斯作業

    sudo security authorizationdb write system.privilege.taskport allow

    我正在西葫蘆功能測試一個VMWare虛擬機,並且從機無法正常啓動模擬器,並且會掛在啓動屏幕上,可能是因爲授權不正確。這幫助我解決了這個問題,希望它能幫助別人。

    +0

    這個命令不會將'allow-root'設置爲true,而是完全覆蓋設置。在運行命令上面的命令之前和之後執行'sudo security authorizationdb read system.privilege.taskport'來比較。 – 2015-03-06 21:57:55

    +0

    這個(也沒有任何其他答案)似乎適用於優勝美地 – markdb314 2015-10-30 21:52:07

    +0

    無法在El Capitan工作。 – devios1 2015-11-17 19:45:44

    0

    在Xcode中 - 如果你加載組織者(Xcode->窗口 - >管理)

    然後選擇下的設備機器 - >「啓用開發模式」

    這應該刪除需要與提示儀器。

    2

    我也在El Capitan面臨這個問題。我發現這篇文章非常有幫助https://www.dssw.co.uk/reference/authorization-rights/。基於它我改變了以下權利,以解決這個問題:

    system.privilege.taskport 
    system.privilege.taskport.debug 
    system.privilege.taskport.safe 
    com.apple.dt.instruments.process.analysis 
    com.apple.dt.instruments.process.kill 
    
    相關問題