1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

Remove pstrings completely except for smbctool (what does this do ?).

Don't build this for now.
Jeremy.
This commit is contained in:
Jeremy Allison
2007-12-07 12:02:44 -08:00
parent 1d5fee5038
commit 46b67fd82c
10 changed files with 102 additions and 132 deletions

View File

@ -679,11 +679,11 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
$(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
#TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
# $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
# $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
# $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
# $(DISPLAY_SEC_OBJ)
UTIL_REG_OBJ = lib/util_reg.o
UTIL_REG_API_OBJ = lib/util_reg_api.o
@ -1168,9 +1168,9 @@ bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS)
bin/smbctool@EXEEXT@: $(BINARY_PREREQS) $(TOOL_OBJ) @BUILD_POPT@
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(TOOL_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -Lbin -lsmbclient
#bin/smbctool@EXEEXT@: $(BINARY_PREREQS) $(TOOL_OBJ) @BUILD_POPT@
# @echo Linking $@
# @$(CC) $(FLAGS) -o $@ $(TOOL_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -Lbin -lsmbclient
bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@
@echo Linking $@

View File

@ -27,15 +27,15 @@ extern char const *dyn_SBINDIR,
*dyn_BINDIR,
*dyn_SWATDIR;
extern pstring dyn_CONFIGFILE;
extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
extern pstring dyn_LIBDIR;
extern pstring dyn_CODEPAGEDIR;
extern char dyn_CONFIGFILE[1024];
extern char dyn_LOGFILEBASE[1024], dyn_LMHOSTSFILE[1024];
extern char dyn_LIBDIR[1024];
extern char dyn_CODEPAGEDIR[1024];
extern fstring dyn_SHLIBEXT;
extern pstring dyn_LOCKDIR;
extern pstring dyn_PIDDIR;
extern pstring dyn_SMB_PASSWD_FILE;
extern pstring dyn_PRIVATE_DIR;
extern char dyn_LOCKDIR[1024];
extern char dyn_PIDDIR[1024];
extern char dyn_SMB_PASSWD_FILE[1024];
extern char dyn_PRIVATE_DIR[1024];
char *dyn_STATEDIR(void);
char *dyn_CACHEDIR(void);

View File

@ -617,8 +617,9 @@ struct timespec {
#define NGROUPS_MAX 32 /* Guess... */
#endif
/* Our own pstrings and fstrings */
#include "pstring.h"
/* Our own fstrings */
#define FSTRING_LEN 256
typedef char fstring[FSTRING_LEN];
/* Lists, trees, caching, database... */
#include "xfile.h"
@ -1033,8 +1034,6 @@ int d_fprintf(FILE *f, const char *, ...) PRINTF_ATTRIBUTE(2,3);
/* PRINTFLIKE2 */
void sys_adminlog(int priority, const char *format_str, ...) PRINTF_ATTRIBUTE(2,3);
/* PRINTFLIKE2 */
int pstr_sprintf(pstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
/* PRINTFLIKE2 */
int fstr_sprintf(fstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);

View File

@ -40,7 +40,7 @@
typedef struct _client_referral {
uint32 proximity;
uint32 ttl;
pstring dfspath;
char *dfspath;
} CLIENT_DFS_REFERRAL;
struct referral {

View File

@ -1,35 +0,0 @@
/*
samba -- Unix SMB/CIFS implementation.
Safe standardized string types
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_LEN 1024
#define FSTRING_LEN 256
typedef char pstring[PSTRING_LEN];
typedef char fstring[FSTRING_LEN];
#define _PSTRING
#endif /* ndef _PSTRING */

View File

@ -86,16 +86,8 @@ size_t __unsafe_string_function_usage_here_char__(void);
#define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
#define push_pstring_base(dest, src, pstring_base) \
(CHECK_STRING_SIZE(pstring_base, sizeof(pstring)) \
? __unsafe_string_function_usage_here_size_t__() \
: push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE))
#else /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */
#define push_pstring_base(dest, src, pstring_base) \
push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE)
#endif /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */
#define safe_strcpy_base(dest, src, base, size) \
@ -105,8 +97,6 @@ size_t __unsafe_string_function_usage_here_char__(void);
but the best we can do in C) and may tag with function name/number to
record the last 'clobber region' on that string */
#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)
#define nstrcpy(d,s) safe_strcpy((d), (s),sizeof(nstring)-1)

View File

@ -2211,9 +2211,9 @@ void dump_data(int level, const unsigned char *buf1,int len)
n = MIN(8,i%16);
print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
n = (i%16) - n;
if (n>0) print_asc(level,&buf[i-n],n);
DEBUGADD(level,("\n"));
}
if (n>0) print_asc(level,&buf[i-n],n);
DEBUGADD(level,("\n"));
}
}
void dump_data_pw(const char *msg, const uchar * data, size_t len)
@ -2229,10 +2229,10 @@ void dump_data_pw(const char *msg, const uchar * data, size_t len)
char *tab_depth(int depth)
{
static pstring spaces;
static fstring spaces;
size_t len = depth * 4;
if (len > sizeof(pstring)-1) {
len = sizeof(pstring)-1;
if (len > sizeof(fstring)-1) {
len = sizeof(fstring)-1;
}
memset(spaces, ' ', len);
@ -2254,7 +2254,7 @@ int str_checksum(const char *s)
int res = 0;
int c;
int i=0;
while(*s) {
c = *s;
res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
@ -2564,7 +2564,7 @@ char *pid_path(const char *name)
*
* @param name File to find, relative to LIBDIR.
*
* @retval Pointer to a static #pstring containing the full path.
* @retval Pointer to a string containing the full path.
**/
char *lib_path(const char *name)

View File

@ -1277,7 +1277,7 @@ void fstring_sub(char *s,const char *pattern,const char *insert)
/**
Similar to string_sub2, but it will accept only allocated strings
and may realloc them so pay attention at what you pass on no
pointers inside strings, no pstrings or const may be passed
pointers inside strings, no const may be passed
as string.
**/
@ -1992,21 +1992,6 @@ char *binary_string(char *buf, int len)
s[j] = 0;
return s;
}
/**
Just a typesafety wrapper for snprintf into a pstring.
**/
int pstr_sprintf(pstring s, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vsnprintf(s, PSTRING_LEN, fmt, ap);
va_end(ap);
return ret;
}
/**
Just a typesafety wrapper for snprintf into a fstring.

View File

@ -570,7 +570,8 @@ static bool cli_dfs_check_error( struct cli_state *cli, NTSTATUS status )
Get the dfs referral link.
********************************************************************/
bool cli_dfs_get_referral(struct cli_state *cli,
bool cli_dfs_get_referral(TALLOC_CTX *ctx,
struct cli_state *cli,
const char *path,
CLIENT_DFS_REFERRAL**refs,
size_t *num_refs,
@ -579,83 +580,116 @@ bool cli_dfs_get_referral(struct cli_state *cli,
unsigned int data_len = 0;
unsigned int param_len = 0;
uint16 setup = TRANSACT2_GET_DFS_REFERRAL;
char param[1024+2];
char *param;
char *rparam=NULL, *rdata=NULL;
char *p;
char *endp;
size_t pathlen = 2*(strlen(path)+1);
uint16 num_referrals;
CLIENT_DFS_REFERRAL *referrals = NULL;
bool ret = false;
memset(param, 0, sizeof(param));
*num_refs = 0;
*refs = NULL;
param = SMB_MALLOC(2+pathlen+2);
if (!param) {
return false;
}
SSVAL(param, 0, 0x03); /* max referral level */
p = &param[2];
p += clistr_push(cli, p, path, MIN(pathlen, sizeof(param)-2),
STR_TERMINATE);
p += clistr_push(cli, p, path, pathlen, STR_TERMINATE);
param_len = PTR_DIFF(p, param);
if (!cli_send_trans(cli, SMBtrans2,
NULL, /* name */
-1, 0, /* fid, flags */
&setup, 1, 0, /* setup, length, max */
param, param_len, 2, /* param, length, max */
NULL, 0, cli->max_xmit /* data, length, max */
)) {
return false;
NULL, /* name */
-1, 0, /* fid, flags */
&setup, 1, 0, /* setup, length, max */
param, param_len, 2, /* param, length, max */
NULL, 0, cli->max_xmit /* data, length, max */
)) {
SAFE_FREE(param);
return false;
}
SAFE_FREE(param);
if (!cli_receive_trans(cli, SMBtrans2,
&rparam, &param_len,
&rdata, &data_len)) {
return false;
}
*consumed = SVAL( rdata, 0 );
num_referrals = SVAL( rdata, 2 );
if (data_len < 4) {
goto out;
}
if ( num_referrals != 0 ) {
endp = rdata + data_len;
*consumed = SVAL(rdata, 0);
num_referrals = SVAL(rdata, 2);
if (num_referrals != 0) {
uint16 ref_version;
uint16 ref_size;
int i;
uint16 node_offset;
referrals = SMB_XMALLOC_ARRAY( CLIENT_DFS_REFERRAL,
referrals = TALLOC_ARRAY(ctx, CLIENT_DFS_REFERRAL,
num_referrals);
if (!referrals) {
goto out;
}
/* start at the referrals array */
p = rdata+8;
for ( i=0; i<num_referrals; i++ ) {
ref_version = SVAL( p, 0 );
ref_size = SVAL( p, 2 );
node_offset = SVAL( p, 16 );
for (i=0; i<num_referrals && p < endp; i++) {
if (p + 18 > endp) {
goto out;
}
ref_version = SVAL(p, 0);
ref_size = SVAL(p, 2);
node_offset = SVAL(p, 16);
if ( ref_version != 3 ) {
if (ref_version != 3) {
p += ref_size;
continue;
}
referrals[i].proximity = SVAL( p, 8 );
referrals[i].ttl = SVAL( p, 10 );
referrals[i].proximity = SVAL(p, 8);
referrals[i].ttl = SVAL(p, 10);
clistr_pull( cli, referrals[i].dfspath, p+node_offset,
sizeof(referrals[i].dfspath), -1,
if (p + node_offset > endp) {
goto out;
}
clistr_pull_talloc(ctx, cli, &referrals[i].dfspath,
p+node_offset,
STR_TERMINATE|STR_UNICODE );
if (!referrals[i].dfspath) {
goto out;
}
p += ref_size;
}
if (i < num_referrals) {
goto out;
}
}
ret = true;
*num_refs = num_referrals;
*refs = referrals;
out:
SAFE_FREE(rdata);
SAFE_FREE(rparam);
return true;
return ret;
}
/********************************************************************
********************************************************************/
@ -667,7 +701,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
char **pp_targetpath)
{
CLIENT_DFS_REFERRAL *refs = NULL;
size_t num_refs;
size_t num_refs = 0;
uint16 consumed;
struct cli_state *cli_ipc = NULL;
char *dfs_path = NULL;
@ -746,15 +780,17 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
return false;
}
if (!cli_dfs_get_referral(cli_ipc, dfs_path, &refs,
if (!cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs,
&num_refs, &consumed) || !num_refs) {
return false;
}
/* Just store the first referral for now. */
if (!refs[0].dfspath) {
return false;
}
split_dfs_path(ctx, refs[0].dfspath, &server, &share, &extrapath );
SAFE_FREE(refs);
if (!server || !share) {
return false;
@ -876,7 +912,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
char **pp_newshare )
{
CLIENT_DFS_REFERRAL *refs = NULL;
size_t num_refs;
size_t num_refs = 0;
uint16 consumed;
char *fullpath = NULL;
bool res;
@ -908,25 +944,25 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
return false;
}
res = cli_dfs_get_referral(cli, fullpath, &refs, &num_refs, &consumed);
res = cli_dfs_get_referral(ctx, cli, fullpath, &refs, &num_refs, &consumed);
if (!cli_tdis(cli)) {
SAFE_FREE(refs);
return false;
}
cli->cnum = cnum;
if (!res || !num_refs) {
SAFE_FREE(refs);
return false;
}
if (!refs[0].dfspath) {
return false;
}
split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
pp_newshare, &newextrapath );
SAFE_FREE(refs);
if (!pp_newserver || !pp_newshare) {
return false;
}

View File

@ -43,13 +43,8 @@
/* 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 */