Import keybase client, a command line tool for working with keybase.io!

OK awolk@, suggestions from edd@
This commit is contained in:
abieber 2016-09-09 14:11:43 +00:00
parent ea32df657b
commit 3c81e423f5
9 changed files with 455 additions and 0 deletions

37
security/keybase/Makefile Normal file
View File

@ -0,0 +1,37 @@
# $OpenBSD: Makefile,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
COMMENT = client for keybase.io
V = 1.0.17
GH_ACCOUNT = keybase
GH_PROJECT = client
GH_TAGNAME = v${V}
DISTNAME = keybase-${V}
CATEGORIES = security
HOMEPAGE = https://keybase.io
MAINTAINER = Aaron Bieber <abieber@openbsd.org>
# BSD
PERMIT_PACKAGE_CDROM = Yes
RUN_DEPENDS = security/gnupg2
WANTLIB += c pthread
WRKSRC = ${WRKDIR}/go/src/github.com/keybase/client
MODULES = lang/go
MODGO_TYPE = bin
MODGO_ENV = PATH="${PORTPATH}" HOME="${PORTHOME}"
do-build:
cd ${WRKSRC}/go/keybase && ${MODGO_CMD} build -tags \
production
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/go/keybase/keybase ${PREFIX}/bin/
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (keybase-1.0.17.tar.gz) = k3tLxhyInvOYKlNS2KSc2opPTbKHMtTLId8f4gEoOZw=
SIZE (keybase-1.0.17.tar.gz) = 33200376

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-go_client_cmd_update_go,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
Disabling this because we don't want the binary to update itself
out from under us.
Upstream doesn't seem interested in our hacky Path finding process:
https://github.com/keybase/go-ps/pull/7#discussion_r73917329
--- go/client/cmd_update.go.orig Wed Sep 7 09:23:58 2016
+++ go/client/cmd_update.go Wed Sep 7 09:24:50 2016
@@ -35,12 +35,7 @@ func newCmdUpdateCheck(cl *libcmdline.CommandLine, g *
Name: "check",
Usage: "Trigger an update check",
Action: func(c *cli.Context) {
- updaterPath, err := install.UpdaterBinPath()
- if err != nil {
- g.Log.Errorf("Error finding updater path: %s", err)
- return
- }
- g.Log.Errorf("This is no longer supported. Instead you can run:\n\n\t%s check", updaterPath)
+ g.Log.Error("Not supported on OpenBSD.")
},
}
}

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-go_install_install_unix_go,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
This can be removed in the next release of keybase:
https://github.com/keybase/client/pull/3832/files
--- go/install/install_unix.go.orig Wed Sep 7 08:25:44 2016
+++ go/install/install_unix.go Wed Sep 7 08:25:48 2016
@@ -1,7 +1,7 @@
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
-// +build linux freebsd
+// +build linux freebsd openbsd
package install

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-go_logger_redirect_stderr_nix_go,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
This can be removed in the next release of keybase:
https://github.com/keybase/client/pull/3832/files
--- go/logger/redirect_stderr_nix.go.orig Wed Sep 7 08:22:21 2016
+++ go/logger/redirect_stderr_nix.go Wed Sep 7 08:22:27 2016
@@ -1,7 +1,7 @@
// Copyright 2016 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
-// +build linux,!android darwin freebsd
+// +build linux,!android darwin freebsd openbsd
package logger

View File

