svn commit: samba r5317 - in trunk/source/utils: .

vlendec at samba.org vlendec at samba.org
Thu Feb 10 17:40:12 GMT 2005


Author: vlendec
Date: 2005-02-10 17:40:02 +0000 (Thu, 10 Feb 2005)
New Revision: 5317

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5317

Log:
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
Modified:
   trunk/source/utils/net.c
   trunk/source/utils/net_help.c


Changeset:
Modified: trunk/source/utils/net.c
===================================================================
--- trunk/source/utils/net.c	2005-02-10 17:38:49 UTC (rev 5316)
+++ trunk/source/utils/net.c	2005-02-10 17:40:02 UTC (rev 5317)
@@ -552,14 +552,16 @@
 
 #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 at 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 @@
 	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 @@
 	{"STATUS", net_status},
 	{"USERSIDLIST", net_usersidlist},
 #ifdef WITH_FAKE_KASERVER
-	{"AFSKEY", net_afskey},
+	{"AFS", net_afs},
 #endif
 
 	{"HELP", net_help},

Modified: trunk/source/utils/net_help.c
===================================================================
--- trunk/source/utils/net_help.c	2005-02-10 17:38:49 UTC (rev 5316)
+++ trunk/source/utils/net_help.c	2005-02-10 17:40:02 UTC (rev 5317)
@@ -269,7 +269,7 @@
 		{"LOOKUP", net_lookup_usage},
 		{"USERSIDLIST", net_usersidlist_usage},
 #ifdef WITH_FAKE_KASERVER
-		{"AFSKEY", net_afskey_usage},
+		{"AFS", net_help_afs},
 #endif
 
 		{"HELP", help_usage},



More information about the samba-cvs mailing list