More work on porting the SSH kitten

This commit is contained in:
Kovid Goyal
2023-02-23 20:20:26 +05:30
parent 6b71b58997
commit 9870c94007
9 changed files with 515 additions and 46 deletions

View File

@@ -4,7 +4,7 @@ package utils
import (
"bytes"
"compress/zlib"
"compress/bzip2"
"encoding/binary"
"fmt"
"io"
@@ -33,11 +33,14 @@ func ReadAll(r io.Reader, expected_size int) ([]byte, error) {
func ReadCompressedEmbeddedData(raw string) []byte {
compressed := UnsafeStringToBytes(raw)
uncompressed_size := binary.LittleEndian.Uint32(compressed)
r, _ := zlib.NewReader(bytes.NewReader(compressed[4:]))
defer r.Close()
r := bzip2.NewReader(bytes.NewReader(compressed[4:]))
ans, err := ReadAll(r, int(uncompressed_size))
if err != nil {
panic(err)
}
return ans
}
func ReaderForCompressedEmbeddedData(raw string) io.Reader {
return bzip2.NewReader(bytes.NewReader(UnsafeStringToBytes(raw)[4:]))
}

View File

@@ -130,7 +130,7 @@ var CacheDir = (&Once[string]{Run: func() (cache_dir string) {
}}).Get
func macos_user_cache_dir() string {
// Sadly Go does not provide confstr() so we use this hack. We could
// Sadly Go does not provide confstr() so we use this hack.
// Note that given a user generateduid and uid we can derive this by using
// the algorithm at https://github.com/ydkhatri/MacForensics/blob/master/darwin_path_generator.py
// but I cant find a good way to get the generateduid. Requires calling dscl in which case we might as well call getconf