Skip to content

Commit

Permalink
Merge pull request #399 from ijjorama/master
Browse files Browse the repository at this point in the history
Added singleshot mode (with -s flag). Return the value of the authZ d…
  • Loading branch information
abh3 committed Jul 29, 2016
2 parents fa92165 + c2d1f50 commit da9724e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/XrdApps/XrdAccTest.cc
Expand Up @@ -117,17 +117,19 @@ void Usage(const char *);
char *p2l(XrdAccPrivs priv, char *buff, int blen);
int rc = 0, argnum;
char c, *argval[32];
int DoIt(int argnum, int argc, char **argv);
int DoIt(int argnum, int argc, char **argv, int singleshot);
XrdOucStream Command;
const int maxargs = sizeof(argval)/sizeof(argval[0]);
char *ConfigFN = (char *)"./acc.cf";
int singleshot = 0;

// Get all of the options.
//
while ((c=getopt(argc,argv,"c:d")) != (char)EOF)
while ((c=getopt(argc,argv,"c:ds")) != (char)EOF)
{ switch(c)
{
case 'c': ConfigFN = optarg; break;
case 's': singleshot = 1; break;
default: Usage("Invalid option.");
}
}
Expand All @@ -141,7 +143,7 @@ if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))

// If command line options specified, process this
//
if (optind < argc) {rc = DoIt(optind, argc, argv); exit(rc);}
if (optind < argc) {rc = DoIt(optind, argc, argv, singleshot); exit(rc);}

// Start accepting command from standard in until eof
//
Expand All @@ -152,15 +154,15 @@ if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))
{for (argnum=2;
argnum < maxargs && (argval[argnum]=Command.GetToken());
argnum++) {}
rc |= DoIt(1, argnum, argval);
rc |= DoIt(1, argnum, argval, singleshot=0);
}

// All done
//
exit(rc);
}

int DoIt(int argpnt, int argc, char **argv)
int DoIt(int argpnt, int argc, char **argv, int singleshot)
{
char *user, *host, *path, *result, buff[16];
Access_Operation cmd2op(char *opname);
Expand Down Expand Up @@ -207,7 +209,8 @@ XrdSecEntity Entity("");
result = PrivsConvert(pargs, buff, sizeof(buff));
}
cout <<result <<": " <<path <<endl;
}
if (singleshot) return !auth;
}

return 0;
}
Expand Down

0 comments on commit da9724e

Please sign in to comment.