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>
17 #include <sys/types.h>
22 #include <netinet/in.h>
24 #include "cellconfig.h"
25 #include <afs/afsutil.h>
27 #include "AFS_component_version_number.c"
32 main(int argc, char **argv)
35 register afs_int32 code;
37 struct afsconf_dir *tdir;
38 struct ktc_principal tserver;
39 struct ktc_token token;
41 strcpy(whoami, argv[0]);
45 ("%s: copies a file system ticket from the local cell to another cell\n",
47 printf("%s: usage is 'setauth <new-cell>\n", whoami);
53 /* lookup the name of the local cell */
54 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
56 printf("copyauth: can't open dir %s\n", AFSDIR_CLIENT_ETC_DIRPATH);
59 code = afsconf_GetLocalCell(tdir, localName, sizeof(localName));
61 printf("%s: can't determine local cell name\n", whoami);
64 /* done with configuration stuff now */
68 /* get ticket in local cell */
69 strcpy(tserver.cell, localName);
70 strcpy(tserver.name, "afs");
71 tserver.instance[0] = 0;
72 code = ktc_GetToken(&tserver, &token, sizeof(token), NULL);
75 ("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n",
76 whoami, tserver.name, tserver.cell, code);
80 /* and now set the ticket in the new cell */
81 strcpy(tserver.cell, argv[1]);
82 code = ktc_SetToken(&tserver, &token, NULL, 0);
85 ("%s: failed to set ticket (code %d), are you sure you're authenticated?\n",
91 printf("Authentication established for cell %s.\n", cname);