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 <afsconfig.h>
11 #include <afs/param.h>
23 #include <sys/types.h>
28 #include <netinet/in.h>
30 #include "cellconfig.h"
31 #include <afs/afsutil.h>
33 #include "AFS_component_version_number.c"
41 register afs_int32 code;
43 struct afsconf_dir *tdir;
44 struct ktc_principal tserver;
45 struct ktc_token token;
47 strcpy(whoami, argv[0]);
50 printf("%s: copies a file system ticket from the local cell to another cell\n",whoami);
51 printf("%s: usage is 'setauth <new-cell>\n",whoami);
57 /* lookup the name of the local cell */
58 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
60 printf("copyauth: can't open dir %s\n", AFSDIR_CLIENT_ETC_DIRPATH);
63 code = afsconf_GetLocalCell(tdir, localName, sizeof(localName));
65 printf("%s: can't determine local cell name\n",whoami);
68 /* done with configuration stuff now */
72 /* get ticket in local cell */
73 strcpy(tserver.cell, localName);
74 strcpy(tserver.name, "afs");
75 tserver.instance[0] = 0;
76 code = ktc_GetToken(&tserver, &token, sizeof(token), NULL);
78 printf("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n", whoami, tserver.name, tserver.cell, code);
82 /* and now set the ticket in the new cell */
83 strcpy(tserver.cell, argv[1]);
84 code = ktc_SetToken(&tserver, &token, NULL, 0);
86 printf("%s: failed to set ticket (code %d), are you sure you're authenticated?\n", whoami, code);
91 printf("Authentication established for cell %s.\n", cname);