Skip to content

Commit

Permalink
Merge pull request bareos#1888
Browse files Browse the repository at this point in the history
matrix remove obsolete SUSE
  • Loading branch information
BareosBot authored Aug 1, 2024
2 parents b2b9ca2 + 6f4b09c commit 13fe542
Show file tree
Hide file tree
Showing 20 changed files with 161 additions and 106 deletions.
6 changes: 3 additions & 3 deletions .matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ OS:
SUSE:
"15":
TYPE: rpm
IMAGE: sle154
CUSTOM_TEST_IMAGES: [ SLE-15_SP3, SLE-15_SP4, openSUSE-Leap_15.4, SLE-15_SP5, openSUSE-Leap_15.5 ]
IMAGE: sle155
CUSTOM_TEST_IMAGES: [ SLE-15_SP3, SLE-15_SP4, openSUSE-Leap_15.4, SLE-15_SP5, openSUSE-Leap_15.5, SLE-15_SP6, openSUSE-Leap_15.6 ]
ARCH:
- x86_64
Fedora:
Expand Down Expand Up @@ -106,7 +106,7 @@ OS:
"8":
TYPE: rpm
IMAGE: rhel8
CUSTOM_TEST_IMAGES: [ Rocky, Alma, Oracle, Stream, RHEL ]
CUSTOM_TEST_IMAGES: [ Rocky, Alma, Oracle, RHEL ]
ARCH:
- x86_64
FreeBSD:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- dird: disallow running always incremental virtual full jobs with empty jobid list [PR #1738]
- msgchan: fix deadlock [PR #1858]
- VMware Plugin: Add option restore_allow_disks_mismatch [PR #1876]
- matrix remove obsolete SUSE [PR #1888]

### Removed
- plugins: remove old deprecated postgres plugin [PR #1606]
Expand Down Expand Up @@ -233,4 +234,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[PR #1878]: https://github.com/bareos/bareos/pull/1878
[PR #1881]: https://github.com/bareos/bareos/pull/1881
[PR #1883]: https://github.com/bareos/bareos/pull/1883
[PR #1888]: https://github.com/bareos/bareos/pull/1888
[unreleased]: https://github.com/bareos/bareos/tree/master
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ print_variables("${DUMP_VARS}")

# REPEAT_UNTIL requires cmake 3.17+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
set(REPEAT_UNTIL "REPEAT UNTIL_PASS:2")
set(REPEAT_UNTIL "")
endif()

configure_file(
Expand Down
2 changes: 1 addition & 1 deletion core/cmake/BareosFindPrograms.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down
38 changes: 8 additions & 30 deletions core/platforms/packaging/bareos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,9 @@ BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-gcc-c++
%endif

%if 0%{?sle_version} == 150400
BuildRequires: gcc11
BuildRequires: gcc11-c++
%else
%if 0%{?sle_version} == 150300 || 0%{?suse_version} > 1500
BuildRequires: gcc10
BuildRequires: gcc10-c++
%else
%if 0%{?suse_version}
BuildRequires: gcc9
BuildRequires: gcc9-c++
%endif
%endif
%if 0%{?suse_version}
BuildRequires: gcc13
BuildRequires: gcc13-c++
%endif

%if 0%{?systemd_support}
Expand Down Expand Up @@ -263,7 +253,7 @@ Bareos source code has been released under the AGPL version 3 license.
%{dscr}


%if 0%{?opensuse_version} || 0%{?sle_version}
%if 0%{?suse_version}
%debug_package
%endif

Expand Down Expand Up @@ -661,7 +651,7 @@ Requires: httpd
%define www_daemon_group apache
%endif

%if 0%{?suse_version} || 0%{?sle_version}
%if 0%{?suse_version}
Conflicts: mod_php_any
%define _apache_conf_dir /etc/apache2/conf.d/
%define www_daemon_user wwwrun
Expand Down Expand Up @@ -841,23 +831,11 @@ source /opt/rh/devtoolset-8/enable
%endif

# use modern compiler on suse
%if 0%{?sle_version} == 150400
CC=gcc-11 ; export CC
CXX=g++-11 ; export CXX
%else
%if 0%{?sle_version} == 150300 || 0%{?suse_version} > 1500
CC=gcc-10 ; export CC
CXX=g++-10 ; export CXX
%else
%if 0%{?suse_version}
CC=gcc-9 ; export CC
CXX=g++-9 ; export CXX
%endif
%endif
%if 0%{?suse_version}
CC=gcc-13 ; export CC
CXX=g++-13 ; export CXX
%endif



CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ;

Expand Down
10 changes: 9 additions & 1 deletion core/scripts/mtx-changer.in
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,15 @@ _EOT_
awk -F ":" -f - "${TMPFILE}" << '_EOT_'
/^Data Transfer Element .*[0-9]:/ {
gsub("Data Transfer Element ","",$1)
F=gensub(/Full \(Storage Element ([0-9]{1,}) Loaded\)/,":F:\\1",1,$2)
match($2,/Full \(Storage Element ([0-9]{1,}) Loaded\)/)
if (RSTART > 0 ) {
T=substr($2,RSTART,RLENGTH)
match(T,/[0-9]{1,}/)
F=":F:" substr(T,RSTART,RLENGTH)
}
else {
F=$2
}
gsub("Empty",":E",F)
gsub("VolumeTag = ",":",$3)
print "D:" $1 F $3
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/tls_openssl_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ bool TlsOpenSslPrivate::init()
return false;
}

ASSERT(tcp_file_descriptor_);
ASSERT(tcp_file_descriptor_ >= 0); // 0 is a good (socket-)fd
BIO_set_fd(bio, tcp_file_descriptor_, BIO_NOCLOSE);

SSL_set_bio(openssl_, bio, bio);
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/tls_openssl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2005-2010 Free Software Foundation Europe e.V.
Copyright (C) 2018-2023 Bareos GmbH & Co. KG
Copyright (C) 2018-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -80,7 +80,7 @@ class TlsOpenSslPrivate {
std::string protocol_;

/* cert attributes */
int tcp_file_descriptor_{};
int tcp_file_descriptor_{kInvalidFiledescriptor};
std::string ca_certfile_;
std::string ca_certdir_;
std::string crlfile_;
Expand Down
99 changes: 72 additions & 27 deletions core/src/tests/bareos_test_sockets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,37 +158,76 @@ static int accept_server_socket(int listen_file_descriptor)
return new_socket;
}

int create_accepted_server_socket(int port)
static std::optional<uint16_t> port_number_of(int sockfd)
{
int sock_fd = create_listening_server_socket(port);
if (sock_fd > 0) { sock_fd = accept_server_socket(sock_fd); }
return sock_fd;
union {
struct sockaddr addr;
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
} buf = {};

// the port gets chosen during StartSocketServer, so we need to query
// the port number afterwards.
socklen_t len = sizeof(buf);
auto error = getsockname(sockfd, &buf.addr, &len);
EXPECT_EQ(error, 0);
if (error != 0) {
perror("sock name error");
return false;
}

if (buf.addr.sa_family != AF_INET && buf.addr.sa_family != AF_INET6) {
return std::nullopt;
}

auto nport = (buf.addr.sa_family == AF_INET) ? buf.addr4.sin_port
: buf.addr6.sin6_port;

auto port = ntohs(nport);

return port;
}

std::unique_ptr<TestSockets> create_connected_server_and_client_bareos_socket()
{
std::unique_ptr<TestSockets> test_sockets(new TestSockets);

uint16_t portnumber = create_unique_socket_number();
int listen_fd = create_listening_server_socket(0);

int server_file_descriptor = create_listening_server_socket(portnumber);
EXPECT_GE(listen_fd, 0) << "Could not create listening socket";
if (listen_fd < 0) { return nullptr; }

EXPECT_GE(server_file_descriptor, 0) << "Could not create listening socket";
if (server_file_descriptor < 0) { return nullptr; }
auto portnumber_opt = port_number_of(listen_fd);

EXPECT_NE(portnumber_opt, std::nullopt) << "Could not find used port number";
if (!portnumber_opt) {
socketClose(listen_fd);
return nullptr;
}

auto portnumber = *portnumber_opt;

test_sockets->client.reset(new BareosSocketTCP);
test_sockets->client->sleep_time_after_authentication_error = 0;

bool ok = test_sockets->client->connect(NULL, 1, 1, 0, "Director daemon",
HOST, NULL, portnumber, false);
EXPECT_EQ(ok, true) << "Could not connect client socket with server socket.";
if (!ok) { return nullptr; }
if (!ok) {
socketClose(listen_fd);
return nullptr;
}

server_file_descriptor = accept_server_socket(server_file_descriptor);
EXPECT_GE(server_file_descriptor, 0) << "Could not accept server socket.";
if (server_file_descriptor <= 0) { return nullptr; }
auto server_fd = accept_server_socket(listen_fd);
EXPECT_GE(server_fd, 0) << "Could not accept server socket.";
if (server_fd <= 0) {
socketClose(listen_fd);
return nullptr;
}

test_sockets->server.reset(create_new_bareos_socket(server_file_descriptor));
socketClose(listen_fd);

test_sockets->server.reset(create_new_bareos_socket(server_fd));

return test_sockets;
}
Expand All @@ -204,23 +243,29 @@ BareosSocket* create_new_bareos_socket(int fd)
return bs;
}

std::optional<listening_socket> create_listening_socket()
{
int sock_fd = create_listening_server_socket(0);

#include <sys/types.h>
#if !defined(HAVE_MSVC)
# include <unistd.h>
#endif
if (sock_fd < 0) { return std::nullopt; }

static uint16_t listening_server_port_number = 0;
auto port = port_number_of(sock_fd);

uint16_t create_unique_socket_number()
{
if (listening_server_port_number == 0) {
pid_t pid = getpid();
uint16_t port_number = 5 * (static_cast<uint32_t>(pid) % 10000) + 10000;
listening_server_port_number = port_number;
} else {
++listening_server_port_number;
if (!port) {
socketClose(sock_fd);
return std::nullopt;
}

return listening_server_port_number;
return listening_socket{*port, sock_fd};
}

int accept_socket(const listening_socket& ls)
{
auto fd = accept_server_socket(ls.sockfd);
return fd;
}

listening_socket::~listening_socket()
{
if (sockfd >= 0) { socketClose(sockfd); }
}
28 changes: 25 additions & 3 deletions core/src/tests/bareos_test_sockets.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2021 Bareos GmbH & Co. KG
Copyright (C) 2018-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -24,6 +24,7 @@
#define BAREOS_TESTS_BAREOS_TEST_SOCKETS_H_

#include <memory>
#include <optional>

class BareosSocketTCP;
class BareosSocket;
Expand All @@ -37,9 +38,30 @@ class TestSockets {
TestSockets(const TestSockets&) = delete;
};

int create_accepted_server_socket(int port);
struct listening_socket {
uint16_t port{};
int sockfd{};

listening_socket() = default;
listening_socket(uint16_t port_, int sockfd_) : port{port_}, sockfd{sockfd_}
{
}
listening_socket(const listening_socket&) = delete;
listening_socket& operator=(const listening_socket&) = delete;
listening_socket(listening_socket&& other) { *this = std::move(other); }
listening_socket& operator=(listening_socket&& other)
{
std::swap(port, other.port);
std::swap(sockfd, other.sockfd);
return *this;
}
~listening_socket();
};

std::optional<listening_socket> create_listening_socket();
int accept_socket(const listening_socket& ls);

BareosSocket* create_new_bareos_socket(int fd);
std::unique_ptr<TestSockets> create_connected_server_and_client_bareos_socket();
uint16_t create_unique_socket_number();

#endif // BAREOS_TESTS_BAREOS_TEST_SOCKETS_H_
6 changes: 3 additions & 3 deletions core/src/tests/create_resource.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2023 Bareos GmbH & Co. KG
Copyright (C) 2018-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -43,7 +43,7 @@ console::DirectorResource* CreateAndInitializeNewDirectorResource()
{
console::DirectorResource* dir = new (console::DirectorResource);
dir->address = (char*)HOST;
dir->DIRport = htons(create_unique_socket_number());
dir->DIRport = 0;
dir->tls_enable_ = false;
dir->tls_require_ = false;
dir->tls_cert_.certfile_ = CERTDIR "/bareos-dir.bareos.org-cert.pem";
Expand Down Expand Up @@ -93,7 +93,7 @@ directordaemon::StorageResource* CreateAndInitializeNewStorageResource()
directordaemon::StorageResource* store
= new (directordaemon::StorageResource);
store->address = (char*)HOST;
store->SDport = htons(create_unique_socket_number());
store->SDport = 0;
store->tls_enable_ = false;
store->tls_require_ = false;
store->tls_cert_.certfile_ = CERTDIR "/bareos-dir.bareos.org-cert.pem";
Expand Down
2 changes: 1 addition & 1 deletion core/src/tests/sd_reservation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct TestJob {
void WaitThenUnreserve(std::unique_ptr<TestJob>&);
void WaitThenUnreserve(std::unique_ptr<TestJob>& job)
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
std::this_thread::sleep_for(std::chrono::seconds(5));
job->jcr->sd_impl->dcr->UnreserveDevice();
ReleaseDeviceCond();
}
Expand Down
Loading

0 comments on commit 13fe542

Please sign in to comment.