X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/regressions/auth/auth-SessionCreate-01-basic.c diff --git a/SecurityTests/regressions/auth/auth-SessionCreate-01-basic.c b/SecurityTests/regressions/auth/auth-SessionCreate-01-basic.c new file mode 100644 index 00000000..5cede143 --- /dev/null +++ b/SecurityTests/regressions/auth/auth-SessionCreate-01-basic.c @@ -0,0 +1,34 @@ +/* NO_AUTOMATED_TESTING */ + +#include +#include /* getenv(3) */ +#include +#include "testmore.h" + +#define SSID_ENV_STR "SECURITYSESSIONID" /* hard-coded in Authorization.cpp */ + +/* + * Not automated because SessionCreate() implicitly invokes task_for_pid(), + * which in turn can trigger an Authorization call (and thus UI) via + * taskgated. + */ +int main(__unused int ac, __unused const char *av[]) +{ + char *ssid = NULL; + + plan_tests(1); + + if ((ssid = getenv(SSID_ENV_STR)) != NULL) + printf("Current SecuritySessionID: %s\n", ssid); + /* + * @@@ SessionCreate() is documented to return "noErr" on success, but + * errSessionSuccess is part of the SessionStatus enum + */ + is(SessionCreate(0/*SessionCreationFlags*/, + sessionHasGraphicAccess|sessionHasTTY/*SessionAttributeFlags*/), + errSessionSuccess, "SessionCreate()"); + if ((ssid = getenv(SSID_ENV_STR)) == NULL) + fprintf(stderr, "Missing %s in environment!\n", SSID_ENV_STR); + printf("New SecuritySessionID: %s\n", ssid); + return 0; +}