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>
15 #include <sys/types.h>
20 #include <netinet/in.h>
22 #include "cellconfig.h"
23 #include <afs/afsutil.h>
25 #include "AFS_component_version_number.c"
30 main(int argc, char **argv)
35 struct afsconf_dir *tdir;
36 struct ktc_principal tserver;
37 struct ktc_token token;
39 strcpy(whoami, argv[0]);
43 ("%s: copies a file system ticket from the local cell to another cell\n",
45 printf("%s: usage is 'setauth <new-cell>\n", whoami);
51 /* lookup the name of the local cell */
52 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
54 printf("copyauth: can't open dir %s\n", AFSDIR_CLIENT_ETC_DIRPATH);
57 code = afsconf_GetLocalCell(tdir, localName, sizeof(localName));
59 printf("%s: can't determine local cell name\n", whoami);
62 /* done with configuration stuff now */
66 /* get ticket in local cell */
67 strcpy(tserver.cell, localName);
68 strcpy(tserver.name, "afs");
69 tserver.instance[0] = 0;
70 code = ktc_GetToken(&tserver, &token, sizeof(token), NULL);
73 ("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n",
74 whoami, tserver.name, tserver.cell, code);
78 /* and now set the ticket in the new cell */
79 strcpy(tserver.cell, argv[1]);
80 code = ktc_SetToken(&tserver, &token, NULL, 0);
83 ("%s: failed to set ticket (code %d), are you sure you're authenticated?\n",
89 printf("Authentication established for cell %s.\n", cname);