diff options
author | Gerald Carter <jerry@samba.org> | 2004-07-07 19:18:31 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-07-07 19:18:31 +0000 |
commit | 0cf550c32aa0018ad834fc2d3cd90d9b2b146621 (patch) | |
tree | 687da224b86274ebc9c46591a812d206935c8efd /source/lib | |
parent | 99c6d9bd34b106ae5109ffed4812b89ef0f3eaa8 (diff) | |
download | samba-0cf550c32aa0018ad834fc2d3cd90d9b2b146621.tar.gz samba-0cf550c32aa0018ad834fc2d3cd90d9b2b146621.tar.xz samba-0cf550c32aa0018ad834fc2d3cd90d9b2b146621.zip |
r1383: sync from 3.0 tree
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/afs_settoken.c | 14 | ||||
-rw-r--r-- | source/lib/charcnv.c | 2 | ||||
-rw-r--r-- | source/lib/iconv.c | 6 | ||||
-rw-r--r-- | source/lib/interface.c | 12 | ||||
-rw-r--r-- | source/lib/smbldap.c | 25 | ||||
-rw-r--r-- | source/lib/snprintf.c | 2 | ||||
-rw-r--r-- | source/lib/time.c | 6 | ||||
-rw-r--r-- | source/lib/username.c | 31 | ||||
-rw-r--r-- | source/lib/util.c | 18 | ||||
-rw-r--r-- | source/lib/util_sock.c | 22 | ||||
-rw-r--r-- | source/lib/util_str.c | 2 |
11 files changed, 100 insertions, 40 deletions
diff --git a/source/lib/afs_settoken.c b/source/lib/afs_settoken.c index eb10c4c66d4..5c646c72e48 100644 --- a/source/lib/afs_settoken.c +++ b/source/lib/afs_settoken.c @@ -28,12 +28,16 @@ #include <afs/venus.h> #include <asm/unistd.h> #include <openssl/des.h> +#include <sys/syscall.h> -_syscall5(int, afs_syscall, int, subcall, - char *, path, - int, cmd, - char *, cmarg, - int, follow); +int afs_syscall( int subcall, + char * path, + int cmd, + char * cmarg, + int follow) +{ + return( syscall( SYS_afs_syscall, subcall, path, cmd, cmarg, follow)); +} struct ClearToken { uint32 AuthHandle; diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c index b9791931a35..3d7678c34cb 100644 --- a/source/lib/charcnv.c +++ b/source/lib/charcnv.c @@ -932,7 +932,7 @@ size_t pull_ascii_fstring(char *dest, const void *src) size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src) { - return pull_ascii(dest, src, dest_len, sizeof(nstring), STR_TERMINATE); + return pull_ascii(dest, src, dest_len, sizeof(nstring)-1, STR_TERMINATE); } /** diff --git a/source/lib/iconv.c b/source/lib/iconv.c index 7df73192f24..4c9ecf992e6 100644 --- a/source/lib/iconv.c +++ b/source/lib/iconv.c @@ -129,7 +129,11 @@ static size_t sys_iconv(void *cd, size_t ret = iconv((iconv_t)cd, inbuf, inbytesleft, outbuf, outbytesleft); - if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL); + if (ret == (size_t)-1) { + int saved_errno = errno; + iconv(cd, NULL, NULL, NULL, NULL); + errno = saved_errno; + } return ret; #else errno = EINVAL; diff --git a/source/lib/interface.c b/source/lib/interface.c index 4d8010e31bc..adf9ca34381 100644 --- a/source/lib/interface.c +++ b/source/lib/interface.c @@ -94,7 +94,7 @@ This handles the following different forms: 4) ip/mask 5) bcast/mask ****************************************************************************/ -static void interpret_interface(const char *token) +static void interpret_interface(char *token) { struct in_addr ip, nmask; char *p; @@ -130,9 +130,9 @@ static void interpret_interface(const char *token) } /* parse it into an IP address/netmasklength pair */ - *p++ = 0; - + *p = 0; ip = *interpret_addr2(token); + *p++ = '/'; if (strlen(p) > 2) { nmask = *interpret_addr2(p); @@ -207,7 +207,11 @@ void load_interfaces(void) if (ptr) { while (*ptr) { - interpret_interface(*ptr); + char *ptr_cpy = strdup(*ptr); + if (ptr_cpy) { + interpret_interface(ptr_cpy); + free(ptr_cpy); + } ptr++; } } diff --git a/source/lib/smbldap.c b/source/lib/smbldap.c index 21e2a7c1018..d058613f004 100644 --- a/source/lib/smbldap.c +++ b/source/lib/smbldap.c @@ -676,7 +676,7 @@ static int rebindproc_with_state (LDAP * ld, char **whop, char **credp, *methodp = LDAP_AUTH_SIMPLE; } - gettimeofday(&(ldap_state->last_rebind),NULL); + GetTimeOfDay(&ldap_state->last_rebind); return 0; } @@ -704,7 +704,7 @@ static int rebindproc_connect_with_state (LDAP *ldap_struct, rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); - gettimeofday(&(ldap_state->last_rebind),NULL); + GetTimeOfDay(&ldap_state->last_rebind); return rc; } @@ -755,8 +755,7 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_ char *ldap_secret; /* get the password */ - if (!fetch_ldap_pw(&ldap_dn, &ldap_secret)) - { + if (!fetch_ldap_pw(&ldap_dn, &ldap_secret)) { DEBUG(0, ("ldap_connect_system: Failed to retrieve password from secrets.tdb\n")); return LDAP_INVALID_CREDENTIALS; } @@ -808,7 +807,7 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_ } /********************************************************************** -Connect to LDAP server (called before every ldap operation) + Connect to LDAP server (called before every ldap operation) *********************************************************************/ static int smbldap_open(struct smbldap_state *ldap_state) { @@ -854,7 +853,7 @@ static int smbldap_open(struct smbldap_state *ldap_state) ldap_state->last_ping = time(NULL); - DEBUG(4,("The LDAP server is succesful connected\n")); + DEBUG(4,("The LDAP server is succesfully connected\n")); return LDAP_SUCCESS; } @@ -933,25 +932,25 @@ int smbldap_search(struct smbldap_state *ldap_state, if (ldap_state->last_rebind.tv_sec > 0) { struct timeval tval; - int tdiff = 0; + SMB_BIG_INT tdiff = 0; int sleep_time = 0; ZERO_STRUCT(tval); + GetTimeOfDay(&tval); - gettimeofday(&tval,NULL); - - tdiff = 1000000 *(tval.tv_sec - ldap_state->last_rebind.tv_sec) + - (tval.tv_usec - ldap_state->last_rebind.tv_usec); + tdiff = usec_time_diff(&tval, &ldap_state->last_rebind.tv_sec); + tdiff /= 1000; /* Convert to milliseconds. */ - sleep_time = ((1000*lp_ldap_replication_sleep())-tdiff)/1000; + sleep_time = lp_ldap_replication_sleep()-(int)tdiff; + sleep_time = MIN(sleep_time, MAX_LDAP_REPLICATION_SLEEP_TIME); if (sleep_time > 0) { /* we wait for the LDAP replication */ DEBUG(5,("smbldap_search: waiting %d milliseconds for LDAP replication.\n",sleep_time)); smb_msleep(sleep_time); DEBUG(5,("smbldap_search: go on!\n")); - ZERO_STRUCT(ldap_state->last_rebind); } + ZERO_STRUCT(ldap_state->last_rebind); } if (push_utf8_allocate(&utf8_filter, filter) == (size_t)-1) { diff --git a/source/lib/snprintf.c b/source/lib/snprintf.c index 5b0cfa1ab33..79de3c0ca5d 100644 --- a/source/lib/snprintf.c +++ b/source/lib/snprintf.c @@ -817,7 +817,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) (*currlen)++; } - int vsnprintf (char *str, size_t count, const char *fmt, va_list args) + int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args) { return dopr(str, count, fmt, args); } diff --git a/source/lib/time.c b/source/lib/time.c index faca2cba879..e63e0b29659 100644 --- a/source/lib/time.c +++ b/source/lib/time.c @@ -754,3 +754,9 @@ BOOL nt_time_is_zero(NTTIME *nt) return True; return False; } + +SMB_BIG_INT usec_time_diff(struct timeval *larget, struct timeval *smallt) +{ + SMB_BIG_INT sec_diff = larget->tv_sec - smallt->tv_sec; + return (sec_diff * 1000000) + (SMB_BIG_INT)(larget->tv_usec - smallt->tv_usec); +} diff --git a/source/lib/username.c b/source/lib/username.c index ac5530b5c71..317935d396f 100644 --- a/source/lib/username.c +++ b/source/lib/username.c @@ -306,7 +306,7 @@ static BOOL user_in_netgroup_list(const char *user, const char *ngname) { #ifdef HAVE_NETGROUP static char *mydomain = NULL; - fstring lowercase_user, lowercase_ngname; + fstring lowercase_user; if (mydomain == NULL) yp_get_default_domain(&mydomain); @@ -318,25 +318,28 @@ static BOOL user_in_netgroup_list(const char *user, const char *ngname) DEBUG(5,("looking for user %s of domain %s in netgroup %s\n", user, mydomain, ngname)); - DEBUG(5,("innetgr is %s\n", innetgr(ngname, NULL, user, mydomain) - ? "TRUE" : "FALSE")); - if (innetgr(ngname, NULL, user, mydomain)) + if (innetgr(ngname, NULL, user, mydomain)) { + DEBUG(5,("user_in_netgroup_list: Found\n")); return (True); + } else { - /* - * Ok, innetgr is case sensitive. Try once more with lowercase - * just in case. Attempt to fix #703. JRA. - */ + /* + * Ok, innetgr is case sensitive. Try once more with lowercase + * just in case. Attempt to fix #703. JRA. + */ - fstrcpy(lowercase_user, user); - strlower_m(lowercase_user); - fstrcpy(lowercase_ngname, ngname); - strlower_m(lowercase_ngname); + fstrcpy(lowercase_user, user); + strlower_m(lowercase_user); - if (innetgr(lowercase_ngname, NULL, lowercase_user, mydomain)) - return (True); + DEBUG(5,("looking for user %s of domain %s in netgroup %s\n", + lowercase_user, mydomain, ngname)); + if (innetgr(ngname, NULL, lowercase_user, mydomain)) { + DEBUG(5,("user_in_netgroup_list: Found\n")); + return (True); + } + } #endif /* HAVE_NETGROUP */ return False; } diff --git a/source/lib/util.c b/source/lib/util.c index 9d7a2648c5b..554f5ee79da 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -1802,6 +1802,9 @@ void set_remote_arch(enum remote_arch_types type) case RA_SAMBA: fstrcpy(remote_arch,"Samba"); break; + case RA_CIFSFS: + fstrcpy(remote_arch,"CIFSFS"); + break; default: ra_type = RA_UNKNOWN; fstrcpy(remote_arch, "UNKNOWN"); @@ -2432,6 +2435,21 @@ BOOL unix_wild_match(const char *pattern, const char *string) return unix_do_match(p2, s2) == 0; } +/********************************************************************** + Converts a name to a fully qalified domain name. +***********************************************************************/ + +void name_to_fqdn(fstring fqdn, const char *name) +{ + struct hostent *hp = sys_gethostbyname(name); + if ( hp && hp->h_name && *hp->h_name ) { + DEBUG(10,("name_to_fqdn: lookup for %s -> %s.\n", name, hp->h_name)); + fstrcpy(fqdn,hp->h_name); + } else { + DEBUG(10,("name_to_fqdn: lookup for %s failed.\n", name)); + fstrcpy(fqdn, name); + } +} #ifdef __INSURE__ diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c index b6bfdca5cf9..4b9881a4499 100644 --- a/source/lib/util_sock.c +++ b/source/lib/util_sock.c @@ -52,6 +52,23 @@ static char *get_socket_addr(int fd) return addr_buf; } +static int get_socket_port(int fd) +{ + struct sockaddr sa; + struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa); + socklen_t length = sizeof(sa); + + if (fd == -1) + return -1; + + if (getsockname(fd, &sa, &length) < 0) { + DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) )); + return -1; + } + + return ntohs(sockin->sin_port); +} + /**************************************************************************** Determine if a file descriptor is in fact a socket. ****************************************************************************/ @@ -837,6 +854,11 @@ char *client_socket_addr(void) return get_socket_addr(client_fd); } +int client_socket_port(void) +{ + return get_socket_port(client_fd); +} + struct in_addr *client_inaddr(struct sockaddr *sa) { struct sockaddr_in *sockin = (struct sockaddr_in *) (sa); diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 65ef306ed17..7c5fa11c92d 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -62,7 +62,7 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) /* copy over the token */ pbuf = buff; for (quoted = False; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) { - if (*s == '\"' || *s == '\'') { + if ( *s == '\"' ) { quoted = !quoted; } else { len++; |