Diff below updates libfilezilla to 0.34.1, which is needed for an update
of filezilla. Overview on changes can be found at
https://lib.filezilla-project.org/.
A patch has been added to work around getspnam_r() and crypt_r(),
which OpenBSD does not have. I would very much appreciate it if people
would have a look at this workaround.
Run tested in combination with filezilla.
Comments/ok?
diff --git Makefile Makefile
index 2c2f8fac1d7..f58787c4e1c 100644
--- Makefile
+++ Makefile
@@ -2,9 +2,9 @@
COMMENT = support library for FileZilla
-DISTNAME = libfilezilla-0.31.1
+DISTNAME = libfilezilla-0.34.1
-SHARED_LIBS += filezilla 9.1 # 17.0.1
+SHARED_LIBS += filezilla 10.0 # 21.1.0
CATEGORIES = net
diff --git distinfo distinfo
index 9bc0b92119d..e88b0a1a6d9 100644
--- distinfo
+++ distinfo
@@ -1,2 +1,2 @@
-SHA256 (libfilezilla-0.31.1.tar.bz2) =
mX1Yh7YBXzhp03Wwy8S0lC/LJNvktDRohclGz+czFm8=
-SIZE (libfilezilla-0.31.1.tar.bz2) = 585070
+SHA256 (libfilezilla-0.34.1.tar.bz2) =
YDdu9x424Q6IewTgo5acCi2QdGyXOHPA1bfWucFmNzQ=
+SIZE (libfilezilla-0.34.1.tar.bz2) = 595048
diff --git patches/patch-lib_glue_unix_cpp patches/patch-lib_glue_unix_cpp
new file mode 100644
index 00000000000..c067a35061f
--- /dev/null
+++ patches/patch-lib_glue_unix_cpp
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+EBADFD is not specified in POSIX, EBADF is.
+
+Index: lib/glue/unix.cpp
+--- lib/glue/unix.cpp.orig
++++ lib/glue/unix.cpp
+@@ -87,7 +87,7 @@ int send_fd(int socket, fz::buffer & buf, int fd, int
+ return -1;
+ }
+ if (socket < 0) {
+- error = EBADFD;
++ error = EBADF;
+ return -1;
+ }
+
+@@ -144,7 +144,7 @@ int read_fd(int socket, fz::buffer & buf, int & fd, in
+ {
+ fd = -1;
+ if (socket < 0) {
+- error = EBADFD;
++ error = EBADF;
+ return -1;
+ }
+
diff --git patches/patch-lib_impersonation_cpp
patches/patch-lib_impersonation_cpp
new file mode 100644
index 00000000000..fbb838c8a8c
--- /dev/null
+++ patches/patch-lib_impersonation_cpp
@@ -0,0 +1,89 @@
+$OpenBSD$
+
+Index: lib/impersonation.cpp
+--- lib/impersonation.cpp.orig
++++ lib/impersonation.cpp
+@@ -7,10 +7,8 @@
+ #include <optional>
+ #include <tuple>
+
+-#include <crypt.h>
+ #include <grp.h>
+ #include <pwd.h>
+-#include <shadow.h>
+ #include <string.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+@@ -51,43 +49,7 @@ passwd_holder get_passwd(fz::native_string const& user
+
+ return ret;
+ }
+-
+-
+-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_;
+- fz::buffer buf_{};
+-};
+-
+-shadow_holder get_shadow(fz::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;
+ }
+-}
+
+ class impersonation_token_impl final
+ {
+@@ -139,20 +101,15 @@ impersonation_token::impersonation_token(fz::native_st
+ {
+ auto pwd = get_passwd(username);
+ if (pwd.pwd_) {
+- auto shadow = get_shadow(username);
+- if (shadow.shadow_) {
+- struct crypt_data data{};
+- char* encrypted = crypt_r(passwd.c_str(),
shadow.shadow_->sp_pwdp, &data);
+- if (encrypted && !strcmp(encrypted,
shadow.shadow_->sp_pwdp)) {
+- impl_ =
std::make_unique<impersonation_token_impl>();
+- impl_->name_ = username;
+- if (pwd.pwd_->pw_dir) {
+- impl_->home_ = pwd.pwd_->pw_dir;
+- }
+- impl_->uid_ = pwd.pwd_->pw_uid;
+- impl_->gid_ = pwd.pwd_->pw_gid;
+- impl_->sup_groups_ =
get_supplementary(username, pwd.pwd_->pw_gid);
++ if (crypt_checkpass(passwd.c_str(), pwd.pwd_->pw_passwd) == 0) {
++ impl_ = std::make_unique<impersonation_token_impl>();
++ impl_->name_ = username;
++ if (pwd.pwd_->pw_dir) {
++ impl_->home_ = pwd.pwd_->pw_dir;
+ }
++ impl_->uid_ = pwd.pwd_->pw_uid;
++ impl_->gid_ = pwd.pwd_->pw_gid;
++ impl_->sup_groups_ = get_supplementary(username,
pwd.pwd_->pw_gid);
+ }
+ }
+ }
diff --git pkg/PLIST pkg/PLIST
index 7355a0726a5..4663b4a05ef 100644
--- pkg/PLIST
+++ pkg/PLIST
@@ -16,6 +16,7 @@ include/libfilezilla/glue/wx.hpp
include/libfilezilla/glue/wxinvoker.hpp
include/libfilezilla/hash.hpp
include/libfilezilla/hostname_lookup.hpp
+include/libfilezilla/impersonation.hpp
include/libfilezilla/invoker.hpp
include/libfilezilla/iputils.hpp
include/libfilezilla/json.hpp