Skip to content

Commit 8a073ff

Browse files
gabrielSteve Sanders
authored andcommitted
Install user components on startup; Install KBFS later (keybase#7733)
* Install user components (only) on startup * Exit with non-zero code on install error * Use go install path exclusively; Allow mount-type none * Fuse status and install from RPC folders tab * Fix install helper CLI missing * Install result, progress indicators * Auto install based on fuse status * Default non-darwin methods for service compile * Move CLI uninstall last * Fix dead code * Uninstall KBFS rpc * Install option for /etc/paths.d in native installer Instead of CLI, which is handled by go install package. Also remove install all option which is ununsed and not entirely accurate (it's not all). * Upgrade fuse to 3.6.3 * Update Xcode instructions * Install banner * Security prefs UI * Break up into install fuse, load kext, install KBFS * Return specific fuse status error codes * Have to load kext to get perm error later * Need to load kext after install to trigger system policy block * Don't want Quit dialog on error * Fuse install with kextPermissionRequired status * Set permission error * Kext error from install * Load kext on install * Remove unused loadFuseKext * Refresh fuse status on focus if in secprefs * Finish install after kextStarting * Update DMG background * Install everything is Fuse is installed * Underline properly even in widget * Handle general Fuse kext error * Update comment * Uninstall KBFS impl * Install/uninstall CLI privileged * Fix compile * Fix installing indication * Change some text on uninstall, move open link * Remove progress indicator * Don't show banner in small mode * Wait for mount and open after install * Wait for mount, show progress * Back button instead of close * Open after KBFS install (show progress) * Change uninstall wording * Set opening before finished * Un-stale protocol * Open in KBFS on link click * Parse and handle install errors in app * Fix comment * Install docs * Update docs * Diagram for installer * Install CLI privileged on CLI error * Don't uninstall cli paths by default * Remove test code * Move CLI to last * Fix links * Type the actions * Rename to getFuseStatus * Use compose branch for Banner * Fix action is method * Needs to call saga * Fuse status update saga * Fix saga getting canceled * Move fuse status to promise all * Type actions * Remove existing /usr/local/bin/keybase * Ensure that it is a link and resolves correctly for installed * Overwrite non-symlink on cli install Do Windows version of split install
1 parent d22b643 commit 8a073ff

92 files changed

Lines changed: 2100 additions & 354 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎go/client/cmd_ctl_start_osx.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ctlStart(g *libkb.GlobalContext, components map[string]bool) error {
7171
}
7272
}
7373
if ok := components[install.ComponentNameKBFS.String()]; ok {
74-
if err := install.InstallKBFS(g, "", false, defaultLaunchdWait, g.Log); err != nil {
74+
if err := install.InstallKBFS(g, "", false, false, defaultLaunchdWait, g.Log); err != nil {
7575
errs = append(errs, err)
7676
g.Log.Errorf("%s", err)
7777
}

‎go/client/cmd_install_osx.go‎

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewCmdInstall(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Comma
3030
},
3131
cli.StringFlag{
3232
Name: "o, format",
33-
Usage: "Format for output. Specify 'j' for JSON or blank for default.",
33+
Usage: "Format for output. Specify 'json' for JSON or blank for default.",
3434
},
3535
cli.StringFlag{
3636
Name: "b, bin-path",
@@ -87,6 +87,9 @@ func (v *CmdInstall) GetUsage() libkb.Usage {
8787
var defaultInstallComponents = []string{
8888
install.ComponentNameUpdater.String(),
8989
install.ComponentNameService.String(),
90+
install.ComponentNameCLI.String(),
91+
install.ComponentNameHelper.String(),
92+
install.ComponentNameFuse.String(),
9093
install.ComponentNameMountDir.String(),
9194
install.ComponentNameKBFS.String(),
9295
install.ComponentNameKBNM.String(),
@@ -141,9 +144,21 @@ func (v *CmdInstall) Run() error {
141144
}
142145
fmt.Fprintf(os.Stdout, "%s\n", out)
143146
}
147+
exitOnError(result)
144148
return nil
145149
}
146150

151+
func exitOnError(result keybase1.InstallResult) {
152+
if result.Fatal {
153+
os.Exit(1)
154+
}
155+
for _, r := range result.ComponentResults {
156+
if r.Status.Code != 0 {
157+
os.Exit(2)
158+
}
159+
}
160+
}
161+
147162
var defaultUninstallComponents = []string{
148163
install.ComponentNameService.String(),
149164
install.ComponentNameKBFS.String(),
@@ -161,7 +176,7 @@ func NewCmdUninstall(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Com
161176
Flags: []cli.Flag{
162177
cli.StringFlag{
163178
Name: "o, format",
164-
Usage: "Format for output. Specify 'j' for JSON or blank for default.",
179+
Usage: "Format for output. Specify 'json' for JSON or blank for default.",
165180
},
166181
cli.StringFlag{
167182
Name: "c, components",
@@ -274,3 +289,75 @@ func DiagnoseSocketError(ui libkb.UI, err error) {
274289
}
275290
}
276291
}
292+
293+
func newCmdInstallAuto(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
294+
return cli.Command{
295+
Name: "install-auto",
296+
Flags: []cli.Flag{
297+
cli.StringFlag{
298+
Name: "b, bin-path",
299+
Usage: "Full path to the executable, if it would be ambiguous otherwise.",
300+
},
301+
cli.DurationFlag{
302+
Name: "t, timeout",
303+
Usage: "Timeout as duration, such as '10s' or '1m'.",
304+
},
305+
cli.StringFlag{
306+
Name: "source-path",
307+
Usage: "Source path to app bundle.",
308+
},
309+
cli.StringFlag{
310+
Name: "o, format",
311+
Usage: "Format for output. Specify 'json' for JSON or blank for default.",
312+
},
313+
},
314+
ArgumentHelp: "",
315+
Usage: "Installs Keybase by choosing automatically which components to install",
316+
Action: func(c *cli.Context) {
317+
cl.SetLogForward(libcmdline.LogForwardNone)
318+
cl.SetForkCmd(libcmdline.NoFork)
319+
cl.ChooseCommand(newCmdInstallAutoRunner(g), "install-auto", c)
320+
},
321+
}
322+
}
323+
324+
type cmdInstallAuto struct {
325+
libkb.Contextified
326+
binPath string
327+
sourcePath string
328+
format string
329+
timeout time.Duration
330+
}
331+
332+
func newCmdInstallAutoRunner(g *libkb.GlobalContext) *cmdInstallAuto {
333+
return &cmdInstallAuto{
334+
Contextified: libkb.NewContextified(g),
335+
}
336+
}
337+
338+
func (v *cmdInstallAuto) GetUsage() libkb.Usage {
339+
return libkb.Usage{}
340+
}
341+
342+
func (v *cmdInstallAuto) ParseArgv(ctx *cli.Context) error {
343+
v.binPath = ctx.String("bin-path")
344+
v.timeout = ctx.Duration("timeout")
345+
v.sourcePath = ctx.String("source-path")
346+
v.format = ctx.String("format")
347+
if v.timeout == 0 {
348+
v.timeout = 11 * time.Second
349+
}
350+
return nil
351+
}
352+
353+
func (v *cmdInstallAuto) Run() error {
354+
result := install.InstallAuto(v.G(), v.binPath, v.sourcePath, v.timeout, v.G().Log)
355+
if v.format == "json" {
356+
out, err := json.MarshalIndent(result, "", " ")
357+
if err != nil {
358+
return err
359+
}
360+
fmt.Fprintf(os.Stdout, "%s\n", out)
361+
}
362+
return nil
363+
}

‎go/client/cmd_kbfs_mount.go‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
package client
77

88
import (
9+
"encoding/json"
910
"errors"
1011
"fmt"
1112

13+
"github.com/keybase/client/go/install"
14+
1215
"github.com/keybase/cli"
1316
"github.com/keybase/client/go/libcmdline"
1417
"github.com/keybase/client/go/libkb"
@@ -18,7 +21,7 @@ import (
1821
func NewCmdKbfsMount(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
1922
return cli.Command{
2023
Name: "kbfsmount",
21-
Usage: "kbfsmount [get|set|getall]",
24+
Usage: "kbfsmount [get|set|getall|status|install]",
2225
Action: func(c *cli.Context) {
2326
cl.ChooseCommand(&CmdKbfsMount{libkb.NewContextified(g), "", ""}, "kbfsmount", c)
2427
},
@@ -33,7 +36,7 @@ type CmdKbfsMount struct {
3336

3437
func (s *CmdKbfsMount) ParseArgv(ctx *cli.Context) error {
3538
if len(ctx.Args()) < 1 {
36-
return fmt.Errorf("kbfsmount needs one of [get|set|getall]")
39+
return fmt.Errorf("kbfsmount needs one of [get|set|getall|status|install]")
3740
}
3841
s.cmd = ctx.Args()[0]
3942
if s.cmd == "set" {
@@ -62,6 +65,16 @@ func (s *CmdKbfsMount) Run() error {
6265
results, err2 := cli.GetAllAvailableMountDirs(context.TODO())
6366
dui.Printf("%v", results)
6467
err = err2
68+
case "status":
69+
status := install.KeybaseFuseStatus("", s.G().Log)
70+
out, err := json.MarshalIndent(status, "", " ")
71+
if err != nil {
72+
return err
73+
}
74+
dui.Printf("%s\n", out)
75+
case "install":
76+
result := install.Install(s.G(), "", "", []string{install.ComponentNameFuse.String()}, false, 0, s.G().Log)
77+
dui.Printf("%v\n", result.Status)
6578
}
6679
return err
6780
}

‎go/client/cmd_launchd_osx.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewCmdLaunchdList(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.C
9292
Flags: []cli.Flag{
9393
cli.StringFlag{
9494
Name: "f, format",
95-
Usage: "Format for output. Specify 'j' for JSON or blank for default.",
95+
Usage: "Format for output. Specify 'json' for JSON or blank for default.",
9696
},
9797
},
9898
Action: func(c *cli.Context) {
@@ -154,7 +154,7 @@ func NewCmdLaunchdStatus(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli
154154
},
155155
cli.StringFlag{
156156
Name: "f, format",
157-
Usage: "Format for output. Specify 'j' for JSON or blank for default.",
157+
Usage: "Format for output. Specify 'json' for JSON or blank for default.",
158158
},
159159
cli.DurationFlag{
160160
Name: "t, timeout",

‎go/client/commands_osx.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func getPlatformSpecificCommands(cl *libcmdline.CommandLine, g *libkb.GlobalCont
1515
return []cli.Command{
1616
NewCmdFuse(cl, g),
1717
NewCmdInstall(cl, g),
18+
newCmdInstallAuto(cl, g),
1819
NewCmdLaunchd(cl, g),
1920
NewCmdUninstall(cl, g),
2021
}

‎go/install/fuse_status_default.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
2+
// this source code is governed by the included BSD license.
3+
4+
// +build !darwin,!windows
5+
6+
package install
7+
8+
import "github.com/keybase/client/go/protocol/keybase1"
9+
10+
func KeybaseFuseStatus(bundleVersion string, log Log) keybase1.FuseStatus {
11+
return keybase1.FuseStatus{}
12+
}

‎go/install/fuse_status_windows.go‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
2+
// this source code is governed by the included BSD license.
3+
4+
// +build windows
5+
6+
package install
7+
8+
import (
9+
"github.com/keybase/client/go/protocol/keybase1"
10+
"golang.org/x/sys/windows/registry"
11+
)
12+
13+
func KeybaseFuseStatus(bundleVersion string, log Log) keybase1.FuseStatus {
14+
status := keybase1.FuseStatus{}
15+
if checkKeybaseDokanCodes(log) {
16+
status.InstallStatus = keybase1.InstallStatus_INSTALLED
17+
status.InstallAction = keybase1.InstallAction_NONE
18+
status.KextStarted = true
19+
} else {
20+
status.InstallStatus = keybase1.InstallStatus_NOT_INSTALLED
21+
status.InstallAction = keybase1.InstallAction_INSTALL
22+
}
23+
return status
24+
}
25+
26+
func checkKeybaseDokanCodes(log Log) bool {
27+
foundDokan, err := checkRegistryKeybaseDokan("DOKANPRODUCT64", log)
28+
if !foundDokan || err != nil {
29+
foundDokan, err = checkRegistryKeybaseDokan("DOKANPRODUCT86", log)
30+
}
31+
if err != nil {
32+
log.Errorf("checkKeybaseDokanCodes error: %v", err.Error())
33+
}
34+
return foundDokan
35+
}
36+
37+
// Our installer writes the dokan product codes to our registry location,
38+
// which we can then look for in the list of windows uninstall keys.
39+
// Another alternative might be to look for %windir%\system32\dokan1.dll
40+
func checkRegistryKeybaseDokan(productIDKey string, log Log) (bool, error) {
41+
k, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\Keybase\Keybase\`, registry.QUERY_VALUE|registry.WOW64_64KEY)
42+
if err != nil {
43+
return false, err
44+
}
45+
defer k.Close()
46+
productID, _, err := k.GetStringValue(productIDKey)
47+
if err != nil {
48+
return false, err
49+
}
50+
log.Info("CheckRegistryKeybaseDokan: Searching registry for %s", productID)
51+
if productID == "" {
52+
log.Info("CheckRegistryKeybaseDokan: Empty product ID, returning false")
53+
return false, err
54+
}
55+
k2, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\`+productID, registry.QUERY_VALUE|registry.WOW64_64KEY)
56+
if err == nil {
57+
return true, nil
58+
}
59+
defer k2.Close()
60+
return false, err
61+
}

‎go/install/install.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ const (
6262
ComponentNameHelper ComponentName = "helper"
6363
// ComponentNameMountDir is the mount directory
6464
ComponentNameMountDir ComponentName = "mountdir"
65+
// ComponentNameCLIPaths is for /etc/paths.d/Keybase
66+
ComponentNameCLIPaths ComponentName = "clipaths"
6567
// ComponentNameUnknown is placeholder for unknown components
6668
ComponentNameUnknown ComponentName = "unknown"
6769
)
6870

6971
// ComponentNames are all the valid component names
70-
var ComponentNames = []ComponentName{ComponentNameCLI, ComponentNameService, ComponentNameKBFS, ComponentNameUpdater, ComponentNameFuse, ComponentNameHelper, ComponentNameApp, ComponentNameKBNM}
72+
var ComponentNames = []ComponentName{ComponentNameCLI, ComponentNameService, ComponentNameKBFS, ComponentNameUpdater, ComponentNameFuse, ComponentNameHelper, ComponentNameApp, ComponentNameKBNM, ComponentNameCLIPaths}
7173

7274
// String returns string for ComponentName
7375
func (c ComponentName) String() string {
@@ -93,6 +95,8 @@ func (c ComponentName) Description() string {
9395
return "Privileged Helper Tool"
9496
case ComponentNameKBNM:
9597
return "Browser Native Messaging"
98+
case ComponentNameCLIPaths:
99+
return "Command Line (privileged)"
96100
}
97101
return "Unknown"
98102
}
@@ -116,6 +120,8 @@ func ComponentNameFromString(s string) ComponentName {
116120
return ComponentNameFuse
117121
case string(ComponentNameHelper):
118122
return ComponentNameHelper
123+
case string(ComponentNameCLIPaths):
124+
return ComponentNameCLIPaths
119125
}
120126
return ComponentNameUnknown
121127
}

0 commit comments

Comments
 (0)