From nobody Thu Aug 15 17:23:38 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WlBmW1L0Mz5SX1F; Thu, 15 Aug 2024 17:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WlBmW0bxTz4gfG; Thu, 15 Aug 2024 17:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723742619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1vAmX9uX18XaDDGbkXyc/7H2Jy6b7AQApSyUPUQ0OZA=; b=xuKGbdIwukD2/zBpJbskShJf7q9Z8C0/bwsZMXbdNvjGCQBK58OCtdd8OP+Ce2fZu7ZYsn dQtBkICy1YGOGWyxeMqKL8IJSJu64NreileYQEnmIHU+MDAt3Ykq1+oKvBjhoO1LhfCF4s 2L1NevzBk8VICWZ8C8AaEThAHnuZteanaA4bm6MAlOnkiUJYMAhm/wwiqk3A5j1wLXaZkO 4YrDV1yH0Obj3Z9F96Xo835wYTE4V9JXgNZEWguDvmLOREG4+B3aLdqbVP9F8LjvIgXqpV Pibe3u7EdPn6JxlpWWy76XyWXlUaMdvMcDU3uXS/b5VfCp0w5qirJdjtbdDcIQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723742619; a=rsa-sha256; cv=none; b=oFRu3g/I2wQ5KgSIBkFp9H4MIo5MRViMbkspA3tQ9tqyOJAT85aNZ+XBwQnaAvBzCZPW4x owCyNeODXs6Q8JwkSYPced+9ZIFZmWODVvX52vuBe6YB8ym3g6hOyzRqjF4EnuB3PLR++O /NV6jSLeva18ozR+w3Co0ZWjNwJqBl0NSnYdCxJmJ5/fqT6btScPDX3satlFqkcnmcRv2s 0UAJALBbgtL3kAlnUMFhkyxq3XN5W7J/0YpPxEfjQuQ8oNFZTcwmCDl3gE9+iKSGezV43t 9VnIY+EiGZaZJP+KKprPbWVzxq2/K4e3CBREfifSzxQUU1DRWunkjgbeOxxmNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723742619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1vAmX9uX18XaDDGbkXyc/7H2Jy6b7AQApSyUPUQ0OZA=; b=tvwwK4JPEk7VbBA2uHdqSN+9Cg1dKERLu8fCwEgEgfcrCmYX2pFk8hnuj3i29flqpU8aCO TpFGiTLW6BNLrMWUNeU3TXAIgQsPQ0r61fPFVXrJZ0JOQO6KrR/7Tf/7BX93sI3x+5H/kz hZNqfA1XSMGXu2NThNogj5KcHUKJWtfaMVOWUhqnl7Rk8WTkS5zpCNXfVZrBoAKHYArOuO RT2nkDmmEzYXTGWwrv3ZW3LKefKGLkzhYSZc9P+Od9TsEn3S0GYsIidq0WmBklJ7zslY8N O/6G2j0wfd5AAkTJmTZ761A/X8HazcMvoH+mpGlvNik6ydQaR1amVjTgDfMrZw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WlBmW0C78zXMr; Thu, 15 Aug 2024 17:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47FHNcVN021993; Thu, 15 Aug 2024 17:23:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47FHNcNi021990; Thu, 15 Aug 2024 17:23:38 GMT (envelope-from git) Date: Thu, 15 Aug 2024 17:23:38 GMT Message-Id: <202408151723.47FHNcNi021990@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Joe Marcus Clarke Subject: git: 078b0010cfaf - main - net-mgmt/mac-telnet: Several fixes List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marcus X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 078b0010cfafc42a073fe1898f8bf0baa41879a4 Auto-Submitted: auto-generated The branch main has been updated by marcus: URL: https://cgit.FreeBSD.org/ports/commit/?id=078b0010cfafc42a073fe1898f8bf0baa41879a4 commit 078b0010cfafc42a073fe1898f8bf0baa41879a4 Author: Joe Marcus Clarke AuthorDate: 2024-08-15 17:21:49 +0000 Commit: Joe Marcus Clarke CommitDate: 2024-08-15 17:21:49 +0000 net-mgmt/mac-telnet: Several fixes * Fix building with OpenSSL 1.1 * Replace use of undirected broadcast with directed broadcast when sockets are bound to an interface IP * Do not override the mactelnetd.users file --- net-mgmt/mac-telnet/Makefile | 8 ++- net-mgmt/mac-telnet/files/patch-configure.ac | 4 +- net-mgmt/mac-telnet/files/patch-src_interfaces.c | 40 +++++++++++ net-mgmt/mac-telnet/files/patch-src_interfaces.h | 17 +++++ net-mgmt/mac-telnet/files/patch-src_mactelnet.c | 38 ++++++++++ net-mgmt/mac-telnet/files/patch-src_mactelnetd.c | 33 +++++++++ net-mgmt/mac-telnet/files/patch-src_mndp.c | 4 +- net-mgmt/mac-telnet/files/patch-src_users.c | 90 ++++++++++++++++++++++++ net-mgmt/mac-telnet/pkg-plist | 2 +- 9 files changed, 229 insertions(+), 7 deletions(-) diff --git a/net-mgmt/mac-telnet/Makefile b/net-mgmt/mac-telnet/Makefile index 51051a7ac0e7..df259fb074e4 100644 --- a/net-mgmt/mac-telnet/Makefile +++ b/net-mgmt/mac-telnet/Makefile @@ -1,5 +1,6 @@ PORTNAME= mac-telnet PORTVERSION= 0.6.1 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= net-mgmt net @@ -20,10 +21,13 @@ GNU_CONFIGURE= yes GNU_CONFIGURE_MANPREFIX= ${PREFIX}/share LDFLAGS+= -L${LOCALBASE}/lib CPPFLAGS+= -I${LOCALBASE}/include +CONFIGURE_ARGS+=--without-config CONFIGURE_ENV+= CRYPTO_CFLAGS="-I${OPENSSLINC}" CRYPTO_LIBS="-L${OPENSSLLIB} -lssl -lcrypto" post-install: - @${CHMOD} 0600 ${STAGEDIR}${PREFIX}/etc/mactelnetd.users - @-${CHOWN} root ${STAGEDIR}${PREFIX}/etc/mactelnetd.users + ${INSTALL_DATA} ${BUILD_WRKSRC}/config/mactelnetd.users \ + ${STAGEDIR}${PREFIX}/etc/mactelnetd.users.sample + @${CHMOD} 0600 ${STAGEDIR}${PREFIX}/etc/mactelnetd.users.sample + @-${CHOWN} root ${STAGEDIR}${PREFIX}/etc/mactelnetd.users.sample .include diff --git a/net-mgmt/mac-telnet/files/patch-configure.ac b/net-mgmt/mac-telnet/files/patch-configure.ac index 5a37adf61b4f..25d07c19154f 100644 --- a/net-mgmt/mac-telnet/files/patch-configure.ac +++ b/net-mgmt/mac-telnet/files/patch-configure.ac @@ -1,6 +1,6 @@ ---- configure.ac.orig 2024-06-19 14:50:22 UTC +--- configure.ac.orig 2024-08-12 21:08:19 UTC +++ configure.ac -@@ -79,6 +79,10 @@ case "$host_os" in +@@ -93,6 +93,10 @@ case "$host_os" in AC_MSG_ERROR([pthreads library not found]) fi ;; diff --git a/net-mgmt/mac-telnet/files/patch-src_interfaces.c b/net-mgmt/mac-telnet/files/patch-src_interfaces.c new file mode 100644 index 000000000000..e3857f1ce4be --- /dev/null +++ b/net-mgmt/mac-telnet/files/patch-src_interfaces.c @@ -0,0 +1,40 @@ +--- src/interfaces.c.orig 2024-08-15 15:58:48 UTC ++++ src/interfaces.c +@@ -150,6 +150,9 @@ int net_get_interfaces(struct net_interface **interfac + static const struct ifaddrs *ifaddrsp; + const struct sockaddr_in *dl_addr; + int found = 0; ++#if !defined(__FreeBSD__) ++ long allones_bcast = htonl(INADDR_BROADCAST); ++#endif + + if (getifaddrs(&int_addrs) < 0) { + perror("getifaddrs"); +@@ -173,8 +176,14 @@ int net_get_interfaces(struct net_interface **interfac + + if (ifaddrsp->ifa_addr->sa_family == AF_INET) { + memcpy(interface->ipv4_addr, &dl_addr->sin_addr, IPV4_ALEN); ++#if defined(__FreeBSD__) ++ memcpy(interface->bcast_addr, &((const struct sockaddr_in *)ifaddrsp->ifa_broadaddr)->sin_addr, IPV4_ALEN); ++#else ++ memcpy(interface->bcast_addr, &allones_bcast, IPV4_ALEN); ++#endif + } else { + memset(interface->ipv4_addr, 0, IPV4_ALEN); ++ memset(interface->bcast_addr, 0, IPV4_ALEN); + } + } + #ifdef __linux__ +@@ -208,9 +217,12 @@ int net_get_interfaces(struct net_interface **interfac + DL_FOREACH(*interfaces, interface) { + struct in_addr *addr = + (struct in_addr *)interface->ipv4_addr; ++ struct in_addr *bcast = ++ (struct in_addr *)interface->bcast_addr; + + printf("Interface %s:\n", interface->name); + printf("\tIP: %s\n", inet_ntoa(*addr)); ++ printf("\tBCAST: %s\n", inet_ntoa(*bcast)); + printf("\tMAC: %s\n", + ether_ntoa((struct ether_addr *)interface->mac_addr)); + #ifdef __linux__ diff --git a/net-mgmt/mac-telnet/files/patch-src_interfaces.h b/net-mgmt/mac-telnet/files/patch-src_interfaces.h new file mode 100644 index 000000000000..6f0fc858ea62 --- /dev/null +++ b/net-mgmt/mac-telnet/files/patch-src_interfaces.h @@ -0,0 +1,17 @@ +--- src/interfaces.h.orig 2024-08-15 16:06:02 UTC ++++ src/interfaces.h +@@ -25,6 +25,7 @@ struct net_interface { + char name[256]; + unsigned char ipv4_addr[IPV4_ALEN]; + unsigned char mac_addr[ETH_ALEN]; ++ unsigned char bcast_addr[IPV4_ALEN]; + + /* used by mactelnetd */ + int socketfd; +@@ -57,4 +58,4 @@ extern int net_send_udp(const int socket, struct net_i + const unsigned char *destmac, const struct in_addr *sourceip, const int sourceport, + const struct in_addr *destip, const int destport, const unsigned char *data, const int datalen); + extern unsigned short in_cksum(unsigned short *addr, int len); +-#endif +\ No newline at end of file ++#endif diff --git a/net-mgmt/mac-telnet/files/patch-src_mactelnet.c b/net-mgmt/mac-telnet/files/patch-src_mactelnet.c new file mode 100644 index 000000000000..e61d3dd6ecc4 --- /dev/null +++ b/net-mgmt/mac-telnet/files/patch-src_mactelnet.c @@ -0,0 +1,38 @@ +--- src/mactelnet.c.orig 2024-08-15 16:46:24 UTC ++++ src/mactelnet.c +@@ -126,6 +126,8 @@ unsigned char mt_direction_fromserver = 0; + + static unsigned int send_socket; + ++static unsigned char *bcast_addr; ++ + static int handle_packet(unsigned char *data, int data_len); + + static void print_version() { +@@ -168,7 +170,7 @@ static int send_udp(struct mt_packet *packet, int retr + struct sockaddr_in socket_address; + socket_address.sin_family = AF_INET; + socket_address.sin_port = htons(MT_MACTELNET_PORT); +- socket_address.sin_addr.s_addr = htonl(INADDR_BROADCAST); ++ memcpy(&(socket_address.sin_addr), bcast_addr, IPV4_ALEN); + + sent_bytes = sendto(send_socket, packet->data, packet->size, 0, (struct sockaddr *)&socket_address, + sizeof(socket_address)); +@@ -470,6 +472,9 @@ static int find_interface() { + continue; + } + ++#if defined(__FreeBSD__) ++ setsockopt(testsocket, IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(optval)); ++#endif + setsockopt(testsocket, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)); + setsockopt(testsocket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + +@@ -488,6 +493,7 @@ static int find_interface() { + send_socket = testsocket; + memcpy(srcmac, interface->mac_addr, ETH_ALEN); + active_interface = interface; ++ bcast_addr = interface->bcast_addr; + + /* Send a SESSIONSTART message with the current device */ + init_packet(&data, MT_PTYPE_SESSIONSTART, srcmac, dstmac, sessionkey, 0); diff --git a/net-mgmt/mac-telnet/files/patch-src_mactelnetd.c b/net-mgmt/mac-telnet/files/patch-src_mactelnetd.c new file mode 100644 index 000000000000..24c25cd212ee --- /dev/null +++ b/net-mgmt/mac-telnet/files/patch-src_mactelnetd.c @@ -0,0 +1,33 @@ +--- src/mactelnetd.c.orig 2024-08-15 17:08:22 UTC ++++ src/mactelnetd.c +@@ -254,6 +254,12 @@ static void setup_sockets() { + perror("SO_BROADCAST"); + continue; + } ++#if defined(__FreeBSD__) ++ if (setsockopt(interface->socketfd, IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(optval)) == -1) { ++ perror("IP_ONESBCAST"); ++ continue; ++ } ++#endif + + setsockopt(interface->socketfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + +@@ -290,7 +296,7 @@ static int send_udp(const struct mt_connection *conn, + struct sockaddr_in socket_address; + socket_address.sin_family = AF_INET; + socket_address.sin_port = htons(conn->srcport); +- socket_address.sin_addr.s_addr = htonl(INADDR_BROADCAST); ++ memcpy(&(socket_address.sin_addr), &conn->interface->bcast_addr, IPV4_ALEN); + + return sendto(conn->interface->socketfd, packet->data, packet->size, 0, (struct sockaddr *)&socket_address, + sizeof(socket_address)); +@@ -315,7 +321,7 @@ static int send_special_udp(struct net_interface *inte + struct sockaddr_in socket_address; + socket_address.sin_family = AF_INET; + socket_address.sin_port = htons(port); +- socket_address.sin_addr.s_addr = htonl(INADDR_BROADCAST); ++ memcpy(&(socket_address.sin_addr), &interface->bcast_addr, IPV4_ALEN); + + return sendto(interface->socketfd, packet->data, packet->size, 0, (struct sockaddr *)&socket_address, + sizeof(socket_address)); diff --git a/net-mgmt/mac-telnet/files/patch-src_mndp.c b/net-mgmt/mac-telnet/files/patch-src_mndp.c index 5e5f11e0bde4..63e50d20effd 100644 --- a/net-mgmt/mac-telnet/files/patch-src_mndp.c +++ b/net-mgmt/mac-telnet/files/patch-src_mndp.c @@ -1,6 +1,6 @@ ---- src/mndp.c.orig 2024-06-19 14:43:14 UTC +--- src/mndp.c.orig 2024-08-12 21:08:19 UTC +++ src/mndp.c -@@ -170,9 +170,12 @@ int mndp(int timeout, int batch_mode) { +@@ -177,9 +177,12 @@ int mndp(int timeout, int batch_mode) { return 0; } diff --git a/net-mgmt/mac-telnet/files/patch-src_users.c b/net-mgmt/mac-telnet/files/patch-src_users.c new file mode 100644 index 000000000000..65cc4329acd0 --- /dev/null +++ b/net-mgmt/mac-telnet/files/patch-src_users.c @@ -0,0 +1,90 @@ +--- src/users.c.orig 2024-08-15 14:34:02 UTC ++++ src/users.c +@@ -211,6 +211,24 @@ struct mt_credentials *find_user(char *username) { + return NULL; + } + ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++/* ++ * Filter out colons from the decoded string. ++ * By default, the OPENSSL_buf2hexstr function in OpenSSL 1.1 ++ * uses colons as a byte separator, and this cannot be overridden. ++ */ ++static void remove_colons(char *s) { ++ const char *p = s; ++ char *q = s; ++ while (*p != '\0') { ++ *q = *p++; ++ q += (*q != ':'); ++ } ++ ++ *q = '\0'; ++} ++#endif ++ + int add_user(const char *username, const char *password) { + FILE *rfile; + FILE *wfile; +@@ -289,12 +307,27 @@ int add_user(const char *username, const char *passwor + continue; + } + fprintf(wfile, "%s:", username); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ char *output; ++ output = OPENSSL_buf2hexstr(newhash, MT_CRED_HASHLEN); ++ remove_colons(output); ++#else + char output[MT_CRED_HASHLEN * 2 + 1]; + OPENSSL_buf2hexstr_ex(output, sizeof(output), NULL, newhash, MT_CRED_HASHLEN, '\0'); ++#endif + fputs(output, wfile); + fputs(":", wfile); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ OPENSSL_free(output); ++ output = OPENSSL_buf2hexstr(newsalt, MT_CRED_SALTLEN); ++ remove_colons(output); ++#else + OPENSSL_buf2hexstr_ex(output, sizeof(output), NULL, newsalt, MT_CRED_SALTLEN, '\0'); ++#endif + fputs(output, wfile); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ OPENSSL_free(output); ++#endif + fputs("\n", wfile); + found = 1; + } else { +@@ -306,12 +339,27 @@ int add_user(const char *username, const char *passwor + if (!found && password != NULL) { + // Write username, salt, and hashed password to the file + fprintf(wfile, "%s:", username); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ char *output; ++ output = OPENSSL_buf2hexstr(newhash, MT_CRED_HASHLEN); ++ remove_colons(output); ++#else + char output[MT_CRED_HASHLEN * 2 + 1]; + OPENSSL_buf2hexstr_ex(output, sizeof(output), NULL, newhash, MT_CRED_HASHLEN, '\0'); ++#endif + fputs(output, wfile); + fputs(":", wfile); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ OPENSSL_free(output); ++ output = OPENSSL_buf2hexstr(newsalt, MT_CRED_SALTLEN); ++ remove_colons(output); ++#else + OPENSSL_buf2hexstr_ex(output, sizeof(output), NULL, newsalt, MT_CRED_SALTLEN, '\0'); ++#endif + fputs(output, wfile); ++#if OPENSSL_VERSION_NUMBER < 0x030000000 // less than 3.0.0 ++ OPENSSL_free(output); ++#endif + fputs("\n", wfile); + } + +@@ -327,4 +375,4 @@ int add_user(const char *username, const char *passwor + } + + return found ? 2 : 1; +-} +\ No newline at end of file ++} diff --git a/net-mgmt/mac-telnet/pkg-plist b/net-mgmt/mac-telnet/pkg-plist index e89013930934..35a54cebd956 100644 --- a/net-mgmt/mac-telnet/pkg-plist +++ b/net-mgmt/mac-telnet/pkg-plist @@ -1,7 +1,7 @@ bin/macping bin/mactelnet bin/mndp -etc/mactelnetd.users +@sample etc/mactelnetd.users.sample sbin/mactelnetd share/locale/bg/LC_MESSAGES/mactelnet.mo share/locale/nb/LC_MESSAGES/mactelnet.mo