@ -0,0 +1,310 @@
$OpenBSD: patch-go_vendor_github_com_keybase_go-ps_process_openbsd_go,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
This can be removed in the next release of keybase:
https://github.com/keybase/client/pull/3832/files
--- go/vendor/github.com/keybase/go-ps/process_openbsd.go.orig Wed Sep 7 08:14:47 2016
+++ go/vendor/github.com/keybase/go-ps/process_openbsd.go Wed Sep 7 08:14:47 2016
@@ -0,0 +1,302 @@
+// +build openbsd,amd64
+
+package ps
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "syscall"
+ "unsafe"
+)
+
+// copied from sys/sysctl.h
+const (
+ CTL_KERN = 1
+ KERN_PROC = 66
+ KERN_PROC_PID = 1
+ KERN_PROC_ARGS = 55
+ KERN_PROC_ARGV = 1
+ KERN_PROC_ALL = 0
+)
+
+/* Generated via cgo:
+
+$ cat /tmp/gen_defs.go
+// +build ignore
+package ps
+// #include <sys/types.h>
+// #include <sys/sysctl.h>
+import "C"
+
+type Kinfo_proc C.struct_kinfo_proc
+
+$ go tool cgo -godefs temp.go
+
+*/
+
+type Kinfo_proc struct {
+ Ki_forw uint64
+ Ki_back uint64
+ Ki_paddr uint64
+ Ki_addr uint64
+ Ki_fd uint64
+ Ki_stats uint64
+ Ki_limit uint64
+ Ki_vmspace uint64
+ Ki_sigacts uint64
+ Ki_sess uint64
+ Ki_tsess uint64
+ Ki_ru uint64
+ Ki_eflag int32
+ Ki_exitsig int32
+ Ki_flag int32
+ Ki_pid int32
+ Ki_ppid int32
+ Ki_sid int32
+ Ki_x_pgid int32
+ Ki_tpgid int32
+ Ki_uid uint32
+ Ki_ruid uint32
+ Ki_gid uint32
+ Ki_rgid uint32
+ Ki_groups [16]uint32
+ Ki_ngroups int16
+ Ki_jobc int16
+ Ki_tdev uint32
+ Ki_estcpu uint32
+ Ki_rtime_sec uint32
+ Ki_rtime_usec uint32
+ Ki_cpticks int32
+ Ki_pctcpu uint32
+ Ki_swtime uint32
+ Ki_slptime uint32
+ Ki_schedflags int32
+ Ki_uticks uint64
+ Ki_sticks uint64
+ Ki_iticks uint64
+ Ki_tracep uint64
+ Ki_traceflag int32
+ Ki_holdcnt int32
+ Ki_siglist int32
+ Ki_sigmask uint32
+ Ki_sigignore uint32
+ Ki_sigcatch uint32
+ Ki_stat int8
+ Ki_priority uint8
+ Ki_usrpri uint8
+ Ki_nice uint8
+ Ki_xstat uint16
+ Ki_acflag uint16
+ //Ki_comm [24]int8
+ Ki_comm [20]byte
+ Ki_wmesg [8]int8
+ Ki_wchan uint64
+ Ki_login [32]int8
+ Ki_vm_rssize int32
+ Ki_vm_tsize int32
+ Ki_vm_dsize int32
+ Ki_vm_ssize int32
+ Ki_uvalid int64
+ Ki_ustart_sec uint64
+ Ki_ustart_usec uint32
+ Ki_uutime_sec uint32
+ Ki_uutime_usec uint32
+ Ki_ustime_sec uint32
+ Ki_ustime_usec uint32
+ Ki_pad_cgo_0 [4]byte
+ Ki_uru_maxrss uint64
+ Ki_uru_ixrss uint64
+ Ki_uru_idrss uint64
+ Ki_uru_isrss uint64
+ Ki_uru_minflt uint64
+ Ki_uru_majflt uint64
+ Ki_uru_nswap uint64
+ Ki_uru_inblock uint64
+ Ki_uru_oublock uint64
+ Ki_uru_msgsnd uint64
+ Ki_uru_msgrcv uint64
+ Ki_uru_nsignals uint64
+ Ki_uru_nvcsw uint64
+ Ki_uru_nivcsw uint64
+ Ki_uctime_sec uint32
+ Ki_uctime_usec uint32
+ Ki_psflags int32
+ Ki_spare int32
+ Ki_svuid uint32
+ Ki_svgid uint32
+ Ki_emul [8]int8
+ Ki_rlim_rss_cur uint64
+ Ki_cpuid uint64
+ Ki_vm_map_size uint64
+ Ki_tid int32
+ Ki_rtableid uint32
+}
+
+var proc_k_size = unsafe.Sizeof(Kinfo_proc{})
+
+// UnixProcess is an implementation of Process that contains Unix-specific
+// fields and information.
+type UnixProcess struct {
+ pid int
+ ppid int
+ state rune
+ pgrp int
+ sid int
+
+ binary string
+}
+
+// Pid returns process id
+func (p *UnixProcess) Pid() int {
+ return p.pid
+}
+
+// PPid returns parent process id
+func (p *UnixProcess) PPid() int {
+ return p.ppid
+}
+
+// Executable returns process executable name
+func (p *UnixProcess) Executable() string {
+ return p.binary
+}
+
+// Path returns path to process executable
+func (p *UnixProcess) Path() (string, error) {
+ // On OpenBSD we don't have the actual path of a binary, the next
+ // best thing we can do is walk $PATH to hopefully find the binary.
+ // More info here: https://github.com/kardianos/osext/commit/b4814f465fb1f92d46e37f7ef84d732ece7c3e3a
+ return "", fmt.Errorf("Unsupported")
+}
+
+// Refresh reloads all the data associated with this process.
+func (p *UnixProcess) Refresh() error {
+ mib := []int32{CTL_KERN, KERN_PROC, KERN_PROC_PID, int32(p.pid), int32(proc_k_size), 1}
+
+ buf, length, err := call_syscall(mib)
+ if err != nil {
+ return err
+ }
+ if length != uint64(proc_k_size) {
+ return err
+ }
+
+ k, err := parse_kinfo_proc(buf)
+ if err != nil {
+ return err
+ }
+
+ p.ppid, p.pgrp, p.sid, p.binary = copy_params(&k)
+ return nil
+}
+
+func copy_params(k *Kinfo_proc) (int, int, int, string) {
+ n := -1
+ for i, b := range k.Ki_comm {
+ if b == 0 {
+ break
+ }
+ n = i + 1
+ }
+ comm := string(k.Ki_comm[:n])
+
+ return int(k.Ki_ppid), int(k.Ki_x_pgid), int(k.Ki_sid), comm
+}
+
+func findProcess(pid int) (Process, error) {
+ mib := []int32{CTL_KERN, KERN_PROC, KERN_PROC_PID, int32(pid), int32(proc_k_size), 1}
+
+ _, _, err := call_syscall(mib)
+ if err != nil {
+ return nil, err
+ }
+
+ return newUnixProcess(pid)
+}
+
+func processes() ([]Process, error) {
+ results := make([]Process, 0, 50)
+
+ mib := []int32{CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0, int32(proc_k_size), 400}
+ buf, length, err := call_syscall(mib)
+ if err != nil {
+ return results, err
+ }
+
+ // get kinfo_proc size
+ procinfo_len := int(proc_k_size)
+ count := int(length / uint64(proc_k_size))
+
+ // parse buf to procs
+ for i := 0; i < count; i++ {
+ b := buf[i*procinfo_len : i*procinfo_len+procinfo_len]
+ k, err := parse_kinfo_proc(b)
+ if err != nil {
+ continue
+ }
+ p, err := newUnixProcess(int(k.Ki_pid))
+ if err != nil {
+ continue
+ }
+ p.ppid, p.pgrp, p.sid, p.binary = copy_params(&k)
+
+ results = append(results, p)
+ }
+
+ return results, nil
+}
+
+func parse_kinfo_proc(buf []byte) (Kinfo_proc, error) {
+ var k Kinfo_proc
+ br := bytes.NewReader(buf)
+ err := binary.Read(br, binary.LittleEndian, &k)
+ if err != nil {
+ return k, err
+ }
+
+ return k, nil
+}
+
+func call_syscall(mib []int32) ([]byte, uint64, error) {
+ miblen := uint64(len(mib))
+
+ // get required buffer size
+ length := uint64(0)
+ _, _, err := syscall.RawSyscall6(
+ syscall.SYS___SYSCTL,
+ uintptr(unsafe.Pointer(&mib[0])),
+ uintptr(miblen),
+ 0,
+ uintptr(unsafe.Pointer(&length)),
+ 0,
+ 0)
+ if err != 0 {
+ b := make([]byte, 0)
+ return b, length, err
+ }
+ if length == 0 {
+ b := make([]byte, 0)
+ return b, length, err
+ }
+ // get proc info itself
+ buf := make([]byte, length)
+ _, _, err = syscall.RawSyscall6(
+ syscall.SYS___SYSCTL,
+ uintptr(unsafe.Pointer(&mib[0])),
+ uintptr(miblen),
+ uintptr(unsafe.Pointer(&buf[0])),
+ uintptr(unsafe.Pointer(&length)),
+ 0,
+ 0)
+ if err != 0 {
+ return buf, length, err
+ }
+
+ return buf, length, nil
+}
+
+func newUnixProcess(pid int) (*UnixProcess, error) {
+ p := &UnixProcess{pid: pid}
+ return p, p.Refresh()
+}

