From c0e14d5021e738a9b89c73558c544596e2ad2000 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 22 Oct 2008 05:14:14 +0200 Subject: Repel pstring to nsswitch/. --- source4/include/pstring.h | 39 ---------------------- source4/nsswitch/wbinfo.c | 1 - source4/nsswitch/winbind_nss_config.h | 11 ------- source4/nsswitch/winbind_struct_protocol.h | 8 +++++ source4/torture/basic/utable.c | 11 +++---- source4/torture/locktest.c | 24 +++++++------- source4/torture/locktest2.c | 52 +++++++++++++++++------------- source4/torture/masktest.c | 39 +++++++++++----------- source4/torture/winbind/struct_based.c | 17 +++++----- source4/utils/ntlm_auth.c | 1 - 10 files changed, 85 insertions(+), 118 deletions(-) delete mode 100644 source4/include/pstring.h diff --git a/source4/include/pstring.h b/source4/include/pstring.h deleted file mode 100644 index 43fd7fdfcf..0000000000 --- a/source4/include/pstring.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - samba -- Unix SMB/CIFS implementation. - - ugly string types from Samba3. Will be removed - with glee when we finally don't use them. - - Copyright (C) Andrew Tridgell 1992-2000 - Copyright (C) John H Terpstra 1996-2000 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Paul Ashton 1998-2000 - Copyright (C) Martin Pool 2002 - - 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 3 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, see . -*/ - -#ifndef _PSTRING -#define _PSTRING - -#define PSTRING_LEN 1024 -#define FSTRING_LEN 256 - -_DEPRECATED_ typedef char pstring[PSTRING_LEN]; -typedef char fstring[FSTRING_LEN]; - -#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1) -#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1) - -#endif diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c index 150d9a68ee..a36a66b80f 100644 --- a/source4/nsswitch/wbinfo.c +++ b/source4/nsswitch/wbinfo.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "pstring.h" #include "winbind_client.h" #include "librpc/gen_ndr/ndr_netlogon.h" #include "libcli/auth/libcli_auth.h" diff --git a/source4/nsswitch/winbind_nss_config.h b/source4/nsswitch/winbind_nss_config.h index ba6153ec28..c5bc853770 100644 --- a/source4/nsswitch/winbind_nss_config.h +++ b/source4/nsswitch/winbind_nss_config.h @@ -40,17 +40,6 @@ #include "nsswitch/winbind_nss.h" -/* I'm trying really hard not to include anything from smb.h with the - result of some silly looking redeclaration of structures. */ - -#ifndef _PSTRING -#define _PSTRING -#define PSTRING_LEN 1024 -#define FSTRING_LEN 256 -typedef char pstring[PSTRING_LEN]; -typedef char fstring[FSTRING_LEN]; -#endif - /* Some systems (SCO) treat UNIX domain sockets as FIFOs */ #ifndef S_IFSOCK diff --git a/source4/nsswitch/winbind_struct_protocol.h b/source4/nsswitch/winbind_struct_protocol.h index fba45230a9..8003ea9585 100644 --- a/source4/nsswitch/winbind_struct_protocol.h +++ b/source4/nsswitch/winbind_struct_protocol.h @@ -18,6 +18,14 @@ #ifndef _WINBINDD_NTDOM_H #define _WINBINDD_NTDOM_H +#define _PSTRING +#define FSTRING_LEN 256 + +typedef char fstring[FSTRING_LEN]; + +#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1) +#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1) + #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */ /* Let the build environment override the public winbindd socket location. This diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 2b222d7c6e..1b44bfe64c 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -23,13 +23,12 @@ #include "system/locale.h" #include "libcli/libcli.h" #include "torture/util.h" -#include "pstring.h" #include "param/param.h" bool torture_utable(struct torture_context *tctx, struct smbcli_state *cli) { - fstring fname; + char fname[256]; const char *alt_name; int fnum; uint8_t c2[4]; @@ -48,13 +47,13 @@ bool torture_utable(struct torture_context *tctx, char *p; SSVAL(c2, 0, c); - fstrcpy(fname, "\\utable\\x"); + strncpy(fname, "\\utable\\x", sizeof(fname)-1); p = fname+strlen(fname); len = convert_string(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; - fstrcat(fname,"_a_long_extension"); + strncat(fname,"_a_long_extension",sizeof(fname)-1); fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); @@ -100,12 +99,12 @@ bool torture_utable(struct torture_context *tctx, static char *form_name(struct smb_iconv_convenience *iconv_convenience, int c) { - static fstring fname; + static char fname[256]; uint8_t c2[4]; char *p; int len; - fstrcpy(fname, "\\utable\\"); + strncpy(fname, "\\utable\\", sizeof(fname)-1); p = fname+strlen(fname); SSVAL(c2, 0, c); diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 69b966b31b..710aa8007a 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -22,7 +22,6 @@ #include "lib/events/events.h" #include "system/filesys.h" #include "system/time.h" -#include "pstring.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" #include "libcli/libcli.h" @@ -110,10 +109,11 @@ return a connection to a server *******************************************************/ static struct smbcli_state *connect_one(struct event_context *ev, struct loadparm_context *lp_ctx, + TALLOC_CTX *mem_ctx, char *share, int snum, int conn) { struct smbcli_state *c; - fstring server, myname; + char *server, *myname; NTSTATUS status; int retries = 10; struct smbcli_options options; @@ -124,7 +124,7 @@ static struct smbcli_state *connect_one(struct event_context *ev, printf("connect_one(%s, %d, %d)\n", share, snum, conn); - fstrcpy(server,share+2); + server = talloc_strdup(mem_ctx, share+2); share = strchr_m(server,'\\'); if (!share) return NULL; *share = 0; @@ -149,13 +149,13 @@ static struct smbcli_state *connect_one(struct event_context *ev, unc_list[conn % num_unc_names]); exit(1); } - fstrcpy(server, h); - fstrcpy(share, s); + server = talloc_strdup(mem_ctx, h); + share = talloc_strdup(mem_ctx, s); } } - slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), snum); + myname = talloc_asprintf(mem_ctx, "lock-%u-%u", getpid(), snum); cli_credentials_set_workstation(servers[snum], myname, CRED_SPECIFIED); do { @@ -182,6 +182,7 @@ static struct smbcli_state *connect_one(struct event_context *ev, static void reconnect(struct event_context *ev, struct loadparm_context *lp_ctx, + TALLOC_CTX *mem_ctx, struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES], char *share[NSERVERS]) { @@ -198,7 +199,7 @@ static void reconnect(struct event_context *ev, } talloc_free(cli[server][conn]); } - cli[server][conn] = connect_one(ev, lp_ctx, share[server], + cli[server][conn] = connect_one(ev, lp_ctx, mem_ctx, share[server], server, conn); if (!cli[server][conn]) { DEBUG(0,("Failed to connect to %s\n", share[server])); @@ -403,6 +404,7 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], */ static int test_locks(struct event_context *ev, struct loadparm_context *lp_ctx, + TALLOC_CTX *mem_ctx, char *share[NSERVERS]) { struct smbcli_state *cli[NSERVERS][NCONNECTIONS]; @@ -454,7 +456,7 @@ static int test_locks(struct event_context *ev, #endif } - reconnect(ev, lp_ctx, cli, fnum, share); + reconnect(ev, lp_ctx, mem_ctx, cli, fnum, share); open_files(cli, fnum); n = retest(cli, fnum, numops); @@ -472,7 +474,7 @@ static int test_locks(struct event_context *ev, n1 = n; close_files(cli, fnum); - reconnect(ev, lp_ctx, cli, fnum, share); + reconnect(ev, lp_ctx, mem_ctx, cli, fnum, share); open_files(cli, fnum); for (i=0;itransport->negotiate.protocol)==0; } -static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name, char *short_name) +static char *reg_test(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *pattern, const char *long_name, const char *short_name) { - static fstring ret; - fstrcpy(ret, "---"); + char *ret; + ret = talloc_strdup(mem_ctx, "---"); pattern = 1+strrchr_m(pattern,'\\'); @@ -80,12 +79,15 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx, struct smbcli_session_options *session_options) { struct smbcli_state *c; - fstring server; + char *server; NTSTATUS status; - fstrcpy(server,share+2); + server = smb_xstrdup(share+2); share = strchr_m(server,'\\'); - if (!share) return NULL; + if (!share) { + SAFE_FREE(server); + return NULL; + } *share = 0; share++; @@ -98,6 +100,8 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx, cmdline_credentials, resolve_ctx, ev, options, session_options); + SAFE_FREE(server); + if (!NT_STATUS_IS_OK(status)) { return NULL; } @@ -130,7 +134,7 @@ static void listfn(struct clilist_file_info *f, const char *s, void *state) } static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, - char **long_name, fstring short_name) + char **long_name, char **short_name) { const char *mask; struct masktest_state state; @@ -151,14 +155,14 @@ static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, listfn, &state); if (f_info_hit) { - fstrcpy(short_name, last_hit.short_name); - strlower(short_name); + *short_name = talloc_strdup(mem_ctx, last_hit.short_name); + strlower(*short_name); *long_name = talloc_strdup(mem_ctx, last_hit.long_name); strlower(*long_name); } if (*short_name == '\0') { - fstrcpy(short_name, *long_name); + *short_name = talloc_strdup(mem_ctx, *long_name); } } @@ -166,16 +170,16 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask, char *file) { int fnum; - fstring res1; + char *res1; char *res2; static int count; - fstring short_name; + char *short_name = NULL; char *long_name = NULL; struct masktest_state state; count++; - fstrcpy(res1, "---"); + res1 = talloc_strdup(mem_ctx, "---"); state.mem_ctx = mem_ctx; @@ -187,15 +191,14 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask, smbcli_close(cli->tree, fnum); resultp = res1; - fstrcpy(short_name, ""); - get_real_name(mem_ctx, cli, &long_name, short_name); - fstrcpy(res1, "---"); + get_real_name(mem_ctx, cli, &long_name, &short_name); + res1 = talloc_strdup(mem_ctx, "---"); smbcli_list_new(cli->tree, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO, listfn, &state); - res2 = reg_test(cli, mask, long_name, short_name); + res2 = reg_test(cli, mem_ctx, mask, long_name, short_name); if (showall || strcmp(res1, res2)) { d_printf("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n", diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c index c27ab24a4d..676b85e467 100644 --- a/source4/torture/winbind/struct_based.c +++ b/source4/torture/winbind/struct_based.c @@ -19,7 +19,6 @@ */ #include "includes.h" -#include "pstring.h" #include "torture/torture.h" #include "torture/winbind/proto.h" #include "nsswitch/winbind_client.h" @@ -275,7 +274,7 @@ static bool get_trusted_domains(struct torture_context *torture, struct winbindd_response rep; struct torture_trust_domain *d = NULL; uint32_t dcount = 0; - fstring line; + char line[256]; const char *extra_data; ZERO_STRUCT(req); @@ -290,7 +289,7 @@ static bool get_trusted_domains(struct torture_context *torture, torture_assert(torture, extra_data, "NULL trust list"); - while (next_token(&extra_data, line, "\n", sizeof(fstring))) { + while (next_token(&extra_data, line, "\n", sizeof(line))) { char *p, *lp; d = talloc_realloc(torture, d, @@ -583,7 +582,7 @@ static bool get_user_list(struct torture_context *torture, char ***users) struct winbindd_response rep; char **u = NULL; uint32_t count; - fstring name; + char name[256]; const char *extra_data; ZERO_STRUCT(req); @@ -595,7 +594,7 @@ static bool get_user_list(struct torture_context *torture, char ***users) torture_assert(torture, extra_data, "NULL extra data"); for(count = 0; - next_token(&extra_data, name, ",", sizeof(fstring)); + next_token(&extra_data, name, ",", sizeof(name)); count++) { u = talloc_realloc(torture, u, char *, count + 2); @@ -633,7 +632,7 @@ static bool get_group_list(struct torture_context *torture, char ***groups) struct winbindd_response rep; char **g = NULL; uint32_t count; - fstring name; + char name[256]; const char *extra_data; ZERO_STRUCT(req); @@ -645,7 +644,7 @@ static bool get_group_list(struct torture_context *torture, char ***groups) torture_assert(torture, extra_data, "NULL extra data"); for(count = 0; - next_token(&extra_data, name, ",", sizeof(fstring)); + next_token(&extra_data, name, ",", sizeof(name)); count++) { g = talloc_realloc(torture, g, char *, count + 2); @@ -688,7 +687,7 @@ static bool get_sequence_numbers(struct torture_context *torture, struct winbindd_request req; struct winbindd_response rep; const char *extra_data; - fstring line; + char line[256]; uint32_t count = 0; struct torture_domain_sequence *s = NULL; @@ -700,7 +699,7 @@ static bool get_sequence_numbers(struct torture_context *torture, extra_data = (char *)rep.extra_data.data; torture_assert(torture, extra_data, "NULL sequence list"); - while (next_token(&extra_data, line, "\n", sizeof(fstring))) { + while (next_token(&extra_data, line, "\n", sizeof(line))) { char *p, *lp; uint32_t seq; diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 1a0a975879..c91d90c214 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -31,7 +31,6 @@ #include "librpc/gen_ndr/ndr_netlogon.h" #include "auth/auth_sam.h" #include "auth/ntlm/ntlm_check.h" -#include "pstring.h" #include "libcli/auth/libcli_auth.h" #include "libcli/security/security.h" #include "lib/events/events.h" -- cgit