mirror of
https://repo.or.cz/socat.git
synced 2025-06-18 23:06:51 +00:00
Satisfy some deprecation warnings of newer Linux distributions
This commit is contained in:
parent
3f4b171523
commit
416fe38e33
4 changed files with 35 additions and 52 deletions
10
CHANGES
10
CHANGES
|
@ -79,6 +79,14 @@ Porting:
|
||||||
Socat failed to build on platforms without flock() function (AIX,
|
Socat failed to build on platforms without flock() function (AIX,
|
||||||
Solaris) due to a missing guard.
|
Solaris) due to a missing guard.
|
||||||
|
|
||||||
|
Newer Linux distributions do not provide libwrap: do not leave unused
|
||||||
|
variable.
|
||||||
|
|
||||||
|
Newer Linux distributions deprecate usleep, replace it.
|
||||||
|
|
||||||
|
OpenSSL-3 loudly deprecates some functions or macros, replace a first
|
||||||
|
bunch of them.
|
||||||
|
|
||||||
Testing:
|
Testing:
|
||||||
test.sh produces file results.txt with columns of test numbers, names,
|
test.sh produces file results.txt with columns of test numbers, names,
|
||||||
and results.
|
and results.
|
||||||
|
@ -92,6 +100,8 @@ Testing:
|
||||||
|
|
||||||
Added a developer test that overwrites malloc'ed memory with non-zeros.
|
Added a developer test that overwrites malloc'ed memory with non-zeros.
|
||||||
|
|
||||||
|
Newer Linux distributions now deprecate usleep; replaced it in test.sh
|
||||||
|
|
||||||
####################### V 1.8.0.2:
|
####################### V 1.8.0.2:
|
||||||
|
|
||||||
Security:
|
Security:
|
||||||
|
|
59
test.sh
59
test.sh
|
@ -112,6 +112,17 @@ MICROS=${S}${uS}
|
||||||
MICROS=${MICROS##0000}; MICROS=${MICROS##00}; MICROS=${MICROS##0}
|
MICROS=${MICROS##0000}; MICROS=${MICROS##00}; MICROS=${MICROS##0}
|
||||||
# changed below again
|
# changed below again
|
||||||
|
|
||||||
|
divide_uint_by_1000000 () {
|
||||||
|
x=$1
|
||||||
|
if [ ${#x} -ge 7 ]; then
|
||||||
|
echo ${x%??????}.${x: -6};
|
||||||
|
else
|
||||||
|
y=000000$x;
|
||||||
|
f=${y: -6};
|
||||||
|
echo 0.$f;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_MICROS=$((MICROS+999999)); SECONDs="${_MICROS%??????}"
|
_MICROS=$((MICROS+999999)); SECONDs="${_MICROS%??????}"
|
||||||
[ -z "$SECONDs" ] && SECONDs=0
|
[ -z "$SECONDs" ] && SECONDs=0
|
||||||
[ "$DEFS" ] && echo "SECONDs=\"$SECONDs\"" >&2
|
[ "$DEFS" ] && echo "SECONDs=\"$SECONDs\"" >&2
|
||||||
|
@ -193,7 +204,7 @@ PATH=$PATH:/sbin # RHEL6:ip
|
||||||
case "$0" in
|
case "$0" in
|
||||||
*/*) PATH="${0%/*}:$PATH"
|
*/*) PATH="${0%/*}:$PATH"
|
||||||
esac
|
esac
|
||||||
PATH=.:$PATH # for usleep,relsleep
|
PATH=.:$PATH # for relsleep
|
||||||
[ "$DEFS" ] && echo "PATH=\"$PATH\"" >&2
|
[ "$DEFS" ] && echo "PATH=\"$PATH\"" >&2
|
||||||
|
|
||||||
#OPENSSL_RAND="-rand /dev/egd-pool"
|
#OPENSSL_RAND="-rand /dev/egd-pool"
|
||||||
|
@ -308,47 +319,6 @@ tolower () {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! which usleep >/dev/null 2>&1; then
|
|
||||||
cat >usleep <<EOF
|
|
||||||
#! /usr/bin/env bash
|
|
||||||
# temporary script from Socat test.sh:
|
|
||||||
# sleep for a number of µs
|
|
||||||
u=\$1
|
|
||||||
l=\${#u}
|
|
||||||
i=0
|
|
||||||
[ "\$l" -gt 6 ] && i=\${u%??????}
|
|
||||||
u0=000000\$u
|
|
||||||
s=\${i}.\${u0: -6:6};
|
|
||||||
#echo \$s
|
|
||||||
sleep \$s
|
|
||||||
EOF
|
|
||||||
chmod a+x usleep
|
|
||||||
fi
|
|
||||||
|
|
||||||
# precision sleep; takes seconds with fractional part; sleep does this on all test platforms
|
|
||||||
if false; then
|
|
||||||
psleep () {
|
|
||||||
local T="$1"
|
|
||||||
[ "$T" = 0 ] && T=0.000002
|
|
||||||
#$SOCAT -T "$T" PIPE PIPE 2>/dev/null
|
|
||||||
sleep "$T"
|
|
||||||
}
|
|
||||||
# time in microseconds to wait in some situations
|
|
||||||
if ! type usleep >/dev/null 2>&1 ||
|
|
||||||
usleep 0 2>&1 |grep -q deprecated; then
|
|
||||||
usleep () {
|
|
||||||
local n="$1"
|
|
||||||
case "$n" in
|
|
||||||
*???????) S="${n%??????}"; uS="${n:${#n}-6}" ;;
|
|
||||||
*) S=0; uS="00000$n"; uS="${uS:${#uS}-6}" ;;
|
|
||||||
esac
|
|
||||||
#$SOCAT -T "$S.$uS" PIPE PIPE 2>/dev/null
|
|
||||||
sleep "$S.$uS"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
#USLEEP=usleep
|
|
||||||
fi
|
|
||||||
|
|
||||||
# calculate the time i*MICROS, output as float number for us with -t
|
# calculate the time i*MICROS, output as float number for us with -t
|
||||||
reltime () {
|
reltime () {
|
||||||
local n="$1"
|
local n="$1"
|
||||||
|
@ -361,11 +331,12 @@ reltime () {
|
||||||
echo "$S.$uS"
|
echo "$S.$uS"
|
||||||
}
|
}
|
||||||
|
|
||||||
# A sleep with configurable clocking ($vat_t)
|
# A sleep with configurable clocking ($val_t)
|
||||||
# val_t should be at least the time that a Socat invocation, no action, and
|
# val_t should be at least the time that a Socat invocation, no action, and
|
||||||
# termination takes
|
# termination takes
|
||||||
relsleep () {
|
relsleep () {
|
||||||
usleep $(($1*MICROS))
|
#sleep $(($1*MICROS/1000000))
|
||||||
|
sleep $(divide_uint_by_1000000 $(($1*MICROS)) )
|
||||||
}
|
}
|
||||||
|
|
||||||
cat >relsleep <<-'EOF'
|
cat >relsleep <<-'EOF'
|
||||||
|
|
|
@ -702,7 +702,7 @@ int _xioopen_openssl_listen(struct single *sfd,
|
||||||
const char *opt_commonname,
|
const char *opt_commonname,
|
||||||
SSL_CTX *ctx,
|
SSL_CTX *ctx,
|
||||||
int level) {
|
int level) {
|
||||||
char error_string[120];
|
char error_string[256];
|
||||||
unsigned long err;
|
unsigned long err;
|
||||||
int errint, ret;
|
int errint, ret;
|
||||||
|
|
||||||
|
@ -764,7 +764,7 @@ int _xioopen_openssl_listen(struct single *sfd,
|
||||||
while (err = ERR_get_error()) {
|
while (err = ERR_get_error()) {
|
||||||
ERR_error_string_n(err, error_string, sizeof(error_string));
|
ERR_error_string_n(err, error_string, sizeof(error_string));
|
||||||
Msg4(level, "SSL_accept(): %s / %s / %s / %s", error_string,
|
Msg4(level, "SSL_accept(): %s / %s / %s / %s", error_string,
|
||||||
ERR_lib_error_string(err), ERR_func_error_string(err),
|
ERR_lib_error_string(err), error_string,
|
||||||
ERR_reason_error_string(err));
|
ERR_reason_error_string(err));
|
||||||
}
|
}
|
||||||
/* Msg1(level, "SSL_accept(): %s", ERR_error_string(e, buf));*/
|
/* Msg1(level, "SSL_accept(): %s", ERR_error_string(e, buf));*/
|
||||||
|
@ -1976,7 +1976,7 @@ static int xioSSL_set_fd(struct single *sfd, int level) {
|
||||||
should not retry for any reason. */
|
should not retry for any reason. */
|
||||||
static int xioSSL_connect(struct single *sfd, const char *opt_commonname,
|
static int xioSSL_connect(struct single *sfd, const char *opt_commonname,
|
||||||
bool opt_ver, int level) {
|
bool opt_ver, int level) {
|
||||||
char error_string[120];
|
char error_string[256];
|
||||||
int errint, status, ret;
|
int errint, status, ret;
|
||||||
unsigned long err;
|
unsigned long err;
|
||||||
|
|
||||||
|
@ -2012,7 +2012,7 @@ static int xioSSL_connect(struct single *sfd, const char *opt_commonname,
|
||||||
while (err = ERR_get_error()) {
|
while (err = ERR_get_error()) {
|
||||||
ERR_error_string_n(err, error_string, sizeof(error_string));
|
ERR_error_string_n(err, error_string, sizeof(error_string));
|
||||||
Msg4(level, "SSL_connect(): %s / %s / %s / %s", error_string,
|
Msg4(level, "SSL_connect(): %s / %s / %s / %s", error_string,
|
||||||
ERR_lib_error_string(err), ERR_func_error_string(err),
|
ERR_lib_error_string(err), error_string,
|
||||||
ERR_reason_error_string(err));
|
ERR_reason_error_string(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2037,7 +2037,7 @@ static int xioSSL_connect(struct single *sfd, const char *opt_commonname,
|
||||||
/* on result < 0: errno is set (at least to EIO) */
|
/* on result < 0: errno is set (at least to EIO) */
|
||||||
ssize_t xioread_openssl(struct single *pipe, void *buff, size_t bufsiz) {
|
ssize_t xioread_openssl(struct single *pipe, void *buff, size_t bufsiz) {
|
||||||
unsigned long err;
|
unsigned long err;
|
||||||
char error_string[120];
|
char error_string[256];
|
||||||
int _errno = EIO; /* if we have no better idea about nature of error */
|
int _errno = EIO; /* if we have no better idea about nature of error */
|
||||||
int errint, ret;
|
int errint, ret;
|
||||||
|
|
||||||
|
@ -2072,7 +2072,7 @@ ssize_t xioread_openssl(struct single *pipe, void *buff, size_t bufsiz) {
|
||||||
while (err = ERR_get_error()) {
|
while (err = ERR_get_error()) {
|
||||||
ERR_error_string_n(err, error_string, sizeof(error_string));
|
ERR_error_string_n(err, error_string, sizeof(error_string));
|
||||||
Error4("SSL_read(): %s / %s / %s / %s", error_string,
|
Error4("SSL_read(): %s / %s / %s / %s", error_string,
|
||||||
ERR_lib_error_string(err), ERR_func_error_string(err),
|
ERR_lib_error_string(err), error_string,
|
||||||
ERR_reason_error_string(err));
|
ERR_reason_error_string(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2098,7 +2098,7 @@ ssize_t xiopending_openssl(struct single *pipe) {
|
||||||
/* on result < 0: errno is set (at least to EIO) */
|
/* on result < 0: errno is set (at least to EIO) */
|
||||||
ssize_t xiowrite_openssl(struct single *pipe, const void *buff, size_t bufsiz) {
|
ssize_t xiowrite_openssl(struct single *pipe, const void *buff, size_t bufsiz) {
|
||||||
unsigned long err;
|
unsigned long err;
|
||||||
char error_string[120];
|
char error_string[256];
|
||||||
int _errno = EIO; /* if we have no better idea about nature of error */
|
int _errno = EIO; /* if we have no better idea about nature of error */
|
||||||
int errint, ret;
|
int errint, ret;
|
||||||
|
|
||||||
|
@ -2131,7 +2131,7 @@ ssize_t xiowrite_openssl(struct single *pipe, const void *buff, size_t bufsiz) {
|
||||||
while (err = ERR_get_error()) {
|
while (err = ERR_get_error()) {
|
||||||
ERR_error_string_n(err, error_string, sizeof(error_string));
|
ERR_error_string_n(err, error_string, sizeof(error_string));
|
||||||
Error4("SSL_write(): %s / %s / %s / %s", error_string,
|
Error4("SSL_write(): %s / %s / %s / %s", error_string,
|
||||||
ERR_lib_error_string(err), ERR_func_error_string(err),
|
ERR_lib_error_string(err), error_string,
|
||||||
ERR_reason_error_string(err));
|
ERR_reason_error_string(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1679,7 +1679,9 @@ int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) {
|
||||||
int xiocheckpeer(xiosingle_t *sfd,
|
int xiocheckpeer(xiosingle_t *sfd,
|
||||||
union sockaddr_union *pa, union sockaddr_union *la) {
|
union sockaddr_union *pa, union sockaddr_union *la) {
|
||||||
char infobuff[256];
|
char infobuff[256];
|
||||||
|
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
|
||||||
int result;
|
int result;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if WITH_IP4 || WITH_IP6
|
#if WITH_IP4 || WITH_IP6
|
||||||
if (sfd->para.socket.dorange) {
|
if (sfd->para.socket.dorange) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue