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 <afs/afsutil.h>
18 #include "cellconfig.h"
20 #include "AFS_component_version_number.c"
25 main(int argc, char **argv)
30 struct afsconf_dir *tdir;
31 struct ktc_principal tserver;
32 struct ktc_token token;
34 strcpy(whoami, argv[0]);
38 ("%s: copies a file system ticket from the local cell to another cell\n",
40 printf("%s: usage is 'setauth <new-cell>\n", whoami);
46 /* lookup the name of the local cell */
47 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
49 printf("copyauth: can't open dir %s\n", AFSDIR_CLIENT_ETC_DIRPATH);
52 code = afsconf_GetLocalCell(tdir, localName, sizeof(localName));
54 printf("%s: can't determine local cell name\n", whoami);
57 /* done with configuration stuff now */
61 /* get ticket in local cell */
62 strcpy(tserver.cell, localName);
63 strcpy(tserver.name, "afs");
64 tserver.instance[0] = 0;
65 code = ktc_GetToken(&tserver, &token, sizeof(token), NULL);
68 ("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n",
69 whoami, tserver.name, tserver.cell, code);
73 /* and now set the ticket in the new cell */
74 strcpy(tserver.cell, argv[1]);
75 code = ktc_SetToken(&tserver, &token, NULL, 0);
78 ("%s: failed to set ticket (code %d), are you sure you're authenticated?\n",
84 printf("Authentication established for cell %s.\n", cname);