1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

r5316: Get 'net afskey' into a subcommand of its own, 'net afs key'.

Implement 'net afs impersonate', generate a token for a specified user. You
obviously need to be root for this operation.

Volker
(This used to be commit 5818b092e6e50d38238b0520329eb8912125c90a)
This commit is contained in:
Volker Lendecke 2005-02-10 17:38:49 +00:00 committed by Gerald (Jerry) Carter
parent 7e72aefc0f
commit b6c143a17f
2 changed files with 43 additions and 5 deletions

View File

@ -552,14 +552,16 @@ static int net_getdomainsid(int argc, const char **argv)
#ifdef WITH_FAKE_KASERVER
int net_afskey_usage(int argc, const char **argv)
int net_help_afs(int argc, const char **argv)
{
d_printf(" net afskey filename\n"
d_printf(" net afs key filename\n"
"\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
d_printf(" net afs impersonate <user> <cell>\n"
"\tCreates a token for user@cell\n\n");
return -1;
}
static int net_afskey(int argc, const char **argv)
static int net_afs_key(int argc, const char **argv)
{
int fd;
struct afs_keyfile keyfile;
@ -592,6 +594,42 @@ static int net_afskey(int argc, const char **argv)
return 0;
}
static int net_afs_impersonate(int argc, const char **argv)
{
char *token;
if (argc != 2) {
fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n");
exit(1);
}
token = afs_createtoken_str(argv[0], argv[1]);
if (token == NULL) {
fprintf(stderr, "Could not create token\n");
exit(1);
}
if (!afs_settoken_str(token)) {
fprintf(stderr, "Could not set token into kernel\n");
exit(1);
}
printf("Success: %s@%s\n", argv[0], argv[1]);
return 0;
}
static int net_afs(int argc, const char **argv)
{
struct functable func[] = {
{"key", net_afs_key},
{"impersonate", net_afs_impersonate},
{"help", net_help_afs},
{NULL, NULL}
};
return net_run_function(argc, argv, func, net_help_afs);
}
#endif /* WITH_FAKE_KASERVER */
static uint32 get_maxrid(void)
@ -707,7 +745,7 @@ static struct functable net_func[] = {
{"STATUS", net_status},
{"USERSIDLIST", net_usersidlist},
#ifdef WITH_FAKE_KASERVER
{"AFSKEY", net_afskey},
{"AFS", net_afs},
#endif
{"HELP", net_help},

View File

@ -269,7 +269,7 @@ int net_help(int argc, const char **argv)
{"LOOKUP", net_lookup_usage},
{"USERSIDLIST", net_usersidlist_usage},
#ifdef WITH_FAKE_KASERVER
{"AFSKEY", net_afskey_usage},
{"AFS", net_help_afs},
#endif
{"HELP", help_usage},