From 93ace5cc2484b53fc33d4689ccc286defbe2b728 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 13:20:51 +1000 Subject: lib/util Re-merge the string_sub() and all_string_sub() from source3 Andrew Bartlett --- lib/util/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 45779912f3..8bbaa0e393 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -284,6 +284,8 @@ _PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_ **/ _PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len); +_PUBLIC_ void string_sub_once(char *s, const char *pattern, + const char *insert, size_t len); _PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, const char *pattern, const char *insert); -- cgit From bcd68837ee308aa4610a4c85783a4b64a349d4f9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 30 Apr 2011 13:10:18 +1000 Subject: lib/util Rename conv_str_size() -> conv_str_size_error() --- lib/util/util.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 8bbaa0e393..8dffece0da 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -371,12 +371,10 @@ _PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean); */ _PUBLIC_ bool conv_str_bool(const char * str, bool * val); -#if _SAMBA_BUILD_ == 4 /** * Convert a size specification like 16K into an integral number of bytes. **/ -_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val); -#endif +_PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val); /** * Parse a uint64_t value from a string -- cgit From fbea52f74a80268446f45936a0cf40400aba8565 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2011 15:23:08 +1000 Subject: lib/util Move more network utility functions from source3 into lib/util This will help with the merge of the interfaces layer. Andrew Bartlett --- lib/util/util.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 8dffece0da..5ed8427498 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -131,8 +131,20 @@ _PUBLIC_ pid_t sys_fork(void); **/ _PUBLIC_ pid_t sys_getpid(void); -/* The following definitions come from lib/util/genrand.c */ +_PUBLIC_ int sys_getpeereid( int s, uid_t *uid); + +struct sockaddr; +_PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa, + int salen, + char *host, + size_t hostlen, + char *service, + size_t servlen, + int flags); +_PUBLIC_ int sys_connect(int fd, const struct sockaddr * addr); + +/* The following definitions come from lib/util/genrand.c */ /** Copy any user given reseed data. **/ -- cgit From 86a62ab4345b8567a346587d2ddf575523d0b5f8 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 3 May 2011 15:23:19 +1000 Subject: lib/util Use compiler-checked safe string macros in top level code. This brings the 'safe' macros to the top level code, and removes duplication of the safe_strcpy() and safe_strcat() functions. Andrew Bartlett --- lib/util/util.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 5ed8427498..45f1b9cd79 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -62,6 +62,8 @@ extern const char *panic_action; #include "lib/util/memory.h" +#include "lib/util/string_wrappers.h" + /** * Write backtrace to debug log */ @@ -248,13 +250,13 @@ _PUBLIC_ _PURE_ size_t count_chars(const char *s, char c); Safe string copy into a known length string. maxlength does not include the terminating zero. **/ -_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength); +_PUBLIC_ char *safe_strcpy_fn(char *dest,const char *src, size_t maxlength); /** Safe string cat into a string. maxlength does not include the terminating zero. **/ -_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength); +_PUBLIC_ char *safe_strcat_fn(char *dest, const char *src, size_t maxlength); /** Routine to get hex characters and turn them into a 16 byte array. -- cgit From ff215f5c89c91a22c910400c8ac81d82d7459ba0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2011 16:43:27 -0700 Subject: I added them, so I get to kill them :-). Finally remove all uses of safe_strcpy and safe_strcat. Change to strlcpy, strlcat. Autobuild-User: Jeremy Allison Autobuild-Date: Wed May 4 22:14:14 CEST 2011 on sn-devel-104 --- lib/util/util.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 45f1b9cd79..64793022c0 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -246,18 +246,6 @@ _PUBLIC_ bool trim_string(char *s, const char *front, const char *back); **/ _PUBLIC_ _PURE_ size_t count_chars(const char *s, char c); -/** - Safe string copy into a known length string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcpy_fn(char *dest,const char *src, size_t maxlength); - -/** - Safe string cat into a string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcat_fn(char *dest, const char *src, size_t maxlength); - /** Routine to get hex characters and turn them into a 16 byte array. the array can be variable length, and any non-hex-numeric -- cgit From 3892112e7b3143f808932771a7b71f4fd335f8cb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 4 May 2011 20:53:33 +1000 Subject: lib/util Rename ms_fnmatch() to ms_fnmatch_protocol() to avoid dup symbol This verison of the function takes a protcol as argument to determine matching rules. Andrew Bartlett --- lib/util/util.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 64793022c0..b91b2eb1fa 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -777,11 +777,12 @@ enum protocol_types { PROTOCOL_SMB2 }; -int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol); +#endif + +int ms_fnmatch_protocol(const char *pattern, const char *string, enum protocol_types protocol); /** a generic fnmatch function - uses for non-CIFS pattern matching */ int gen_fnmatch(const char *pattern, const char *string); -#endif /* The following definitions come from lib/util/idtree.c */ -- cgit From 8aae59a277fe4bf5a1a84cb4730e5772c9ffca8c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 4 May 2011 21:20:57 +1000 Subject: lib/util don't use enum protocol_types in ms_fnmatch_protocol This makes it easier to compile this in the top level with s3 and s4 headers. Andrew Bartlett Autobuild-User: Andrew Bartlett Autobuild-Date: Fri May 6 08:50:52 CEST 2011 on sn-devel-104 --- lib/util/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index b91b2eb1fa..93b181b1fc 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -779,7 +779,7 @@ enum protocol_types { #endif -int ms_fnmatch_protocol(const char *pattern, const char *string, enum protocol_types protocol); +int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol); /** a generic fnmatch function - uses for non-CIFS pattern matching */ int gen_fnmatch(const char *pattern, const char *string); -- cgit From 52399f3177515fce777d85288650ff89f9028dc9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 31 May 2011 10:41:42 +1000 Subject: lib/util Move sys_memalign into lib/util/system.c --- lib/util/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index 93b181b1fc..d1c5e82bdd 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -115,6 +115,8 @@ void CatchChildLeaveStatus(void); /* The following definitions come from lib/util/system.c */ +void *sys_memalign( size_t align, size_t size ); + /************************************************************************** A wrapper for gethostbyname() that tries avoids looking up hostnames in the root domain, which can cause dial-on-demand links to come up for no -- cgit From de46ad9084aff4384f33660acf91da3b81554a88 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 6 Jun 2011 14:37:06 +1000 Subject: lib/util use modules_path(), data_path() and shlib_ext() from source3 This brings these helpful utility functions in common, as they are not based on either loadparm system. (The 'modules dir' parameter from Samba4 will shortly be removed, so there is no loss in functionality) Andrew Bartlett --- lib/util/util.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index d1c5e82bdd..e89c4ac997 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -891,4 +891,30 @@ int samba_runcmd_recv(struct tevent_req *req, int *perrno); void samba_start_debugger(void); #endif +/** + * @brief Returns an absolute path to a file in the Samba modules directory. + * + * @param name File to find, relative to MODULESDIR. + * + * @retval Pointer to a string containing the full path. + **/ +char *modules_path(TALLOC_CTX *mem_ctx, const char *name); + +/** + * @brief Returns an absolute path to a file in the Samba data directory. + * + * @param name File to find, relative to CODEPAGEDIR. + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ +char *data_path(TALLOC_CTX *mem_ctx, const char *name); + +/** + * @brief Returns the platform specific shared library extension. + * + * @retval Pointer to a const char * containing the extension. + **/ +const char *shlib_ext(void); + + #endif /* _SAMBA_UTIL_H_ */ -- cgit From 16b1c77644217796f70a3a0bf1d95c245f9ee2d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 14:05:55 +1000 Subject: lib/util Bring procid_str() into lib/util as server_id_string() This is needed for OpenChange, which prints Samba struct server_id values in debug messages. Andrew Bartlett --- lib/util/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index e89c4ac997..e50cc38a2f 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -916,5 +916,7 @@ char *data_path(TALLOC_CTX *mem_ctx, const char *name); **/ const char *shlib_ext(void); +struct server_id; +char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id); #endif /* _SAMBA_UTIL_H_ */ -- cgit From f3d6b742b18589306e0f19cc52e06f108fc1268e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 20 Jun 2011 15:02:46 +1000 Subject: lib/util Make unused d_vfprintf() static --- lib/util/util.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index e50cc38a2f..f4861a6fcf 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -214,7 +214,6 @@ _PUBLIC_ char** generate_unique_strs(TALLOC_CTX *mem_ctx, size_t len, #if _SAMBA_BUILD_ == 4 _PUBLIC_ void d_set_iconv(smb_iconv_t); -_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0); _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3); _PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2); _PUBLIC_ void display_set_stderr(void); -- cgit From f83fca1c576e094e2a852cc466bd9110c05fe731 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 20 Jun 2011 19:56:50 +1000 Subject: lib/util: Use common d_printf() in the whole codebase This removes the lang_tdb based varient, the only user of the lang_tdb code is SWAT, which calls that directly. 'net' and 'pam_winbind' are internationalised using gettext. Andrew Bartlett --- lib/util/util.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/util/util.h') diff --git a/lib/util/util.h b/lib/util/util.h index f4861a6fcf..c715440186 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -211,13 +211,10 @@ _PUBLIC_ char** generate_unique_strs(TALLOC_CTX *mem_ctx, size_t len, uint32_t num); /* The following definitions come from lib/util/dprintf.c */ -#if _SAMBA_BUILD_ == 4 -_PUBLIC_ void d_set_iconv(smb_iconv_t); _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3); _PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2); _PUBLIC_ void display_set_stderr(void); -#endif /* The following definitions come from lib/util/util_str.c */ -- cgit