Skip to content

Commit

Permalink
net/xapsd: update to g20240326
Browse files Browse the repository at this point in the history
ChangeLog:
https://github.com/freswa/dovecot-xaps-daemon/compare/836a75b..1e589be

PR:		278199
Reported by:	PopularMoment@protonmail.com (maintainer)
  • Loading branch information
Henry authored and fernape committed Apr 11, 2024
1 parent 37579ae commit fd3628b
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 11 deletions.
13 changes: 5 additions & 8 deletions net/xapsd/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PORTNAME= xapsd
DISTVERSION= g20231019
PORTREVISION= 1
DISTVERSION= g20240326
CATEGORIES= net

MAINTAINER= PopularMoment@protonmail.com
Expand All @@ -10,16 +9,12 @@ WWW= https://github.com/freswa/dovecot-xaps-daemon
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE

DEPRECATED= Requires deprecated lang/go19
EXPIRATION_DATE= 2024-04-24

# must use 1.19 due to https://github.com/freswa/dovecot-xaps-daemon/issues/24
USES= go:1.19,modules
USES= go:modules
USE_RC_SUBR= xapsd
USE_GITHUB= yes
GH_ACCOUNT= freswa
GH_PROJECT= dovecot-xaps-daemon
GH_TAGNAME= 836a75b
GH_TAGNAME= 1e589be

GH_TUPLE= freswa:go-plist:900e8a7d907d:freswa_go_plist/vendor/github.com/freswa/go-plist \
fsnotify:fsnotify:v1.6.0:fsnotify_fsnotify/vendor/github.com/fsnotify/fsnotify \
Expand Down Expand Up @@ -54,6 +49,8 @@ GO_TARGET= ./cmd/xapsd:${PREFIX}/sbin/xapsd
USERS= ${PORTNAME}
GROUPS= ${PORTNAME}

PORTSCOUT= ignore:1

post-install:
${MKDIR} ${STAGEDIR}${PREFIX}/etc/xapsd
${INSTALL_DATA} ${WRKSRC}/configs/xapsd/xapsd.yaml ${STAGEDIR}${PREFIX}/etc/xapsd/xapsd.yaml.sample
Expand Down
6 changes: 3 additions & 3 deletions net/xapsd/distinfo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TIMESTAMP = 1698718840
SHA256 (freswa-dovecot-xaps-daemon-g20231019-836a75b_GH0.tar.gz) = 806a6b32a7b872a140c68421719c93c65bc3205e6e86800dd36c2e5ade2954d0
SIZE (freswa-dovecot-xaps-daemon-g20231019-836a75b_GH0.tar.gz) = 109537
TIMESTAMP = 1712416748
SHA256 (freswa-dovecot-xaps-daemon-g20240326-1e589be_GH0.tar.gz) = 1e6c019df01f9c54e4499537678fbebf83270a39570c24677b41b93ed2022e17
SIZE (freswa-dovecot-xaps-daemon-g20240326-1e589be_GH0.tar.gz) = 110569
SHA256 (freswa-go-plist-900e8a7d907d_GH0.tar.gz) = 2b4a06b8805bc1436ab8f34d6fd140645a0a01ccaf9f4b3a7dc3e0e35f5a2e88
SIZE (freswa-go-plist-900e8a7d907d_GH0.tar.gz) = 47675
SHA256 (fsnotify-fsnotify-v1.6.0_GH0.tar.gz) = 583b2b399709d04807c5c3185e7d4dc0543d532af91fdeb85eeaf803a0b7703b
Expand Down
99 changes: 99 additions & 0 deletions net/xapsd/files/0001-fix-apple-ignore-malformed-HTTP-headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 1c52af3a7cc168cec089a810c32e861ab988840c Mon Sep 17 00:00:00 2001
From: Leon Klingele <git@leonklingele.de>
Date: Wed, 13 Mar 2024 22:12:25 +0100
Subject: [PATCH] fix(apple): ignore malformed HTTP headers

See also https://github.com/golang/go/issues/21290.

Fixes https://github.com/freswa/dovecot-xaps-daemon/issues/24.
---
pkg/apple_xserver_certs/http.go | 51 ++++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/pkg/apple_xserver_certs/http.go b/pkg/apple_xserver_certs/http.go
index d39a6fc..939fcf0 100644
--- a/pkg/apple_xserver_certs/http.go
+++ b/pkg/apple_xserver_certs/http.go
@@ -1,11 +1,16 @@
package apple_xserver_certs

import (
+ "bufio"
"bytes"
+ "context"
+ "crypto/tls"
"encoding/pem"
+ "io"
"io/ioutil"
"log"
"net/http"
+ "time"
)

func NewCerts(username string, passwordhash string) *Certificates {
@@ -50,7 +55,6 @@ func handleResponse(certs *Certificates, response []byte) *Certificates {
}

func sendRequest(reqBody []byte, newCerts bool) (respBody []byte) {
- client := &http.Client{}
r := bytes.NewReader(reqBody)
url := "https://identity.apple.com/pushcert/caservice/renew"
if newCerts {
@@ -67,12 +71,51 @@ func sendRequest(reqBody []byte, newCerts bool) (respBody []byte) {
req.Header.Set("Accept", "*/*")
req.Header.Set("Accept-Language", "en-us")

- resp, err := client.Do(req)
+ req.Close = true
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+
+ conn, err := new(tls.Dialer).DialContext(
+ ctx,
+ "tcp",
+ req.URL.Host+":443",
+ )
if err != nil {
- log.Fatalln(err)
+ log.Fatalln(err) // TODO: Handle error properly
+ }
+ defer func() {
+ _ = conn.Close() //nolint:errcheck,gosec // Ignored on purpose
+ }()
+
+ if err := req.Write(conn); err != nil {
+ log.Fatalln(err) // TODO: Handle error properly
+ }
+
+ buf, err := io.ReadAll(io.LimitReader(conn, 1<<10))
+ if err != nil {
+ log.Fatalln(err) // TODO: Handle error properly
+ }
+
+ const (
+ cr = "\r"
+ nl = "\n"
+ )
+ for _, ign := range []string{
+ "1;: mode=block",
+ "max-age=31536000;: includeSubdomains",
+ } {
+ buf = bytes.Replace(buf, []byte(nl+ign+cr+nl), []byte(nl), 1)
+ }
+
+ resp, err := http.ReadResponse(bufio.NewReader(bytes.NewReader(buf)), req)
+ if err != nil {
+ log.Fatalln(err) // TODO: Handle error properly
}
+ defer func() {
+ _ = resp.Body.Close() //nolint:errcheck,gosec // Ignored on purpose
+ }()

- defer resp.Body.Close()
respBody, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
--
2.34.1

0 comments on commit fd3628b

Please sign in to comment.