1/* NO_AUTOMATED_TESTING */ 2#include <Security/Authorization.h> 3#include <stdio.h> 4#include <stdint.h> 5#include <dirent.h> 6#include "testmore.h" 7 8#define EXECUTABLE "/bin/ls" 9#define LSTARGET "/private/var/db/shadow" 10 11/* XXX/gh interactive, so inappropriate for auto-regressions */ 12int main(__unused int ac, const char *av[]) 13{ 14 AuthorizationRef authRef = NULL; 15 char *lsargs[2] = { "-l", LSTARGET }; 16 FILE *commPipe = NULL; 17 DIR *dir = NULL; 18 char lsbuf[6]; /* "total" */ 19 /* uint32_t total; */ 20 21 plan_tests(5); 22 23 /* make sure LSTARGET isn't readable by mere mortals */ 24 dir = opendir(LSTARGET); 25 is(errno, EACCES, "AEWP-basic: opendir()"); 26 ok_status(AuthorizationCreate(NULL, NULL, kAuthorizationFlagDefaults, &authRef), 27 "AEWP-basic: AuthCreate()"); 28 ok(authRef != NULL, "AEWP-basic: NULL authRef"); 29 ok_status(AuthorizationExecuteWithPrivileges(authRef, 30 EXECUTABLE, 31 kAuthorizationFlagDefaults, 32 lsargs, 33 &commPipe), 34 "AEWP-basic: AEWP()"); 35 36 /* stops at first white space */ 37 is_status(fscanf(commPipe, "%s", lsbuf), 1, "AEWP-basic: fscanf()"); 38 printf("ls output: %s\n", lsbuf); 39 return 0; 40} 41