gss-token: implement -S to split tokens up on output.

This commit is contained in:
Roland C. Dowdeswell
2020-10-07 16:11:20 +01:00
parent 9693bdb272
commit 0055c1c80b
2 changed files with 32 additions and 7 deletions

View File

@@ -15,6 +15,7 @@
.Fl r
.Op Fl MNln
.Op Fl C Ar ccache
.Op Fl S Ar maxsize
.Op Fl c count
.Op Ar service@host
.Sh DESCRIPTION
@@ -52,6 +53,11 @@ This can be used to load test the KDC.
prepend
.Dq Negotiate\
to generated tokens and expect it on consumed tokens.
.It Fl S Ar maxsize
split each token that is generated into components of maximum
size
.Ar maxsize .
Each token is base64 encoded and output separately.
.It Fl c Ar count
repeat the operation
.Ar count

View File

@@ -89,6 +89,7 @@
* global variables
*/
int Sflag = 0;
int nflag = 0;
static char *
@@ -207,18 +208,35 @@ write_token(gss_buffer_t out, int negotiate)
char *outstr = NULL;
char *p = out->value;
size_t len = out->length;
size_t inc;
int ret;
int first = 1;
if (nflag)
return 0;
ret = rk_base64_encode(p, len, &outstr);
if (ret < 0) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
printf("%s%s\n", negotiate?"Negotiate ":"", outstr);
free(outstr);
inc = len;
if (Sflag)
inc = Sflag;
do {
if (first)
first = 0;
else
printf("\n");
if (len < inc)
inc = len;
ret = rk_base64_encode(p, inc, &outstr);
if (ret < 0) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
printf("%s%s\n", negotiate?"Negotiate ":"", outstr);
free(outstr);
p += inc;
len -= inc;
} while (len > 0);
return 0;
}
@@ -528,6 +546,7 @@ main(int argc, char **argv)
{ NULL, 'D', arg_flag, &Dflag, NULL, NULL },
{ NULL, 'M', arg_flag, &Mflag, NULL, NULL },
{ NULL, 'N', arg_flag, &Nflag, NULL, NULL },
{ NULL, 'S', arg_integer, &Sflag, NULL, NULL },
{ NULL, 'c', arg_integer, &count, NULL, NULL },
{ NULL, 'l', arg_flag, &lflag, NULL, NULL },
{ NULL, 'n', arg_flag, &nflag, NULL, NULL },