2 Samba Unix/Linux SMB client library
4 Copyright (C) 2003 Volker Lendecke (vl@samba.org)
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "utils/net.h"
23 int net_afs_usage(struct net_context
*c
, int argc
, const char **argv
)
25 d_printf(" net afs key filename\n"
26 "\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
27 d_printf(" net afs impersonate <user> <cell>\n"
28 "\tCreates a token for user@cell\n\n");
32 int net_afs_key(struct net_context
*c
, int argc
, const char **argv
)
35 struct afs_keyfile keyfile
;
38 d_printf("usage: 'net afs key <keyfile> cell'\n");
42 if (!secrets_init()) {
43 d_fprintf(stderr
, "Could not open secrets.tdb\n");
47 if ((fd
= open(argv
[0], O_RDONLY
, 0)) < 0) {
48 d_fprintf(stderr
, "Could not open %s\n", argv
[0]);
52 if (read(fd
, &keyfile
, sizeof(keyfile
)) != sizeof(keyfile
)) {
53 d_fprintf(stderr
, "Could not read keyfile\n");
57 if (!secrets_store_afs_keyfile(argv
[1], &keyfile
)) {
58 d_fprintf(stderr
, "Could not write keyfile to secrets.tdb\n");
65 int net_afs_impersonate(struct net_context
*c
, int argc
,
71 fprintf(stderr
, "Usage: net afs impersonate <user> <cell>\n");
75 token
= afs_createtoken_str(argv
[0], argv
[1]);
78 fprintf(stderr
, "Could not create token\n");
82 if (!afs_settoken_str(token
)) {
83 fprintf(stderr
, "Could not set token into kernel\n");
87 printf("Success: %s@%s\n", argv
[0], argv
[1]);
91 int net_afs(struct net_context
*c
, int argc
, const char **argv
)
93 struct functable func
[] = {
98 "Import an OpenAFS keyfile",
99 "net afs key <filename>\n"
100 " Import kefile from <filename>."
107 "net afs impersonate <user> <cell>\n"
108 " Create token for user@cell"
110 {NULL
, NULL
, 0, NULL
, NULL
}
112 return net_run_function(c
, argc
, argv
, "net afs", func
);