forwarding tokens to other machines

Assar Westerlund assar at stacken.kth.se
Thu Jul 8 04:59:07 CEST 1999


Herbert Huber <Herbert.Huber at lrz-muenchen.de> writes:
> Has anybody a small program which reads AFS token from stdin, writes AFS
> token into token cache and works under arla? I need this program to
> forward an AFS token which a user has on my interactive machines to the
> machine where his batch job will run.

I'm not really sure I understand all the requirements that you have
here, but I hacked together two proof-of-concepts program for what you
described here.  gettok will fetch the first token from the kernel and
print it on standard output.  settok will read a single token and
install in the kernel.  Link them with -lkafs -lkrb.  (You might also
need to remove <sys/ioccom.h>.)

TODO:

* handle different endians
* handle more than one token

For some reason arla didn't return the secret part of the token, which
means that you also need to apply the appended patch to messages.c

> PS: The reaction of IBM is in my opinion absolutely not acceptable. I
> therefore prefer to use arla which is yet not as stable as the official
> client but will improve for shure.

Thanks.  We're that you want to use arla.  Please report the bugs and
problems that you have and we'll do our best top exterminate them.

/assar


#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/ioccom.h>
#include <krb.h>
#include <kafs.h>

int
main(void)
{
    int ret;
    u_int32_t i = 0;
    unsigned char buf[1024];
    unsigned char *p;
    struct ViceIoctl parms;
    int32_t tmp;
    size_t len;

    parms.in       = (void *)&i;
    parms.in_size  = sizeof(i);
    parms.out      = (void *)buf;
    parms.out_size = sizeof(buf);

    if (!k_hasafs ()) {
	fprintf (stderr, "no afs\n");
	exit (1);
    }

    ret = k_pioctl (NULL, VIOCGETTOK, &parms, 0);
    if (ret) {
	fprintf (stderr, "pioctl GETTOK failed\n");
	exit (1);
    }
    len = 0;
    p = buf;
    memcpy (&tmp, p, sizeof(tmp));
    p += sizeof(tmp) + tmp;
    memcpy (&tmp, p, sizeof(tmp));
    p += sizeof(tmp) + tmp;
    p += sizeof(int32_t);
    p += strlen(p) + 1;

    len = p - buf;

    write (1, buf, len);
    return 0;
}


#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/ioccom.h>
#include <krb.h>
#include <kafs.h>

int
main(void)
{
    int ret;
    u_int32_t i;
    unsigned char buf[1024];
    struct ViceIoctl parms;

    ret = read (0, buf, sizeof(buf));
    if (ret < 0) {
	fprintf (stderr, "read failed\n");
	exit (1);
    }

    parms.in       = (void *)buf;
    parms.in_size  = ret;
    parms.out      = NULL;
    parms.out_size = 0;

    if (!k_hasafs ()) {
	fprintf (stderr, "no afs\n");
	exit (1);
    }

    ret = k_pioctl (NULL, VIOCSETTOK, &parms, 0);
    if (ret) {
	fprintf (stderr, "pioctl SETTOK failed\n");
	exit (1);
    }
    return 0;
}


Index: arlad/messages.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/arlad/messages.c,v
retrieving revision 1.136
diff -u -w -u -w -r1.136 messages.c
--- messages.c	1999/07/04 09:14:13	1.136
+++ messages.c	1999/07/08 02:47:40
@@ -2490,9 +2502,11 @@
     ct.BeginTimestamp = cred->issue_date + 1;
     ct.EndTimestamp   = ce->expire;
 
-    tmp = 0;
+    tmp = cred->ticket_st.length;
     memcpy (p, &tmp, sizeof(tmp));
     p += sizeof(tmp);
+    memcpy (p, cred->ticket_st.dat, tmp);
+    p += tmp;
     tmp = sizeof(ct);
     memcpy (p, &tmp, sizeof(tmp));
     p += sizeof(tmp);





More information about the Arla-drinkers mailing list