mirror of https://gogs.blitter.com/RLabs/xs
-Added -z option back to tarpipes
-Moved remaining chatty fmt.Prints to log.Print
This commit is contained in:
parent
b33e9de139
commit
bff56a2c61
|
@ -102,7 +102,7 @@ func parseNonSwitchArgs(a []string) (user, host, path string, isDest bool, other
|
||||||
// doCopyMode begins a secure hkexsh local<->remote file copy operation.
|
// doCopyMode begins a secure hkexsh local<->remote file copy operation.
|
||||||
func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec) (err error, exitStatus uint32) {
|
func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec) (err error, exitStatus uint32) {
|
||||||
if remoteDest {
|
if remoteDest {
|
||||||
fmt.Println("local files:", files, "remote filepath:", string(rec.cmd))
|
log.Println("local files:", files, "remote filepath:", string(rec.cmd))
|
||||||
|
|
||||||
var c *exec.Cmd
|
var c *exec.Cmd
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec)
|
||||||
//os.Setenv("TERM", "vt102") // TODO: server or client option?
|
//os.Setenv("TERM", "vt102") // TODO: server or client option?
|
||||||
|
|
||||||
cmdName := "/bin/tar"
|
cmdName := "/bin/tar"
|
||||||
cmdArgs := []string{"-c", "-f", "/dev/stdout"}
|
cmdArgs := []string{"-cz", "-f", "/dev/stdout"}
|
||||||
files = strings.TrimSpace(files)
|
files = strings.TrimSpace(files)
|
||||||
// Awesome fact: tar actually can take multiple -C args, and
|
// Awesome fact: tar actually can take multiple -C args, and
|
||||||
// changes to the dest dir *as it sees each one*. This enables
|
// changes to the dest dir *as it sees each one*. This enables
|
||||||
|
@ -136,14 +136,14 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec)
|
||||||
//cmdArgs = append(cmdArgs, v)
|
//cmdArgs = append(cmdArgs, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[%v %v]\n", cmdName, cmdArgs)
|
log.Printf("[%v %v]\n", cmdName, cmdArgs)
|
||||||
// NOTE the lack of quotes around --xform option's sed expression.
|
// NOTE the lack of quotes around --xform option's sed expression.
|
||||||
// When args are passed in exec() format, no quoting is required
|
// When args are passed in exec() format, no quoting is required
|
||||||
// (as this isn't input from a shell) (right? -rlm 20180823)
|
// (as this isn't input from a shell) (right? -rlm 20180823)
|
||||||
//cmdArgs := []string{"-xvz", "-C", files, `--xform=s#.*/\(.*\)#\1#`}
|
//cmdArgs := []string{"-xvz", "-C", files, `--xform=s#.*/\(.*\)#\1#`}
|
||||||
c = exec.Command(cmdName, cmdArgs...)
|
c = exec.Command(cmdName, cmdArgs...)
|
||||||
c.Dir, _ = os.Getwd()
|
c.Dir, _ = os.Getwd()
|
||||||
fmt.Println("[wd:", c.Dir, "]")
|
log.Println("[wd:", c.Dir, "]")
|
||||||
c.Stdout = conn
|
c.Stdout = conn
|
||||||
stdErrBuffer := new(bytes.Buffer)
|
stdErrBuffer := new(bytes.Buffer)
|
||||||
c.Stderr = stdErrBuffer
|
c.Stderr = stdErrBuffer
|
||||||
|
@ -177,7 +177,7 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec)
|
||||||
_, _ = conn.Read(nil /*ackByte*/)
|
_, _ = conn.Read(nil /*ackByte*/)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("remote filepath:", string(rec.cmd), "local files:", files)
|
log.Println("remote filepath:", string(rec.cmd), "local files:", files)
|
||||||
var c *exec.Cmd
|
var c *exec.Cmd
|
||||||
|
|
||||||
//os.Clearenv()
|
//os.Clearenv()
|
||||||
|
@ -187,8 +187,8 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *cmdSpec)
|
||||||
cmdName := "/bin/tar"
|
cmdName := "/bin/tar"
|
||||||
destPath := files
|
destPath := files
|
||||||
|
|
||||||
cmdArgs := []string{"-x", "-C", destPath}
|
cmdArgs := []string{"-xz", "-C", destPath}
|
||||||
fmt.Printf("[%v %v]\n", cmdName, cmdArgs)
|
log.Printf("[%v %v]\n", cmdName, cmdArgs)
|
||||||
// NOTE the lack of quotes around --xform option's sed expression.
|
// NOTE the lack of quotes around --xform option's sed expression.
|
||||||
// When args are passed in exec() format, no quoting is required
|
// When args are passed in exec() format, no quoting is required
|
||||||
// (as this isn't input from a shell) (right? -rlm 20180823)
|
// (as this isn't input from a shell) (right? -rlm 20180823)
|
||||||
|
|
|
@ -68,7 +68,7 @@ func runClientToServerCopyAs(who string, conn hkexnet.Conn, fpath string, chaffi
|
||||||
destDir = path.Join(u.HomeDir, fpath)
|
destDir = path.Join(u.HomeDir, fpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArgs := []string{"-x", "-C", destDir}
|
cmdArgs := []string{"-xz", "-C", destDir}
|
||||||
|
|
||||||
// NOTE the lack of quotes around --xform option's sed expression.
|
// NOTE the lack of quotes around --xform option's sed expression.
|
||||||
// When args are passed in exec() format, no quoting is required
|
// When args are passed in exec() format, no quoting is required
|
||||||
|
@ -147,7 +147,7 @@ func runServerToClientCopyAs(who string, conn hkexnet.Conn, srcPath string, chaf
|
||||||
}
|
}
|
||||||
|
|
||||||
srcDir, srcBase := path.Split(srcPath)
|
srcDir, srcBase := path.Split(srcPath)
|
||||||
cmdArgs := []string{"-c", "-C", srcDir, "-f", "-", srcBase}
|
cmdArgs := []string{"-cz", "-C", srcDir, "-f", "-", srcBase}
|
||||||
|
|
||||||
c = exec.Command(cmdName, cmdArgs...)
|
c = exec.Command(cmdName, cmdArgs...)
|
||||||
|
|
||||||
|
@ -192,12 +192,10 @@ func runServerToClientCopyAs(who string, conn hkexnet.Conn, srcPath string, chaf
|
||||||
// an ExitStatus() method with the same signature.
|
// an ExitStatus() method with the same signature.
|
||||||
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
|
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
|
||||||
exitStatus = uint32(status.ExitStatus())
|
exitStatus = uint32(status.ExitStatus())
|
||||||
log.Printf("Exit Status: %d", exitStatus)
|
|
||||||
// TODO: send stdErrBuffer to client via specific packet
|
|
||||||
// type so it can inform user
|
|
||||||
if len(stdErrBuffer.Bytes()) > 0 {
|
if len(stdErrBuffer.Bytes()) > 0 {
|
||||||
fmt.Print("TODO: (stderrBuffer to client):", stdErrBuffer)
|
log.Print(stdErrBuffer)
|
||||||
}
|
}
|
||||||
|
log.Printf("Exit Status: %d", exitStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue