]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
net: Use dom_sid_str_buf
authorVolker Lendecke <vl@samba.org>
Sat, 8 Dec 2018 14:05:53 +0000 (15:05 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 10 Dec 2018 23:40:30 +0000 (00:40 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/utils/net_groupmap.c
source3/utils/net_lookup.c
source3/utils/net_rpc.c
source3/utils/net_rpc_shell.c
source3/utils/net_sam.c
source3/utils/net_usershare.c

index 6559cd7f0b996ac8ff91ce068cd98b4a6d1cfd23..b4da9bae556a1ece30e17536111fc7902d943012 100644 (file)
@@ -68,12 +68,16 @@ static bool get_sid_from_input(struct dom_sid *sid, char *input)
 
 static void print_map_entry (const GROUP_MAP *map, bool long_list)
 {
+       struct dom_sid_buf buf;
+
        if (!long_list)
                d_printf("%s (%s) -> %s\n", map->nt_name,
-                        sid_string_tos(&map->sid), gidtoname(map->gid));
+                        dom_sid_str_buf(&map->sid, &buf),
+                        gidtoname(map->gid));
        else {
                d_printf("%s\n", map->nt_name);
-               d_printf(_("\tSID       : %s\n"), sid_string_tos(&map->sid));
+               d_printf(_("\tSID       : %s\n"),
+                        dom_sid_str_buf(&map->sid, &buf));
                d_printf(_("\tUnix gid  : %u\n"), (unsigned int)map->gid);
                d_printf(_("\tUnix group: %s\n"), gidtoname(map->gid));
                d_printf(_("\tGroup type: %s\n"),
@@ -303,8 +307,9 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
        /* Default is domain group. */
        map->sid_name_use = SID_NAME_DOM_GRP;
        if (pdb_getgrgid(map, gid)) {
+               struct dom_sid_buf buf;
                d_printf(_("Unix group %s already mapped to SID %s\n"),
-                        unixgrp, sid_string_tos(&map->sid));
+                        unixgrp, dom_sid_str_buf(&map->sid, &buf));
                TALLOC_FREE(map);
                return -1;
        }
@@ -767,9 +772,10 @@ static int net_groupmap_cleanup(struct net_context *c, int argc, const char **ar
                if (!sid_check_is_in_our_sam(&maps[i]->sid) &&
                    !sid_check_is_in_builtin(&maps[i]->sid))
                {
+                       struct dom_sid_buf buf;
                        printf(_("Deleting mapping for NT Group %s, sid %s\n"),
                                maps[i]->nt_name,
-                               sid_string_tos(&maps[i]->sid));
+                               dom_sid_str_buf(&maps[i]->sid, &buf));
                        pdb_delete_group_mapping_entry(maps[i]->sid);
                }
        }
@@ -850,7 +856,8 @@ static int net_groupmap_listmem(struct net_context *c, int argc, const char **ar
        }
 
        for (i = 0; i < num; i++) {
-               printf("%s\n", sid_string_tos(&(members[i])));
+               struct dom_sid_buf buf;
+               printf("%s\n", dom_sid_str_buf(&(members[i]), &buf));
        }
 
        TALLOC_FREE(members);
@@ -864,6 +871,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
 {
        uint32_t *alias_rids;
        size_t i, num_alias_rids;
+       struct dom_sid_buf buf;
 
        alias_rids = NULL;
        num_alias_rids = 0;
@@ -872,14 +880,14 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
                                     mem_ctx, domain_sid, member, 1,
                                     &alias_rids, &num_alias_rids))) {
                d_fprintf(stderr, _("Could not list memberships for sid %s\n"),
-                        sid_string_tos(member));
+                         dom_sid_str_buf(member, &buf));
                return false;
        }
 
        for (i = 0; i < num_alias_rids; i++) {
                struct dom_sid alias;
                sid_compose(&alias, domain_sid, alias_rids[i]);
-               printf("%s\n", sid_string_tos(&alias));
+               printf("%s\n", dom_sid_str_buf(&alias, &buf));
        }
 
        return true;
index 140f9900795e5c029f98d6f41ddf8a0a9b56cb7c..df047f617e7787edb40cfb13425703ad62522f08 100644 (file)
@@ -337,6 +337,7 @@ static int net_lookup_name(struct net_context *c, int argc, const char **argv)
 {
        const char *dom, *name;
        struct dom_sid sid;
+       struct dom_sid_buf buf;
        enum lsa_SidType type;
 
        if (argc != 1) {
@@ -352,7 +353,7 @@ static int net_lookup_name(struct net_context *c, int argc, const char **argv)
                return -1;
        }
 
-       d_printf("%s %d (%s) %s\\%s\n", sid_string_tos(&sid),
+       d_printf("%s %d (%s) %s\\%s\n", dom_sid_str_buf(&sid, &buf),
                 type, sid_type_lookup(type), dom, name);
        return 0;
 }
@@ -361,6 +362,7 @@ static int net_lookup_sid(struct net_context *c, int argc, const char **argv)
 {
        const char *dom, *name;
        struct dom_sid sid;
+       struct dom_sid_buf buf;
        enum lsa_SidType type;
 
        if (argc != 1) {
@@ -381,7 +383,7 @@ static int net_lookup_sid(struct net_context *c, int argc, const char **argv)
                return -1;
        }
 
-       d_printf("%s %d (%s) %s\\%s\n", sid_string_tos(&sid),
+       d_printf("%s %d (%s) %s\\%s\n", dom_sid_str_buf(&sid, &buf),
                 type, sid_type_lookup(type), dom, name);
        return 0;
 }
index d6ade7471b4c3bfcb1e6e47b2c2a0e57a483a494..a3b3727b484b4dd23e5d02a9da07cbae68baca87 100644 (file)
@@ -4843,7 +4843,9 @@ static void dump_user_token(struct user_token *token)
        d_printf("%s\n", token->name);
 
        for (i=0; i<token->token.num_sids; i++) {
-               d_printf(" %s\n", sid_string_tos(&token->token.sids[i]));
+               struct dom_sid_buf buf;
+               d_printf(" %s\n",
+                        dom_sid_str_buf(&token->token.sids[i], &buf));
        }
 }
 
index 120cfa6af95ef920e29dcbcbfd8c2c5f080f51a6..f07ba779bbafeb1f76cb1418c0758e4579420ca5 100644 (file)
@@ -27,6 +27,7 @@
 #include "lib/netapi/netapi_net.h"
 #include "../libcli/smbreadline/smbreadline.h"
 #include "libsmb/libsmb.h"
+#include "libcli/security/dom_sid.h"
 
 static NTSTATUS rpc_sh_info(struct net_context *c,
                            TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
@@ -219,6 +220,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv)
 {
        NTSTATUS status;
        struct rpc_sh_ctx *ctx;
+       struct dom_sid_buf buf;
 
        if (argc != 0 || c->display_usage) {
                d_printf("%s\nnet rpc shell\n", _("Usage:"));
@@ -258,7 +260,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv)
        }
 
        d_printf(_("Talking to domain %s (%s)\n"), ctx->domain_name,
-                sid_string_tos(ctx->domain_sid));
+                dom_sid_str_buf(ctx->domain_sid, &buf));
 
        this_ctx = ctx;
 
index 52d6515f0140d3584d17ff87d7479b2e550a36ab..5a9d1792d51ba35e018f710e63e4d6d8bcff7325 100644 (file)
@@ -693,13 +693,15 @@ static int net_sam_rights_list(struct net_context *c, int argc,
                for (i=0; i<num_sids; i++) {
                        const char *dom, *name;
                        enum lsa_SidType type;
+                       struct dom_sid_buf buf;
 
                        if (lookup_sid(talloc_tos(), &sids[i], &dom, &name,
                                       &type)) {
                                d_printf("%s\\%s\n", dom, name);
                        }
                        else {
-                               d_printf("%s\n", sid_string_tos(&sids[i]));
+                               d_printf("%s\n",
+                                        dom_sid_str_buf(&sids[i], &buf));
                        }
                }
                return 0;
@@ -871,6 +873,7 @@ static int net_sam_mapunixgroup(struct net_context *c, int argc, const char **ar
        NTSTATUS status;
        GROUP_MAP *map;
        struct group *grp;
+       struct dom_sid_buf buf;
 
        if (argc != 1 || c->display_usage) {
                d_fprintf(stderr, "%s\n%s",
@@ -900,7 +903,7 @@ static int net_sam_mapunixgroup(struct net_context *c, int argc, const char **ar
        }
 
        d_printf(_("Mapped unix group %s to SID %s\n"), argv[0],
-                sid_string_tos(&map->sid));
+                dom_sid_str_buf(&map->sid, &buf));
 
        TALLOC_FREE(map);
        return 0;
@@ -1328,8 +1331,11 @@ static int net_sam_delmem(struct net_context *c, int argc, const char **argv)
                d_printf(_("Deleted %s\\%s from %s\\%s\n"),
                         memberdomain, membername, groupdomain, groupname);
        } else {
+               struct dom_sid_buf buf;
                d_printf(_("Deleted %s from %s\\%s\n"),
-                        sid_string_tos(&member), groupdomain, groupname);
+                        dom_sid_str_buf(&member, &buf),
+                        groupdomain,
+                        groupname);
        }
 
        return 0;
@@ -1406,7 +1412,9 @@ static int net_sam_listmem(struct net_context *c, int argc, const char **argv)
                if (lookup_sid(talloc_tos(), &members[i], &dom, &name, NULL)) {
                        d_printf(" %s\\%s\n", dom, name);
                } else {
-                       d_printf(" %s\n", sid_string_tos(&members[i]));
+                       struct dom_sid_buf buf;
+                       d_printf(" %s\n",
+                                dom_sid_str_buf(&members[i], &buf));
                }
        }
 
@@ -1555,6 +1563,7 @@ static int net_sam_list(struct net_context *c, int argc, const char **argv)
 static int net_sam_show(struct net_context *c, int argc, const char **argv)
 {
        struct dom_sid sid;
+       struct dom_sid_buf buf;
        enum lsa_SidType type;
        const char *dom, *name;
 
@@ -1572,7 +1581,7 @@ static int net_sam_show(struct net_context *c, int argc, const char **argv)
        }
 
        d_printf(_("%s\\%s is a %s with SID %s\n"), dom, name,
-                sid_type_lookup(type), sid_string_tos(&sid));
+                sid_type_lookup(type), dom_sid_str_buf(&sid, &buf));
 
        return 0;
 }
index 1e2925979d0ea396939b8ca7478f528f1f8b8bf2..f5b126aa3d1a2b759513a34b0a1bd6fd5c4b56b7 100644 (file)
@@ -818,6 +818,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
 
        for (i = 0; i < num_aces; i++) {
                struct dom_sid sid;
+               struct dom_sid_buf buf;
                const char *pcolon = strchr_m(pacl, ':');
                const char *name;
 
@@ -881,7 +882,10 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                        }
                }
                us_acl = talloc_asprintf_append(
-                       us_acl, "%s:%c,", sid_string_tos(&sid), pcolon[1]);
+                       us_acl,
+                       "%s:%c,",
+                       dom_sid_str_buf(&sid, &buf),
+                       pcolon[1]);
 
                /* Move to the next ACL entry. */
                if (pcolon[2] == ',') {