1/* NO_AUTOMATED_TESTING */
2#include <Security/Authorization.h>
3#include <Security/AuthorizationTagsPriv.h>
4#include <stdio.h>
5#include <stdint.h>
6#include "testmore.h"
7
8/*
9 * XXX/gh  These should be in AuthorizationTagsPriv.h
10 */
11#ifdef AUTHHOST_TYPE_AGENT
12#warning AUTHHOST_TYPE_AGENT defined, clean up immediate-agent test
13#else
14#define AUTHHOST_TYPE_AGENT      1  // SecurityAgent
15#endif
16
17#ifdef AUTHHOST_TYPE_PRIVILEGED
18#warning AUTHHOST_TYPE_PRIVILEGED defined, clean up immediate-agent test
19#else
20#define AUTHHOST_TYPE_PRIVILEGED 2  // authorizationhost
21#endif
22
23int main(__unused int ac, const char *av[])
24{
25    uint32_t hostType = AUTHHOST_TYPE_AGENT;
26    AuthorizationItem item = { AGENT_HINT_IMMEDIATE_LAUNCH, sizeof(hostType), &hostType, 0 };
27    AuthorizationEnvironment hints = { 1, &item };
28    const char *hostTypeStr;
29
30    plan_tests(1);
31
32    switch(hostType)
33    {
34        case AUTHHOST_TYPE_AGENT: hostTypeStr = "SecurityAgent"; break;
35        case AUTHHOST_TYPE_PRIVILEGED: hostTypeStr = "authorizationhost"; break;
36        default: hostTypeStr = "unknown host type"; break;
37    }
38    ok_status(AuthorizationCreate(NULL, &hints, kAuthorizationFlagDefaults, NULL), "force immediate agent launch");
39
40    return 0;
41}
42