diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/include/pstring.h | 39 | ||||
-rw-r--r-- | source4/nsswitch/wbinfo.c | 1 | ||||
-rw-r--r-- | source4/nsswitch/winbind_nss_config.h | 11 | ||||
-rw-r--r-- | source4/nsswitch/winbind_struct_protocol.h | 8 | ||||
-rw-r--r-- | source4/torture/basic/utable.c | 11 | ||||
-rw-r--r-- | source4/torture/locktest.c | 24 | ||||
-rw-r--r-- | source4/torture/locktest2.c | 52 | ||||
-rw-r--r-- | source4/torture/masktest.c | 39 | ||||
-rw-r--r-- | source4/torture/winbind/struct_based.c | 17 | ||||
-rw-r--r-- | source4/utils/ntlm_auth.c | 1 |
10 files changed, 85 insertions, 118 deletions
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 <http://www.gnu.org/licenses/>. -*/ - -#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;i<n-skip;i+=skip) { @@ -510,7 +512,7 @@ static int test_locks(struct event_context *ev, } close_files(cli, fnum); - reconnect(ev, lp_ctx, cli, fnum, share); + reconnect(ev, lp_ctx, mem_ctx, cli, fnum, share); open_files(cli, fnum); showall = true; n1 = retest(cli, fnum, n); @@ -647,6 +649,6 @@ static void usage(poptContext pc) seed, lock_base, lock_range, min_length)); srandom(seed); - return test_locks(ev, lp_ctx, share); + return test_locks(ev, lp_ctx, NULL, share); } diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index b49b8d256a..e7cbf13c74 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -63,16 +63,19 @@ static struct record *recorded; static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *fname, int flags) { - pstring path; + char *path; + int ret; switch (fstype) { case FSTYPE_SMB: return smbcli_open(c, fname, flags, DENY_NONE); case FSTYPE_NFS: - slprintf(path, sizeof(path), "%s%s", nfs, fname); - pstring_sub(path,"\\", "/"); - return open(path, flags, 0666); + asprintf(&path, "%s%s", nfs, fname); + string_replace(path,'\\', '/'); + ret = open(path, flags, 0666); + SAFE_FREE(Path); + return ret; } return -1; @@ -137,19 +140,20 @@ static bool try_unlock(struct smbcli_state *c, int fstype, /***************************************************** return a connection to a server *******************************************************/ -static struct smbcli_state *connect_one(char *share, const char **ports, +static struct smbcli_state *connect_one(TALLOC_CTX *mem_ctx, + char *share, const char **ports, struct smb_options *options, struct smb_options *session_options, struct event_context *ev) { struct smbcli_state *c; char *server_n; - fstring server; - fstring myname; + char *server; + char *myname; static int count; NTSTATUS nt_status; - fstrcpy(server,share+2); + server = talloc_strdup(mem_ctx, share+2); share = strchr_m(server,'\\'); if (!share) return NULL; *share = 0; @@ -160,11 +164,11 @@ static struct smbcli_state *connect_one(char *share, const char **ports, if (!got_pass) { char *pass = getpass("Password: "); if (pass) { - fstrcpy(password, pass); + password = talloc_strdup(mem_ctx, pass); } } - slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++); + myname = talloc_asprintf(mem_ctx, "lock-%u-%u", getpid(), count++); nt_status = smbcli_full_connection(NULL, &c, myname, server_n, ports, share, NULL, @@ -181,7 +185,8 @@ static struct smbcli_state *connect_one(char *share, const char **ports, } -static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], +static void reconnect(TALLOC_CTX *mem_ctx, + struct smbcli_state *cli[NSERVERS][NCONNECTIONS], char *nfs[NSERVERS], int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], const char **ports, @@ -206,7 +211,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], smbcli_ulogoff(cli[server][conn]); talloc_free(cli[server][conn]); } - cli[server][conn] = connect_one(share[server], ports, options, session_options, ev); + cli[server][conn] = connect_one(mem_ctx, share[server], ports, options, session_options, ev); if (!cli[server][conn]) { DEBUG(0,("Failed to connect to %s\n", share[server])); exit(1); @@ -352,7 +357,7 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], we then do random locking ops in tamdem on the 4 fnums from each server and ensure that the results match */ -static void test_locks(char *share1, char *share2, +static void test_locks(TALLOC_CTX *mem_ctx, char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options, @@ -386,7 +391,7 @@ static void test_locks(char *share1, char *share2, recorded[n].needed = true; } - reconnect(cli, nfs, fnum, ports, options, session_options, ev, share1, share2); + reconnect(mem_ctx, cli, nfs, fnum, ports, options, session_options, ev, share1, share2); open_files(cli, nfs, fnum); n = retest(cli, nfs, fnum, numops); @@ -397,7 +402,7 @@ static void test_locks(char *share1, char *share2, n1 = n; close_files(cli, nfs, fnum); - reconnect(cli, nfs, fnum, ports, options, session_options, ev, share1, share2); + reconnect(mem_ctx, cli, nfs, fnum, ports, options, session_options, ev, share1, share2); open_files(cli, nfs, fnum); for (i=0;i<n-1;i++) { @@ -424,7 +429,7 @@ static void test_locks(char *share1, char *share2, } close_files(cli, nfs, fnum); - reconnect(cli, nfs, fnum, ports, options, session_options, ev, share1, share2); + reconnect(mem_ctx, cli, nfs, fnum, ports, options, session_options, ev, share1, share2); open_files(cli, nfs, fnum); showall = true; n1 = retest(cli, nfs, fnum, n); @@ -473,12 +478,15 @@ static void usage(void) extern int optind; struct smbcli_options options; struct smbcli_session_options session_options; + TALLOC_CTX *mem_ctx; int opt; char *p; int seed; struct loadparm_context *lp_ctx; struct event_context *ev; + mem_ctx = talloc_autofree_context(); + setlinebuf(stdout); dbf = x_stderr; @@ -501,11 +509,11 @@ static void usage(void) argc -= 4; argv += 4; - lp_ctx = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(mem_ctx); lp_load(lp_ctx, dyn_CONFIGFILE); if (getenv("USER")) { - fstrcpy(username,getenv("USER")); + username = talloc_strdup(mem_ctx, getenv("USER")); } seed = time(NULL); @@ -513,11 +521,11 @@ static void usage(void) while ((opt = getopt(argc, argv, "U:s:ho:aAW:O")) != EOF) { switch (opt) { case 'U': - fstrcpy(username,optarg); + username = talloc_strdup(mem_ctx, optarg); p = strchr_m(username,'%'); if (p) { *p = 0; - fstrcpy(password, p+1); + password = talloc_strdup(mem_ctx, p+1); got_pass = 1; } break; @@ -554,12 +562,12 @@ static void usage(void) DEBUG(0,("seed=%u\n", seed)); srandom(seed); - ev = s4_event_context_init(talloc_autofree_context()); + ev = s4_event_context_init(mem_ctx); locking_init(1); lp_smbcli_options(lp_ctx, &options); lp_smbcli_session_options(lp_ctx, &session_options); - test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx), + test_locks(mem_ctx, share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx), &options, &session_options, ev); return(0); diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index a739a1e1b5..5eccf86f11 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -24,7 +24,6 @@ #include "libcli/libcli.h" #include "libcli/raw/libcliraw.h" #include "system/time.h" -#include "pstring.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" #include "param/param.h" @@ -55,10 +54,10 @@ static bool reg_match_one(struct smbcli_state *cli, const char *pattern, const c return ms_fnmatch(pattern, file, cli->transport->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" |