summaryrefslogtreecommitdiff
path: root/source3/utils/net.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-02-10 17:38:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:37 -0500
commitb6c143a17f40f9b34da4f0aeb83b0180d5a198e0 (patch)
tree66437dc885988cd2ec9c437bf782679462cf9ce2 /source3/utils/net.c
parent7e72aefc0f9fa8fb41d4949796330c493e919651 (diff)
downloadsamba-b6c143a17f40f9b34da4f0aeb83b0180d5a198e0.tar.gz
samba-b6c143a17f40f9b34da4f0aeb83b0180d5a198e0.tar.bz2
samba-b6c143a17f40f9b34da4f0aeb83b0180d5a198e0.zip
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)
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r--source3/utils/net.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index cfbc8aca51..9c05828357 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -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},