2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

9728 Commits

Author SHA1 Message Date
Adrian Reber
ae2ab5ddad lsm: also dump and restore sockcreate
The file /proc/PID/attr/sockcreate is used by SELinux to label newly
created sockets with the label available at sockcreate.

If it is NULL, the default label of the process will be used.

This reads out that file during checkpoint and restores the value during
restore.

This value is irrelevant for existing sockets as they might have been
created with another context. This is only to make sure that newly
created sockets have the correct context.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-05-16 09:39:30 -07:00
Pavel Emelyanov
437561d2bb criu: Version 3.12
Suddenly it's a feature-reach release. We have support for Android build
and several tempting C/R things -- raw sockets, selinux labels and ro
ghost files.

And a couple of fixes, of course.
v3.12
2019-04-25 20:26:57 +03:00
Andrei Vagin
5412247572 arm: fix atomic_{add,sub}_return
Now, this code doesn't pass this simple test:

        atomic_t a;;
        int c = 0;
        atomic_set(&a, c);
        c = atomic_inc(&a);
        if (c != 0) {
                pr_err("c = %x &a = %p\n", c, &a);
                return 1;
        }

08:28:51.771: 26187: ERR: fd.c:36: c = 7ef47a60 &a = 0x7ef47a60

Reported-by: Mr Jenkins
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-25 20:23:18 +03:00
Radostin Stoyanov
59930e5afb tools.mk: Define CC if not set to 'default'
FOO ?= bar

is equivalent to

	ifeq ($(origin FOO), undefined)
	FOO = bar
	endif

However, when CC is not set its value is 'default' rather than
'undefined'.

>From [1]:

'undefined': if variable was never defined.

'default': if variable has a default definition, as is usual with CC
and so on. See Variables Used by Implicit Rules. Note that if you have
redefined a default variable, the origin function will return the
origin of the later definition.

[1] https://www.gnu.org/software/make/manual/make.html

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
69e3536285 Bump SONAME to 2
libcriu.so used to have the SONAME

$ readelf -d lib/c/libcriu.so   | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libcriu.so.1]

The recent changes to libcriu (removed and added functions, changes from
`char *`-args to `const char *`) are breaking ABI and API. This requires
a new SONAME of 2. This patch changes the SONAME to 2:

$ readelf -d lib/c/libcriu.so   | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libcriu.so.2]

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Andrei Vagin
6c8ea60491 util: don't leak file descriprots to third-party tools
https://github.com/containers/container-selinux/issues/68
Cc: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Andrei Vagin
b548ed9473 criu: raise the task file limit for specific commands
We don't need to do this from early_init.

Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Cyrill Gorcunov
32d6e7b54d early_init: Raise nr_open limit on particular commands
For swrk, service, dump, restore we need to to raise
nr_file limit to be able to process containers with
huge number of files opened.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Cyrill Gorcunov
5adf790859 sfd: Make sure we're not overwriting existing files
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Cyrill Gorcunov
d2d3b6ff48 sfd: Move service fds to separate file
It has nothing to do with utils but
rather a separate service engine.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Dmitry Safonov
7905b9f65e ia32: Add compatible sigmask to sigframe
It has a different alignment - rework ugly macro RT_SIGFRAME_UC_SIGMASK
into helpers.

Fixes: #666

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Dmitry Safonov
d52720a49d travis-ci: Enable ia32 tests
Travis CI with Xenial has 4.15 kernel these days - all support for ia32
C/R should be inplace. Finally :)

Putting it into "allow_failures" to let it soak a bit.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
e7aba32efe tools.mk: support override CC/LD command line
due to Android NDK's clang is x86_64-linux-android28-clang --sysroot ${SYSROOT_PATH}
and it's ld is x86_64-linux-android-ld,
it's not able to use a single pattern to discript clang and ld.

