diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/asn1.c | 2 | ||||
-rw-r--r-- | source3/libsmb/cliconnect.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clidgram.c | 4 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clierror.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clikrb5.c | 2 | ||||
-rw-r--r-- | source3/libsmb/cliprint.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clirap.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clirap2.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clireadwrite.c | 12 | ||||
-rw-r--r-- | source3/libsmb/doserr.c | 4 | ||||
-rw-r--r-- | source3/libsmb/errormap.c | 6 | ||||
-rw-r--r-- | source3/libsmb/libsmb_compat.c | 8 | ||||
-rw-r--r-- | source3/libsmb/libsmbclient.c | 169 | ||||
-rw-r--r-- | source3/libsmb/namecache.c | 323 | ||||
-rw-r--r-- | source3/libsmb/namequery.c | 189 | ||||
-rw-r--r-- | source3/libsmb/nmblib.c | 8 | ||||
-rw-r--r-- | source3/libsmb/nterr.c | 8 | ||||
-rw-r--r-- | source3/libsmb/smberr.c | 12 | ||||
-rw-r--r-- | source3/libsmb/unexpected.c | 4 |
20 files changed, 470 insertions, 301 deletions
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c index b967927871..b7cfca41fb 100644 --- a/source3/libsmb/asn1.c +++ b/source3/libsmb/asn1.c @@ -338,7 +338,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) } /* check that the next object ID is correct */ -BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) +BOOL asn1_check_OID(ASN1_DATA *data, char *OID) { char *id; diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index b758af41c4..584ad15174 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1258,8 +1258,8 @@ again: if (service) { if (!cli_send_tconX(cli, service, service_type, password, strlen(password)+1)) { - nt_status = cli_nt_error(cli); DEBUG(1,("failed tcon_X with %s\n", nt_errstr(nt_status))); + nt_status = cli_nt_error(cli); cli_shutdown(cli); if (NT_STATUS_IS_OK(nt_status)) { nt_status = NT_STATUS_UNSUCCESSFUL; diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index 5ab6bef87b..8f4bdf7be6 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -26,7 +26,7 @@ * cli_send_mailslot, send a mailslot for client code ... */ -int cli_send_mailslot(int dgram_sock, BOOL unique, const char *mailslot, +int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, char *buf, int len, const char *srcname, int src_type, const char *dstname, int dest_type, @@ -100,7 +100,7 @@ int cli_send_mailslot(int dgram_sock, BOOL unique, const char *mailslot, /* * cli_get_response: Get a response ... */ -int cli_get_response(int dgram_sock, BOOL unique, const char *mailslot, char *buf, int bufsiz) +int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz) { struct packet_struct *packet; diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index ed1286d627..c843d49d27 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -327,7 +327,7 @@ void cli_shutdown(struct cli_state *cli) Set socket options on a open connection. ****************************************************************************/ -void cli_sockopt(struct cli_state *cli, const char *options) +void cli_sockopt(struct cli_state *cli, char *options) { set_socket_options(cli->fd, options); } diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 12a7b5dba1..f5281eb047 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -33,7 +33,7 @@ static const struct { int err; - const char *message; + char *message; } rap_errmap[] = { {5, "RAP5: User has insufficient privilege" }, @@ -62,7 +62,7 @@ static const struct /**************************************************************************** return a description of an SMB error ****************************************************************************/ -static const char *cli_smb_errstr(struct cli_state *cli) +static char *cli_smb_errstr(struct cli_state *cli) { return smb_dos_errstr(cli->inbuf); } @@ -73,7 +73,7 @@ static const char *cli_smb_errstr(struct cli_state *cli) in which case they can be safely ignored. ****************************************************************************/ -const char *cli_errstr(struct cli_state *cli) +char *cli_errstr(struct cli_state *cli) { static fstring cli_error_message; uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index a7b11d777e..54a8a6ffe8 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -94,7 +94,7 @@ cleanup_princ: /* get a kerberos5 ticket for the given service */ -DATA_BLOB krb5_get_ticket(const char *principal, time_t time_offset) +DATA_BLOB krb5_get_ticket(char *principal, time_t time_offset) { krb5_error_code retval; krb5_data packet; diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c index bfa33bc514..92fbf02e91 100644 --- a/source3/libsmb/cliprint.c +++ b/source3/libsmb/cliprint.c @@ -27,7 +27,7 @@ This function contains code to prevent core dumps if the server returns invalid data. *****************************************************************************/ -static const char *fix_char_ptr(unsigned int datap, unsigned int converter, +static char *fix_char_ptr(unsigned int datap, unsigned int converter, char *rdata, int rdrcnt) { if (datap == 0) { /* turn NULL pointers into zero length strings */ diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 792a3e7aa0..b4924fd773 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -26,7 +26,7 @@ /**************************************************************************** Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, @@ -176,7 +176,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *sname = p; int type = SVAL(p,14); int comment_offset = IVAL(p,16) & 0xFFFF; - const char *cmnt = comment_offset?(rdata+comment_offset-converter):""; + char *cmnt = comment_offset?(rdata+comment_offset-converter):""; pstring s1, s2; pull_ascii_pstring(s1, sname); @@ -253,7 +253,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, for (i = 0;i < count;i++, p += 26) { char *sname = p; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - const char *cmnt = comment_offset?(rdata+comment_offset):""; + char *cmnt = comment_offset?(rdata+comment_offset):""; pstring s1, s2; if (comment_offset < 0 || comment_offset > rdrcnt) continue; diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c index 948e88061a..9c3ec212d5 100644 --- a/source3/libsmb/clirap2.c +++ b/source3/libsmb/clirap2.c @@ -128,7 +128,7 @@ pull_ascii_pstring(s, off?(r+off-c):"");\ } while(0) -static char *make_header(char *param, uint16 apinum, const char *reqfmt, const char *datafmt) +static char *make_header(char *param, uint16 apinum, char *reqfmt, char *datafmt) { PUTWORD(param,apinum); if (reqfmt) diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 0715aa7f1a..187a40cade 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -248,8 +248,7 @@ ssize_t cli_readraw(struct cli_state *cli, int fnum, char *buf, off_t offset, si issue a single SMBwrite and don't wait for a reply ****************************************************************************/ -static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, - uint16 mode, const char *buf, +static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint16 mode, char *buf, size_t size, int i) { char *p; @@ -285,13 +284,10 @@ static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, SIVAL(cli->outbuf,smb_vwv5,0); SSVAL(cli->outbuf,smb_vwv7,mode); - SSVAL(cli->outbuf,smb_vwv8,(mode & 0x0008) ? size : 0); /* - * According to CIFS-TR-1p00, this following field should only - * be set if CAP_LARGE_WRITEX is set. We should check this - * locally. However, this check might already have been - * done by our callers. + * THe following is still wrong ... */ + SSVAL(cli->outbuf,smb_vwv8,(mode & 0x0008) ? size : 0); SSVAL(cli->outbuf,smb_vwv9,((size>>16)&1)); SSVAL(cli->outbuf,smb_vwv10,size); SSVAL(cli->outbuf,smb_vwv11, @@ -320,7 +316,7 @@ static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, ssize_t cli_write(struct cli_state *cli, int fnum, uint16 write_mode, - const char *buf, off_t offset, size_t size) + char *buf, off_t offset, size_t size) { int bwritten = 0; int issued = 0; diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c index c9de4cf319..02db625685 100644 --- a/source3/libsmb/doserr.c +++ b/source3/libsmb/doserr.c @@ -24,7 +24,7 @@ typedef const struct { - const char *dos_errstr; + char *dos_errstr; WERROR werror; } werror_code_struct; @@ -73,7 +73,7 @@ werror_code_struct dos_errs[] = /***************************************************************************** returns a DOS error message. not amazingly helpful, but better than a number. *****************************************************************************/ -const char *dos_errstr(WERROR werror) +char *dos_errstr(WERROR werror) { static pstring msg; int idx = 0; diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c index 09340caccd..8bd29b55c0 100644 --- a/source3/libsmb/errormap.c +++ b/source3/libsmb/errormap.c @@ -45,7 +45,7 @@ */ /* NT status -> dos error map */ -static const struct { +const static struct { uint8 dos_class; uint32 dos_code; NTSTATUS ntstatus; @@ -611,7 +611,7 @@ static const struct { /* dos -> nt status error map */ -static const struct { +const static struct { uint8 dos_class; uint32 dos_code; NTSTATUS ntstatus; @@ -866,7 +866,7 @@ static const struct { }; /* errmap NTSTATUS->Win32 */ -static const struct { +const static struct { NTSTATUS ntstatus; WERROR werror; } ntstatus_to_werror_map[] = { diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 27b274953a..bba90c648e 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -24,7 +24,11 @@ #include "includes.h" -#include "../include/libsmb_internal.h" +/* + * Define this to get the real SMBCFILE and SMBCSRV structures + */ +#define _SMBC_INTERNAL +#include "../include/libsmbclient.h" struct smbc_compat_fdlist { SMBCFILE * file; @@ -268,7 +272,7 @@ int smbc_open_print_job(const char *fname) return (int) file; } -int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) +int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn) { return statcont->list_print_jobs(statcont, purl, fn); } diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index edf582b34d..a1fb380c37 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -23,7 +23,7 @@ #include "includes.h" -#include "../include/libsmb_internal.h" +#include "../include/libsmbclient.h" /* * Functions exported by libsmb_cache.c that we need here @@ -218,7 +218,7 @@ int smbc_check_server(SMBCCTX * context, SMBCSRV * server) } /* - * Remove a server from the cached server list it's unused. + * Remove a server from the list server_table if it's unused. * On success, 0 is returned. 1 is returned if the server could not be removed. * * Also useable outside libsmbclient @@ -228,12 +228,11 @@ int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv) SMBCFILE * file; /* are we being fooled ? */ - if (!context || !context->internal || - !context->internal->_initialized || !srv) return 1; + if (!context || !context->_initialized || !srv) return 1; /* Check all open files/directories for a relation with this server */ - for (file = context->internal->_files; file; file=file->next) { + for (file = context->_files; file; file=file->next) { if (file->srv == srv) { /* Still used */ DEBUG(3, ("smbc_remove_usused_server: %p still used by %p.\n", @@ -242,7 +241,7 @@ int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv) } } - DLIST_REMOVE(context->internal->_servers, srv); + DLIST_REMOVE(context->_servers, srv); cli_shutdown(&srv->cli); @@ -475,8 +474,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m SMBCFILE *file = NULL; int fd; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; /* Best I can think of ... */ return NULL; @@ -543,7 +541,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m file->offset = 0; file->file = True; - DLIST_ADD(context->internal->_files, file); + DLIST_ADD(context->_files, file); return file; } @@ -574,8 +572,7 @@ static int creat_bits = O_WRONLY | O_CREAT | O_TRUNC; /* FIXME: Do we need this static SMBCFILE *smbc_creat_ctx(SMBCCTX *context, const char *path, mode_t mode) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return NULL; @@ -593,8 +590,7 @@ static ssize_t smbc_read_ctx(SMBCCTX *context, SMBCFILE *file, void *buf, size_t { int ret; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -603,7 +599,7 @@ static ssize_t smbc_read_ctx(SMBCCTX *context, SMBCFILE *file, void *buf, size_t DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + if (!file || !DLIST_CONTAINS(context->_files, file)) { errno = EBADF; return -1; @@ -644,15 +640,14 @@ static ssize_t smbc_write_ctx(SMBCCTX *context, SMBCFILE *file, void *buf, size_ { int ret; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || context->_initialized) { errno = EINVAL; return -1; } - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + if (!file || !DLIST_CONTAINS(context->_files, file)) { errno = EBADF; return -1; @@ -690,15 +685,14 @@ static int smbc_close_ctx(SMBCCTX *context, SMBCFILE *file) { SMBCSRV *srv; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + if (!file || !DLIST_CONTAINS(context->_files, file)) { errno = EBADF; return -1; @@ -720,7 +714,7 @@ static int smbc_close_ctx(SMBCCTX *context, SMBCFILE *file) * from the server cache if unused */ errno = smbc_errno(context, &file->srv->cli); srv = file->srv; - DLIST_REMOVE(context->internal->_files, file); + DLIST_REMOVE(context->_files, file); SAFE_FREE(file->fname); SAFE_FREE(file); context->callbacks.remove_unused_server_fn(context, srv); @@ -742,7 +736,7 @@ static int smbc_close_ctx(SMBCCTX *context, SMBCFILE *file) * from the server cache if unused */ errno = smbc_errno(context, &file->srv->cli); srv = file->srv; - DLIST_REMOVE(context->internal->_files, file); + DLIST_REMOVE(context->_files, file); SAFE_FREE(file->fname); SAFE_FREE(file); context->callbacks.remove_unused_server_fn(context, srv); @@ -750,7 +744,7 @@ static int smbc_close_ctx(SMBCCTX *context, SMBCFILE *file) return -1; } - DLIST_REMOVE(context->internal->_files, file); + DLIST_REMOVE(context->_files, file); SAFE_FREE(file->fname); SAFE_FREE(file); @@ -767,8 +761,7 @@ static BOOL smbc_getatr(SMBCCTX * context, SMBCSRV *srv, char *path, SMB_INO_T *ino) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -804,8 +797,7 @@ static int smbc_unlink_ctx(SMBCCTX *context, const char *fname) pstring path; SMBCSRV *srv = NULL; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || context->_initialized) { errno = EINVAL; /* Best I can think of ... */ return -1; @@ -899,10 +891,8 @@ static int smbc_rename_ctx(SMBCCTX *ocontext, const char *oname, pstring path1, path2; SMBCSRV *srv = NULL; - if (!ocontext || !ncontext || - !ocontext->internal || !ncontext->internal || - !ocontext->internal->_initialized || - !ncontext->internal->_initialized) { + if (!ocontext || !ncontext || + !ocontext->_initialized || !ncontext->_initialized) { errno = EINVAL; /* Best I can think of ... */ return -1; @@ -970,15 +960,14 @@ static off_t smbc_lseek_ctx(SMBCCTX *context, SMBCFILE *file, off_t offset, int { size_t size; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + if (!file || !DLIST_CONTAINS(context->_files, file)) { errno = EBADF; return -1; @@ -1031,8 +1020,7 @@ static ino_t smbc_inode(SMBCCTX *context, const char *name) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -1100,8 +1088,7 @@ static int smbc_stat_ctx(SMBCCTX *context, const char *fname, struct stat *st) uint16 mode = 0; SMB_INO_T ino = 0; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; /* Best I can think of ... */ return -1; @@ -1184,15 +1171,14 @@ static int smbc_fstat_ctx(SMBCCTX *context, SMBCFILE *file, struct stat *st) uint16 mode; SMB_INO_T ino = 0; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + if (!file || !DLIST_CONTAINS(context->_files, file)) { errno = EBADF; return -1; @@ -1285,6 +1271,9 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint ZERO_STRUCTP(dirent); + ZERO_STRUCTP(dirent); + + if (dir->dir_list == NULL) { dir->dir_list = malloc(sizeof(struct smbc_dir_list)); @@ -1365,6 +1354,8 @@ list_fn(const char *name, uint32 type, const char *comment, void *state) dirent_type = SMBC_FILE_SHARE; /* FIXME, error? */ break; } + ZERO_STRUCTP(dir->dir_list); + } else dirent_type = dir->dir_type; @@ -1399,9 +1390,9 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) SMBCSRV *srv = NULL; SMBCFILE *dir = NULL; struct in_addr rem_ip; + int slot = 0; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return NULL; @@ -1497,6 +1488,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) return NULL; } + ZERO_STRUCTP(dir->dir_end); dir->srv = srv; @@ -1676,7 +1668,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) } - DLIST_ADD(context->internal->_files, dir); + DLIST_ADD(context->_files, dir); return dir; } @@ -1688,15 +1680,14 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) static int smbc_closedir_ctx(SMBCCTX *context, SMBCFILE *dir) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { + if (!dir || !DLIST_CONTAINS(context->_files, dir)) { errno = EBADF; return -1; @@ -1705,7 +1696,7 @@ static int smbc_closedir_ctx(SMBCCTX *context, SMBCFILE *dir) smbc_remove_dir(dir); /* Clean it up */ - DLIST_REMOVE(context->internal->_files, dir); + DLIST_REMOVE(context->_files, dir); if (dir) { @@ -1728,15 +1719,14 @@ struct smbc_dirent *smbc_readdir_ctx(SMBCCTX *context, SMBCFILE *dir) /* Check that all is ok first ... */ - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return NULL; } - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { + if (!dir || !DLIST_CONTAINS(context->_files, dir)) { errno = EBADF; return NULL; @@ -1765,12 +1755,12 @@ struct smbc_dirent *smbc_readdir_ctx(SMBCCTX *context, SMBCFILE *dir) /* Hmmm, do I even need to copy it? */ - memcpy(context->internal->_dirent, dirent, dirent->dirlen); /* Copy the dirent */ - dirp = (struct smbc_dirent *)context->internal->_dirent; + memcpy(context->_dirent, dirent, dirent->dirlen); /* Copy the dirent */ + dirp = (struct smbc_dirent *)context->_dirent; dirp->comment = (char *)(&dirp->name + dirent->namelen + 1); dir->dir_next = dir->dir_next->next; - return (struct smbc_dirent *)context->internal->_dirent; + return (struct smbc_dirent *)context->_dirent; } } @@ -1787,15 +1777,14 @@ static int smbc_getdents_ctx(SMBCCTX *context, SMBCFILE *dir, struct smbc_dirent /* Check that all is ok first ... */ - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { + if (!dir || !DLIST_CONTAINS(context->_files, dir)) { errno = EBADF; return -1; @@ -1874,8 +1863,7 @@ static int smbc_mkdir_ctx(SMBCCTX *context, const char *fname, mode_t mode) fstring server, share, user, password, workgroup; pstring path; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -1961,8 +1949,7 @@ static int smbc_rmdir_ctx(SMBCCTX *context, const char *fname) fstring server, share, user, password, workgroup; pstring path; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -2059,15 +2046,14 @@ static int smbc_rmdir_ctx(SMBCCTX *context, const char *fname) static off_t smbc_telldir_ctx(SMBCCTX *context, SMBCFILE *dir) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; } - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { + if (!dir || !DLIST_CONTAINS(context->_files, dir)) { errno = EBADF; return -1; @@ -2124,8 +2110,7 @@ static int smbc_lseekdir_ctx(SMBCCTX *context, SMBCFILE *dir, off_t offset) struct smbc_dirent *dirent = (struct smbc_dirent *)offset; struct smbc_dir_list *list_ent = NULL; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -2171,8 +2156,7 @@ static int smbc_lseekdir_ctx(SMBCCTX *context, SMBCFILE *dir, off_t offset) static int smbc_fstatdir_ctx(SMBCCTX *context, SMBCFILE *dir, struct stat *st) { - if (!context || !context->internal || - !context->internal->_initialized) { + if (context || !context->_initialized) { errno = EINVAL; return -1; @@ -2194,8 +2178,7 @@ static SMBCFILE *smbc_open_print_job_ctx(SMBCCTX *context, const char *fname) fstring server, share, user, password; pstring path; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || context->_initialized) { errno = EINVAL; return NULL; @@ -2232,8 +2215,8 @@ static int smbc_print_file_ctx(SMBCCTX *c_file, const char *fname, SMBCCTX *c_pr int bytes, saverr, tot_bytes = 0; char buf[4096]; - if (!c_file || !c_file->internal->_initialized || !c_print || - !c_print->internal->_initialized) { + if (!c_file || !c_file->_initialized || !c_print || + !c_print->_initialized) { errno = EINVAL; return -1; @@ -2302,14 +2285,13 @@ static int smbc_print_file_ctx(SMBCCTX *c_file, const char *fname, SMBCCTX *c_pr * Routine to list print jobs on a printer share ... */ -static int smbc_list_print_jobs_ctx(SMBCCTX *context, const char *fname, smbc_list_print_job_fn fn) +static int smbc_list_print_jobs_ctx(SMBCCTX *context, const char *fname, void (*fn)(struct print_job_info *)) { SMBCSRV *srv; fstring server, share, user, password, workgroup; pstring path; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -2339,7 +2321,7 @@ static int smbc_list_print_jobs_ctx(SMBCCTX *context, const char *fname, smbc_li } - if (cli_print_queue(&srv->cli, (void (*)(struct print_job_info *))fn) < 0) { + if (cli_print_queue(&srv->cli, fn) < 0) { errno = smbc_errno(context, &srv->cli); return -1; @@ -2361,8 +2343,7 @@ static int smbc_unlink_print_job_ctx(SMBCCTX *context, const char *fname, int id pstring path; int err; - if (!context || !context->internal || - !context->internal->_initialized) { + if (!context || !context->_initialized) { errno = EINVAL; return -1; @@ -2413,23 +2394,14 @@ SMBCCTX * smbc_new_context(void) { SMBCCTX * context; - context = malloc(sizeof(SMBCCTX)); + context = malloc(sizeof(*context)); if (!context) { errno = ENOMEM; return NULL; } - + ZERO_STRUCTP(context); - context->internal = malloc(sizeof(struct smbc_internal_data)); - if (!context->internal) { - errno = ENOMEM; - return NULL; - } - - ZERO_STRUCTP(context->internal); - - /* ADD REASONABLE DEFAULTS */ context->debug = 0; context->timeout = 20000; /* 20 seconds */ @@ -2484,25 +2456,25 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx) SMBCFILE * f; DEBUG(1,("Performing aggressive shutdown.\n")); - f = context->internal->_files; + f = context->_files; while (f) { context->close(context, f); f = f->next; } - context->internal->_files = NULL; + context->_files = NULL; /* First try to remove the servers the nice way. */ if (context->callbacks.purge_cached_fn(context)) { SMBCSRV * s; DEBUG(1, ("Could not purge all servers, Nice way shutdown failed.\n")); - s = context->internal->_servers; + s = context->_servers; while (s) { cli_shutdown(&s->cli); context->callbacks.remove_cached_srv_fn(context, s); SAFE_FREE(s); s = s->next; } - context->internal->_servers = NULL; + context->_servers = NULL; } } else { @@ -2512,12 +2484,12 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx) errno = EBUSY; return 1; } - if (context->internal->_servers) { + if (context->_servers) { DEBUG(1, ("Active servers in context, free_context failed.\n")); errno = EBUSY; return 1; } - if (context->internal->_files) { + if (context->_files) { DEBUG(1, ("Active files in context, free_context failed.\n")); errno = EBUSY; return 1; @@ -2530,7 +2502,6 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx) SAFE_FREE(context->user); DEBUG(3, ("Context %p succesfully freed\n", context)); - SAFE_FREE(context->internal); SAFE_FREE(context); return 0; } @@ -2549,13 +2520,13 @@ SMBCCTX * smbc_init_context(SMBCCTX * context) int pid; char *user = NULL, *home = NULL; - if (!context || !context->internal) { + if (!context) { errno = EBADF; return NULL; } /* Do not initialise the same client twice */ - if (context->internal->_initialized) { + if (context->_initialized) { return 0; } @@ -2662,7 +2633,7 @@ SMBCCTX * smbc_init_context(SMBCCTX * context) * FIXME: Should we check the function pointers here? */ - context->internal->_initialized = 1; + context->_initialized = 1; return context; } diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c index 40777011a1..724e0237d2 100644 --- a/source3/libsmb/namecache.c +++ b/source3/libsmb/namecache.c @@ -1,10 +1,9 @@ /* Unix SMB/CIFS implementation. - NetBIOS name cache module on top of gencache mechanism. - - Copyright (C) Tim Potter 2002 - Copyright (C) Rafal Szczesniak 2002 + NetBIOS name cache module. + + Copyright (C) Tim Potter, 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 @@ -23,224 +22,242 @@ #include "includes.h" -#define NBTKEY_FMT "NBT/%s#%02X" +static BOOL done_namecache_init; +static BOOL enable_namecache; +static TDB_CONTEXT *namecache_tdb; +struct nc_value { + time_t expiry; /* When entry expires */ + int count; /* Number of addresses */ + struct in_addr ip_list[1]; /* Address list */ +}; -/** - * Initialise namecache system. Function calls gencache - * initialisation function to perform necessary actions - * - * @return true upon successful initialisation of the cache or - * false on failure - **/ +/* Initialise namecache system */ BOOL namecache_enable(void) { - /* - * Check if name caching disabled by setting the name cache - * timeout to zero. - */ + /* Check if we have been here before, or name caching disabled + by setting the name cache timeout to zero. */ + + if (done_namecache_init) + return False; + + done_namecache_init = True; if (lp_name_cache_timeout() == 0) { - DEBUG(5, ("namecache_enable: disabling netbios name cache\n")); + DEBUG(5, ("namecache_init: disabling netbios name cache\n")); return False; } - /* Init namecache by calling gencache initialisation */ + /* Open namecache tdb in read/write or readonly mode */ - if (!gencache_init()) { - DEBUG(2, ("namecache_enable: Couldn't initialise namecache on top of gencache.\n")); + namecache_tdb = tdb_open_log( + lock_path("namecache.tdb"), 0, + TDB_DEFAULT, O_RDWR | O_CREAT, 0644); + + if (!namecache_tdb) { + DEBUG(5, ("namecache_init: could not open %s\n", + lock_path("namecache.tdb"))); return False; } - /* I leave it for now, though I don't think we really need this (mimir, 27.09.2002) */ - DEBUG(5, ("namecache_enable: enabling netbios namecache, timeout %d " + DEBUG(5, ("namecache_init: enabling netbios namecache, timeout %d " "seconds\n", lp_name_cache_timeout())); + enable_namecache = True; + return True; } +/* Return a key for a name and name type. The caller must free + retval.dptr when finished. */ -/** - * Shutdown namecache. Routine calls gencache close function - * to safely close gencache file. - * - * @return true upon successful shutdown of the cache or - * false on failure - **/ - -BOOL namecache_shutdown(void) +static TDB_DATA namecache_key(const char *name, int name_type) { - if (!gencache_shutdown()) { - DEBUG(2, ("namecache_shutdown: Couldn't close namecache on top of gencache.\n")); - return False; - } - - DEBUG(5, ("namecache_shutdown: netbios namecache closed successfully.\n")); - return True; -} + TDB_DATA retval; + char *keystr; + asprintf(&keystr, "%s#%02X", strupper_static(name), name_type); -/** - * Generates a key for netbios name lookups on basis of - * netbios name and type. - * The caller must free returned key string when finished. - * - * @param name netbios name string (case insensitive) - * @param name_type netbios type of the name being looked up - * - * @return string consisted of uppercased name and appended - * type number - */ + retval.dsize = strlen(keystr) + 1; + retval.dptr = keystr; -static char* namecache_key(const char *name, int name_type) + return retval; +} + +/* Return a data value for an IP list. The caller must free + retval.dptr when finished. */ + +static TDB_DATA namecache_value(struct in_addr *ip_list, int num_names, + time_t expiry) { - char *keystr; - asprintf(&keystr, NBTKEY_FMT, strupper_static(name), name_type); + TDB_DATA retval; + struct nc_value *value; + int size = sizeof(struct nc_value); - return keystr; -} + if (num_names > 0) + size += sizeof(struct in_addr) * (num_names-1); + + value = (struct nc_value *)malloc(size); + + memset(value, 0, size); + + value->expiry = expiry; + value->count = num_names; + if (ip_list) + memcpy(value->ip_list, ip_list, sizeof(struct in_addr) * num_names); -/** - * Store a name(s) in the name cache - * - * @param name netbios names array - * @param name_type integer netbios name type - * @param num_names number of names being stored - * @param ip_list array of in_addr structures containing - * ip addresses being stored - **/ + retval.dptr = (char *)value; + retval.dsize = size; -BOOL namecache_store(const char *name, int name_type, - int num_names, struct in_addr *ip_list) + return retval; +} + +/* Store a name in the name cache */ + +void namecache_store(const char *name, int name_type, + int num_names, struct in_addr *ip_list) { + TDB_DATA key, value; time_t expiry; - char *key, *value_string; int i; - /* - * we use gecache call to avoid annoying debug messages about - * initialised namecache again and again... - */ - if (!gencache_init()) return False; + if (!enable_namecache) + return; DEBUG(5, ("namecache_store: storing %d address%s for %s#%02x: ", - num_names, num_names == 1 ? "": "es", name, name_type)); + num_names, num_names == 1 ? "": "es", name, name_type)); for (i = 0; i < num_names; i++) DEBUGADD(5, ("%s%s", inet_ntoa(ip_list[i]), - i == (num_names - 1) ? "" : ", ")); + i == (num_names - 1) ? "" : ", ")); DEBUGADD(5, ("\n")); key = namecache_key(name, name_type); - /* - * Cache pdc location or dc lists for only a little while - * otherwise if we lock on to a bad DC we can potentially be - * out of action for the entire cache timeout time! - */ + /* Cache pdc location or dc lists for only a little while + otherwise if we lock on to a bad DC we can potentially be + out of action for the entire cache timeout time! */ - if (name_type == 0x1b || name_type == 0x1c) + if (name_type != 0x1b || name_type != 0x1c) expiry = time(NULL) + 10; else expiry = time(NULL) + lp_name_cache_timeout(); - /* - * Generate string representation of ip addresses list - * First, store the number of ip addresses and then - * place each single ip - */ - ipstr_list_make(&value_string, ip_list, num_names); - - /* set the entry */ - return (gencache_set(key, value_string, expiry)); -} + value = namecache_value(ip_list, num_names, expiry); + tdb_store(namecache_tdb, key, value, TDB_REPLACE); + + free(key.dptr); + free(value.dptr); +} -/** - * Look up a name in the cache. - * - * @param name netbios name to look up for - * @param name_type netbios name type of @param name - * @param ip_list mallocated list of IP addresses if found in the cache, - * NULL otherwise - * @param num_names number of entries found - * - * @return true upon successful fetch or - * false if name isn't found in the cache or has expired - **/ +/* Look up a name in the name cache. Return a mallocated list of IP + addresses if the name is contained in the cache. */ BOOL namecache_fetch(const char *name, int name_type, struct in_addr **ip_list, - int *num_names) + int *num_names) { - char *key, *value; - time_t timeout; + TDB_DATA key, value; + struct nc_value *data = NULL; + time_t now; + int i; + *ip_list = NULL; *num_names = 0; - /* exit now if null pointers were passed as they're required further */ - if (!ip_list || !num_names) return False; - - if (!gencache_init()) + if (!enable_namecache) return False; - /* - * Use gencache interface - lookup the key - */ + /* Read value */ + key = namecache_key(name, name_type); - if (!gencache_get(key, &value, &timeout)) { - DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type)); - SAFE_FREE(key); - return False; - } else { - DEBUG(5, ("name %s#%02X found.\n", name, name_type)); - } - - /* - * Split up the stored value into the list of IP adresses - */ - *num_names = ipstr_list_parse(value, ip_list); + value = tdb_fetch(namecache_tdb, key); - SAFE_FREE(key); - SAFE_FREE(value); - return *num_names > 0; /* true only if some ip has been fetched */ -} + if (!value.dptr) { + DEBUG(5, ("namecache_fetch: %s#%02x not found\n", + name, name_type)); + goto done; + } + data = (struct nc_value *)value.dptr; -/** - * Delete single namecache entry. Look at the - * gencache_iterate definition. - * - **/ + /* Check expiry time */ -static void flush_netbios_name(const char* key, const char *value, time_t timeout, void* dptr) -{ - gencache_del(key); - DEBUG(5, ("Deleting entry %s\n", key)); -} + now = time(NULL); + + if (now > data->expiry) { + + DEBUG(5, ("namecache_fetch: entry for %s#%02x expired\n", + name, name_type)); + + tdb_delete(namecache_tdb, key); + value = tdb_null; -/** - * Flush all names from the name cache. - * It's done by gencache_iterate() - * - * @return True upon successful deletion or - * False in case of an error - **/ + goto done; + } + + if ((data->expiry - now) > lp_name_cache_timeout()) { + + /* Someone may have changed the system time on us */ + + DEBUG(5, ("namecache_fetch: entry for %s#%02x has bad expiry\n", + name, name_type)); + + tdb_delete(namecache_tdb, key); + + value = tdb_null; + + goto done; + } + + /* Extract and return namelist */ + + DEBUG(5, ("namecache_fetch: returning %d address%s for %s#%02x: ", + data->count, data->count == 1 ? "" : "es", name, name_type)); + + if (data->count) { + + *ip_list = (struct in_addr *)malloc( + sizeof(struct in_addr) * data->count); + + memcpy(*ip_list, data->ip_list, sizeof(struct in_addr) * data->count); + + *num_names = data->count; + + for (i = 0; i < *num_names; i++) + DEBUGADD(5, ("%s%s", inet_ntoa((*ip_list)[i]), + i == (*num_names - 1) ? "" : ", ")); + + } + + DEBUGADD(5, ("\n")); + +done: + SAFE_FREE(key.dptr); + SAFE_FREE(data); + + return value.dsize > 0; +} + +/* Flush all names from the name cache */ void namecache_flush(void) { - if (!gencache_init()) + int result; + + if (!namecache_tdb) return; - /* - * iterate through each NBT cache's entry and flush it - * by flush_netbios_name function - */ - gencache_iterate(flush_netbios_name, NULL, "NBT/*"); - DEBUG(5, ("Namecache flushed\n")); -} + result = tdb_traverse(namecache_tdb, tdb_traverse_delete_fn, NULL); + if (result == -1) + DEBUG(5, ("namecache_flush: error deleting cache entries\n")); + else + DEBUG(5, ("namecache_flush: deleted %d cache entr%s\n", + result, result == 1 ? "y" : "ies")); +} diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index f446453b9a..0f81ff3eab 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -837,6 +837,11 @@ static BOOL internal_resolve_name(const char *name, int name_type, if (resolve_hosts(name, return_iplist, return_count)) { result = True; goto done; + } else { + + /* Store negative lookup result */ + + namecache_store(name, name_type, 0, NULL); } } } else if(strequal( tok, "lmhosts")) { @@ -911,10 +916,7 @@ static BOOL internal_resolve_name(const char *name, int name_type, } /* Save in name cache */ - for (i = 0; i < *return_count && DEBUGLEVEL == 100; i++) - DEBUG(100, ("Storing name %s of type %d (ip: %s)\n", name, - name_type, inet_ntoa((*return_iplist)[i]))); - + namecache_store(name, name_type, *return_count, *return_iplist); /* Display some debugging info */ @@ -1001,6 +1003,7 @@ BOOL find_master_ip(const char *group, struct in_addr *master_ip) BOOL lookup_dc_name(const char *srcname, const char *domain, struct in_addr *dc_ip, char *ret_name) { +#if !defined(I_HATE_WINDOWS_REPLY_CODE) fstring dc_name; BOOL ret; @@ -1024,6 +1027,184 @@ BOOL lookup_dc_name(const char *srcname, const char *domain, } return False; + +#else /* defined(I_HATE_WINDOWS_REPLY_CODE) */ + +JRA - This code is broken with BDC rollover - we need to do a full +NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all... + + int retries = 3; + int retry_time = 2000; + struct timeval tval; + struct packet_struct p; + struct dgram_packet *dgram = &p.packet.dgram; + char *ptr,*p2; + char tmp[4]; + int len; + struct sockaddr_in sock_name; + int sock_len = sizeof(sock_name); + const char *mailslot = NET_LOGON_MAILSLOT; + char *mailslot_name; + char buffer[1024]; + char *bufp; + int dgm_id = generate_trn_id(); + int sock = open_socket_in(SOCK_DGRAM, 0, 3, interpret_addr(lp_socket_address()), True ); + + if(sock == -1) + return False; + + /* Find out the transient UDP port we have been allocated. */ + if(getsockname(sock, (struct sockaddr *)&sock_name, &sock_len)<0) { + DEBUG(0,("lookup_pdc_name: Failed to get local UDP port. Error was %s\n", + strerror(errno))); + close(sock); + return False; + } + + /* + * Create the request data. + */ + + memset(buffer,'\0',sizeof(buffer)); + bufp = buffer; + SSVAL(bufp,0,QUERYFORPDC); + bufp += 2; + fstrcpy(bufp,srcname); + bufp += (strlen(bufp) + 1); + slprintf(bufp, sizeof(fstring)-1, "\\MAILSLOT\\NET\\GETDC%d", dgm_id); + mailslot_name = bufp; + bufp += (strlen(bufp) + 1); + bufp = ALIGN2(bufp, buffer); + bufp += push_ucs2(NULL, bufp, srcname, sizeof(buffer) - (bufp - buffer), STR_TERMINATE); + + SIVAL(bufp,0,1); + SSVAL(bufp,4,0xFFFF); + SSVAL(bufp,6,0xFFFF); + bufp += 8; + len = PTR_DIFF(bufp,buffer); + + memset((char *)&p,'\0',sizeof(p)); + + /* DIRECT GROUP or UNIQUE datagram. */ + dgram->header.msg_type = 0x10; + dgram->header.flags.node_type = M_NODE; + dgram->header.flags.first = True; + dgram->header.flags.more = False; + dgram->header.dgm_id = dgm_id; + dgram->header.source_ip = *iface_ip(*pdc_ip); + dgram->header.source_port = ntohs(sock_name.sin_port); + dgram->header.dgm_length = 0; /* Let build_dgram() handle this. */ + dgram->header.packet_offset = 0; + + make_nmb_name(&dgram->source_name,srcname,0); + make_nmb_name(&dgram->dest_name,domain,0x1C); + + ptr = &dgram->data[0]; + + /* Setup the smb part. */ + ptr -= 4; /* XXX Ugliness because of handling of tcp SMB length. */ + memcpy(tmp,ptr,4); + set_message(ptr,17,17 + len,True); + memcpy(ptr,tmp,4); + + CVAL(ptr,smb_com) = SMBtrans; + SSVAL(ptr,smb_vwv1,len); + SSVAL(ptr,smb_vwv11,len); + SSVAL(ptr,smb_vwv12,70 + strlen(mailslot)); + SSVAL(ptr,smb_vwv13,3); + SSVAL(ptr,smb_vwv14,1); + SSVAL(ptr,smb_vwv15,1); + SSVAL(ptr,smb_vwv16,2); + p2 = smb_buf(ptr); + pstrcpy(p2,mailslot); + p2 = skip_string(p2,1); + + memcpy(p2,buffer,len); + p2 += len; + + dgram->datasize = PTR_DIFF(p2,ptr+4); /* +4 for tcp length. */ + + p.ip = *pdc_ip; + p.port = DGRAM_PORT; + p.fd = sock; + p.timestamp = time(NULL); + p.packet_type = DGRAM_PACKET; + + GetTimeOfDay(&tval); + + if (!send_packet(&p)) { + DEBUG(0,("lookup_pdc_name: send_packet failed.\n")); + close(sock); + return False; + } + + retries--; + + while (1) { + struct timeval tval2; + struct packet_struct *p_ret; + + GetTimeOfDay(&tval2); + if (TvalDiff(&tval,&tval2) > retry_time) { + if (!retries) + break; + if (!send_packet(&p)) { + DEBUG(0,("lookup_pdc_name: send_packet failed.\n")); + close(sock); + return False; + } + GetTimeOfDay(&tval); + retries--; + } + + if ((p_ret = receive_dgram_packet(sock,90,mailslot_name))) { + struct dgram_packet *dgram2 = &p_ret->packet.dgram; + char *buf; + char *buf2; + + buf = &dgram2->data[0]; + buf -= 4; + + if (CVAL(buf,smb_com) != SMBtrans) { + DEBUG(0,("lookup_pdc_name: datagram type %u != SMBtrans(%u)\n", (unsigned int) + CVAL(buf,smb_com), (unsigned int)SMBtrans )); + free_packet(p_ret); + continue; + } + + len = SVAL(buf,smb_vwv11); + buf2 = smb_base(buf) + SVAL(buf,smb_vwv12); + + if (len <= 0) { + DEBUG(0,("lookup_pdc_name: datagram len < 0 (%d)\n", len )); + free_packet(p_ret); + continue; + } + + DEBUG(4,("lookup_pdc_name: datagram reply from %s to %s IP %s for %s of type %d len=%d\n", + nmb_namestr(&dgram2->source_name),nmb_namestr(&dgram2->dest_name), + inet_ntoa(p_ret->ip), smb_buf(buf),SVAL(buf2,0),len)); + + if(SVAL(buf2,0) != QUERYFORPDC_R) { + DEBUG(0,("lookup_pdc_name: datagram type (%u) != QUERYFORPDC_R(%u)\n", + (unsigned int)SVAL(buf,0), (unsigned int)QUERYFORPDC_R )); + free_packet(p_ret); + continue; + } + + buf2 += 2; + /* Note this is safe as it is a bounded strcpy. */ + fstrcpy(ret_name, buf2); + ret_name[sizeof(fstring)-1] = '\0'; + close(sock); + free_packet(p_ret); + return True; + } + } + + close(sock); + return False; +#endif /* defined(I_HATE_WINDOWS_REPLY_CODE) */ } /******************************************************** diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index 30ce5b6b10..d38e2ff0ec 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -25,7 +25,7 @@ int num_good_sends = 0; int num_good_receives = 0; static const struct opcode_names { - const char *nmb_opcode_name; + char *nmb_opcode_name; int opcode; } nmb_header_opcode_names[] = { {"Query", 0 }, @@ -57,7 +57,7 @@ static const char *lookup_opcode_name( int opcode ) /**************************************************************************** print out a res_rec structure ****************************************************************************/ -static void debug_nmb_res_rec(struct res_rec *res, const char *hdr) +static void debug_nmb_res_rec(struct res_rec *res, char *hdr) { int i, j; @@ -1005,7 +1005,7 @@ struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id) queue. The packet must be a reply packet and have the specified mailslot name The timeout is in milliseconds ***************************************************************************/ -struct packet_struct *receive_dgram_packet(int fd, int t, const char *mailslot_name) +struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name) { struct packet_struct *p; @@ -1024,7 +1024,7 @@ struct packet_struct *receive_dgram_packet(int fd, int t, const char *mailslot_n /**************************************************************************** see if a datagram has the right mailslot name ***************************************************************************/ -BOOL match_mailslot_name(struct packet_struct *p, const char *mailslot_name) +BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name) { struct dgram_packet *dgram = &p->packet.dgram; char *buf; diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c index dbad05b91e..e494995f86 100644 --- a/source3/libsmb/nterr.c +++ b/source3/libsmb/nterr.c @@ -24,7 +24,7 @@ typedef const struct { - const char *nt_errstr; + char *nt_errstr; NTSTATUS nt_errcode; } nt_err_code_struct; @@ -575,7 +575,7 @@ nt_err_code_struct nt_err_desc[] = /***************************************************************************** returns an NT error message. not amazingly helpful, but better than a number. *****************************************************************************/ -const char *nt_errstr(NTSTATUS nt_code) +char *nt_errstr(NTSTATUS nt_code) { static pstring msg; int idx = 0; @@ -597,7 +597,7 @@ const char *nt_errstr(NTSTATUS nt_code) Print friendler version fo NT error code ***********************************************************************/ -const char *get_friendly_nt_error_msg(NTSTATUS nt_code) +char *get_friendly_nt_error_msg(NTSTATUS nt_code) { int idx = 0; @@ -617,7 +617,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code) /***************************************************************************** returns an NT_STATUS constant as a string for inclusion in autogen C code *****************************************************************************/ -const char *get_nt_error_c_code(NTSTATUS nt_code) +char *get_nt_error_c_code(NTSTATUS nt_code) { static pstring out; int idx = 0; diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c index 82efbdb689..724c8edd54 100644 --- a/source3/libsmb/smberr.c +++ b/source3/libsmb/smberr.c @@ -37,9 +37,9 @@ typedef const struct { - const char *name; + char *name; int code; - const char *message; + char *message; } err_code_struct; /* Dos Error Messages */ @@ -142,7 +142,7 @@ err_code_struct hard_msgs[] = { const struct { int code; - const char *class; + char *class; err_code_struct *err_msgs; } err_classes[] = { {0,"SUCCESS",NULL}, @@ -160,7 +160,7 @@ const struct /**************************************************************************** return a SMB error name from a class and code ****************************************************************************/ -const char *smb_dos_err_name(uint8 class, uint16 num) +char *smb_dos_err_name(uint8 class, uint16 num) { static pstring ret; int i,j; @@ -184,7 +184,7 @@ const char *smb_dos_err_name(uint8 class, uint16 num) /* Return a string for a DOS error */ -const char *get_dos_error_msg(WERROR result) +char *get_dos_error_msg(WERROR result) { uint16 errnum; @@ -196,7 +196,7 @@ const char *get_dos_error_msg(WERROR result) /**************************************************************************** return a SMB error class name as a string. ****************************************************************************/ -const char *smb_dos_err_class(uint8 class) +char *smb_dos_err_class(uint8 class) { static pstring ret; int i; diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c index 97d6071e71..4fc3914481 100644 --- a/source3/libsmb/unexpected.c +++ b/source3/libsmb/unexpected.c @@ -110,7 +110,7 @@ void clear_unexpected(time_t t) static struct packet_struct *matched_packet; static int match_id; static enum packet_type match_type; -static const char *match_name; +static char *match_name; /**************************************************************************** tdb traversal fn to find a matching 137 packet @@ -144,7 +144,7 @@ static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void check for a particular packet in the unexpected packet queue **************************************************************************/ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, - const char *mailslot_name) + char *mailslot_name) { TDB_CONTEXT *tdb2; |