135 strncpy(Entity.prot,
"host",
sizeof(Entity.prot));
136 if (Entity.grps) free(Entity.grps);
138 if (Entity.host) free(Entity.host);
140 if (Entity.vorg) free(Entity.vorg);
142 if (Entity.role) free(Entity.role);
144 if (Entity.name) free(Entity.name);
160 XrdVersionInfo &myVer);
161int DoIt(
int argpnt,
int argc,
char **argv,
bool singleshot);
163const char *cfHost =
"localhost", *cfProg =
"xrootd";
165char *argval[32], buff[255],
tident[80], c;
166int DoIt(
int argnum,
int argc,
char **argv,
int singleshot);
168const int maxargs =
sizeof(argval)/
sizeof(argval[0]);
169char *at, *lp, *ConfigFN = (
char *)
"./acc.cf";
171bool singleshot=
false;
175 if (argc == 1)
Usage(0);
176 Entity.addrInfo = &netAddr;
177 sprintf(
tident,
"acctest.%d:0@localhost", getpid());
182 while ((c=getopt(argc,argv,
"a:c:de:g:h:o:r:u:s")) != (
char)EOF)
186 {
size_t size =
sizeof(Entity.prot)-1;
187 strncpy(Entity.prot, optarg, size);
188 Entity.prot[size] =
'\0';
192 case 'e': Entity.ueid = atoi(optarg); v2 =
true;
break;
193 case 'g':
SetID(Entity.grps, optarg); v2 =
true;
break;
194 case 'h':
SetID(Entity.host, optarg); v2 =
true;
break;
195 case 'o':
SetID(Entity.vorg, optarg); v2 =
true;
break;
196 case 'r':
SetID(Entity.role, optarg); v2 =
true;
break;
197 case 'u':
SetID(Entity.name, optarg); v2 =
true;
break;
198 case 'c': ConfigFN = optarg;
break;
199 case 's': singleshot =
true;
break;
200 default: sprintf(buff,
"-%c option is invalid.", c);
207 if ((at = index(ConfigFN,
'@')))
208 {*at++ = 0;
if (*at) cfHost = at;}
209 sprintf(buff,
"%s anon@%s", cfProg, cfHost);
215 {std::cerr <<
"testaccess: Initialization failed." <<std::endl;
227 std::cerr <<
"Enter arguments: ";
228 while((lp = Command.
GetLine()) && *lp)
236 {
if (*xp ==
' ') *xp =
'\t';
237 else if (*xp ==
'\'') {*xp++ =
' ';
break;}
244 argnum < maxargs && (argval[argnum]=Command.
GetToken());
247 {
for (
int i = 1; i < argnum; i++)
248 {
char *ap = argval[i];
249 while(*ap) {
if (*ap ==
'\t') *ap =
' '; ap++;}
253 rc |=
DoIt(1, argnum, argval, singleshot=0);
254 std::cerr <<
"Enter arguments: ";
262int DoIt(
int argpnt,
int argc,
char **argv,
bool singleshot)
264char *opc, *opv, *path, *result, buff[80];
266void Usage(
const char *);
273 while(argpnt < argc && *argv[argpnt] ==
'-')
274 {opc = argv[argpnt++];
276 {sprintf(buff,
"%s option value not specified.", opc);
279 opv = argv[argpnt++];
280 if (strlen(opc) != 2)
281 {sprintf(buff,
"%s option is invalid.", opc);
285 {
case 'a': {
size_t size =
sizeof(Entity.prot)-1;
286 strncpy(Entity.prot, opv, size);
287 Entity.prot[size] =
'\0';
290 case 'e': Entity.ueid = atoi(opv); v2 =
true;
break;
291 case 'g':
SetID(Entity.grps, opv); v2 =
true;
break;
292 case 'h':
SetID(Entity.host, opv); v2 =
true;
break;
293 case 'o':
SetID(Entity.vorg, opv); v2 =
true;
break;
294 case 'r':
SetID(Entity.role, opv); v2 =
true;
break;
295 case 'u':
SetID(Entity.name, opv); v2 =
true;
break;
296 default: sprintf(buff,
"%s option is invalid.", opc);
305 {
if (argpnt >= argc)
Usage(
"user not specified.");
306 Entity.name = argv[argpnt++];
307 if (argpnt >= argc)
Usage(
"host not specified.");
308 Entity.host = argv[argpnt++];
315 else Usage(
"operation not specified.");
317 if (!strcmp(argv[argpnt],
"*"))
321 optype =
cmd2op(argv[argpnt++]);
325 if (argpnt >= argc)
Usage(
"path not specified.");
329 if (Entity.host) netAddr.Set(Entity.host, 0);
334 {path = argv[argpnt++];
338 if (optype !=
AOP_Any) result=(auth?(
char *)
"allowed":(
char *)
"denied");
342 std::cout <<result <<
": " <<path <<std::endl;
343 if (singleshot)
return !auth;