[952] in arla-drinkers

home help back first fref pref prev next nref lref last post

Re: forwarding tokens to other machines

daemon@ATHENA.MIT.EDU (Assar Westerlund)
Wed Jul 7 23:06:11 1999

From owner-arla-drinkers@stacken.kth.se Thu Jul 08 03:06:09 1999
Return-Path: <owner-arla-drinkers@stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 1640 invoked from network); 8 Jul 1999 03:06:08 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
  by bloom-picayune.mit.edu with SMTP; 8 Jul 1999 03:06:08 -0000
Received: (from majordom@localhost)
	by sundance.stacken.kth.se (8.8.8/8.8.8) id EAA02451
	for arla-drinkers-list; Thu, 8 Jul 1999 04:59:07 +0200 (MET DST)
Received: from assaris.sics.se (assaris.sics.se [193.10.66.108])
	by sundance.stacken.kth.se (8.8.8/8.8.8) with ESMTP id EAA02447
	for <arla-drinkers@stacken.kth.se>; Thu, 8 Jul 1999 04:59:02 +0200 (MET DST)
Received: (from assar@localhost) by assaris.sics.se (8.9.3/8.7.3) id EAA22666; Thu, 8 Jul 1999 04:59:33 +0200 (CEST)
From: Assar Westerlund <assar@stacken.kth.se>
To: Herbert Huber <Herbert.Huber@lrz-muenchen.de>
Cc: arla-drinkers@stacken.kth.se
Subject: Re: forwarding tokens to other machines
References: <377A444A.27D39A72@lrz-muenchen.de>
Mime-Version: 1.0 (generated by tm-edit 7.68)
Content-Type: multipart/mixed;
 boundary="Multipart_Thu_Jul__8_04:59:32_1999-1"
Content-Transfer-Encoding: 7bit
Date: 08 Jul 1999 04:59:32 +0200
In-Reply-To: Herbert Huber's message of "Wed, 30 Jun 1999 16:22:35 +0000"
Message-ID: <5lu2rf26ej.fsf@assaris.sics.se>
Lines: 153
X-Mailer: Gnus v5.5/Emacs 19.34
Sender: owner-arla-drinkers@stacken.kth.se
Precedence: bulk

--Multipart_Thu_Jul__8_04:59:32_1999-1
Content-Type: text/plain; charset=US-ASCII

Herbert Huber <Herbert.Huber@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

--Multipart_Thu_Jul__8_04:59:32_1999-1
Content-Type: text/plain; charset=US-ASCII

#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;
}

--Multipart_Thu_Jul__8_04:59:32_1999-1
Content-Type: text/plain; charset=US-ASCII

#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;
}

--Multipart_Thu_Jul__8_04:59:32_1999-1
Content-Type: text/plain; charset=US-ASCII

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);

--Multipart_Thu_Jul__8_04:59:32_1999-1--

home help back first fref pref prev next nref lref last post