The branch, master has been updated
       via  1d9ea911e39b4619a0857171a3362bc2ff40bf96 (commit)
       via  c0e14d5021e738a9b89c73558c544596e2ad2000 (commit)
       via  1d5beb7294d939504864c9b1203a5d7dcde7041a (commit)
       via  6d9b24de782b04466ca3c1ce6f6e82d54e93d2f3 (commit)
      from  7a683618e79acef94235ff4adee275c462559ab5 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1d9ea911e39b4619a0857171a3362bc2ff40bf96
Author: Jelmer Vernooij <[EMAIL PROTECTED]>
Date:   Wed Oct 22 05:24:00 2008 +0200

    Change buffer size back to 256, just to be sure.

commit c0e14d5021e738a9b89c73558c544596e2ad2000
Author: Jelmer Vernooij <[EMAIL PROTECTED]>
Date:   Wed Oct 22 05:14:14 2008 +0200

    Repel pstring to nsswitch/.

commit 1d5beb7294d939504864c9b1203a5d7dcde7041a
Author: Jelmer Vernooij <[EMAIL PROTECTED]>
Date:   Wed Oct 22 04:30:54 2008 +0200

    Remove pstring usage.

commit 6d9b24de782b04466ca3c1ce6f6e82d54e93d2f3
Author: Jelmer Vernooij <[EMAIL PROTECTED]>
Date:   Wed Oct 22 04:25:00 2008 +0200

    Remove pstring usages.

-----------------------------------------------------------------------

Summary of changes:
 source4/client/smbmount.c                  |    3 ++
 source4/include/pstring.h                  |   41 ----------------------
 source4/libcli/auth/smbencrypt.c           |    3 +-
 source4/nsswitch/wb_common.c               |   14 ++-----
 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                  |   25 +++++--------
 13 files changed, 103 insertions(+), 146 deletions(-)
 delete mode 100644 source4/include/pstring.h


Changeset truncated at 500 lines:

diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c
index 37c9eaa..d2e98eb 100644
--- a/source4/client/smbmount.c
+++ b/source4/client/smbmount.c
@@ -24,6 +24,9 @@
 #include <asm/types.h>
 #include <linux/smb_fs.h>
 
+#define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
+#define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
+
 static pstring credentials;
 static pstring my_netbios_name;
 static pstring password;
diff --git a/source4/include/pstring.h b/source4/include/pstring.h
deleted file mode 100644
index 0cbc964..0000000
--- a/source4/include/pstring.h
+++ /dev/null
@@ -1,41 +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 pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
-#define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
-#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/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index 096f51e..a78c444 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -27,7 +27,6 @@
 #include "auth/ntlmssp/msrpc_parse.h"
 #include "../lib/crypto/crypto.h"
 #include "libcli/auth/libcli_auth.h"
-#include "pstring.h"
 #include "param/param.h"
 
 /*
@@ -94,7 +93,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
 bool E_deshash(const char *passwd, uint8_t p16[16])
 {
        bool ret = true;
-       fstring dospwd; 
+       char dospwd[256];
        ZERO_STRUCT(dospwd);
 
        /* Password must be converted to DOS charset - null terminated, 
uppercase. */
diff --git a/source4/nsswitch/wb_common.c b/source4/nsswitch/wb_common.c
index 2ae85dc..6cf4223 100644
--- a/source4/nsswitch/wb_common.c
+++ b/source4/nsswitch/wb_common.c
@@ -168,7 +168,7 @@ static int winbind_named_pipe_sock(const char *dir)
 {
        struct sockaddr_un sunaddr;
        struct stat st;
-       pstring path;
+       char *path;
        int fd;
        int wait_time;
        int slept;
@@ -186,24 +186,18 @@ static int winbind_named_pipe_sock(const char *dir)
        
        /* Connect to socket */
        
-       strncpy(path, dir, sizeof(path) - 1);
-       path[sizeof(path) - 1] = '\0';
-       
-       strncat(path, "/", sizeof(path) - 1 - strlen(path));
-       path[sizeof(path) - 1] = '\0';
-       
-       strncat(path, WINBINDD_SOCKET_NAME, sizeof(path) - 1 - strlen(path));
-       path[sizeof(path) - 1] = '\0';
+       asprintf(&path, "%s/%s", dir, WINBINDD_SOCKET_NAME);
        
        ZERO_STRUCT(sunaddr);
        sunaddr.sun_family = AF_UNIX;
        strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
+       SAFE_FREE(path);
        
        /* If socket file doesn't exist, don't bother trying to connect
           with retry.  This is an attempt to make the system usable when
           the winbindd daemon is not running. */
 
-       if (lstat(path, &st) == -1) {
+       if (lstat(sunaddr.sun_path, &st) == -1) {
                return -1;
        }
        
diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c
index 150d9a6..a36a66b 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 ba6153e..c5bc853 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 fba4523..8003ea9 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 2b222d7..1b44bfe 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 69b966b..710aa80 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 b49b8d2..e7cbf13 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);


-- 
Samba Shared Repository

Reply via email to