]> git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/auth/auth-SessionCreate-01-basic.c
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / regressions / auth / auth-SessionCreate-01-basic.c
1 /* NO_AUTOMATED_TESTING */
2
3 #include <stdio.h>
4 #include <stdlib.h> /* getenv(3) */
5 #include <Security/AuthSession.h>
6 #include "testmore.h"
7
8 #define SSID_ENV_STR "SECURITYSESSIONID" /* hard-coded in Authorization.cpp */
9
10 /*
11 * Not automated because SessionCreate() implicitly invokes task_for_pid(),
12 * which in turn can trigger an Authorization call (and thus UI) via
13 * taskgated.
14 */
15 int main(__unused int ac, __unused const char *av[])
16 {
17 char *ssid = NULL;
18
19 plan_tests(1);
20
21 if ((ssid = getenv(SSID_ENV_STR)) != NULL)
22 printf("Current SecuritySessionID: %s\n", ssid);
23 /*
24 * @@@ SessionCreate() is documented to return "noErr" on success, but
25 * errSessionSuccess is part of the SessionStatus enum
26 */
27 is(SessionCreate(0/*SessionCreationFlags*/,
28 sessionHasGraphicAccess|sessionHasTTY/*SessionAttributeFlags*/),
29 errSessionSuccess, "SessionCreate()");
30 if ((ssid = getenv(SSID_ENV_STR)) == NULL)
31 fprintf(stderr, "Missing %s in environment!\n", SSID_ENV_STR);
32 printf("New SecuritySessionID: %s\n", ssid);
33 return 0;
34 }