2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
11 #include <sys/types.h>
16 #include <netinet/in.h>
18 #include "cellconfig.h"
19 #include <afs/afsutil.h>
21 #include "AFS_component_version_number.c"
29 register afs_int32 code;
31 struct afsconf_dir *tdir;
32 struct ktc_principal tserver;
33 struct ktc_token token;
35 strcpy(whoami, argv[0]);
38 printf("%s: copies a file system ticket from the local cell to another cell\n",whoami);
39 printf("%s: usage is 'setauth <new-cell>\n",whoami);
45 /* lookup the name of the local cell */
46 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
48 printf("copyauth: can't open dir %s\n", AFSDIR_CLIENT_ETC_DIRPATH);
51 code = afsconf_GetLocalCell(tdir, localName, sizeof(localName));
53 printf("%s: can't determine local cell name\n",whoami);
56 /* done with configuration stuff now */
60 /* get ticket in local cell */
61 strcpy(tserver.cell, localName);
62 strcpy(tserver.name, "afs");
63 tserver.instance[0] = 0;
64 code = ktc_GetToken(&tserver, &token, sizeof(token), (char *) 0);
66 printf("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n", whoami, tserver.name, tserver.cell, code);
70 /* and now set the ticket in the new cell */
71 strcpy(tserver.cell, argv[1]);
72 code = ktc_SetToken(&tserver, &token, (char *) 0, 0);
74 printf("%s: failed to set ticket (code %d), are you sure you're authenticated?\n", whoami, code);
79 printf("Authentication established for cell %s.\n", cname);