WIP Kerberized iwhd
Jim Meyering
jim at meyering.net
Tue Jun 28 19:38:20 UTC 2011
Pete Zaitcev wrote:
> If I understood it right, you expressed interest in patches that do not
> work... and this one does not. Still needs a way to set up a header for
> all future transfers. But I think generally this is how it is going to
> look.
Thanks for the preview!
> diff --git a/configure.ac b/configure.ac
> index 8945f7c..9820033 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -70,6 +70,9 @@ AC_CHECK_LIB([uuid], [uuid_generate_random],
> [AC_MSG_ERROR([Missing required uuid lib])])
> AC_SUBST([UUID_LIB])
>
> +dnl How to check properly?
> +LIBS="$LIBS -lgssapi_krb5"
I'll be happy to write code to do that.
...
> diff --git a/rest.c b/rest.c
...
> +static bool nego_token(char **pbuf, size_t *plen, const char *val)
> +{
> + char *buf;
> + size_t len;
> + const char *p;
> + bool rcb;
> +
> + p = val;
> + while (*p == ' ') {
> + if (*p == 0) {
> + return false;
> + }
> + p++;
> + }
The *p == 0 test above can never be true.
I think you intended this instead:
while (*p == ' ') {
p++;
if (*p == 0) {
return false;
}
}
> + if (strncmp(p, "Negotiate ", sizeof("Negotiate ")-1) != 0)
> + return false;
> + p += sizeof("Negotiate ")-1;
> + while (*p == ' ') {
> + if (*p == 0) {
> + return false;
> + }
> + p++;
> + }
If you fix this loop the same way, then you can change
the if len == 0 block into a simple "assert (len);" statement,
since the corrected loop guarantees that upon exit (not via "return")
*p is not 0.
> + len = strlen(p);
> + if (len == 0) {
> + return false;
> + }
> +
> + /* actually should be 3/4, but whatever */
> + buf = malloc(len);
> + if (!buf)
> + return false; // or maybe just abort()?
> +
> + rcb = base64_decode(p, len, buf, &len);
> + if (!rcb) {
> + // free(buf);
> + return false;
> + }
> +
> + *pbuf = buf;
> + *plen = len;
> + return true;
> +}
That's as far as I got today.
More information about the iwhd-devel
mailing list