mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Native support for iOS dirs; bind SSH dir to variable
This commit is contained in:
+2
-2
@@ -46,7 +46,7 @@ func LibmuttonInit(inputCB func(prompt string) string, rcwPassword []byte, appen
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ensure ssh key file exists (and is a file)
|
// ensure ssh key file exists (and is a file)
|
||||||
fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519"
|
fallbackSSHKey := global.SSHDir + global.PathSeparator + "id_ed25519"
|
||||||
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
||||||
_, err := back.TargetIsFile(sshKeyPath, true)
|
_, err := back.TargetIsFile(sshKeyPath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -70,7 +70,7 @@ func LibmuttonInit(inputCB func(prompt string) string, rcwPassword []byte, appen
|
|||||||
return errors.New("unable to initialize libmutton directories: " + err.Error())
|
return errors.New("unable to initialize libmutton directories: " + err.Error())
|
||||||
}
|
}
|
||||||
//// write config file
|
//// write config file
|
||||||
//// temporarily leave sshEntryRootPath, sshAgeDirPath, and sshIsWindows as nil to pass initial device ID registration
|
//// temporarily leave sshEntryRootPath, sshAgeDirPath, and sshIsWindows as nil/default to pass initial device ID registration
|
||||||
newCfg.Libmutton.OfflineMode = &forceOfflineMode // forceOfflineMode must be false to reach this point, so we can avoid the extra declaration
|
newCfg.Libmutton.OfflineMode = &forceOfflineMode // forceOfflineMode must be false to reach this point, so we can avoid the extra declaration
|
||||||
newCfg.Libmutton.SSHUser = &sshUser
|
newCfg.Libmutton.SSHUser = &sshUser
|
||||||
newCfg.Libmutton.SSHIP = &sshIP
|
newCfg.Libmutton.SSHIP = &sshIP
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//go:build ios
|
||||||
|
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// get the app's Library/Application Support directory (private, not backed up by iCloud)
|
||||||
|
back.Home = filepath.Join(back.Home, "Library", "Application Support", "libmutton-ios")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
EntryRoot = back.Home + "/entries" // Path to libmutton entry directory
|
||||||
|
CfgDir = back.Home + "/config" // Path to libmutton configuration directory
|
||||||
|
CfgPath = CfgDir + "/libmuttoncfg.json" // Path to libmutton configuration file
|
||||||
|
AgeDir = CfgDir + "/age" // Path to libmutton password age directory
|
||||||
|
SSHDir = back.Home + "/ssh" // Path to SSH directory
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PathSeparator = "/" // Platform-specific path separator
|
||||||
|
IsWindows = false // Platform indicator
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build !windows
|
//go:build !windows && !ios && !android
|
||||||
|
|
||||||
package global
|
package global
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ var (
|
|||||||
CfgDir = back.Home + "/.config/libmutton" // Path to libmutton configuration directory
|
CfgDir = back.Home + "/.config/libmutton" // Path to libmutton configuration directory
|
||||||
CfgPath = CfgDir + "/libmuttoncfg.json" // Path to libmutton configuration file
|
CfgPath = CfgDir + "/libmuttoncfg.json" // Path to libmutton configuration file
|
||||||
AgeDir = CfgDir + "/age" // Path to libmutton password age directory
|
AgeDir = CfgDir + "/age" // Path to libmutton password age directory
|
||||||
|
SSHDir = back.Home + "/.ssh" // Path to SSH directory
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ var (
|
|||||||
CfgDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
|
CfgDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
|
||||||
CfgPath = CfgDir + "\\libmuttoncfg.json" // Path to libmutton configuration file
|
CfgPath = CfgDir + "\\libmuttoncfg.json" // Path to libmutton configuration file
|
||||||
AgeDir = CfgDir + "\\age" // Path to libmutton password age directory
|
AgeDir = CfgDir + "\\age" // Path to libmutton password age directory
|
||||||
|
SSHDir = back.Home + "\\.ssh" // Path to SSH directory
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func GetSSHClient() (*ssh.Client, bool, *bool, *string, *string, error) {
|
|||||||
|
|
||||||
// read known hosts file
|
// read known hosts file
|
||||||
var hostKeyCallback ssh.HostKeyCallback
|
var hostKeyCallback ssh.HostKeyCallback
|
||||||
hostKeyCallback, err = knownhosts.New(back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "known_hosts")
|
hostKeyCallback, err = knownhosts.New(global.SSHDir + global.PathSeparator + "known_hosts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, nil, nil, nil, errors.New("unable to read known hosts file: " + err.Error())
|
return nil, false, nil, nil, nil, errors.New("unable to read known hosts file: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user