upg libssh

This commit is contained in:
joborun linux 2024-01-06 03:57:13 +02:00
parent 8039fc3208
commit 2807f5a511
3 changed files with 158 additions and 7 deletions

136
libssh/1a02364b.patch Normal file
View File

@ -0,0 +1,136 @@
From 1a02364b5107a4125ea3cb76fcdb6beabaebf3be Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Fri, 22 Dec 2023 10:32:40 +0100
Subject: [PATCH] Fix regression in IPv6 addresses in hostname parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 4f997aee7c7d7ea346b3e8ba505da0b7601ff318)
---
include/libssh/config_parser.h | 11 ++++++++---
src/config.c | 4 ++--
src/config_parser.c | 16 +++++++++++-----
src/options.c | 10 ++--------
4 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/include/libssh/config_parser.h b/include/libssh/config_parser.h
index a7dd42a2c..ca353432b 100644
--- a/include/libssh/config_parser.h
+++ b/include/libssh/config_parser.h
@@ -30,6 +30,8 @@
extern "C" {
#endif
+#include <stdbool.h>
+
char *ssh_config_get_cmd(char **str);
char *ssh_config_get_token(char **str);
@@ -49,14 +51,17 @@ int ssh_config_get_yesno(char **str, int notfound);
* be stored or NULL if we do not care about the result.
* @param[out] port Pointer to the location, where the new port will
* be stored or NULL if we do not care about the result.
+ * @param[in] ignore_port Set to true if the we should not attempt to parse
+ * port number.
*
* @returns SSH_OK if the provided string is in format of SSH URI,
* SSH_ERROR on failure
*/
int ssh_config_parse_uri(const char *tok,
- char **username,
- char **hostname,
- char **port);
+ char **username,
+ char **hostname,
+ char **port,
+ bool ignore_port);
#ifdef __cplusplus
}
diff --git a/src/config.c b/src/config.c
index c5c40125a..273db7c8c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -464,7 +464,7 @@ ssh_config_parse_proxy_jump(ssh_session session, const char *s, bool do_parsing)
}
if (parse_entry) {
/* We actually care only about the first item */
- rv = ssh_config_parse_uri(cp, &username, &hostname, &port);
+ rv = ssh_config_parse_uri(cp, &username, &hostname, &port, false);
/* The rest of the list needs to be passed on */
if (endp != NULL) {
next = strdup(endp + 1);
@@ -475,7 +475,7 @@ ssh_config_parse_proxy_jump(ssh_session session, const char *s, bool do_parsing)
}
} else {
/* The rest is just sanity-checked to avoid failures later */
- rv = ssh_config_parse_uri(cp, NULL, NULL, NULL);
+ rv = ssh_config_parse_uri(cp, NULL, NULL, NULL, false);
}
if (rv != SSH_OK) {
goto out;
diff --git a/src/config_parser.c b/src/config_parser.c
index b8b94611a..d4b2d2c3b 100644
--- a/src/config_parser.c
+++ b/src/config_parser.c
@@ -162,9 +162,10 @@ int ssh_config_get_yesno(char **str, int notfound)
}
int ssh_config_parse_uri(const char *tok,
- char **username,
- char **hostname,
- char **port)
+ char **username,
+ char **hostname,
+ char **port,
+ bool ignore_port)
{
char *endp = NULL;
long port_n;
@@ -210,12 +211,17 @@ int ssh_config_parse_uri(const char *tok,
if (endp == NULL) {
goto error;
}
- } else {
- /* Hostnames or aliases expand to the last colon or to the end */
+ } else if (!ignore_port) {
+ /* Hostnames or aliases expand to the last colon (if port is requested)
+ * or to the end */
endp = strrchr(tok, ':');
if (endp == NULL) {
endp = strchr(tok, '\0');
}
+ } else {
+ /* If no port is requested, expand to the end of line
+ * (to accommodate the IPv6 addresses) */
+ endp = strchr(tok, '\0');
}
if (tok == endp) {
/* Zero-length hostnames are not valid */
diff --git a/src/options.c b/src/options.c
index 385114555..b3ecffe15 100644
--- a/src/options.c
+++ b/src/options.c
@@ -516,17 +516,11 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
ssh_set_error_invalid(session);
return -1;
} else {
- char *username = NULL, *hostname = NULL, *port = NULL;
- rc = ssh_config_parse_uri(value, &username, &hostname, &port);
+ char *username = NULL, *hostname = NULL;
+ rc = ssh_config_parse_uri(value, &username, &hostname, NULL, true);
if (rc != SSH_OK) {
return -1;
}
- if (port != NULL) {
- SAFE_FREE(username);
- SAFE_FREE(hostname);
- SAFE_FREE(port);
- return -1;
- }
if (username != NULL) {
SAFE_FREE(session->opts.username);
session->opts.username = username;
--
GitLab

View File

@ -9,18 +9,25 @@
#pkgname=(libssh libssh-docs)
pkgname=libssh
pkgver=0.10.6
pkgrel=01
pkgrel=02
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
depends=(zlib openssl)
makedepends=(cmake cmocka doxygen python openssh)
provides=(libssh.so)
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc})
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc}
https://gitlab.com/libssh/libssh-mirror/-/commit/1a02364b.patch)
prepare() {
# Fix regression in IPv6 addresses in hostname parsing
patch -d $pkgname-$pkgver -p1 < 1a02364b.patch
}
build() {
cmake -B build -S $pkgname-$pkgver \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_GSSAPI=OFF \
-DWITH_IPV6=OFF \
-DUNIT_TESTING=ON
cmake --build build
cmake --build build --target docs
@ -55,7 +62,8 @@ license=(LGPL)
validpgpkeys=(8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D) # Andreas Schneider <asn@cryptomilk.org>
sha256sums=(1861d498f5b6f1741b6abc73e608478491edcf9c9d4b6630eef6e74596de9dc1 # libssh-0.10.6.tar.xz
140420406d7796548b0beaf736e73864c32291787cf2bd3983fdbc41741494ae) # libssh-0.10.6.tar.xz.asc
140420406d7796548b0beaf736e73864c32291787cf2bd3983fdbc41741494ae # libssh-0.10.6.tar.xz.asc
124612313b78dc89e47e87a17698113b8d2736c213e724c0ae0f84f87136ba48) # 1a02364b.patch
## 5efa3d0469bd5ad48d653917bec68c31d513ef4d4679000169a3e42d48a61587 libssh-0.10.6-01-x86_64.pkg.tar.lz
## 71c31622012ae3c263805c145604e6f42b8c1c0adf810abc2ab07d98a5256f8f libssh-0.10.6-02-x86_64.pkg.tar.lz

View File

@ -8,7 +8,7 @@ pkgbase=libssh
pkgname=(libssh
libssh-docs)
pkgver=0.10.6
pkgrel=1
pkgrel=2
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
license=(LGPL)
@ -22,11 +22,18 @@ makedepends=(cmake
openssh
python)
provides=(libssh.so)
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc})
source=(https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz{,.asc}
https://gitlab.com/libssh/libssh-mirror/-/commit/1a02364b.patch)
sha256sums=('1861d498f5b6f1741b6abc73e608478491edcf9c9d4b6630eef6e74596de9dc1'
'SKIP')
'SKIP'
'124612313b78dc89e47e87a17698113b8d2736c213e724c0ae0f84f87136ba48')
validpgpkeys=('8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D') # Andreas Schneider <asn@cryptomilk.org>
prepare() {
# Fix regression in IPv6 addresses in hostname parsing
patch -d $pkgname-$pkgver -p1 < 1a02364b.patch
}
build() {
cmake -B build -S $pkgname-$pkgver \
-DCMAKE_INSTALL_PREFIX=/usr \