summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-11-22 14:17:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:01 -0500
commitb724a280197e01b4b1dd0d82edff1d97f511eb44 (patch)
tree5aae2515f0d3794dd436a17b57353d895f77c009 /source3/utils
parent45fcd0f0b7166d36da2453b0e3bf57d4b02228a7 (diff)
downloadsamba-b724a280197e01b4b1dd0d82edff1d97f511eb44.tar.gz
samba-b724a280197e01b4b1dd0d82edff1d97f511eb44.tar.bz2
samba-b724a280197e01b4b1dd0d82edff1d97f511eb44.zip
r19835: Some net sam policy improvements.
Thanks to Karolin Seeger <ks@sernet.de> Volker (This used to be commit 2091018a534006cddaa5cf52f564fd7e023473b6)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_sam.c127
1 files changed, 77 insertions, 50 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index 03e0ff0a9c..b041bd7a65 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -357,78 +357,105 @@ static int net_sam_set(int argc, const char **argv)
}
/*
- * Change account policies
+ * Manage account policies
*/
-static int net_sam_policy(int argc, const char **argv)
+static int net_sam_policy_set(int argc, const char **argv)
{
-
const char *account_policy = NULL;
uint32 value, old_value;
int field;
- if ((argc < 1) || (argc > 2)) {
- d_fprintf(stderr, "usage: net sam policy \"<account policy>\" "
- "-> show current value\n");
- d_fprintf(stderr, "usage: net sam policy \"<account policy>\" "
- "<value> -> set a new value\n");
- return -1;
- }
+ if (argc != 2) {
+ d_fprintf(stderr, "usage: net sam policy set"
+ "\"<account policy>\" <value> \n");
+ return -1;
+ }
+ value = strtoul(argv[1], NULL, 10);
account_policy = argv[0];
field = account_policy_name_to_fieldnum(account_policy);
- if (field == 0) {
- char *apn = account_policy_names_list();
- d_fprintf(stderr, "No account policy by that name!\n");
- if (apn) {
- d_fprintf(stderr, "Valid account policies "
- "are:\n%s\n", apn);
- }
- SAFE_FREE(apn);
- return -1;
- }
+ printf("Account policy \"%s\" description: %s\n", account_policy,
+ account_policy_get_desc(field));
+ printf("Account policy \"%s\" value was: %d\n", account_policy,
+ old_value);
- if (!pdb_get_account_policy(field, &old_value)) {
- fprintf(stderr, "Valid account policy, but unable to "
- "fetch value!\n");
- return -1;
- }
+ if (!pdb_set_account_policy(field, value)) {
+ d_fprintf(stderr, "Setting account policy %s to %u failed \n",
+ account_policy, value);
+ }
- if (argc == 1) {
- /*
- * Just read the value
- */
+ printf("Account policy \"%s\" value is now: %d\n", account_policy,
+ value);
- printf("Account policy \"%s\" description: %s\n",
- account_policy, account_policy_get_desc(field));
- printf("Account policy \"%s\" value is: %d\n", account_policy,
- old_value);
- return 0;
- }
+ return 0;
+}
- /*
- * Here we know we have 2 args, so set it
- */
+static int net_sam_policy_show(int argc, const char **argv)
+{
+ const char *account_policy = NULL;
+ uint32 old_value;
+ int field;
+
+ if (argc != 1) {
+ d_fprintf(stderr, "usage: net sam policy show"
+ " \"<account policy>\" \n");
+ return -1;
+ }
- value = strtoul(argv[1], NULL, 10);
+ account_policy = argv[0];
+ field = account_policy_name_to_fieldnum(account_policy);
+
+ if (field == 0) {
+ char *apn = account_policy_names_list();
+ d_fprintf(stderr, "No account policy by that name!\n");
+ if (apn) {
+ d_fprintf(stderr, "Valid account policies "
+ "are:\n%s\n", apn);
+ }
+ SAFE_FREE(apn);
+ return -1;
+ }
- printf("Account policy \"%s\" description: %s\n", account_policy,
- account_policy_get_desc(field));
- printf("Account policy \"%s\" value was: %d\n", account_policy,
+ if (!pdb_get_account_policy(field, &old_value)) {
+ fprintf(stderr, "Valid account policy, but unable to "
+ "fetch value!\n");
+ return -1;
+ }
+
+ printf("Account policy \"%s\" description: %s\n",
+ account_policy, account_policy_get_desc(field));
+ printf("Account policy \"%s\" value is: %d\n", account_policy,
old_value);
+ return 0;
+}
- if (!pdb_set_account_policy(field, value)) {
- d_fprintf(stderr, "Setting account policy %s to %u failed \n",
- account_policy, value);
+static int net_sam_policy_list(int argc, const char **argv)
+{
+ char *apn = account_policy_names_list();
+ if (apn) {
+ d_fprintf(stderr, "Valid account policies "
+ "are:\n\n%s\n", apn);
}
-
- printf("Account policy \"%s\" value is now: %d\n", account_policy,
- value);
-
- return 0;
+ SAFE_FREE(apn);
+ return -1;
}
+static int net_sam_policy(int argc, const char **argv)
+{
+ struct functable2 func[] = {
+ { "list", net_sam_policy_list,
+ "List account policies" },
+ { "show", net_sam_policy_show,
+ "Show account policies" },
+ { "set", net_sam_policy_set,
+ "Change account policies" },
+ {NULL, NULL}
+ };
+
+ return net_run_function2(argc, argv, "net sam policy", func);
+}
/*
* Map a unix group to a domain group