diff options
author | bubulle <bubulle@alioth.debian.org> | 2008-11-01 11:09:46 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2008-11-01 11:09:46 +0000 |
commit | a2b71a0141763c20552bb45eeb4cb78c4b513118 (patch) | |
tree | 85b64d98387145ea4e00c1b529e1820542a979a3 /source/utils/net_sam.c | |
parent | 2203bd59918d6d70515f9dad601cb5c0ef098092 (diff) | |
download | samba-a2b71a0141763c20552bb45eeb4cb78c4b513118.tar.gz |
Revert the merge of 3.3.0~pre2 in upstream branch
git-svn-id: svn://svn.debian.org/svn/pkg-samba/branches/samba/upstream@2200 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source/utils/net_sam.c')
-rw-r--r-- | source/utils/net_sam.c | 624 |
1 files changed, 181 insertions, 443 deletions
diff --git a/source/utils/net_sam.c b/source/utils/net_sam.c index ce132131f7..b5cd8e637a 100644 --- a/source/utils/net_sam.c +++ b/source/utils/net_sam.c @@ -25,8 +25,7 @@ * Set a user's data */ -static int net_sam_userset(struct net_context *c, int argc, const char **argv, - const char *field, +static int net_sam_userset(int argc, const char **argv, const char *field, bool (*fn)(struct samu *, const char *, enum pdb_value_state)) { @@ -36,7 +35,7 @@ static int net_sam_userset(struct net_context *c, int argc, const char **argv, const char *dom, *name; NTSTATUS status; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam set %s <user> <value>\n", field); return -1; @@ -82,45 +81,39 @@ static int net_sam_userset(struct net_context *c, int argc, const char **argv, return 0; } -static int net_sam_set_fullname(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_fullname(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "fullname", + return net_sam_userset(argc, argv, "fullname", pdb_set_fullname); } -static int net_sam_set_logonscript(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_logonscript(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "logonscript", + return net_sam_userset(argc, argv, "logonscript", pdb_set_logon_script); } -static int net_sam_set_profilepath(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_profilepath(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "profilepath", + return net_sam_userset(argc, argv, "profilepath", pdb_set_profile_path); } -static int net_sam_set_homedrive(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_homedrive(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "homedrive", + return net_sam_userset(argc, argv, "homedrive", pdb_set_dir_drive); } -static int net_sam_set_homedir(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_homedir(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "homedir", + return net_sam_userset(argc, argv, "homedir", pdb_set_homedir); } -static int net_sam_set_workstations(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_workstations(int argc, const char **argv) { - return net_sam_userset(c, argc, argv, "workstations", + return net_sam_userset(argc, argv, "workstations", pdb_set_workstations); } @@ -128,8 +121,7 @@ static int net_sam_set_workstations(struct net_context *c, int argc, * Set account flags */ -static int net_sam_set_userflag(struct net_context *c, int argc, - const char **argv, const char *field, +static int net_sam_set_userflag(int argc, const char **argv, const char *field, uint16 flag) { struct samu *sam_acct = NULL; @@ -139,9 +131,8 @@ static int net_sam_set_userflag(struct net_context *c, int argc, NTSTATUS status; uint16 acct_flags; - if ((argc != 2) || c->display_usage || - (!strequal(argv[1], "yes") && - !strequal(argv[1], "no"))) { + if ((argc != 2) || (!strequal(argv[1], "yes") && + !strequal(argv[1], "no"))) { d_fprintf(stderr, "usage: net sam set %s <user> [yes|no]\n", field); return -1; @@ -193,36 +184,31 @@ static int net_sam_set_userflag(struct net_context *c, int argc, return 0; } -static int net_sam_set_disabled(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_disabled(int argc, const char **argv) { - return net_sam_set_userflag(c, argc, argv, "disabled", ACB_DISABLED); + return net_sam_set_userflag(argc, argv, "disabled", ACB_DISABLED); } -static int net_sam_set_pwnotreq(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_pwnotreq(int argc, const char **argv) { - return net_sam_set_userflag(c, argc, argv, "pwnotreq", ACB_PWNOTREQ); + return net_sam_set_userflag(argc, argv, "pwnotreq", ACB_PWNOTREQ); } -static int net_sam_set_autolock(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_autolock(int argc, const char **argv) { - return net_sam_set_userflag(c, argc, argv, "autolock", ACB_AUTOLOCK); + return net_sam_set_userflag(argc, argv, "autolock", ACB_AUTOLOCK); } -static int net_sam_set_pwnoexp(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_pwnoexp(int argc, const char **argv) { - return net_sam_set_userflag(c, argc, argv, "pwnoexp", ACB_PWNOEXP); + return net_sam_set_userflag(argc, argv, "pwnoexp", ACB_PWNOEXP); } /* * Set pass last change time, based on force pass change now */ -static int net_sam_set_pwdmustchangenow(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_pwdmustchangenow(int argc, const char **argv) { struct samu *sam_acct = NULL; DOM_SID sid; @@ -230,9 +216,8 @@ static int net_sam_set_pwdmustchangenow(struct net_context *c, int argc, const char *dom, *name; NTSTATUS status; - if ((argc != 2) || c->display_usage || - (!strequal(argv[1], "yes") && - !strequal(argv[1], "no"))) { + if ((argc != 2) || (!strequal(argv[1], "yes") && + !strequal(argv[1], "no"))) { d_fprintf(stderr, "usage: net sam set pwdmustchangenow <user> [yes|no]\n"); return -1; } @@ -284,8 +269,7 @@ static int net_sam_set_pwdmustchangenow(struct net_context *c, int argc, * Set a user's or a group's comment */ -static int net_sam_set_comment(struct net_context *c, int argc, - const char **argv) +static int net_sam_set_comment(int argc, const char **argv) { GROUP_MAP map; DOM_SID sid; @@ -293,7 +277,7 @@ static int net_sam_set_comment(struct net_context *c, int argc, const char *dom, *name; NTSTATUS status; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam set comment <name> " "<comment>\n"); return -1; @@ -306,7 +290,7 @@ static int net_sam_set_comment(struct net_context *c, int argc, } if (type == SID_NAME_USER) { - return net_sam_userset(c, argc, argv, "comment", + return net_sam_userset(argc, argv, "comment", pdb_set_acct_desc); } @@ -338,116 +322,44 @@ static int net_sam_set_comment(struct net_context *c, int argc, return 0; } -static int net_sam_set(struct net_context *c, int argc, const char **argv) +static int net_sam_set(int argc, const char **argv) { - struct functable func[] = { - { - "homedir", - net_sam_set_homedir, - NET_TRANSPORT_LOCAL, - "Change a user's home directory", - "net sam set homedir\n" - " Change a user's home directory" - }, - { - "profilepath", - net_sam_set_profilepath, - NET_TRANSPORT_LOCAL, - "Change a user's profile path", - "net sam set profilepath\n" - " Change a user's profile path" - }, - { - "comment", - net_sam_set_comment, - NET_TRANSPORT_LOCAL, - "Change a users or groups description", - "net sam set comment\n" - " Change a users or groups description" - }, - { - "fullname", - net_sam_set_fullname, - NET_TRANSPORT_LOCAL, - "Change a user's full name", - "net sam set fullname\n" - " Change a user's full name" - }, - { - "logonscript", - net_sam_set_logonscript, - NET_TRANSPORT_LOCAL, - "Change a user's logon script", - "net sam set logonscript\n" - " Change a user's logon script" - }, - { - "homedrive", - net_sam_set_homedrive, - NET_TRANSPORT_LOCAL, - "Change a user's home drive", - "net sam set homedrive\n" - " Change a user's home drive" - }, - { - "workstations", - net_sam_set_workstations, - NET_TRANSPORT_LOCAL, - "Change a user's allowed workstations", - "net sam set workstations\n" - " Change a user's allowed workstations" - }, - { - "disabled", - net_sam_set_disabled, - NET_TRANSPORT_LOCAL, - "Disable/Enable a user", - "net sam set disable\n" - " Disable/Enable a user" - }, - { - "pwnotreq", - net_sam_set_pwnotreq, - NET_TRANSPORT_LOCAL, - "Disable/Enable the password not required flag", - "net sam set pwnotreq\n" - " Disable/Enable the password not required flag" - }, - { - "autolock", - net_sam_set_autolock, - NET_TRANSPORT_LOCAL, - "Disable/Enable a user's lockout flag", - "net sam set autolock\n" - " Disable/Enable a user's lockout flag" - }, - { - "pwnoexp", - net_sam_set_pwnoexp, - NET_TRANSPORT_LOCAL, - "Disable/Enable whether a user's pw does not expire", - "net sam set pwnoexp\n" - " Disable/Enable whether a user's pw does not expire" - }, - { - "pwdmustchangenow", - net_sam_set_pwdmustchangenow, - NET_TRANSPORT_LOCAL, - "Force users password must change at next logon", - "net sam set pwdmustchangenow\n" - " Force users password must change at next logon" - }, - {NULL, NULL, 0, NULL, NULL} + struct functable2 func[] = { + { "homedir", net_sam_set_homedir, + "Change a user's home directory" }, + { "profilepath", net_sam_set_profilepath, + "Change a user's profile path" }, + { "comment", net_sam_set_comment, + "Change a users or groups description" }, + { "fullname", net_sam_set_fullname, + "Change a user's full name" }, + { "logonscript", net_sam_set_logonscript, + "Change a user's logon script" }, + { "homedrive", net_sam_set_homedrive, + "Change a user's home drive" }, + { "workstations", net_sam_set_workstations, + "Change a user's allowed workstations" }, + { "disabled", net_sam_set_disabled, + "Disable/Enable a user" }, + { "pwnotreq", net_sam_set_pwnotreq, + "Disable/Enable the password not required flag" }, + { "autolock", net_sam_set_autolock, + "Disable/Enable a user's lockout flag" }, + { "pwnoexp", net_sam_set_pwnoexp, + "Disable/Enable whether a user's pw does not expire" }, + { "pwdmustchangenow", net_sam_set_pwdmustchangenow, + "Force users password must change at next logon" }, + {NULL, NULL} }; - return net_run_function(c, argc, argv, "net sam set", func); + return net_run_function2(argc, argv, "net sam set", func); } /* * Manage account policies */ -static int net_sam_policy_set(struct net_context *c, int argc, const char **argv) +static int net_sam_policy_set(int argc, const char **argv) { const char *account_policy = NULL; uint32 value = 0; @@ -455,7 +367,7 @@ static int net_sam_policy_set(struct net_context *c, int argc, const char **argv int field; char *endptr; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam policy set " "\"<account policy>\" <value> \n"); return -1; @@ -515,18 +427,18 @@ static int net_sam_policy_set(struct net_context *c, int argc, const char **argv return 0; } -static int net_sam_policy_show(struct net_context *c, int argc, const char **argv) +static int net_sam_policy_show(int argc, const char **argv) { const char *account_policy = NULL; uint32 old_value; int field; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam policy show" " \"<account policy>\" \n"); return -1; } - + account_policy = argv[0]; field = account_policy_name_to_fieldnum(account_policy); @@ -552,7 +464,7 @@ static int net_sam_policy_show(struct net_context *c, int argc, const char **arg "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, @@ -560,19 +472,11 @@ static int net_sam_policy_show(struct net_context *c, int argc, const char **arg return 0; } -static int net_sam_policy_list(struct net_context *c, int argc, const char **argv) +static int net_sam_policy_list(int argc, const char **argv) { const char **names; int count; int i; - - if (c->display_usage) { - d_printf("Usage:\n" - "net sam policy list\n" - " List account policies\n"); - return 0; - } - account_policy_names_list(&names, &count); if (count != 0) { d_fprintf(stderr, "Valid account policies " @@ -585,47 +489,28 @@ static int net_sam_policy_list(struct net_context *c, int argc, const char **arg return -1; } -static int net_sam_policy(struct net_context *c, int argc, const char **argv) +static int net_sam_policy(int argc, const char **argv) { - struct functable func[] = { - { - "list", - net_sam_policy_list, - NET_TRANSPORT_LOCAL, - "List account policies", - "net sam policy list\n" - " List account policies" - }, - { - "show", - net_sam_policy_show, - NET_TRANSPORT_LOCAL, - "Show account policies", - "net sam policy show\n" - " Show account policies" - }, - { - "set", - net_sam_policy_set, - NET_TRANSPORT_LOCAL, - "Change account policies", - "net sam policy set\n" - " Change account policies" - }, - {NULL, NULL, 0, NULL, NULL} + 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_function(c, argc, argv, "net sam policy", func); + return net_run_function2(argc, argv, "net sam policy", func); } extern PRIVS privs[]; -static int net_sam_rights_list(struct net_context *c, int argc, - const char **argv) +static int net_sam_rights_list(int argc, const char **argv) { SE_PRIV mask; - if (argc > 1 || c->display_usage) { + if (argc > 1) { d_fprintf(stderr, "usage: net sam rights list [privilege name]\n"); return -1; } @@ -671,15 +556,14 @@ static int net_sam_rights_list(struct net_context *c, int argc, return -1; } -static int net_sam_rights_grant(struct net_context *c, int argc, - const char **argv) +static int net_sam_rights_grant(int argc, const char **argv) { DOM_SID sid; enum lsa_SidType type; const char *dom, *name; SE_PRIV mask; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam rights grant <name> " "<right>\n"); return -1; @@ -705,14 +589,14 @@ static int net_sam_rights_grant(struct net_context *c, int argc, return 0; } -static int net_sam_rights_revoke(struct net_context *c, int argc, const char **argv) +static int net_sam_rights_revoke(int argc, const char **argv) { DOM_SID sid; enum lsa_SidType type; const char *dom, *name; SE_PRIV mask; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam rights revoke <name> " "<right>\n"); return -1; @@ -738,36 +622,18 @@ static int net_sam_rights_revoke(struct net_context *c, int argc, const char **a return 0; } -static int net_sam_rights(struct net_context *c, int argc, const char **argv) +static int net_sam_rights(int argc, const char **argv) { - struct functable func[] = { - { - "list", - net_sam_rights_list, - NET_TRANSPORT_LOCAL, - "List possible user rights", - "net sam rights list\n" - " List possible user rights" - }, - { - "grant", - net_sam_rights_grant, - NET_TRANSPORT_LOCAL, - "Grant a right", - "net sam rights grant\n" - " Grant a right" - }, - { - "revoke", - net_sam_rights_revoke, - NET_TRANSPORT_LOCAL, - "Revoke a right", - "net sam rights revoke\n" - " Revoke a right" - }, - {NULL, NULL, 0, NULL, NULL} + struct functable2 func[] = { + { "list", net_sam_rights_list, + "List possible user rights" }, + { "grant", net_sam_rights_grant, + "Grant a right" }, + { "revoke", net_sam_rights_revoke, + "Revoke a right" }, + { NULL } }; - return net_run_function(c, argc, argv, "net sam rights", func); + return net_run_function2(argc, argv, "net sam rights", func); } /* @@ -829,13 +695,13 @@ static NTSTATUS map_unix_group(const struct group *grp, GROUP_MAP *pmap) return status; } -static int net_sam_mapunixgroup(struct net_context *c, int argc, const char **argv) +static int net_sam_mapunixgroup(int argc, const char **argv) { NTSTATUS status; GROUP_MAP map; struct group *grp; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam mapunixgroup <name>\n"); return -1; } @@ -891,13 +757,13 @@ static NTSTATUS unmap_unix_group(const struct group *grp, GROUP_MAP *pmap) return status; } -static int net_sam_unmapunixgroup(struct net_context *c, int argc, const char **argv) +static int net_sam_unmapunixgroup(int argc, const char **argv) { NTSTATUS status; GROUP_MAP map; struct group *grp; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam unmapunixgroup <name>\n"); return -1; } @@ -925,12 +791,12 @@ static int net_sam_unmapunixgroup(struct net_context *c, int argc, const char ** * Create a local group */ -static int net_sam_createlocalgroup(struct net_context *c, int argc, const char **argv) +static int net_sam_createlocalgroup(int argc, const char **argv) { NTSTATUS status; uint32 rid; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam createlocalgroup <name>\n"); return -1; } @@ -958,14 +824,14 @@ static int net_sam_createlocalgroup(struct net_context *c, int argc, const char * Delete a local group */ -static int net_sam_deletelocalgroup(struct net_context *c, int argc, const char **argv) +static int net_sam_deletelocalgroup(int argc, const char **argv) { DOM_SID sid; enum lsa_SidType type; const char *dom, *name; NTSTATUS status; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam deletelocalgroup <name>\n"); return -1; } @@ -996,10 +862,10 @@ static int net_sam_deletelocalgroup(struct net_context *c, int argc, const char } /* - * Create a builtin group + * Create a local group */ -static int net_sam_createbuiltingroup(struct net_context *c, int argc, const char **argv) +static int net_sam_createbuiltingroup(int argc, const char **argv) { NTSTATUS status; uint32 rid; @@ -1007,28 +873,28 @@ static int net_sam_createbuiltingroup(struct net_context *c, int argc, const cha fstring groupname; DOM_SID sid; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam createbuiltingroup <name>\n"); return -1; } if (!winbind_ping()) { - d_fprintf(stderr, "winbind seems not to run. createbuiltingroup " + d_fprintf(stderr, "winbind seems not to run. createlocalgroup " "only works when winbind runs.\n"); return -1; } /* validate the name and get the group */ - + fstrcpy( groupname, "BUILTIN\\" ); fstrcat( groupname, argv[0] ); - + if ( !lookup_name(talloc_tos(), groupname, LOOKUP_NAME_ALL, NULL, NULL, &sid, &type)) { d_fprintf(stderr, "%s is not a BUILTIN group\n", argv[0]); return -1; } - + if ( !sid_peek_rid( &sid, &rid ) ) { d_fprintf(stderr, "Failed to get RID for %s\n", argv[0]); return -1; @@ -1051,14 +917,14 @@ static int net_sam_createbuiltingroup(struct net_context *c, int argc, const cha * Add a group member */ -static int net_sam_addmem(struct net_context *c, int argc, const char **argv) +static int net_sam_addmem(int argc, const char **argv) { const char *groupdomain, *groupname, *memberdomain, *membername; DOM_SID group, member; enum lsa_SidType grouptype, membertype; NTSTATUS status; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam addmem <group> <member>\n"); return -1; } @@ -1082,7 +948,7 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv) } if ( !lookup_sid(talloc_tos(), &member, &memberdomain, - &membername, &membertype) ) + &membername, &membertype) ) { d_fprintf(stderr, "Could not resolve SID %s\n", argv[1]); return -1; @@ -1112,7 +978,7 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv) return -1; } - d_printf("Added %s\\%s to %s\\%s\n", memberdomain, membername, + d_printf("Added %s\\%s to %s\\%s\n", memberdomain, membername, groupdomain, groupname); return 0; @@ -1122,7 +988,7 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv) * Delete a group member */ -static int net_sam_delmem(struct net_context *c, int argc, const char **argv) +static int net_sam_delmem(int argc, const char **argv) { const char *groupdomain, *groupname; const char *memberdomain = NULL; @@ -1131,7 +997,7 @@ static int net_sam_delmem(struct net_context *c, int argc, const char **argv) enum lsa_SidType grouptype; NTSTATUS status; - if (argc != 2 || c->display_usage) { + if (argc != 2) { d_fprintf(stderr, "usage: net sam delmem <group> <member>\n"); return -1; } @@ -1182,14 +1048,14 @@ static int net_sam_delmem(struct net_context *c, int argc, const char **argv) * List group members */ -static int net_sam_listmem(struct net_context *c, int argc, const char **argv) +static int net_sam_listmem(int argc, const char **argv) { const char *groupdomain, *groupname; DOM_SID group; enum lsa_SidType grouptype; NTSTATUS status; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam listmem <group>\n"); return -1; } @@ -1204,7 +1070,7 @@ static int net_sam_listmem(struct net_context *c, int argc, const char **argv) (grouptype == SID_NAME_WKN_GRP)) { DOM_SID *members = NULL; size_t i, num_members = 0; - + status = pdb_enum_aliasmem(&group, &members, &num_members); if (!NT_STATUS_IS_OK(status)) { @@ -1238,12 +1104,12 @@ static int net_sam_listmem(struct net_context *c, int argc, const char **argv) /* * Do the listing */ -static int net_sam_do_list(struct net_context *c, int argc, const char **argv, +static int net_sam_do_list(int argc, const char **argv, struct pdb_search *search, const char *what) { bool verbose = (argc == 1); - if ((argc > 1) || c->display_usage || + if ((argc > 1) || ((argc == 1) && !strequal(argv[0], "verbose"))) { d_fprintf(stderr, "usage: net sam list %s [verbose]\n", what); return -1; @@ -1254,7 +1120,7 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv, return -1; } - while (true) { + while (True) { struct samr_displayentry entry; if (!search->next_entry(search, &entry)) { break; @@ -1273,39 +1139,34 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv, return 0; } -static int net_sam_list_users(struct net_context *c, int argc, - const char **argv) +static int net_sam_list_users(int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_users(ACB_NORMAL), + return net_sam_do_list(argc, argv, pdb_search_users(ACB_NORMAL), "users"); } -static int net_sam_list_groups(struct net_context *c, int argc, - const char **argv) +static int net_sam_list_groups(int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_groups(), "groups"); + return net_sam_do_list(argc, argv, pdb_search_groups(), "groups"); } -static int net_sam_list_localgroups(struct net_context *c, int argc, - const char **argv) +static int net_sam_list_localgroups(int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, + return net_sam_do_list(argc, argv, pdb_search_aliases(get_global_sam_sid()), "localgroups"); } -static int net_sam_list_builtin(struct net_context *c, int argc, - const char **argv) +static int net_sam_list_builtin(int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, + return net_sam_do_list(argc, argv, pdb_search_aliases(&global_sid_Builtin), "builtin"); } -static int net_sam_list_workstations(struct net_context *c, int argc, - const char **argv) +static int net_sam_list_workstations(int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, + return net_sam_do_list(argc, argv, pdb_search_users(ACB_WSTRUST), "workstations"); } @@ -1314,66 +1175,36 @@ static int net_sam_list_workstations(struct net_context *c, int argc, * List stuff */ -static int net_sam_list(struct net_context *c, int argc, const char **argv) +static int net_sam_list(int argc, const char **argv) { - struct functable func[] = { - { - "users", - net_sam_list_users, - NET_TRANSPORT_LOCAL, - "List SAM users", - "net sam list users\n" - " List SAM users" - }, - { - "groups", - net_sam_list_groups, - NET_TRANSPORT_LOCAL, - "List SAM groups", - "net sam list groups\n" - " List SAM groups" - }, - { - "localgroups", - net_sam_list_localgroups, - NET_TRANSPORT_LOCAL, - "List SAM local groups", - "net sam list localgroups\n" - " List SAM local groups" - }, - { - "builtin", - net_sam_list_builtin, - NET_TRANSPORT_LOCAL, - "List builtin groups", - "net sam list builtin\n" - " List builtin groups" - }, - { - "workstations", - net_sam_list_workstations, - NET_TRANSPORT_LOCAL, - "List domain member workstations", - "net sam list workstations\n" - " List domain member workstations" - }, - {NULL, NULL, 0, NULL, NULL} + struct functable2 func[] = { + { "users", net_sam_list_users, + "List SAM users" }, + { "groups", net_sam_list_groups, + "List SAM groups" }, + { "localgroups", net_sam_list_localgroups, + "List SAM local groups" }, + { "builtin", net_sam_list_builtin, + "List builtin groups" }, + { "workstations", net_sam_list_workstations, + "List domain member workstations" }, + {NULL, NULL} }; - return net_run_function(c, argc, argv, "net sam list", func); + return net_run_function2(argc, argv, "net sam list", func); } /* * Show details of SAM entries */ -static int net_sam_show(struct net_context *c, int argc, const char **argv) +static int net_sam_show(int argc, const char **argv) { DOM_SID sid; enum lsa_SidType type; const char *dom, *name; - if (argc != 1 || c->display_usage) { + if (argc != 1) { d_fprintf(stderr, "usage: net sam show <name>\n"); return -1; } @@ -1397,7 +1228,7 @@ static int net_sam_show(struct net_context *c, int argc, const char **argv) * if ldapsam:editposix is enabled */ -static int net_sam_provision(struct net_context *c, int argc, const char **argv) +static int net_sam_provision(int argc, const char **argv) { TALLOC_CTX *tc; char *ldap_bk; @@ -1411,13 +1242,6 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv) struct samu *samuser; struct passwd *pwd; - if (c->display_usage) { - d_printf("Usage:\n" - "net sam provision\n" - " Init an LDAP tree with default users/groups\n"); - return 0; - } - tc = talloc_new(NULL); if (!tc) { d_fprintf(stderr, "Out of Memory!\n"); @@ -1443,8 +1267,8 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv) goto failed; } - if (!lp_parm_bool(-1, "ldapsam", "trusted", false) || - !lp_parm_bool(-1, "ldapsam", "editposix", false)) { + if (!lp_parm_bool(-1, "ldapsam", "trusted", False) || + !lp_parm_bool(-1, "ldapsam", "editposix", False)) { d_fprintf(stderr, "Provisioning works only if ldapsam:trusted" " and ldapsam:editposix are enabled.\n"); @@ -1806,133 +1630,47 @@ failed: /*********************************************************** migrated functionality from smbgroupedit **********************************************************/ -int net_sam(struct net_context *c, int argc, const char **argv) +int net_sam(int argc, const char **argv) { - struct functable func[] = { - { - "createbuiltingroup", - net_sam_createbuiltingroup, - NET_TRANSPORT_LOCAL, - "Create a new BUILTIN group", - "net sam createbuiltingroup\n" - " Create a new BUILTIN group" - }, - { - "createlocalgroup", - net_sam_createlocalgroup, - NET_TRANSPORT_LOCAL, - "Create a new local group", - "net sam createlocalgroup\n" - " Create a new local group" - }, - { - "deletelocalgroup", - net_sam_deletelocalgroup, - NET_TRANSPORT_LOCAL, - "Delete an existing local group", - "net sam deletelocalgroup\n" - " Delete an existing local group" - }, - { - "mapunixgroup", - net_sam_mapunixgroup, - NET_TRANSPORT_LOCAL, - "Map a unix group to a domain group", - "net sam mapunixgroup\n" - " Map a unix group to a domain group" - }, - { - "unmapunixgroup", - net_sam_unmapunixgroup, - NET_TRANSPORT_LOCAL, - "Remove a group mapping of an unix group to a domain " - "group", - "net sam unmapunixgroup\n" - " Remove a group mapping of an unix group to a " - "domain group" - }, - { - "addmem", - net_sam_addmem, - NET_TRANSPORT_LOCAL, - "Add a member to a group", - "net sam addmem\n" - " Add a member to a group" - }, - { - "delmem", - net_sam_delmem, - NET_TRANSPORT_LOCAL, - "Delete a member from a group", - "net sam delmem\n" - " Delete a member from a group" - }, - { - "listmem", - net_sam_listmem, - NET_TRANSPORT_LOCAL, - "List group members", - "net sam listmem\n" - " List group members" - }, - { - "list", - net_sam_list, - NET_TRANSPORT_LOCAL, - "List users, groups and local groups", - "net sam list\n" - " List users, groups and local groups" - }, - { - "show", - net_sam_show, - NET_TRANSPORT_LOCAL, - "Show details of a SAM entry", - "net sam show\n" - " Show details of a SAM entry" - }, - { - "set", - net_sam_set, - NET_TRANSPORT_LOCAL, - "Set details of a SAM account", - "net sam set\n" - " Set details of a SAM account" - }, - { - "policy", - net_sam_policy, - NET_TRANSPORT_LOCAL, - "Set account policies", - "net sam policy\n" - " Set account policies" - }, - { - "rights", - net_sam_rights, - NET_TRANSPORT_LOCAL, - "Manipulate user privileges", - "net sam rights\n" - " Manipulate user privileges" - }, + struct functable2 func[] = { + { "createbuiltingroup", net_sam_createbuiltingroup, + "Create a new BUILTIN group" }, + { "createlocalgroup", net_sam_createlocalgroup, + "Create a new local group" }, + { "deletelocalgroup", net_sam_deletelocalgroup, + "Delete an existing local group" }, + { "mapunixgroup", net_sam_mapunixgroup, + "Map a unix group to a domain group" }, + { "unmapunixgroup", net_sam_unmapunixgroup, + "Remove a group mapping of an unix group to a domain group" }, + { "addmem", net_sam_addmem, + "Add a member to a group" }, + { "delmem", net_sam_delmem, + "Delete a member from a group" }, + { "listmem", net_sam_listmem, + "List group members" }, + { "list", net_sam_list, + "List users, groups and local groups" }, + { "show", net_sam_show, + "Show details of a SAM entry" }, + { "set", net_sam_set, + "Set details of a SAM account" }, + { "policy", net_sam_policy, + "Set account policies" }, + { "rights", net_sam_rights, + "Manipulate user privileges" }, #ifdef HAVE_LDAP - { - "provision", - net_sam_provision, - NET_TRANSPORT_LOCAL, - "Provision a clean user database", - "net sam privison\n" - " Provision a clear user database" - }, + { "provision", net_sam_provision, + "Provision a clean User Database" }, #endif - {NULL, NULL, 0, NULL, NULL} + { NULL, NULL, NULL } }; if (getuid() != 0) { d_fprintf(stderr, "You are not root, most things won't " "work\n"); } - - return net_run_function(c, argc, argv, "net sam", func); + + return net_run_function2(argc, argv, "net sam", func); } |