aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andree <mandree@FreeBSD.org>2024-04-21 07:21:14 +0000
committerKurt Jaeger <pi@FreeBSD.org>2024-04-21 07:21:47 +0000
commitc392b136785e44d496fb7dc744ee616a9374197e (patch)
tree1d15d6af81052edcba0912d3b08aa419ff446b02
parentfee0f7fac2e857eabe806ed77df66c9688ad43b2 (diff)
downloadports-c392b136785e44d496fb7dc744ee616a9374197e.tar.gz
ports-c392b136785e44d496fb7dc744ee616a9374197e.zip
ftp/libfilezilla: fix build by adding missing patch
PR: 278463
-rw-r--r--ftp/libfilezilla/files/patch-lib_impersonation.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/ftp/libfilezilla/files/patch-lib_impersonation.cpp b/ftp/libfilezilla/files/patch-lib_impersonation.cpp
new file mode 100644
index 000000000000..423e5bf90e44
--- /dev/null
+++ b/ftp/libfilezilla/files/patch-lib_impersonation.cpp
@@ -0,0 +1,73 @@
+FreeBSD defines crypt_r() via <unistd.h>.
+
+--- lib/impersonation.cpp.orig 2023-06-28 13:00:47 UTC
++++ lib/impersonation.cpp
+@@ -8,8 +8,6 @@
+ #include <tuple>
+
+ #if FZ_UNIX
+-#include <crypt.h>
+-#include <shadow.h>
+ #endif
+ #include <grp.h>
+ #include <limits.h>
+@@ -98,43 +96,7 @@ std::optional<gid_t> get_group(native_string const& gn
+ return {};
+ }
+
+-#if FZ_UNIX
+-struct shadow_holder {
+- shadow_holder() = default;
+- shadow_holder(shadow_holder const&) = delete;
+- shadow_holder(shadow_holder &&) = default;
+-
+- shadow_holder& operator=(shadow_holder const&) = delete;
+- shadow_holder& operator=(shadow_holder &&) = default;
+-
+- ~shadow_holder() noexcept = default;
+-
+- struct spwd* shadow_{};
+-
+- struct spwd shadow_buffer_;
+- buffer buf_{};
+-};
+-
+-shadow_holder get_shadow(native_string const& username)
+-{
+- shadow_holder ret;
+-
+- size_t s = 1024;
+- int res{};
+- do {
+- s *= 2;
+- ret.buf_.get(s);
+- res = getspnam_r(username.c_str(), &ret.shadow_buffer_, reinterpret_cast<char*>(ret.buf_.get(s)), s, &ret.shadow_);
+- } while (res == ERANGE);
+-
+- if (res) {
+- ret.shadow_ = nullptr;
+- }
+-
+- return ret;
+ }
+-#endif
+-}
+
+ class impersonation_token_impl final
+ {
+@@ -191,14 +153,7 @@ bool check_auth(native_string const& username, native_
+ bool check_auth(native_string const& username, native_string const& password)
+ {
+ #if FZ_UNIX
+- auto shadow = get_shadow(username);
+- if (shadow.shadow_) {
+- struct crypt_data data{};
+- char* encrypted = crypt_r(password.c_str(), shadow.shadow_->sp_pwdp, &data);
+- if (encrypted && !strcmp(encrypted, shadow.shadow_->sp_pwdp)) {
+- return true;
+- }
+- }
++ return false; // FreeBSD does not have shadow.h support
+ #elif FZ_MAC
+ bool ret{};
+