From 10e7ae7e7463879b89abaae37f80253a19df3c4f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 19 Aug 2002 15:33:54 +0000 Subject: remove 'admin log' parameter (discussed with Jeremy) remove 'alternate permissions' parameter (deprecated and not used since 2.0) (discussed with tridge) (This used to be commit 6e34651591d1de3293b239195078778ba1d0e565) --- source3/lib/system.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/system.c b/source3/lib/system.c index edda54a78d..8822d3c414 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1239,9 +1239,6 @@ void sys_adminlog(int priority, const char *format_str, ...) int ret; char **msgbuf = NULL; - if (!lp_admin_log()) - return; - va_start( ap, format_str ); ret = vasprintf( msgbuf, format_str, ap ); va_end( ap ); -- cgit From e6fa31d6cb8056b6a0e60e4068e9828599a5689a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 19 Aug 2002 16:55:29 +0000 Subject: added a generic print_guid utility, and get the byte order handing right (This used to be commit ec2c17c56f06e122868b2a55bc7c292106ad3911) --- source3/lib/util_sid.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index ad09f91234..8bb06e8866 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -525,3 +525,18 @@ char *sid_binstring(DOM_SID *sid) return s; } + +/* + print a GUID structure for debugging +*/ +void print_guid(GUID *guid) +{ + int i; + + d_printf("%08x-%04x-%04x", + IVAL(guid->info, 0), SVAL(guid->info, 4), SVAL(guid->info, 6)); + d_printf("-%02x%02x-", guid->info[8], guid->info[9]); + for (i=10;iinfo[i]); + d_printf("\n"); +} -- cgit From f744db7a5dee0764bb41c43336b1b1a933a79682 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Aug 2002 20:54:32 +0000 Subject: IFSTEST fixes for open fid, nametoolong. Jeremy. (This used to be commit e53a81261ed189881c0f07e1b46f97aa6770cab7) --- source3/lib/error.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/error.c b/source3/lib/error.c index 608d2b89ba..af8cf960e8 100644 --- a/source3/lib/error.c +++ b/source3/lib/error.c @@ -45,6 +45,9 @@ const struct unix_error_map unix_dos_nt_errmap[] = { #endif #ifdef EROFS { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, +#endif +#ifdef ENAMETOOLONG + { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID }, #endif { 0, 0, 0, NT_STATUS_OK } }; -- cgit From 1ea5e17f950a8b7f50723649a48f67b4bca75160 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 21 Aug 2002 11:48:05 +0000 Subject: Fix debug level initialization for net.c Volker (This used to be commit 5af5326f1311a49d3c8316e1dcc27037b831065a) --- source3/lib/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 842d2dac1d..6dd9225bac 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -350,7 +350,7 @@ int debug_lookup_classname(const char *classname) /**************************************************************************** -dump the current registered denug levels +dump the current registered debug levels ****************************************************************************/ static void debug_dump_status(int level) { -- cgit From d3aa76cef528a15571cade12ebdd10973f4ca579 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Aug 2002 19:59:23 +0000 Subject: Patch from Paul Green to be more POSIX-compatible (This used to be commit addf29e6765393b25c35bd833d29e29e4581c233) --- source3/lib/util_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 5e2b7c5ed9..56ef4a6ab1 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -871,7 +871,7 @@ static BOOL matchname(char *remotehost,struct in_addr addr) /* Look up the host address in the address list we just got. */ for (i = 0; hp->h_addr_list[i]; i++) { - if (memcmp(hp->h_addr_list[i], (caddr_t) & addr, sizeof(addr)) == 0) + if (memcmp(hp->h_addr_list[i], (char *) & addr, sizeof(addr)) == 0) return True; } -- cgit From 7c4d1ba0581dfd152a876f8726124938515410bd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Aug 2002 02:51:32 +0000 Subject: fix a few segfaults (This used to be commit ccb02f7cfcec4a555cf7304816c739f4bf7b46f0) --- source3/lib/system.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/system.c b/source3/lib/system.c index 8822d3c414..873b8737d5 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1233,23 +1233,23 @@ int sys_dup2(int oldfd, int newfd) Wrapper for Admin Logs. ****************************************************************************/ -void sys_adminlog(int priority, const char *format_str, ...) +void sys_adminlog(int priority, char *format_str, ...) { va_list ap; int ret; - char **msgbuf = NULL; + char *msgbuf = NULL; va_start( ap, format_str ); - ret = vasprintf( msgbuf, format_str, ap ); + ret = vasprintf( &msgbuf, format_str, ap ); va_end( ap ); if (ret == -1) return; #if defined(HAVE_SYSLOG) - syslog( priority, "%s", *msgbuf ); + syslog( priority, "%s", msgbuf ); #else - DEBUG(0,("%s", *msgbuf )); + DEBUG(0,("%s", msgbuf )); #endif - SAFE_FREE(*msgbuf); + SAFE_FREE(msgbuf); } -- cgit From 3276da43142bb4a0886747dabcfce6a436f11f25 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 22 Aug 2002 09:48:06 +0000 Subject: Spelling fixes. (This used to be commit 24fa84bda49a3a77fbc092652a0b6b132f06ff7c) --- source3/lib/account_pol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c index 07b5e2ecfc..b5f205c508 100644 --- a/source3/lib/account_pol.c +++ b/source3/lib/account_pol.c @@ -128,7 +128,7 @@ BOOL account_policy_get(int field, uint32 *value) return False; } if (!tdb_fetch_uint32(tdb, name, value)) { - DEBUG(1, ("account_policy_get: tdb_fetch_uint32 failed for feild %d (%s), returning 0", field, name)); + DEBUG(1, ("account_policy_get: tdb_fetch_uint32 failed for efild %d (%s), returning 0", field, name)); return False; } DEBUG(10,("account_policy_get: %s:%d\n", name, *value)); @@ -151,7 +151,7 @@ BOOL account_policy_set(int field, uint32 value) } if (!tdb_store_uint32(tdb, name, value)) { - DEBUG(1, ("tdb_store_uint32 failed for feild %d (%s) on value %u", field, name, value)); + DEBUG(1, ("tdb_store_uint32 failed for field %d (%s) on value %u", field, name, value)); return False; } -- cgit From a10519049eaff027056e82440444638b68b8cf3a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Aug 2002 22:44:06 +0000 Subject: added a useful unistr2 display function (This used to be commit f4581133649b5208d8f91c4995ef60579e04b6f6) --- source3/lib/util_unistr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index ba02819bdc..eb47252413 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -218,6 +218,16 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen) pull_ucs2(NULL, dest, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN); } +/******************************************************************* +give a static string for displaying a UNISTR2 +********************************************************************/ +const char *unistr2_static(const UNISTR2 *str) +{ + static pstring ret; + unistr2_to_ascii(ret, str, sizeof(ret)); + return ret; +} + /******************************************************************* duplicate a UNISTR2 string into a null terminated char* -- cgit From 89586f0b7c256c39a72dfac798e1882c97b24838 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Aug 2002 22:53:33 +0000 Subject: added smb_xstrndup() (This used to be commit 26fc20187d405702c50d1e7a38d3a94c84932bed) --- source3/lib/util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index ae94b710b2..bf012b9721 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1819,6 +1819,17 @@ char *smb_xstrdup(const char *s) return s1; } +/** + strndup that aborts on malloc fail. +**/ +char *smb_xstrndup(const char *s, size_t n) +{ + char *s1 = strndup(s, n); + if (!s1) + smb_panic("smb_xstrndup: malloc fail\n"); + return s1; +} + /* vasprintf that aborts on malloc fail */ -- cgit From 548203a0c42727d7ff3fc339968fdd448180bcae Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 23 Aug 2002 12:31:36 +0000 Subject: We need to return the value here... Andrew Bartlett (This used to be commit 8fbc964f2f40de80851cf89f7bed0ddc5d01b074) --- source3/lib/system_smbd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index 28ceaf3939..580ef8a463 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -101,5 +101,6 @@ int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt) become_root(); retval = getgrouplist_internals(user, gid, groups, grpcnt); unbecome_root(); + return retval; #endif } -- cgit From f38fc7b3b1ded90c2562bdfc9aaa7a026ec1e56a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 23 Aug 2002 15:01:07 +0000 Subject: We never checked if the smb packet len is != 0 Should fix a supposed DoS too. (This used to be commit f76e5b2677beb161c2f9c0d3dd78e707655e942f) --- source3/lib/util_sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 56ef4a6ab1..03c780f8bf 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -585,8 +585,8 @@ BOOL receive_smb(int fd,char *buffer, unsigned int timeout) memset(buffer,'\0',smb_size + 100); len = read_smb_length_return_keepalive(fd,buffer,timeout); - if (len < 0) { - DEBUG(10,("receive_smb: length < 0!\n")); + if (len < 0 || len == 0) { + DEBUG(10,("receive_smb: length < 0 or == 0!\n")); /* * Correct fix. smb_read_error may have already been -- cgit From b97a387c0ff29bcafacc8109069e1c2f3cce7c1b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 25 Aug 2002 21:46:49 +0000 Subject: Patch from mimir to back out idra's attempted DOS mitigation patch. (It broke port 139 name exchange) I've been thinking about this, and doing is properly is actually rather difficult - but I'll try and get somthing in there. (My worry is what smb_read_error should be set to, and how that interacts with the rest of samba). Andrew Bartlett (This used to be commit 3e682867bbb13dae265cb9a8acea8b7cc87d82a6) --- source3/lib/util_sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 03c780f8bf..56ef4a6ab1 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -585,8 +585,8 @@ BOOL receive_smb(int fd,char *buffer, unsigned int timeout) memset(buffer,'\0',smb_size + 100); len = read_smb_length_return_keepalive(fd,buffer,timeout); - if (len < 0 || len == 0) { - DEBUG(10,("receive_smb: length < 0 or == 0!\n")); + if (len < 0) { + DEBUG(10,("receive_smb: length < 0!\n")); /* * Correct fix. smb_read_error may have already been -- cgit From 014792fc03c9d4030794e4e06fb137cd2ce32b17 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 25 Aug 2002 23:33:22 +0000 Subject: Clarify function comments (This used to be commit a613dde7edab62c4439d256932b9f9b4ae2ec4e0) --- source3/lib/charcnv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 6e96136643..03337cbf26 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -432,6 +432,7 @@ int push_ucs2(const void *base_ptr, void *dest, const char *src, int dest_len, i * @param dest always set at least to NULL * * @retval The number of bytes occupied by the string in the destination + * or -1 in case of error. **/ int push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) { @@ -447,6 +448,7 @@ int push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) * @param dest always set at least to NULL * * @retval The number of bytes occupied by the string in the destination + * or -1 in case of error. **/ int push_ucs2_allocate(void **dest, const char *src) { -- cgit From 9c7742727a03daa486d77a4ae5f7c4314ced6ad4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 26 Aug 2002 00:43:06 +0000 Subject: Try to support non-root-mode systems without getgrouplist(). Andrew Bartlett (This used to be commit 17096315a0f30f946ddecb79708604a111c37011) --- source3/lib/system_smbd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index 580ef8a463..5eda37d903 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -41,6 +41,11 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, in gid_t *gids_saved; int ret, ngrp_saved; + if (non_root_mode()) { + *grpcnt = 0; + return 0; + } + /* work out how many groups we need to save */ ngrp_saved = getgroups(0, NULL); if (ngrp_saved == -1) { -- cgit From 2560c73026ced1917a04f0e670f51ebcc984bb86 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 26 Aug 2002 03:08:37 +0000 Subject: Updates! - Don't print an uninitialised buffer in service.c - Change some charcnv.c functions to take smb_ucs2_t ** instead of void ** - Update NTLMv2 code to use dynamic buffers - Update experimental SMB signing code - still more work to do - Move sys_getgrouplist() to SAFE_FREE() and do a DEBUG() on initgroups() failure. Andrew Bartlett (This used to be commit de1964f7fa855022258a84556b266100b917444b) --- source3/lib/charcnv.c | 8 ++++---- source3/lib/system_smbd.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 03337cbf26..cd8aa4fe55 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -434,12 +434,12 @@ int push_ucs2(const void *base_ptr, void *dest, const char *src, int dest_len, i * @retval The number of bytes occupied by the string in the destination * or -1 in case of error. **/ -int push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) +int push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src) { int src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_UCS2, src, src_len, dest); + return convert_string_talloc(ctx, CH_UNIX, CH_UCS2, src, src_len, (void **)dest); } /** @@ -450,12 +450,12 @@ int push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) * @retval The number of bytes occupied by the string in the destination * or -1 in case of error. **/ -int push_ucs2_allocate(void **dest, const char *src) +int push_ucs2_allocate(smb_ucs2_t **dest, const char *src) { int src_len = strlen(src)+1; *dest = NULL; - return convert_string_allocate(CH_UNIX, CH_UCS2, src, src_len, dest); + return convert_string_allocate(CH_UNIX, CH_UCS2, src, src_len, (void **)dest); } /**************************************************************************** diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index 5eda37d903..0cd3086945 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -61,13 +61,14 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, in ngrp_saved = getgroups(ngrp_saved, gids_saved); if (ngrp_saved == -1) { - free(gids_saved); + SAFE_FREE(gids_saved); /* very strange! */ return -1; } if (initgroups(user, gid) != 0) { - free(gids_saved); + DEBUG(0, ("getgrouplist_internals: initgroups() failed!\n")); + SAFE_FREE(gids_saved); return -1; } -- cgit From 8f6c926a8f9c8ff7abe67efb0784e0a1f96ac636 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 27 Aug 2002 09:07:08 +0000 Subject: add a trivial seeking function to xfile (tseek) that does not do SEEK_CUR and add commands reget and reput to smbclient that continues a transfer that has been onterrupted. thanks to josef Zlomek that did the original patch. (This used to be commit b275547c9ecc13bede5bd21a392fa1d695a3926d) --- source3/lib/xfile.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c index b5710f3a39..7621712e9a 100644 --- a/source3/lib/xfile.c +++ b/source3/lib/xfile.c @@ -43,6 +43,7 @@ XFILE *x_stderr = &_x_stderr; #define X_FLAG_EOF 1 #define X_FLAG_ERROR 2 +#define X_FLAG_EINVAL 3 /* simulate setvbuf() */ int x_setvbuf(XFILE *f, char *buf, int mode, size_t size) @@ -341,3 +342,36 @@ char *x_fgets(char *s, int size, XFILE *stream) *s = 0; return s0; } + +/* trivial seek, works only for SEEK_SET and SEEK_END if SEEK_CUR is + * set then an error is returned */ +off_t x_tseek(XFILE *f, off_t offset, int whence) +{ + if (f->flags & X_FLAG_ERROR) + return -1; + + /* only SEEK_SET and SEEK_END are supported */ + /* SEEK_CUR needs internal offset counter */ + if (whence != SEEK_SET && whence != SEEK_END) { + f->flags |= X_FLAG_EINVAL; + errno = EINVAL; + return -1; + } + + /* empty the buffer */ + switch (f->open_flags & O_ACCMODE) { + case O_RDONLY: + f->bufused = 0; + break; + case O_WRONLY: + if (x_fflush(f) != 0) + return -1; + break; + default: + errno = EINVAL; + return -1; + } + + f->flags &= ~X_FLAG_EOF; + return (off_t)sys_lseek(f->fd, offset, whence); +} -- cgit From f1597ae9d1e724e33d1bd25e49f75a84beae6b89 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 28 Aug 2002 02:11:24 +0000 Subject: Some debugs for panic_action. (This used to be commit 8f065f788b3af333c7c61236e33b6571b62b0c0d) --- source3/lib/util.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index bf012b9721..377457a714 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1140,8 +1140,18 @@ something really nasty happened - panic! void smb_panic(char *why) { char *cmd = lp_panic_action(); + int result; + if (cmd && *cmd) { - system(cmd); + DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd)); + result = system(cmd); + + if (result == -1) + DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n", + strerror(errno))); + else + DEBUG(0, ("smb_panic(): action returned status %d\n", + WEXITSTATUS(result))); } DEBUG(0,("PANIC: %s\n", why)); dbgflush(); -- cgit From 61e4ee500f70939b95fb293ec4005e481f95076a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Aug 2002 04:21:11 +0000 Subject: Make const (This used to be commit b1ab3bec8dc7c5d0873b7a4b4c6fab2d7591c9b3) --- source3/lib/util_seaccess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c index 9fdf03adfc..5aef69e554 100644 --- a/source3/lib/util_seaccess.c +++ b/source3/lib/util_seaccess.c @@ -224,7 +224,7 @@ void se_map_standard(uint32 *access_mask, struct standard_mapping *mapping) "Access-Checking" document in MSDN. *****************************************************************************/ -BOOL se_access_check(SEC_DESC *sd, NT_USER_TOKEN *token, +BOOL se_access_check(SEC_DESC *sd, const NT_USER_TOKEN *token, uint32 acc_desired, uint32 *acc_granted, NTSTATUS *status) { -- cgit From 2b2b0f7119fe043f61259579ce70e782f5f9ec5f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Aug 2002 04:54:43 +0000 Subject: Put in intermediate version of new SAM system. It's not stable yet, code might be ugly, etc - please don't blame me for anything but instead try to fix the code :-). Compiling of the new sam system can be enabled with the configure option --with-sam Removing passdb/passgrp.c as it's unused fix typo in utils/testparm.c (This used to be commit 4b7de5ee236c043e6169f137992baf09a95c6f2c) --- source3/lib/debug.c | 1 + source3/lib/time.c | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 6dd9225bac..65cac144cc 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -153,6 +153,7 @@ static const char *default_classname_table[] = { "rpc_srv", /* DBGC_RPC_SRV */ "rpc_cli", /* DBGC_RPC_CLI */ "passdb", /* DBGC_PASSDB */ + "sam" /* DBGC_SAM */ "auth", /* DBGC_AUTH */ "winbind", /* DBGC_WINBIND */ NULL diff --git a/source3/lib/time.c b/source3/lib/time.c index 9d87414aea..f37380df70 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -40,6 +40,12 @@ int extra_time_offset = 0; #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) #endif +void get_nttime_max(NTTIME *t) +{ + /* FIXME: This is incorrect */ + unix_to_nt_time(get_time_t_max(),t); +} + /******************************************************************* External access to time_t_min and time_t_max. ********************************************************************/ -- cgit From b786c9a2eccd821903fc057829192ce36e636c96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Aug 2002 16:35:33 +0000 Subject: Make debuglevel a string for use with debug classes (This used to be commit fc29385029bf000dc70d23154e39970ee76e4d30) --- source3/lib/popt_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index a3d6af4fbc..bbc17cb704 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -33,7 +33,7 @@ static void debug_callback(poptContext con, switch(opt->val) { case 'd': if (arg) { - DEBUGLEVEL = atoi(arg); + debug_parse_levels(arg); AllowDebugChange = False; } @@ -43,7 +43,7 @@ static void debug_callback(poptContext con, struct poptOption popt_common_debug[] = { { NULL, 0, POPT_ARG_CALLBACK, debug_callback }, - { "debuglevel", 'd', POPT_ARG_INT, NULL, 'd', "Set debug level", + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { 0 } }; -- cgit From 8e729a4d846f8cd4ee5bea549c1abbcf1653b3b3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Aug 2002 16:38:43 +0000 Subject: Move samr_make_sam_obj_sd to lib/util_seaccess.c. samtest now compiles and links successfully! (This used to be commit 0ea4bcb6b772a0d95d20f7c1a2a0c08a0ba9e466) --- source3/lib/util_seaccess.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c index 5aef69e554..87711ff5ad 100644 --- a/source3/lib/util_seaccess.c +++ b/source3/lib/util_seaccess.c @@ -21,6 +21,8 @@ #include "includes.h" +extern DOM_SID global_sid_Builtin; + /********************************************************************************** Check if this ACE has a SID in common with the token. **********************************************************************************/ @@ -442,3 +444,42 @@ SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, return sdb; } + +/******************************************************************* + samr_make_sam_obj_sd + ********************************************************************/ + +NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, SAMR_EXECUTE | SAMR_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, SAMR_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} -- cgit From dd0d4b527006d4f3724e496ff9d8be3cc1a176b3 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 30 Aug 2002 14:05:22 +0000 Subject: based on function prototype, the args were switched - this gave an error on the IRIX compiler. could whoever put the FIXME message take a look and see if it is still broken. (This used to be commit 29a8f2121114cafca07797cadaeb26c9d0055b24) --- source3/lib/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/time.c b/source3/lib/time.c index f37380df70..ef12dc15f3 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -43,7 +43,7 @@ int extra_time_offset = 0; void get_nttime_max(NTTIME *t) { /* FIXME: This is incorrect */ - unix_to_nt_time(get_time_t_max(),t); + unix_to_nt_time(t, get_time_t_max()); } /******************************************************************* -- cgit From 7aca67c3e90b55e590d8741d3c24bc37b45120b7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 31 Aug 2002 06:59:00 +0000 Subject: Add a bit of 'const' and move a lot of our 'repeditive' DEBUG() statements to 'DEBUGADD', so we don't repeat headers. (Makes them much easier to read). (Based on patch by kai) Andrew Bartlett (This used to be commit 9deada345c5f89f338530c4de62835cc1eeb3d0e) --- source3/lib/util.c | 83 +++++++++++++++++++++------------------------ source3/lib/util_seaccess.c | 19 ++++++----- 2 files changed, 49 insertions(+), 53 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 377457a714..51b92568b4 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -260,8 +260,8 @@ void show_msg(char *buf) int i; int bcc=0; - if (DEBUGLEVEL < 5) return; - + if (!DEBUGLVL(5)) return; + DEBUG(5,("size=%d\nsmb_com=0x%x\nsmb_rcls=%d\nsmb_reh=%d\nsmb_err=%d\nsmb_flg=%d\nsmb_flg2=%d\n", smb_len(buf), (int)CVAL(buf,smb_com), @@ -270,31 +270,26 @@ void show_msg(char *buf) (int)SVAL(buf,smb_err), (int)CVAL(buf,smb_flg), (int)SVAL(buf,smb_flg2))); - DEBUG(5,("smb_tid=%d\nsmb_pid=%d\nsmb_uid=%d\nsmb_mid=%d\nsmt_wct=%d\n", + DEBUGADD(5,("smb_tid=%d\nsmb_pid=%d\nsmb_uid=%d\nsmb_mid=%d\n", (int)SVAL(buf,smb_tid), (int)SVAL(buf,smb_pid), (int)SVAL(buf,smb_uid), - (int)SVAL(buf,smb_mid), - (int)CVAL(buf,smb_wct))); + (int)SVAL(buf,smb_mid))); + DEBUGADD(5,("smt_wct=%d\n",(int)CVAL(buf,smb_wct))); for (i=0;i<(int)CVAL(buf,smb_wct);i++) - { - DEBUG(5,("smb_vwv[%d]=%d (0x%X)\n",i, + DEBUGADD(5,("smb_vwv[%2d]=%5d (0x%X)\n",i, SVAL(buf,smb_vwv+2*i),SVAL(buf,smb_vwv+2*i))); - } - + bcc = (int)SVAL(buf,smb_vwv+2*(CVAL(buf,smb_wct))); - DEBUG(5,("smb_bcc=%d\n",bcc)); + DEBUGADD(5,("smb_bcc=%d\n",bcc)); if (DEBUGLEVEL < 10) return; - if (DEBUGLEVEL < 50) - { - bcc = MIN(bcc, 512); - } + if (DEBUGLEVEL < 50) bcc = MIN(bcc, 512); - dump_data(10, smb_buf(buf), bcc); + dump_data(10, smb_buf(buf), bcc); } /******************************************************************* @@ -1574,35 +1569,35 @@ void print_asc(int level, const unsigned char *buf,int len) void dump_data(int level, const char *buf1,int len) { - const unsigned char *buf = (const unsigned char *)buf1; - int i=0; - if (len<=0) return; - - DEBUG(level,("[%03X] ",i)); - for (i=0;i8) DEBUG(level,(" ")); - while (n--) DEBUG(level,(" ")); - - n = MIN(8,i%16); - print_asc(level,&buf[i-(i%16)],n); DEBUG(level,(" ")); - n = (i%16) - n; - if (n>0) print_asc(level,&buf[i-n],n); - DEBUG(level,("\n")); - } + const unsigned char *buf = (const unsigned char *)buf1; + int i=0; + if (len<=0) return; + + if (!DEBUGLVL(level)) return; + + DEBUGADD(level,("[%03X] ",i)); + for (i=0;i8) DEBUGADD(level,(" ")); + while (n--) DEBUGADD(level,(" ")); + 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")); + } } char *tab_depth(int depth) diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c index 87711ff5ad..b137023e55 100644 --- a/source3/lib/util_seaccess.c +++ b/source3/lib/util_seaccess.c @@ -44,7 +44,7 @@ static BOOL token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace) bits not yet granted. Zero means permission allowed (no more needed bits). **********************************************************************************/ -static uint32 check_ace(SEC_ACE *ace, NT_USER_TOKEN *token, uint32 acc_desired, +static uint32 check_ace(SEC_ACE *ace, const NT_USER_TOKEN *token, uint32 acc_desired, NTSTATUS *status) { uint32 mask = ace->info.mask; @@ -104,7 +104,7 @@ static uint32 check_ace(SEC_ACE *ace, NT_USER_TOKEN *token, uint32 acc_desired, include other bits requested. **********************************************************************************/ -static BOOL get_max_access( SEC_ACL *the_acl, NT_USER_TOKEN *token, uint32 *granted, +static BOOL get_max_access( SEC_ACL *the_acl, const NT_USER_TOKEN *token, uint32 *granted, uint32 desired, NTSTATUS *status) { @@ -264,12 +264,13 @@ BOOL se_access_check(SEC_DESC *sd, const NT_USER_TOKEN *token, } /* The user sid is the first in the token */ - - DEBUG(3, ("se_access_check: user sid is %s\n", sid_to_string(sid_str, &token->user_sids[PRIMARY_USER_SID_INDEX]) )); - - for (i = 1; i < token->num_sids; i++) { - DEBUG(3, ("se_access_check: also %s\n", - sid_to_string(sid_str, &token->user_sids[i]))); + if (DEBUGLVL(3)) { + DEBUG(3, ("se_access_check: user sid is %s\n", sid_to_string(sid_str, &token->user_sids[PRIMARY_USER_SID_INDEX]) )); + + for (i = 1; i < token->num_sids; i++) { + DEBUGADD(3, ("se_access_check: also %s\n", + sid_to_string(sid_str, &token->user_sids[i]))); + } } /* Is the token the owner of the SID ? */ @@ -299,7 +300,7 @@ BOOL se_access_check(SEC_DESC *sd, const NT_USER_TOKEN *token, for ( i = 0 ; i < the_acl->num_aces && tmp_acc_desired != 0; i++) { SEC_ACE *ace = &the_acl->ace[i]; - DEBUG(10,("se_access_check: ACE %u: type %d, flags = 0x%02x, SID = %s mask = %x, current desired = %x\n", + DEBUGADD(10,("se_access_check: ACE %u: type %d, flags = 0x%02x, SID = %s mask = %x, current desired = %x\n", (unsigned int)i, ace->type, ace->flags, sid_to_string(sid_str, &ace->trustee), (unsigned int) ace->info.mask, -- cgit From 098b0b40fe8a165c16a5353be0314136de42bac2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 1 Sep 2002 10:24:34 +0000 Subject: wrong way to handle things, bug found by kai (This used to be commit 58f912da47d18a6a548c50dc9d4298c6bec7ea0d) --- source3/lib/debug.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 65cac144cc..e20f329860 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -372,8 +372,7 @@ static void debug_dump_status(int level) parse the debug levels from smbcontrol. Example debug level parameter: printdrivers:7 ****************************************************************************/ -BOOL debug_parse_params(char **params, int *debuglevel_class, - BOOL *debuglevel_class_isset) +static BOOL debug_parse_params(char **params) { int i, ndx; char *class_name; @@ -386,8 +385,8 @@ BOOL debug_parse_params(char **params, int *debuglevel_class, * v.s. "all:10", this is the traditional way to set DEBUGLEVEL */ if (isdigit((int)params[0][0])) { - debuglevel_class[DBGC_ALL] = atoi(params[0]); - debuglevel_class_isset[DBGC_ALL] = True; + DEBUGLEVEL_CLASS[DBGC_ALL] = atoi(params[0]); + DEBUGLEVEL_CLASS_ISSET[DBGC_ALL] = True; i = 1; /* start processing at the next params */ } else @@ -398,8 +397,8 @@ BOOL debug_parse_params(char **params, int *debuglevel_class, if ((class_name=strtok(params[i],":")) && (class_level=strtok(NULL, "\0")) && ((ndx = debug_lookup_classname(class_name)) != -1)) { - debuglevel_class[ndx] = atoi(class_level); - debuglevel_class_isset[ndx] = True; + DEBUGLEVEL_CLASS[ndx] = atoi(class_level); + DEBUGLEVEL_CLASS_ISSET[ndx] = True; } else { DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i])); return False; @@ -426,8 +425,7 @@ BOOL debug_parse_levels(const char *params_str) params = str_list_make(params_str, NULL); - if (debug_parse_params(params, DEBUGLEVEL_CLASS, - DEBUGLEVEL_CLASS_ISSET)) + if (debug_parse_params(params)) { debug_dump_status(5); str_list_free(¶ms); -- cgit From d38ab3857f841dee9f7ec2170730b87d5af6e480 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 2 Sep 2002 10:58:03 +0000 Subject: Fix typo - Thanks Kai (This used to be commit 8fb4534212e49d2f64f45cbeb481b9f4a69f3158) --- source3/lib/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index e20f329860..c8a4721bce 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -153,7 +153,7 @@ static const char *default_classname_table[] = { "rpc_srv", /* DBGC_RPC_SRV */ "rpc_cli", /* DBGC_RPC_CLI */ "passdb", /* DBGC_PASSDB */ - "sam" /* DBGC_SAM */ + "sam", /* DBGC_SAM */ "auth", /* DBGC_AUTH */ "winbind", /* DBGC_WINBIND */ NULL -- cgit From a1aafce4dc69b4bc4967ce9b70550ee3ecfab43b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Sep 2002 19:13:06 +0000 Subject: Add bcast_msg_flags to connection struct. Allows sender to filter when sending broadcast messages. Also initial cut-down of printing notify messages (not yet finished). Jeremy. (This used to be commit aca333719695b278843c59e1c6eb07d6655fd59c) --- source3/lib/messages.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index e6d2de4a58..21470dff5c 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -382,10 +382,11 @@ void message_deregister(int msg_type) struct msg_all { int msg_type; + uint32 msg_flag; const void *buf; size_t len; BOOL duplicates; - int n_sent; + int n_sent; }; /**************************************************************************** @@ -405,13 +406,20 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void if (crec.cnum != -1) return 0; - /* if the msg send fails because the pid was not found (i.e. smbd died), + /* Don't send if the receiver hasn't registered an interest. */ + + if(!(crec.bcast_msg_flags & msg_all->msg_flag)) + return 0; + + /* If the msg send fails because the pid was not found (i.e. smbd died), * the msg has already been deleted from the messages.tdb.*/ + if (!message_send_pid(crec.pid, msg_all->msg_type, msg_all->buf, msg_all->len, msg_all->duplicates)) { - /* if the pid was not found delete the entry from connections.tdb */ + /* If the pid was not found delete the entry from connections.tdb */ + if (errno == ESRCH) { DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n", (unsigned int)crec.pid, crec.cnum, crec.name)); @@ -442,6 +450,17 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, struct msg_all msg_all; msg_all.msg_type = msg_type; + if (msg_type < 1000) + msg_all.msg_flag = FLAG_MSG_GENERAL; + else if (msg_type > 1000 && msg_type < 2000) + msg_all.msg_flag = FLAG_MSG_NMBD; + else if (msg_type > 2000 && msg_type < 3000) + msg_all.msg_flag = FLAG_MSG_PRINTING; + else if (msg_type > 3000 && msg_type < 4000) + msg_all.msg_flag = FLAG_MSG_SMBD; + else + return False; + msg_all.buf = buf; msg_all.len = len; msg_all.duplicates = duplicates_allowed; -- cgit From 2d881357149c4cec6c109b801cef487ae0955126 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Sep 2002 11:58:18 +0000 Subject: patch from metze: add a 'vfs' debug class (This used to be commit 601b56e04fddd9ddfb9be5b0a625d6d279df7f4c) --- source3/lib/debug.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index c8a4721bce..f4f3ee2f9f 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -156,6 +156,7 @@ static const char *default_classname_table[] = { "sam", /* DBGC_SAM */ "auth", /* DBGC_AUTH */ "winbind", /* DBGC_WINBIND */ + "vfs", /* DBGC_VFS */ NULL }; -- cgit From df4e6c9bcc2bb007e07c6f775e33f9174ea57931 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Sep 2002 23:10:28 +0000 Subject: As per the 'OK' at CIFS2002, only use the readline headers (and this crasy #ifdef mess...) in readline.c, we don't need or use them in the rest of Samba. (This OK was of course conditional on 'if you break it, you better fix it...') Andrew Bartlett (This used to be commit 55ee289f587f107fa03c5f889491fdaab101df2d) --- source3/lib/readline.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/readline.c b/source3/lib/readline.c index d80c571dd3..58c4ecf482 100644 --- a/source3/lib/readline.c +++ b/source3/lib/readline.c @@ -21,6 +21,24 @@ #include "includes.h" +#ifdef HAVE_LIBREADLINE +# ifdef HAVE_READLINE_READLINE_H +# include +# ifdef HAVE_READLINE_HISTORY_H +# include +# endif +# else +# ifdef HAVE_READLINE_H +# include +# ifdef HAVE_HISTORY_H +# include +# endif +# else +# undef HAVE_LIBREADLINE +# endif +# endif +#endif + #ifdef HAVE_NEW_LIBREADLINE # define RL_COMPLETION_CAST (rl_completion_func_t *) #else -- cgit From ec4f2af04a09a50e87a95c0ad494a581b0364f03 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 7 Sep 2002 04:08:03 +0000 Subject: configure.in: reflect the new example/VFS/ directory organization lib/substitue.c: added helper functions needed by recycle bin (This used to be commit 29b4b9a2b5a0347d227b1a30e3f34bf40afa6de4) --- source3/lib/substitute.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 026df0f67f..767ca0c071 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -675,6 +675,19 @@ void standard_sub_conn(connection_struct *conn, char *str, size_t len) conn->gid, current_user_info.smb_name, str, len); } +char *talloc_sub_conn(TALLOC_CTX *mem_ctx, connection_struct *conn, char *str) +{ + return talloc_sub_advanced(mem_ctx, SNUM(conn), conn->user, + conn->connectpath, conn->gid, + current_user_info.smb_name, str); +} + +char *alloc_sub_conn(connection_struct *conn, char *str) +{ + return alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath, + conn->gid, current_user_info.smb_name, str); +} + /**************************************************************************** Like standard_sub but by snum. ****************************************************************************/ -- cgit From dc1c14ca22555e55b9d784980d50ac6ad763f188 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Mon, 9 Sep 2002 21:01:53 +0000 Subject: lowercase global_myname in %L substitution (This used to be commit 43a39e85b67c026a5edd93bcd58b76ae67315975) --- source3/lib/substitute.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 767ca0c071..2550d00d14 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -297,8 +297,13 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len) case 'L' : if (local_machine_name && *local_machine_name) string_sub(p,"%L", local_machine_name,l); - else - string_sub(p,"%L", global_myname,l); + else { + pstring temp_name; + + pstrcpy(temp_name, global_myname); + strlower(temp_name); + string_sub(p,"%L", temp_name,l); + } break; case 'M' : string_sub(p,"%M", client_name(),l); -- cgit From cdca2ad1c4ca396e130a1091063c3aeedbb06cd8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 11 Sep 2002 14:07:21 +0000 Subject: added gencache implementation from mimir - thanks! (This used to be commit 05a202c287f5daeb1ccbaf9479aa93e7928e93db) --- source3/lib/gencache.c | 319 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 source3/lib/gencache.c (limited to 'source3/lib') diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c new file mode 100644 index 0000000000..9e2009ad4a --- /dev/null +++ b/source3/lib/gencache.c @@ -0,0 +1,319 @@ +/* + Unix SMB/CIFS implementation. + + Generic, persistent and shared between processes cache mechanism for use + by various parts of the Samba code + + Copyright (C) Rafal Szczesniak 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_TDB + +#define TIMEOUT_LEN 12 +#define CACHE_DATA_FMT "%12u/%s" + +static TDB_CONTEXT *cache; + +/** + * @file gencache.c + * @brief Generic, persistent and shared between processes cache mechanism + * for use by various parts of the Samba code + * + **/ + + +/** + * Cache initialisation function. Opens cache tdb file or creates + * it if does not exist. + * + * @return true on successful initialisation of the cache or + * false on failure + **/ + +BOOL gencache_init(void) +{ + char* cache_fname = NULL; + + /* skip file open if it's already opened */ + if (cache) return True; + + asprintf(&cache_fname, "%s/%s", lp_lockdir(), "gencache.tdb"); + if (cache_fname) + DEBUG(5, ("Opening cache file at %s\n", cache_fname)); + else { + DEBUG(0, ("Filename allocation failed.\n")); + return False; + } + + cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, + O_RDWR|O_CREAT, 0644); + + SAFE_FREE(cache_fname); + if (!cache) { + DEBUG(0, ("Attempt to open the cache file has failed.\n")); + return False; + } + return True; +} + + +/** + * Cache shutdown function. Closes opened cache tdb file. + * + * @return true on successful closing the cache or + * false on failure during cache shutdown + **/ + +BOOL gencache_shutdown(void) +{ + /* tdb_close routine returns 0 on successful close */ + if (!cache) return False; + DEBUG(5, ("Closing cache file\n")); + return tdb_close(cache) ? False : True; +} + + +/** + * Add one entry to the cache file. + * (it part of tridge's proposed API) + * + * @param key string that represents a key of this entry + * @param value text representation value being cached + * @param timeout time when the value is expired + * + * @return true when entry is successfuly stored or + * false on the attempt's failure + **/ + +BOOL gencache_add(const char *keystr, const char *value, time_t timeout) +{ + int ret; + TDB_DATA keybuf, databuf; + char* valstr = NULL; + + /* fail completely if get null pointers passed */ + SMB_ASSERT(keystr && value); + + if (!gencache_init()) return False; + + asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); + keybuf.dptr = strdup(keystr); + keybuf.dsize = strlen(keystr); + databuf.dptr = strdup(valstr); + databuf.dsize = strlen(valstr); + DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout \ + = %s (%d seconds %s)\n", keybuf.dptr, value, ctime(&timeout), + (int)(timeout - time(NULL)), timeout > time(NULL) ? "ahead" : "in the past")); + + ret = tdb_store(cache, keybuf, databuf, TDB_INSERT); + SAFE_FREE(valstr); + SAFE_FREE(keybuf.dptr); + SAFE_FREE(databuf.dptr); + + return ret == 0 ? True : False; +} + + +/** + * Set existing entry to the cache file. + * (it part of tridge's proposed API) + * + * @param key string that represents a key of this entry + * @param value text representation value being cached + * @param timeout time when the value is expired + * + * @return true when entry is successfuly set or + * false on the attempt's failure + **/ + +BOOL gencache_set(const char *keystr, const char *valstr, time_t timeout) +{ + int ret = -1; + TDB_DATA keybuf, databuf; + char *old_valstr, *datastr; + time_t old_timeout; + + /* fail completely if get null pointers passed */ + SMB_ASSERT(keystr && valstr); + + if (!gencache_init()) return False; + + /* + * Check whether entry exists in the cache + * Don't verify gencache_get exit code, since the entry may be expired + */ + gencache_get(keystr, &old_valstr, &old_timeout); + + if (!(old_valstr && old_timeout)) return False; + + DEBUG(10, ("Setting cache entry with key = %s; old value = %s and old timeout \ + = %s\n", keystr, old_valstr, ctime(&old_timeout))); + + asprintf(&datastr, CACHE_DATA_FMT, (int)timeout, valstr); + keybuf.dptr = strdup(keystr); + keybuf.dsize = strlen(keystr); + databuf.dptr = strdup(datastr); + databuf.dsize = strlen(datastr); + DEBUGADD(10, ("New value = %s, new timeout = %s (%d seconds %s)", valstr, + ctime(&timeout), (int)(timeout - time(NULL)), + timeout > time(NULL) ? "ahead" : "in the past")); + + + ret = tdb_store(cache, keybuf, databuf, TDB_REPLACE); + + SAFE_FREE(datastr); + SAFE_FREE(old_valstr); + SAFE_FREE(keybuf.dptr); + SAFE_FREE(databuf.dptr); + + return ret == 0 ? True : False; +} + + +/** + * Delete one entry from the cache file. + * (it part of tridge's proposed API) + * + * @param key string that represents a key of this entry + * + * @return true upon successful deletion or + * false in case of failure + **/ + +BOOL gencache_del(const char *keystr) +{ + int ret; + TDB_DATA keybuf; + + /* fail completely if get null pointers passed */ + SMB_ASSERT(keystr); + + if (!gencache_init()) return False; + + keybuf.dptr = strdup(keystr); + keybuf.dsize = strlen(keystr); + DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr)); + ret = tdb_delete(cache, keybuf); + + SAFE_FREE(keybuf.dptr); + return ret == 0 ? True : False; +} + + +/** + * Get existing entry from the cache file. + * (it part of tridge's proposed API) + * + * @param key string that represents a key of this entry + * @param value buffer that is allocated and filled with the entry value + * buffer's disposing is done outside + * @param timeout pointer to a time_t that is filled with entry's + * timeout + * + * @return true when entry is successfuly fetched or + * false on the failure + **/ + +BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout) +{ + TDB_DATA keybuf, databuf; + + /* fail completely if get null pointers passed */ + SMB_ASSERT(keystr && valstr && timeout); + + if (!gencache_init()) return False; + + keybuf.dptr = strdup(keystr); + keybuf.dsize = strlen(keystr); + databuf = tdb_fetch(cache, keybuf); + + if (databuf.dptr) { + char* entry_buf = strndup(databuf.dptr, databuf.dsize); + *valstr = (char*)malloc(sizeof(char) * (databuf.dsize - TIMEOUT_LEN)); + + sscanf(entry_buf, CACHE_DATA_FMT, (int*)timeout, *valstr); + SAFE_FREE(entry_buf); + + DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, timeout = %s\n", + *timeout > time(NULL) ? "valid" : "expired", keystr, *valstr, + ctime(timeout))); + return *timeout > time(NULL); + } else { + *valstr = NULL; + timeout = NULL; + DEBUG(10, ("Cache entry with key = %s couldn't be found\n", keystr)); + return False; + } +} + + +/** + * Iterate through all entries which key matches to specified pattern + * + * @param fn pointer to the function that will be supplied with each single + * matching cache entry (key, value and timeout) as an arguments + * @param keystr_pattern pattern the existing entries' keys are matched to + * + **/ + +void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout), + const char* keystr_pattern) +{ + TDB_LIST_NODE *node, *first_node; + TDB_DATA databuf; + char *keystr = NULL, *valstr = NULL, *entry = NULL; + time_t timeout = 0; + + /* fail completely if get null pointers passed */ + SMB_ASSERT(fn && keystr_pattern); + + if (!gencache_init()) return; + + DEBUG(5, ("Searching cache keys with pattern %s", keystr_pattern)); + node = tdb_search_keys(cache, keystr_pattern); + first_node = node; + + while (node) { + /* ensure null termination of the key string */ + node->node_key.dptr[node->node_key.dsize] = '\0'; + keystr = node->node_key.dptr; + + /* + * We don't use gencache_get function, because we need to iterate through + * all of the entries. Validity verification is up to fn routine. + */ + databuf = tdb_fetch(cache, node->node_key); + entry = strndup(databuf.dptr, databuf.dsize); + valstr = (char*)malloc(sizeof(char) * (databuf.dsize - TIMEOUT_LEN)); + sscanf(entry, CACHE_DATA_FMT, (int*)(&timeout), valstr); + + DEBUG(10, ("Calling function with arguments (key = %s, value = %s, timeout = %s)\n", + keystr, valstr, ctime(&timeout))); + fn(keystr, valstr, timeout); + + SAFE_FREE(valstr); + SAFE_FREE(entry); + node = node->next; + } + + tdb_search_list_free(first_node); +} + + -- cgit From 4f613ac61e9bc442715141188d915b537e15f4c6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Sep 2002 02:12:52 +0000 Subject: First cut at portable sendfile code. Only used in readX at the moment and doesn't actually call sendfile. Needs to be vectored through the VFS and tested on all supported platforms (Solaris/HPUX/FreeBSD/Linux). Linux doesn't actually work (2.4.19 kernel) at the moment because it doesn't have a 64-bit clean sendfile. Jeremy. (This used to be commit fd772ca7b16cd86e0d50c7ed8d537c202976a6d2) --- source3/lib/sendfile.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 source3/lib/sendfile.c (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c new file mode 100644 index 0000000000..33282e704a --- /dev/null +++ b/source3/lib/sendfile.c @@ -0,0 +1,158 @@ +/* + Unix SMB/Netbios implementation. + Version 2.2.x / 3.0.x + sendfile implementations. + Copyright (C) Jeremy Allison 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + * This file handles the OS dependent sendfile implementations. + * The API is such that it returns -1 on error, else returns the + * number of bytes written. + */ + +#include "includes.h" + +#if defined(LINUX_SENDFILE_API) + +#include + +#ifndef MSG_MORE +#define MSG_MORE 0x8000 +#endif + +ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ + size_t total=0; + ssize_t ret; + + /* + * Send the header first. + * Use MSG_MORE to cork the TCP output until sendfile is called. + */ + + while (total < header->length) { + ret = sys_send(outfd, header->data + total,header->length - total, MSG_MORE); + if (ret == -1) + return -1; + total += ret; + } + + total = count; + while (total) { + ssize_t nwritten; + do { +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) + nwritten = sendfile64(outfd, infd, &offset, total); +#else + nwritten = sendfile(outfd, infd, &offset, total); +#endif + } while (nwritten == -1 && errno == EINTR); + if (nwritten == -1) + return -1; + if (nwritten == 0) + return -1; /* I think we're at EOF here... */ + total -= nwritten; + } + return count + header->length; +} + +#elif defined(SOLARIS_SENDFILE_API) + +ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ +} + +#elif defined(HPUX_SENDFILE_API) + +#include +#include + +ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ + size_t total=0; + struct iovec hdtrl[2]; + + /* Set up the header/trailer iovec. */ + hdtrl[0].iov_base = header->data; + hdtrl[0].iov_len = header->length; + hdtrl[1].iov_base = NULL; + hdtrl[1].iov_base = 0; + + total = count; + while (total) { + ssize_t nwritten; + do { +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) + nwritten = sendfile64(outfd, infd, &offset, total, &hdtrl, 0); +#else + nwritten = sendfile(outfd, infd, &offset, total, &hdtrl, 0); +#endif + } while (nwritten == -1 && errno == EINTR); + if (nwritten == -1) + return -1; + total -= nwritten; + } + return count + header->length; +} + +#elif defined(FREEBSD_SENDFILE_API) + +#include +#include +#include + +ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ + size_t total=0; + struct sf_hdtr hdr; + struct iovec hdtrl; + + hdr->headers = &hdtrl; + hdr->hdr_cnt = 1; + hdr->trailers = NULL; + hdr->trl_cnt = 0; + + /* Set up the header iovec. */ + hdtrl.iov_base = header->data; + hdtrl.iov_len = header->length; + + total = count; + while (total) { + ssize_t nwritten; + do { +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) + nwritten = sendfile64(outfd, infd, &offset, total, &hdr, NULL, 0); +#else + nwritten = sendfile(outfd, infd, &offset, total, &hdr, NULL, 0); +#endif + } while (nwritten == -1 && errno == EINTR); + if (nwritten == -1) + return -1; + total -= nwritten; + } + return count + header->length; +} + +#else /* No sendfile implementation. Return error. */ + +ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ + /* No sendfile syscall. */ + errno = ENOSYS; + return -1; +} +#endif -- cgit From fdb8c4dfe1d367deda6d0183d94f44d5d5e14992 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Sep 2002 06:24:41 +0000 Subject: Fixup sendfile to match HPUX semantics with signal interrups. This was fiddly.... :-(. Jeremy. (This used to be commit 2b33a500a8ad13acdd7e4f593aba65229dc8dd96) --- source3/lib/sendfile.c | 64 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 33282e704a..11bf38ebee 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -38,17 +38,21 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off { size_t total=0; ssize_t ret; + ssize_t hdr_len = 0; /* * Send the header first. * Use MSG_MORE to cork the TCP output until sendfile is called. */ - while (total < header->length) { - ret = sys_send(outfd, header->data + total,header->length - total, MSG_MORE); - if (ret == -1) - return -1; - total += ret; + if (header) { + hdr_len = header->length; + while (total < hd_len) { + ret = sys_send(outfd, header->data + total,hdr_len - total, MSG_MORE); + if (ret == -1) + return -1; + total += ret; + } } total = count; @@ -67,7 +71,7 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off return -1; /* I think we're at EOF here... */ total -= nwritten; } - return count + header->length; + return count + hdr_len; } #elif defined(SOLARIS_SENDFILE_API) @@ -85,16 +89,30 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off { size_t total=0; struct iovec hdtrl[2]; - - /* Set up the header/trailer iovec. */ - hdtrl[0].iov_base = header->data; - hdtrl[0].iov_len = header->length; + size_t hdr_len = 0; + + if (header) { + /* Set up the header/trailer iovec. */ + hdtrl[0].iov_base = header->data; + hdtrl[0].iov_len = hdr_len = header->length; + } else { + hdtrl[0].iov_base = NULL; + hdtrl[0].iov_len = hdr_len = 0; + } hdtrl[1].iov_base = NULL; hdtrl[1].iov_base = 0; total = count; - while (total) { + while (total + hdtrl[0].iov_len) { ssize_t nwritten; + + /* + * HPUX guarantees that if any data was written before + * a signal interrupt then sendfile returns the number of + * bytes written (which may be less than requested) not -1. + * nwritten includes the header data sent. + */ + do { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) nwritten = sendfile64(outfd, infd, &offset, total, &hdtrl, 0); @@ -104,9 +122,31 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off } while (nwritten == -1 && errno == EINTR); if (nwritten == -1) return -1; + if (nwritten == 0) + return -1; /* I think we're at EOF here... */ + + /* + * If this was a short (signal interrupted) write we may need + * to subtract it from the header data, or null out the header + * data altogether if we wrote more than hdtrl[0].iov_len bytes. + * We change nwritten to be the number of file bytes written. + */ + + if (hdtrl[0].iov_base && hdtrl[0].iov_len) { + if (nwritten >= hdtrl[0].iov_len) { + nwritten -= hdtrl[0].iov_len; + hdtrl[0].iov_base = NULL; + hdtrl[0].iov_len = 0; + } else { + nwritten = 0; + hdtrl[0].iov_base += nwritten; + hdtrl[0].iov_len -= nwritten; + } + } total -= nwritten; + offset += nwritten; } - return count + header->length; + return count + hdr_len; } #elif defined(FREEBSD_SENDFILE_API) -- cgit From 8c5f577c6f40de2f346b4545cbcdfb08e30f629f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Sep 2002 06:26:06 +0000 Subject: HPUX takes offset, not pointer to offset. Jeremy. (This used to be commit d7024e8cb94a20cba789deb2c5b70221f6cca4fd) --- source3/lib/sendfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 11bf38ebee..23d1154718 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -115,9 +115,9 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off do { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) - nwritten = sendfile64(outfd, infd, &offset, total, &hdtrl, 0); + nwritten = sendfile64(outfd, infd, offset, total, &hdtrl[0], 0); #else - nwritten = sendfile(outfd, infd, &offset, total, &hdtrl, 0); + nwritten = sendfile(outfd, infd, offset, total, &hdtrl[0], 0); #endif } while (nwritten == -1 && errno == EINTR); if (nwritten == -1) -- cgit From 6cf499ecff96880acef4e53817dccd7d838edd62 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Sep 2002 18:18:35 +0000 Subject: Fixed up FreeBSD sendfile code - only Solaris left then I can add the configure tests... Jeremy. (This used to be commit 9dad88e1d4d09f61da87dab2633c6e989a9dd77f) --- source3/lib/sendfile.c | 77 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 22 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 23d1154718..6e093c31ff 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -34,7 +34,7 @@ #define MSG_MORE 0x8000 #endif -ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { size_t total=0; ssize_t ret; @@ -48,7 +48,7 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off if (header) { hdr_len = header->length; while (total < hd_len) { - ret = sys_send(outfd, header->data + total,hdr_len - total, MSG_MORE); + ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE); if (ret == -1) return -1; total += ret; @@ -60,9 +60,9 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off ssize_t nwritten; do { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) - nwritten = sendfile64(outfd, infd, &offset, total); + nwritten = sendfile64(tofd, fromfd, &offset, total); #else - nwritten = sendfile(outfd, infd, &offset, total); + nwritten = sendfile(tofd, fromfd, &offset, total); #endif } while (nwritten == -1 && errno == EINTR); if (nwritten == -1) @@ -76,7 +76,7 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off #elif defined(SOLARIS_SENDFILE_API) -ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { } @@ -85,7 +85,7 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off #include #include -ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { size_t total=0; struct iovec hdtrl[2]; @@ -115,9 +115,9 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off do { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) - nwritten = sendfile64(outfd, infd, offset, total, &hdtrl[0], 0); + nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0); #else - nwritten = sendfile(outfd, infd, offset, total, &hdtrl[0], 0); + nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0); #endif } while (nwritten == -1 && errno == EINTR); if (nwritten == -1) @@ -155,11 +155,12 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off #include #include -ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { size_t total=0; struct sf_hdtr hdr; struct iovec hdtrl; + size_t hdr_len = 0; hdr->headers = &hdtrl; hdr->hdr_cnt = 1; @@ -167,29 +168,61 @@ ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T off hdr->trl_cnt = 0; /* Set up the header iovec. */ - hdtrl.iov_base = header->data; - hdtrl.iov_len = header->length; + if (header) { + hdtrl.iov_base = header->data; + hdtrl.iov_len = hdr_len = header->length; + } else { + hdtrl.iov_base = NULL; + hdtrl.iov_len = 0; + } total = count; - while (total) { - ssize_t nwritten; + while (total + hdtrl.iov_len) { + SMB_OFF_T nwritten; + int ret; + + /* + * FreeBSD sendfile returns 0 on success, -1 on error. + * Remember, the tofd and fromfd are reversed..... :-). + * nwritten includes the header data sent. + */ + do { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) - nwritten = sendfile64(outfd, infd, &offset, total, &hdr, NULL, 0); -#else - nwritten = sendfile(outfd, infd, &offset, total, &hdr, NULL, 0); -#endif - } while (nwritten == -1 && errno == EINTR); - if (nwritten == -1) + ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0); + } while (ret == -1 && errno == EINTR); + if (ret == -1) return -1; + + if (nwritten == 0) + return -1; /* I think we're at EOF here... */ + + /* + * If this was a short (signal interrupted) write we may need + * to subtract it from the header data, or null out the header + * data altogether if we wrote more than hdtrl.iov_len bytes. + * We change nwritten to be the number of file bytes written. + */ + + if (hdtrl[0].iov_base && hdtrl.iov_len) { + if (nwritten >= hdtrl.iov_len) { + nwritten -= hdtrl.iov_len; + hdtrl.iov_base = NULL; + hdtrl.iov_len = 0; + } else { + nwritten = 0; + hdtrl.iov_base += nwritten; + hdtrl.iov_len -= nwritten; + } + } total -= nwritten; + offset += nwritten; } - return count + header->length; + return count + hdr_len; } #else /* No sendfile implementation. Return error. */ -ssize_t sys_sendfile(int outfd, int infd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { /* No sendfile syscall. */ errno = ENOSYS; -- cgit From febd3f929b0f922a4bac69aa131089da4675cb1e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 14 Sep 2002 00:34:46 +0000 Subject: Added fix for broken Linux (no sendfile64). When offset + count > 2GB then return ENOSYS and let the upper layer handle it. Jeremy (This used to be commit 872dfd87cda585c33c3823b06580cb301567a9b9) --- source3/lib/sendfile.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 6e093c31ff..2707495d5b 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -74,6 +74,63 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of return count + hdr_len; } +#elif defined(LINUX_BROKEN_SENDFILE_API) + +#include + +#ifndef MSG_MORE +#define MSG_MORE 0x8000 +#endif + +ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) +{ + size_t total=0; + ssize_t ret; + ssize_t hdr_len = 0; + + /* + * Fix for broken Linux 2.4 systems with no working sendfile64(). + * If the offset+count > 2 GB then pretend we don't have the + * system call sendfile at all. The upper later catches this + * and uses a normal read. JRA. + */ + + if ((sizeof(SMB_OFF_T) >= 8) && (offset + count > (SMB_OFF_T)0x7FFFFFFF)) { + errno = ENOSYS; + return -1; + } + + /* + * Send the header first. + * Use MSG_MORE to cork the TCP output until sendfile is called. + */ + + if (header) { + hdr_len = header->length; + while (total < hd_len) { + ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE); + if (ret == -1) + return -1; + total += ret; + } + } + + total = count; + while (total) { + ssize_t nwritten; + do { + nwritten = sendfile(tofd, fromfd, &offset, total); + } while (nwritten == -1 && errno == EINTR); + if (nwritten == -1) + return -1; + if (nwritten == 0) + return -1; /* I think we're at EOF here... */ + total -= nwritten; + } + return count + hdr_len; +} + + #elif defined(SOLARIS_SENDFILE_API) ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) -- cgit From 3f02393bfd49dea3f48fdb759d8f932d5bb3a8f6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 14 Sep 2002 01:38:55 +0000 Subject: Use HAVE_SENDFILE64, not SENDFILE64. Jeremy. (This used to be commit 7e2f9769c9a7ee5d11267a8a8864371fc0aa8f50) --- source3/lib/sendfile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 2707495d5b..4613cfb864 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -59,7 +59,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of while (total) { ssize_t nwritten; do { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_SENDFILE64) nwritten = sendfile64(tofd, fromfd, &offset, total); #else nwritten = sendfile(tofd, fromfd, &offset, total); @@ -133,8 +133,11 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of #elif defined(SOLARIS_SENDFILE_API) +/* Hmmm. Can't find Solaris sendfile API docs.... Where is it ? */ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) { + errno = ENOSYS; + return -1; } #elif defined(HPUX_SENDFILE_API) @@ -171,7 +174,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of */ do { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(SENDFILE64) +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_SENDFILE64) nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0); #else nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0); -- cgit From 479e82b8d8413c88989dfb091c21a0ba003ed005 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 15 Sep 2002 17:49:53 +0000 Subject: Put unixsocket calls between #ifdef HAVE_UNIXSOCKET's - required for Stratus VOS (Double checked) (This used to be commit dc3c14fc2b661a62a1876149e96af6de07a2c4a6) --- source3/lib/util_sock.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 56ef4a6ab1..fc2abf976f 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -976,6 +976,7 @@ int create_pipe_sock(const char *socket_dir, const char *socket_name, mode_t dir_perms) { +#ifdef HAVE_UNIXSOCKET struct sockaddr_un sunaddr; struct stat st; int sock; @@ -1064,6 +1065,10 @@ int create_pipe_sock(const char *socket_dir, /* Success! */ return sock; +#else + DEBUG(0, ("create_pipe_sock: No Unix sockets on this system\n")); + return -1; +#endif /* HAVE_UNIXSOCKET */ } /******************************************************************* -- cgit From f74086ccf09e8157419f7c51490dc31effb6ba20 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Sep 2002 01:00:03 +0000 Subject: Attempt to make broken Linux sendfile work.... Still in progress. Jeremy. (This used to be commit f956a4d29d0d88cd92fac0f0c9f636fc152afe0a) --- source3/lib/sendfile.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 4613cfb864..8bcb9dbd02 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -76,7 +76,13 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of #elif defined(LINUX_BROKEN_SENDFILE_API) -#include +/* + * We must use explicit 32 bit types here. This code path means Linux + * won't do proper 64-bit sendfile. JRA. + */ + +extern int32 sendfile (int out_fd, int in_fd, int32 *offset, uint32 count); + #ifndef MSG_MORE #define MSG_MORE 0x8000 @@ -87,11 +93,13 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of size_t total=0; ssize_t ret; ssize_t hdr_len = 0; + uint32 small_total = 0; + int32 small_offset; /* * Fix for broken Linux 2.4 systems with no working sendfile64(). * If the offset+count > 2 GB then pretend we don't have the - * system call sendfile at all. The upper later catches this + * system call sendfile at all. The upper layer catches this * and uses a normal read. JRA. */ @@ -115,17 +123,19 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of } } - total = count; - while (total) { - ssize_t nwritten; + small_total = (uint32)count; + small_offset = (int32)offset; + + while (small_total) { + int32 nwritten; do { - nwritten = sendfile(tofd, fromfd, &offset, total); + nwritten = sendfile(tofd, fromfd, &small_offset, small_total); } while (nwritten == -1 && errno == EINTR); if (nwritten == -1) return -1; if (nwritten == 0) return -1; /* I think we're at EOF here... */ - total -= nwritten; + small_total -= nwritten; } return count + hdr_len; } -- cgit From 9bab1d0c1a51a7532da0c55a59cf5a91b8ab6a3d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Sep 2002 19:48:19 +0000 Subject: Actually use sendfile if selected. Jeremy. (This used to be commit 5881f0a22633ed9fb73e6cd788d0751c4db6cd32) --- source3/lib/sendfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index 8bcb9dbd02..bcace5fee2 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -47,7 +47,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of if (header) { hdr_len = header->length; - while (total < hd_len) { + while (total < hdr_len) { ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE); if (ret == -1) return -1; @@ -115,7 +115,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of if (header) { hdr_len = header->length; - while (total < hd_len) { + while (total < hdr_len) { ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE); if (ret == -1) return -1; -- cgit From 8b46126a076075aeed31dae1c80eca1ed9f5a251 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Sep 2002 23:45:21 +0000 Subject: Never, *ever* hold a mutex lock in the message database where there may be traversals being attempted. Yes, this was from bitter experience (and an out of control server :-). Also allow callers to break out of a tdb_chainlock with sigalarm if desired. Jeremy. (This used to be commit a7781f91d8c1177210bffc199cd2f3b7ff993eaf) --- source3/lib/messages.c | 69 ---------------------------------------------- source3/lib/server_mutex.c | 5 ++-- 2 files changed, 2 insertions(+), 72 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 21470dff5c..d9886a54da 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -471,73 +471,4 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, *n_sent = msg_all.n_sent; return True; } - -static SIG_ATOMIC_T gotalarm; - -/*************************************************************** - Signal function to tell us we timed out. -****************************************************************/ - -static void gotalarm_sig(void) -{ - gotalarm = 1; -} - -/** - * Lock the messaging tdb based on a string - this is used as a primitive - * form of mutex between smbd instances. - * - * @param name A string identifying the name of the mutex. - */ - -BOOL message_named_mutex(char *name, unsigned int timeout) -{ - TDB_DATA key; - int ret; - void (*oldsig_handler)(int) = NULL; - - if (!message_init()) - return False; - - key.dptr = name; - key.dsize = strlen(name)+1; - - if (timeout) { - gotalarm = 0; - oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); - alarm(timeout); - } - - ret = tdb_chainlock(tdb, key); - - if (timeout) { - alarm(0); - CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler); - if (gotalarm) - return False; - } - - if (ret == 0) - DEBUG(10,("message_named_mutex: got mutex for %s\n", name )); - - return (ret == 0); -} - -/** - * Unlock a named mutex. - * - * @param name A string identifying the name of the mutex. - */ - -void message_named_mutex_release(char *name) -{ - TDB_DATA key; - - key.dptr = name; - key.dsize = strlen(name)+1; - - tdb_chainunlock(tdb, key); - DEBUG(10,("message_named_mutex: released mutex for %s\n", name )); -} - /** @} **/ diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c index 416d77564d..3e5512c734 100644 --- a/source3/lib/server_mutex.c +++ b/source3/lib/server_mutex.c @@ -38,7 +38,7 @@ BOOL grab_server_mutex(const char *name) DEBUG(0,("grab_server_mutex: malloc failed for %s\n", name)); return False; } - if (!message_named_mutex(mutex_server_name, 20)) { + if (!secrets_named_mutex(mutex_server_name, 10)) { DEBUG(10,("grab_server_mutex: failed for %s\n", name)); SAFE_FREE(mutex_server_name); return False; @@ -50,8 +50,7 @@ BOOL grab_server_mutex(const char *name) void release_server_mutex(void) { if (mutex_server_name) { - message_named_mutex_release(mutex_server_name); + secrets_named_mutex_release(mutex_server_name); SAFE_FREE(mutex_server_name); } } - -- cgit From 994638f577d2d0df8f5f185fd96d4448dcd9d7e5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 18 Sep 2002 20:07:56 +0000 Subject: HPUX sendfile is now detected correctly. Jeremy. (This used to be commit 91e41ebe97c143f413e2a5614b20f3db4642490f) --- source3/lib/sendfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index bcace5fee2..df6c1980d0 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -209,7 +209,8 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of hdtrl[0].iov_len = 0; } else { nwritten = 0; - hdtrl[0].iov_base += nwritten; + /* iov_base is defined as a void *... */ + hdtrl[0].iov_base = ((char *)hdtrl[0].iov_base) + nwritten; hdtrl[0].iov_len -= nwritten; } } -- cgit From 515c1d42eec8d7c0a5eabeb72b274f5446012945 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 21 Sep 2002 08:53:05 +0000 Subject: Merge back Richard's FreeBSD sendfile fixes. Jeremy. (This used to be commit f4845b0213aec58e0f489eba5653aa7b3855610f) --- source3/lib/sendfile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index df6c1980d0..98a52608b8 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -233,10 +233,10 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of struct iovec hdtrl; size_t hdr_len = 0; - hdr->headers = &hdtrl; - hdr->hdr_cnt = 1; - hdr->trailers = NULL; - hdr->trl_cnt = 0; + hdr.headers = &hdtrl; + hdr.hdr_cnt = 1; + hdr.trailers = NULL; + hdr.trl_cnt = 0; /* Set up the header iovec. */ if (header) { @@ -274,7 +274,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of * We change nwritten to be the number of file bytes written. */ - if (hdtrl[0].iov_base && hdtrl.iov_len) { + if (hdtrl.iov_base && hdtrl.iov_len) { if (nwritten >= hdtrl.iov_len) { nwritten -= hdtrl.iov_len; hdtrl.iov_base = NULL; -- cgit From b952ddfbe6e6527892cabf0076e16a4c14f952b8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Sep 2002 05:11:25 +0000 Subject: Merge of "profile acls" code. Jeremy. (This used to be commit cfd1bf250b417f3ba3ad21ff681ab282311bb7eb) --- source3/lib/util_sid.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 8bb06e8866..e9635fc7f8 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -30,13 +30,11 @@ extern fstring global_myworkgroup; * Some useful sids */ -DOM_SID global_sid_Builtin; /* Local well-known domain */ DOM_SID global_sid_World_Domain; /* Everyone domain */ DOM_SID global_sid_World; /* Everyone */ DOM_SID global_sid_Creator_Owner_Domain; /* Creator Owner domain */ DOM_SID global_sid_NT_Authority; /* NT Authority */ DOM_SID global_sid_NULL; /* NULL sid */ -DOM_SID global_sid_Builtin_Guests; /* Builtin guest users */ DOM_SID global_sid_Authenticated_Users; /* All authenticated rids */ DOM_SID global_sid_Network; /* Network rids */ @@ -44,6 +42,11 @@ static DOM_SID global_sid_Creator_Owner; /* Creator Owner */ static DOM_SID global_sid_Creator_Group; /* Creator Group */ static DOM_SID global_sid_Anonymous; /* Anonymous login */ +DOM_SID global_sid_Builtin; /* Local well-known domain */ +DOM_SID global_sid_Builtin_Administrators; +DOM_SID global_sid_Builtin_Users; +DOM_SID global_sid_Builtin_Guests; /* Builtin guest users */ + /* * An NT compatible anonymous token. */ @@ -99,6 +102,8 @@ const char *sid_type_lookup(uint32 sid_type) void generate_wellknown_sids(void) { string_to_sid(&global_sid_Builtin, "S-1-5-32"); + string_to_sid(&global_sid_Builtin_Administrators, "S-1-5-32-544"); + string_to_sid(&global_sid_Builtin_Users, "S-1-5-32-545"); string_to_sid(&global_sid_Builtin_Guests, "S-1-5-32-546"); string_to_sid(&global_sid_World_Domain, "S-1-1"); string_to_sid(&global_sid_World, "S-1-1-0"); -- cgit From 8a3bb8b36bf1bedabb6dfa931ec9a1d579f80500 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 25 Sep 2002 09:55:41 +0000 Subject: Kill of Get_Pwnam_Modify and smb_getpwnam(). The latter assumes some things that just don't apply any more - now that we always keep username and domain seperate. Also, the policy it was trying to permit is now implemented by the auth code. Andrew Bartlett (This used to be commit 760c0740cad948665db4a1d462fbbd99332713ef) --- source3/lib/username.c | 57 -------------------------------------------------- 1 file changed, 57 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/username.c b/source3/lib/username.c index 5db7f58b1e..ef11542ab1 100644 --- a/source3/lib/username.c +++ b/source3/lib/username.c @@ -273,27 +273,6 @@ done: return ret; } -/**************************************************************************** - Get_Pwnam wrapper for modification. - NOTE: This can potentially modify 'user'! -****************************************************************************/ - -struct passwd *Get_Pwnam_Modify(fstring user) -{ - fstring user2; - struct passwd *ret; - - fstrcpy(user2, user); - - ret = Get_Pwnam_internals(user, user2); - - /* If caller wants the modified username, ensure they get it */ - fstrcpy(user,user2); - - /* We can safely assume ret is NULL if none of the above succeed */ - return(ret); -} - /**************************************************************************** Get_Pwnam wrapper without modification. NOTE: This with NOT modify 'user'! @@ -636,39 +615,3 @@ static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(c return(NULL); } -/**************************************************************************** - These wrappers allow appliance mode to work. In appliance mode the username - takes the form DOMAIN/user. -****************************************************************************/ - -struct passwd *smb_getpwnam(char *user, BOOL allow_change) -{ - struct passwd *pw; - char *p; - char *sep; - extern pstring global_myname; - - if (allow_change) - pw = Get_Pwnam_Modify(user); - else - pw = Get_Pwnam(user); - - if (pw) - return pw; - - /* - * If it is a domain qualified name and it isn't in our password - * database but the domain portion matches our local machine name then - * lookup just the username portion locally. - */ - - sep = lp_winbind_separator(); - p = strchr_m(user,*sep); - if (p && strncasecmp(global_myname, user, strlen(global_myname))==0) { - if (allow_change) - pw = Get_Pwnam_Modify(p+1); - else - pw = Get_Pwnam(p+1); - } - return NULL; -} -- cgit