View File

@ -0,0 +1,39 @@
$OpenBSD: patch-go_vendor_vendor_json,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
This can be removed in the next release of keybase:
https://github.com/keybase/client/pull/3832/files
--- go/vendor/vendor.json.orig Tue Aug 9 11:52:34 2016
+++ go/vendor/vendor.json Wed Sep 7 08:15:22 2016
@@ -204,14 +204,16 @@
"revisionTime": "2016-03-09T18:35:02Z"
},
{
+ "checksumSHA1": "07FctQiwHCBvhiXp2mTLc8e0ll8=",
"path": "github.com/keybase/go-ps",
- "revision": "a56a1a84b3b72e5685e6f97c27b352b2ccec99c1",
- "revisionTime": "2016-07-11T15:06:55Z"
+ "revision": "9c11ca40a47944f49e0784b77a66636cb098445a",
+ "revisionTime": "2016-08-09T20:56:21Z"
},
{
+ "checksumSHA1": "KNf4CdZexyFjpEugzBv3b7YJs4U=",
"path": "github.com/keybase/go-ps/darwincgo",
- "revision": "a56a1a84b3b72e5685e6f97c27b352b2ccec99c1",
- "revisionTime": "2016-07-11T15:06:55Z"
+ "revision": "9c11ca40a47944f49e0784b77a66636cb098445a",
+ "revisionTime": "2016-08-09T20:56:21Z"
},
{
"path": "github.com/keybase/go-triplesec",
@@ -288,6 +290,10 @@
"path": "github.com/keybase/npipe",
"revision": "1f399aeffbab7364397986a1b531b6f02b15cd3e",
"revisionTime": "2016-07-08T16:39:56-04:00"
+ },
+ {
+ "path": "github.com/keybase/ps-go",
+ "revision": ""
},
{
"path": "github.com/keybase/saltpack",

View File

@ -0,0 +1,9 @@
Command line client for Keybase.io
Keybase maps your identity to your public keys, and vice versa. It
lets you 'prove' ownership of things like github accounts, domains and
twitter accounts.
Once you have proven various identities, it is easier for people to
verify that you are actually who you say you are. This gives some
confidence when sending / receiving signed or encrypted messages!

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2016/09/09 14:11:43 abieber Exp $
@bin bin/keybase