and there is a error for x86_64-linux-android-ld.
x86_64-linux-android-ld  -L/home/ning/source/criu/protobuf-c/../target/lib -lprotobuf-c -r -z noexecstack -T ./compel/arch/x86/scripts/compel-pack.lds.S  -o criu/pie/parasite.built-in.o  criu/pie/parasite.o criu/pie/pie.lib.a ./compel/plugins/std.lib.a
./compel/compel-host hgen -f criu/pie/parasite.built-in.o -o criu/pie/parasite-blob.h
Error (compel/src/lib/handle-elf-host.c:335): Unexpected undefined symbol: `'. External symbol in PIE?
criu/pie/Makefile:49: recipe for target 'criu/pie/parasite-blob.h' failed

rebuild with host ld, can pass build.

so support override CC/LD from command line can pass build.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
f4fa53cf9b Android NDK: __errno is already defined as a function
criu/log.c:356:16: error: called object type 'int' is not a function or function pointer
        int __errno = errno;
                      ^~~~~
/root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'
                ~~~~~~~^
criu/log.c:391:2: error: called object type 'int' is not a function or function pointer
        errno =  __errno;
        ^~~~~
/root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'

in Android NDK's errno.h:

42: int* __errno(void) __attribute_const__;
43: #define errno (*__errno())

so rename __errno to _errno to pass build

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
de2c917aa7 Android NDK/Clang: fix implicit macro define
it reports:
criu/pie/util-vdso-elf32.c:255:8: error: implicit declaration of function 'ELF32_ST_TYPE' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        if (ELF_ST_TYPE(sym->st_info) != STT_FUNC &&
                            ^
criu/include/util-vdso.h:72:21: note: expanded from macro 'ELF_ST_TYPE'
                        ^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/linux/elf.h:114:26: note: expanded from macro 'ELF32_ST_TYPE'
                         ^
criu/include/util-vdso.h:72:21: note: expanded from macro 'ELF_ST_TYPE'

add #ifndef to check whether these macro is already defined.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
ff7c66e6b1 Clang: __unused is illegal varible name for newer version clang
with Android P's Clang versoin: 6.0.2, and Android NDK's Clang version 8.0.2

Clang will report below error:
criu/compel/include/uapi/compel/sigframe-common.h:55:34: error: expected member name or ';' after declaration specifiers
        int                     __unused[32 - (sizeof (k_rtsigset_t) / sizeof (int))];
        ~~~                             ^

it takes __unused as an attribute, not a varible, chang to _unused, pass compile.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
6d69f65341 Android NDK: elf.h missing defines
in Android NDK, <elf.h> doesn't has define for:
NT_X86_XSTATE
NT_PRSTATUS

so add these defines to pass compile.

NOTE: add <linux/elf.h> will have more build errors

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
e65c7b55e9 zdtm: Replace imp module with importlib
imp.load_source() has been deprecated [1]. The recommended alternative
API for loading a module is exec_module() [2].

[1] https://docs.python.org/2.7/library/imp.html#imp.load_module
[2] https://docs.python.org/3.4/library/importlib.html#importlib.abc.Loader.exec_module

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Pavel Tikhomirov
43095fad2f rpc: reserve number for --check-mounts feature
We want to commit --check-mounts feature to vz-criu. But to maintain
image level compatibility between ms-criu and vz-criu one shouldn't use
the same field id for different data. So add a comment that these id is
reserved.
2019-04-20 20:25:26 -07:00
Zhang Ning
cffeb263b7 Add notes for Android NDK cross compile
some notes for Android NDK cross compile.

Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
31e3e01fe4 Android NDK: no index function in strings.h
due to Android NDK's strings.h doesn't have index function.
Declare this function in CRIU, just like povit_root.

still need to provide index function implement, for link CRIU.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
74bb7a56ea Android NDK: UNIX_PATH_MAX is defined in un.h
in Android NDK, UNIX_PATH_MAX is already defined,
add ifndef to check.

linux/un.h:
22: #define UNIX_PATH_MAX 108

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-04-20 20:25:26 -07:00
Zhang Ning
5605907333 Android NDK: necessary Makefile changes
1, do not hardcode libnl's cflags
    when cross compile CRIU, libnl's header file should not point to host.

2, remove link to rt
    Android NDK doesn't have library rt, and CRIU is not really need it,
    so disable it to pass link

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
1bc3e588dd restore: support restoring threads with SELinux
Restoring a multi-threaded process with CRIU's SELinux support fails
because SELinux does not always support changing the process context of
a multi-threaded process.

Reading the man-page for setcon(), to change the context of a running
process, it states that changing the SELinux context of a multi-threaded
process can only work 'if the new security context is bounded by the old
security context'.

To be able to restore a process without the need to have 'the new
security context [] bounded by the old security context', this sets the
SELinux process context before creating the threads. Thus all threads
are created with the process context of the main process.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Andrei Vagin
0d5c0b2d3a scripts/build: use the last stable release for s390
And get qemu-static from the 18.04 LTS Ubuntu repos.

https://github.com/checkpoint-restore/criu/issues/652
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
b3a199186d docker-test: Fix deprecated security-opt format
The flag --security-opt doesn't use the colon separator (:) anymore
to divide keys and values, instead it uses the equal symbol (=) for
consistency with other similar flags, like --storage-opt.

Deprecated in release: v1.11.0
Target for removal in release: v17.06

https://docs.docker.com/engine/deprecated/

 #653

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
2844b95f67 test: add selinux00 test
This tests if CRIU can restore a process with the same policy as during
checkpointing.

The test selinux00 is started and if SELinux is available the test
process moves itself to another process context. To make this possible
either a new SELinux policy needs to be available containing:

2d537cabbb

Or for a short time SELinux is switched to permissive mode.

The correct SELinux setup is done by zdtm/static/selinux00.checkskip and
zdtm/static/selinux00.hook and after the test the previous SELinux
policy state is restored.

After the test case is restored the test case checks if it still has the
same SELinux process context as before. If not the test cases fails.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
b701774f9d net: add correct SELinux label to parasite socket
If running on a system with SELinux enabled the socket for the
communication between parasite daemon and the main CRIU process needs to
be correctly labeled.

Initially this was motivated by Podman's use case: The container is
usually running as something like '...:...:container_t:...:....' and
CRIU started from runc and Podman will run as
'...:...:container_runtime_t:...:...'. As the parasite will be running
with the same context as the container process: 'container_t'.

Allowing a container process to connect via socket to the outside
of the container ('container_runtime_t') is not desired and therefore
CRIU needs to label the socket with the context of the
container: 'container_t'.

So this first gets the context of the root container process and tells
SELinux to label the next created socket with the same label as the root
container process. For this to work it is necessary to have the correct
SELinux policies installed. For Fedora based systems this is part of the
container-selinux package.

This assumes that all processes CRIU wants to dump are labeled with the
same SELinux context. If some of the child processes have different
labels this will not work and needs additional SELinux policies. But the
whole SELinux socket labeling relies on the correct SELinux being
available.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
d9c51a7034 lsm: dump and restore any SELinux process label
There was support for SELinux process labels in CRIU but because it was
never tested or verified CRIU only supported the 'unconfined_t' process
label. This was basically no SELinux support.

For successful container checkpoint and restore on a SELinux enabled
host it is necessary that the restored container has the same process
context as before checkpointing.

This commit only removes the check if the label is 'unconfined_t' and
now stores any process label to be restored.

For 'normal' processes started from the command-line which are usually
running in the 'unconfined_t' this just works.

For the container use case this needs additional policies. The latest
container-selinux package on Fedora has the necessary policy to allow
CRIU (running as 'container_runtime_t' when used from Podman) to
transition the restored process to 'container_t'.

Restoring a process running under systemd's control (which means
'unconfined_service_t' without additional policies) will fail because
CRIU will be not allowed to change the context of the restored process.

For each additional CRIU use case on SELinux enabled systems, besides
container processes and command-line/shell processes, additional SELinux
policies are required to allow CRIU to do a 'dyntransition' (change the

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Cyrill Gorcunov
fd1653b851 tty: Make params setup synchronous
It was never designed to run params in ansync mode,
and i always been against this change because async
here is too fragile.

p.s.:

I think this might be a reason for

https://github.com/checkpoint-restore/criu/issues/647

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Harshavardhan Unnibhavi
79fbdb92c1 action-scripts: Reducing scope of variables
https://github.com/checkpoint-restore/criu/issues/329

Signed-off-by: Harshavardhan Unnibhavi <hvubfoss@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Mitul Karnik
861afa0bc7 Removing Unneeded Return Value Assignments
Removed return value assignment statements as they are not referenced or used
anywhere after the assignment is done.

Fixes #334: Removing Unneeded Assignments

Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Ashutosh Mehra
9f176a9686 Access pathname relative to root of mntns
Use faccessat() in check_path_remap() to check if the file (relative
to root of mnt ns) is accessible or not.

Signed-off-by: Ashutosh Mehra <asmehra1@in.ibm.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
31f3a6a737 test: fix compilation error
binfmt_misc.c:168:23: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
  168 |   sprintf(path, "%s/%s", dirname, NAME[i]);
      |                       ^

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
3608293773 criu: fix gcc9 rawhide compilation errors
Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
8bb2f22937 readme: Update asciinema demo
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
051ab38a29 Remove irrelevant comment
Support for printing early log messages was recently added, which makes this
comment is no longer relevant.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
a256500185 Rename version protobuf RPC members
In rpc.proto the interface to query the CRIU version number uses major
and minor as keywords. This creates errors when using the RPC
definitions with C++: https://github.com/checkpoint-restore/criu/issues/625

In this commit the fields are renamed from major to major_number and
from minor to minor_number.

For existing programs using the RPC protobuf definition this should be a
transparent change. Only for programs importing the latest rpc.proto it
will require code changes.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
7f4779059d util: Introduce fd_set_nonblocking()
Combine the functionality of socket_set_non_blocking() and
socket_set_blocking() into a new function, and move it in
criu/util.c to enable reusability throughout the code base.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Mitul Karnik
116e3cb649 test: Kill dead code from pipes test
Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
d5cbd48a28 config: Add msg for obsolete use of port/address
When the --ps-socket option is specified the provided file descriptor
of a socket will be reused for incoming TCP connection. In such case
the --address and --port options are ignored.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
ee79bb3a1a criu(8): Fix typo
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
d5d65ae2c4 seek_pagemap: Use pagemap_len()
The variable `len` is used only to calculate the value of `end`. We
already have the static inline function pagemap_len(), which can be
used instead.

Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
38769e94d6 rpc/libcriu: Add lsm-profile option
The --lsm-profile option allows a container engine to specify LSM
profile name.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
44a3af2ddb page-xfer: Fix typo
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
fd9fb7d339 socket-tcp-skip-in-flight: Use set_nonblock
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
635db4895a socket-tcp-skip-in-flight: Don't fail on EAGAIN
The server socket is marked as nonblocking, and if the client doesn't
connect, accept() will fail and set errno to EAGAIN (or EWOULDBLOCK).
Instead, use poll to wait for POLLIN event on the file descriptor.

Suggested-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Adrian Reber
681c05392d crit: display help message when using python3
Running crit with python2 gives following minimal help message:

 $ crit/crit
 usage: crit [-h] {decode,encode,info,x,show} ...
 crit: error: too few arguments

Using a python3 only system crit shows the following error:

 $ crit/crit
 Traceback (most recent call last):
   File "crit/crit", line 6, in <module>
     cli.main()
   File "/home/criu/crit/pycriu/cli.py", line 334, in main
     opts["func"](opts)
 KeyError: 'func'

Using this patch the python3 output changes to:

 $ crit/crit
 usage: crit [-h] {decode,encode,info,x,show} ...
 crit: error: too few arguments

Suggested-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
58fbe6de3a page-xfer: Don't log addr/port on disconnect
When the --ps-socket option is used with page-server, instead of
--address and --port, this message would appear as:

    (00.028440) Disconnect from the page server (null):0

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00
Radostin Stoyanov
ee2916a56f util: Don't log errno on bad server address
From man inet_pton(3):

    inet_pton() returns 1 on success (network address was successfully
    converted). 0 is returned if src does not contain a character
    string representing a valid network address in the specified
    address family. If af does not contain a valid address family,
    -1 is returned and errno is set to EAFNOSUPPORT.

We can assume that the return value is 1 or 0 (because af is set to
AF_INET4 or AF_INET6), therefore errno will not be set.

If a user attempts to bind a server using invalid network address the
following error message will be shown:

 Bad server address: Success

Which is not very clear, with this change the error message will look
like this:

Invalid server address "localhost". The address must be in IPv4 or IPv6 format.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-04-20 20:25:26 -07:00