From 0af1500fc0bafe61019f1b2ab1d9e1d369221240 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Feb 2006 22:19:41 +0000 Subject: r13316: Let the carnage begin.... Sync with trunk as off r13315 (This used to be commit 17e63ac4ed8325c0d44fe62b2442449f3298559f) --- source3/utils/netlookup.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 source3/utils/netlookup.c (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c new file mode 100644 index 0000000000..edb2f7d5ba --- /dev/null +++ b/source3/utils/netlookup.c @@ -0,0 +1,209 @@ +/* + Unix SMB/CIFS implementation. + + Name lookup. + + Copyright (C) Jeremy Allison 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "utils/net.h" + +/******************************************************** + Connection cachine struct. Goes away when ctx destroyed. +********************************************************/ + +struct con_struct { + BOOL failed_connect; + struct cli_state *cli; + struct rpc_pipe_client *lsapipe; + POLICY_HND pol; +}; + +static struct con_struct *cs; + +/******************************************************** + Close connection on context destruction. +********************************************************/ + +static int cs_destructor(void *p) +{ + if (cs->cli) { + cli_shutdown(cs->cli); + } + cs = NULL; + return 0; +} + +/******************************************************** + Create the connection to localhost. +********************************************************/ + +static struct con_struct *create_cs(TALLOC_CTX *ctx) +{ + NTSTATUS nt_status; + struct in_addr loopback_ip = *interpret_addr2("127.0.0.1");; + + if (cs) { + if (cs->failed_connect) { + return NULL; + } + return cs; + } + + cs = TALLOC_P(ctx, struct con_struct); + if (!cs) { + return NULL; + } + + ZERO_STRUCTP(cs); + talloc_set_destructor(cs, cs_destructor); + + /* Connect to localhost with given username/password. */ + /* JRA. Pretty sure we can just do this anonymously.... */ +#if 0 + if (!opt_password && !opt_machine_pass) { + char *pass = getpass("Password:"); + if (pass) { + opt_password = SMB_STRDUP(pass); + } + } +#endif + + nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(), + &loopback_ip, 0, + "IPC$", "IPC", +#if 0 + opt_user_name, + opt_workgroup, + opt_password, +#else + "", + opt_workgroup, + "", +#endif + 0, + Undefined, + NULL); + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status))); + cs->failed_connect = True; + return NULL; + } + + cs->lsapipe = cli_rpc_pipe_open_noauth(cs->cli, + PI_LSARPC, + &nt_status); + + if (cs->lsapipe == NULL) { + DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status))); + cs->failed_connect = True; + return NULL; + } + + nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &cs->pol); + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(2,("create_cs: rpccli_lsa_open_policy failed. Error was %s\n", nt_errstr(nt_status))); + cs->failed_connect = True; + return NULL; + } + + return cs; +} + +/******************************************************** + Do a lookup_sids call to localhost. + Check if the local machine is authoritative for this sid. We can't + check if this is our SID as that's stored in the root-read-only + secrets.tdb. + The local smbd will also ask winbindd for us, so we don't have to. +********************************************************/ + +BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, + DOM_SID *psid, + const char **ppdomain, + const char **ppname) +{ + NTSTATUS nt_status; + struct con_struct *csp = NULL; + char **domains; + char **names; + uint32 *types; + + *ppdomain = NULL; + *ppname = NULL; + + csp = create_cs(ctx); + if (csp == NULL) { + return False; + } + + nt_status = rpccli_lsa_lookup_sids(csp->lsapipe, ctx, + &csp->pol, + 1, psid, + &domains, + &names, + &types); + + if (!NT_STATUS_IS_OK(nt_status)) { + return False; + } + + *ppdomain = domains[0]; + *ppname = names[0]; + /* Don't care about type here. */ + + /* Converted OK */ + return True; +} + +/******************************************************** + Do a lookup_names call to localhost. +********************************************************/ + +BOOL net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *pret_sid) +{ + NTSTATUS nt_status; + struct con_struct *csp = NULL; + DOM_SID *sids = NULL; + uint32 *types = NULL; + + csp = create_cs(ctx); + if (csp == NULL) { + return False; + } + + nt_status = rpccli_lsa_lookup_names(csp->lsapipe, ctx, + &csp->pol, + 1, + &full_name, + NULL, &sids, + &types); + + if (!NT_STATUS_IS_OK(nt_status)) { + return False; + } + + *pret_sid = sids[0]; + + /* Converted OK */ + return True; +} -- cgit From 8189bb6e4c5a3cde757bb7823f51541c8940914b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 15 Feb 2006 02:07:14 +0000 Subject: r13502: Fix error messages for usershares when smbd is not running. More generic error return cleanup in libsmb/ needs doing (everything returning NTSTATUS not BOOL). Jeremy (This used to be commit 654bb9853b450c5d509d182f67ec26ac320fd590) --- source3/utils/netlookup.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index edb2f7d5ba..df0fe0c843 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -29,6 +29,7 @@ struct con_struct { BOOL failed_connect; + NTSTATUS err; struct cli_state *cli; struct rpc_pipe_client *lsapipe; POLICY_HND pol; @@ -53,13 +54,16 @@ static int cs_destructor(void *p) Create the connection to localhost. ********************************************************/ -static struct con_struct *create_cs(TALLOC_CTX *ctx) +static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) { NTSTATUS nt_status; struct in_addr loopback_ip = *interpret_addr2("127.0.0.1");; + *perr = NT_STATUS_OK; + if (cs) { if (cs->failed_connect) { + *perr = cs->err; return NULL; } return cs; @@ -67,6 +71,7 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx) cs = TALLOC_P(ctx, struct con_struct); if (!cs) { + *perr = NT_STATUS_NO_MEMORY; return NULL; } @@ -103,6 +108,8 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx) if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status))); cs->failed_connect = True; + cs->err = nt_status; + *perr = nt_status; return NULL; } @@ -113,6 +120,8 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx) if (cs->lsapipe == NULL) { DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status))); cs->failed_connect = True; + cs->err = nt_status; + *perr = nt_status; return NULL; } @@ -123,9 +132,11 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx) if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: rpccli_lsa_open_policy failed. Error was %s\n", nt_errstr(nt_status))); cs->failed_connect = True; + cs->err = nt_status; + *perr = nt_status; return NULL; } - + return cs; } @@ -137,7 +148,7 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx) The local smbd will also ask winbindd for us, so we don't have to. ********************************************************/ -BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, +NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, DOM_SID *psid, const char **ppdomain, const char **ppname) @@ -151,9 +162,9 @@ BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, *ppdomain = NULL; *ppname = NULL; - csp = create_cs(ctx); + csp = create_cs(ctx, &nt_status); if (csp == NULL) { - return False; + return nt_status; } nt_status = rpccli_lsa_lookup_sids(csp->lsapipe, ctx, @@ -164,7 +175,7 @@ BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, &types); if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return nt_status; } *ppdomain = domains[0]; @@ -172,23 +183,23 @@ BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, /* Don't care about type here. */ /* Converted OK */ - return True; + return NT_STATUS_OK; } /******************************************************** Do a lookup_names call to localhost. ********************************************************/ -BOOL net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *pret_sid) +NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *pret_sid) { NTSTATUS nt_status; struct con_struct *csp = NULL; DOM_SID *sids = NULL; uint32 *types = NULL; - csp = create_cs(ctx); + csp = create_cs(ctx, &nt_status); if (csp == NULL) { - return False; + return nt_status; } nt_status = rpccli_lsa_lookup_names(csp->lsapipe, ctx, @@ -199,11 +210,11 @@ BOOL net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *p &types); if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return nt_status; } *pret_sid = sids[0]; /* Converted OK */ - return True; + return NT_STATUS_OK; } -- cgit From 2b8abc030b1eca43f7c0c05dc96eebeb6c492030 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 21:30:21 +0000 Subject: r16644: Fix bug #3887 reported by jason@ncac.gwu.edu by converting the lookup_XX functions to correctly return SID_NAME_TYPE enums. Jeremy. (This used to be commit ee2b2d96b60c668e37592c79e86c2fd851e15f69) --- source3/utils/netlookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index df0fe0c843..2d105335e8 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -157,7 +157,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, struct con_struct *csp = NULL; char **domains; char **names; - uint32 *types; + enum SID_NAME_USE *types; *ppdomain = NULL; *ppname = NULL; @@ -195,7 +195,7 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI NTSTATUS nt_status; struct con_struct *csp = NULL; DOM_SID *sids = NULL; - uint32 *types = NULL; + enum SID_NAME_USE *types = NULL; csp = create_cs(ctx, &nt_status); if (csp == NULL) { -- cgit From 2681f88fbc24fc000ca713d769a4fcfd412cce71 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 26 Jul 2006 16:47:58 +0000 Subject: r17260: remove extra ;SAMBA_3_0_23/source/utils/netlookup.c (This used to be commit c152d20e9073eb741047cc4b5f8e8086e2bc9ddd) --- source3/utils/netlookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 2d105335e8..b9948485b9 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -57,7 +57,7 @@ static int cs_destructor(void *p) static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) { NTSTATUS nt_status; - struct in_addr loopback_ip = *interpret_addr2("127.0.0.1");; + struct in_addr loopback_ip = *interpret_addr2("127.0.0.1"); *perr = NT_STATUS_OK; -- cgit From 3bc4fd1bb9bfbd0e0efd89d47c50bf798e5a1481 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Aug 2006 19:14:25 +0000 Subject: r17924: Get rid of warnings now that talloc is merged. Destructors now take a pointer to the "real" destroyed object as an argument. Volker (This used to be commit 70edd716ef0ccb218fe18d1233bd30abe46b62bf) --- source3/utils/netlookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index b9948485b9..d82630e5c8 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -41,7 +41,7 @@ static struct con_struct *cs; Close connection on context destruction. ********************************************************/ -static int cs_destructor(void *p) +static int cs_destructor(struct con_struct *p) { if (cs->cli) { cli_shutdown(cs->cli); -- cgit From 2b27c93a9a8471693d7dcb5fdbe8afe65b22ff66 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Sep 2006 14:28:06 +0000 Subject: r18271: Big change: * autogenerate lsa ndr code * rename 'enum SID_NAME_USE' to 'enum lsa_SidType' * merge a log more security descriptor functions from gen_ndr/ndr_security.c in SAMBA_4_0 The most embarassing thing is the "#define strlen_m strlen" We need a real implementation in SAMBA_3_0 which I'll work on after this code is in. (This used to be commit 3da9f80c28b1e75ef6d46d38fbb81ade6b9fa951) --- source3/utils/netlookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index d82630e5c8..33b6c4bb25 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -157,7 +157,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, struct con_struct *csp = NULL; char **domains; char **names; - enum SID_NAME_USE *types; + enum lsa_SidType *types; *ppdomain = NULL; *ppname = NULL; @@ -195,7 +195,7 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI NTSTATUS nt_status; struct con_struct *csp = NULL; DOM_SID *sids = NULL; - enum SID_NAME_USE *types = NULL; + enum lsa_SidType *types = NULL; csp = create_cs(ctx, &nt_status); if (csp == NULL) { -- cgit From 7eb828135bd7407851a10c32d57c404ecb030140 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Jun 2007 11:42:17 +0000 Subject: r23627: Allow to pass down the lookup-level to rpccli_lsa_lookup_names(). Guenther (This used to be commit e9a7512a9f630340004913f1379452eea8a9b6ae) --- source3/utils/netlookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 33b6c4bb25..82e1b8af80 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -206,8 +206,8 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI &csp->pol, 1, &full_name, - NULL, &sids, - &types); + NULL, 1, + &sids, &types); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/utils/netlookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 82e1b8af80..aaa32e4ac7 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/utils/netlookup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index aaa32e4ac7..58c0f01019 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 8e54530b52fd256137740107e9fdf000f00a7a30 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Oct 2007 18:25:16 -0700 Subject: Add start of IPv6 implementation. Currently most of this is avoiding IPv6 in winbindd, but moves most of the socket functions that were wrongly in lib/util.c into lib/util_sock.c and provides generic IPv4/6 independent versions of most things. Still lots of work to do, but now I can see how I'll fix the access check code. Nasty part that remains is the name resolution code which is used to returning arrays of in_addr structs. Jeremy. (This used to be commit 3f6bd0e1ec5cc6670f3d08f76fc2cd94c9cd1a08) --- source3/utils/netlookup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 58c0f01019..998e77c68e 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -56,8 +56,9 @@ static int cs_destructor(struct con_struct *p) static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) { NTSTATUS nt_status; - struct in_addr loopback_ip = *interpret_addr2("127.0.0.1"); + struct in_addr loopback_ip; + loopback_ip.s_addr = htonl(INADDR_LOOPBACK); *perr = NT_STATUS_OK; if (cs) { -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/utils/netlookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 998e77c68e..315a89d5a8 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -27,7 +27,7 @@ ********************************************************/ struct con_struct { - BOOL failed_connect; + bool failed_connect; NTSTATUS err; struct cli_state *cli; struct rpc_pipe_client *lsapipe; -- cgit From f88b7a076be74a29a3bf876b4e2705f4a1ecf42b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 24 Oct 2007 14:16:54 -0700 Subject: This is a large patch (sorry). Migrate from struct in_addr to struct sockaddr_storage in most places that matter (ie. not the nmbd and NetBIOS lookups). This passes make test on an IPv4 box, but I'll have to do more work/testing on IPv6 enabled boxes. This should now give us a framework for testing and finishing the IPv6 migration. It's at the state where someone with a working IPv6 setup should (theorecically) be able to type : smbclient //ipv6-address/share and have it work. Jeremy. (This used to be commit 98e154c3125d5732c37a72d74b0eb5cd7b6155fd) --- source3/utils/netlookup.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 315a89d5a8..90f99e4c8b 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -56,11 +56,15 @@ static int cs_destructor(struct con_struct *p) static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) { NTSTATUS nt_status; - struct in_addr loopback_ip; + struct sockaddr_storage loopback_ss; - loopback_ip.s_addr = htonl(INADDR_LOOPBACK); *perr = NT_STATUS_OK; + if (!interpret_string_addr(&loopback_ss, "127.0.0.1", AI_NUMERICHOST)) { + *perr = NT_STATUS_INVALID_PARAMETER; + return NULL; + } + if (cs) { if (cs->failed_connect) { *perr = cs->err; @@ -90,7 +94,7 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) #endif nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(), - &loopback_ip, 0, + &loopback_ss, 0, "IPC$", "IPC", #if 0 opt_user_name, -- cgit From f5769109447d8da0f09b102d444a816ad97a00dc Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 9 May 2008 23:22:12 +0200 Subject: net: Remove globals (This used to be commit 1e9319cf88b65a2a8d4f5099a1fe5297e405ed2e) --- source3/utils/netlookup.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 90f99e4c8b..7d144cf624 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -53,7 +53,8 @@ static int cs_destructor(struct con_struct *p) Create the connection to localhost. ********************************************************/ -static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) +static struct con_struct *create_cs(struct net_context *c, + TALLOC_CTX *ctx, NTSTATUS *perr) { NTSTATUS nt_status; struct sockaddr_storage loopback_ss; @@ -97,12 +98,12 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) &loopback_ss, 0, "IPC$", "IPC", #if 0 - opt_user_name, - opt_workgroup, - opt_password, + c->opt_user_name, + c->opt_workgroup, + c->opt_password, #else "", - opt_workgroup, + c->opt_workgroup, "", #endif 0, @@ -152,7 +153,8 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr) The local smbd will also ask winbindd for us, so we don't have to. ********************************************************/ -NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, +NTSTATUS net_lookup_name_from_sid(struct net_context *c, + TALLOC_CTX *ctx, DOM_SID *psid, const char **ppdomain, const char **ppname) @@ -166,7 +168,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, *ppdomain = NULL; *ppname = NULL; - csp = create_cs(ctx, &nt_status); + csp = create_cs(c, ctx, &nt_status); if (csp == NULL) { return nt_status; } @@ -194,14 +196,15 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx, Do a lookup_names call to localhost. ********************************************************/ -NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *pret_sid) +NTSTATUS net_lookup_sid_from_name(struct net_context *c, TALLOC_CTX *ctx, + const char *full_name, DOM_SID *pret_sid) { NTSTATUS nt_status; struct con_struct *csp = NULL; DOM_SID *sids = NULL; enum lsa_SidType *types = NULL; - csp = create_cs(ctx, &nt_status); + csp = create_cs(c, ctx, &nt_status); if (csp == NULL) { return nt_status; } -- cgit From 16938883e6fcae7601eb6343177aa2d56dd2136e Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 12 May 2008 11:53:23 +0200 Subject: net: Use true/false instead of True/False. (This used to be commit a8b567aac3b0e39cfe67fb97167b10312ca5e73a) --- source3/utils/netlookup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 7d144cf624..844db51fc0 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -112,7 +112,7 @@ static struct con_struct *create_cs(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; @@ -124,19 +124,19 @@ static struct con_struct *create_cs(struct net_context *c, if (cs->lsapipe == NULL) { DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; } - nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, True, + nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &cs->pol); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: rpccli_lsa_open_policy failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; -- cgit From 1335da2a7cc639310e5d389e8e8dbe67c4e7ca25 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jul 2008 11:04:31 +0200 Subject: Refactoring: Change calling conventions for cli_rpc_pipe_open_noauth Pass in ndr_syntax_id instead of pipe_idx, return NTSTATUS (This used to be commit 9abc9dc4dc13bd3e42f98eff64eacf24b51f5779) --- source3/utils/netlookup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/utils/netlookup.c') diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 844db51fc0..14f2dddebc 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -118,11 +118,11 @@ static struct con_struct *create_cs(struct net_context *c, return NULL; } - cs->lsapipe = cli_rpc_pipe_open_noauth(cs->cli, - PI_LSARPC, - &nt_status); + nt_status = cli_rpc_pipe_open_noauth(cs->cli, + &ndr_table_lsarpc.syntax_id, + &cs->lsapipe); - if (cs->lsapipe == NULL) { + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status))); cs->failed_connect = true; cs->err = nt_status; -- cgit