diff --git a/main-mshell.go b/main-mshell.go index b6b8ab33..b9a5e86f 100644 --- a/main-mshell.go +++ b/main-mshell.go @@ -528,9 +528,6 @@ Examples: # run a script as root (via sudo), capture output mshell --sudo-with-passfile pw.txt --ssh ubuntu@somehost -- "python3 /dev/fd/3 > /dev/fd/4" 3< myscript.py 4> script-output.txt < script-input.txt - -mshell is licensed under the MPLv2 -Please see https://github.com/scripthaus-dev/mshell for extended usage modes, source code, bugs, and feature requests ` fmt.Printf("%s\n\n", strings.TrimSpace(usage)) } diff --git a/pkg/cirfile/cirfile.go b/pkg/cirfile/cirfile.go index 797b09bd..59e44651 100644 --- a/pkg/cirfile/cirfile.go +++ b/pkg/cirfile/cirfile.go @@ -352,6 +352,28 @@ func (f *File) ReadAll(ctx context.Context) (int64, []byte, error) { return realOffset, buf[0:nr], err } +func (f *File) ReadAtWithMax(ctx context.Context, offset int64, maxSize int64) (int64, []byte, error) { + err := f.flock(ctx, syscall.LOCK_SH) + if err != nil { + return 0, nil, err + } + defer f.unflock() + err = f.readMeta() + if err != nil { + return 0, nil, err + } + chunks := f.getFileChunks() + curSize := totalChunksSize(chunks) + var buf []byte + if maxSize > curSize { + buf = make([]byte, curSize) + } else { + buf = make([]byte, maxSize) + } + realOffset, nr, err := f.internalReadNext(buf, offset) + return realOffset, buf[0:nr], err +} + func (f *File) internalReadNext(buf []byte, offset int64) (int64, int, error) { if offset < f.FileOffset { offset = f.FileOffset diff --git a/pkg/shexec/client.go b/pkg/shexec/client.go index 9dd5d974..7037c240 100644 --- a/pkg/shexec/client.go +++ b/pkg/shexec/client.go @@ -75,7 +75,7 @@ func MakeClientProc(ctx context.Context, ecmd *exec.Cmd) (*ClientProc, *packet.I initPk := pk.(*packet.InitPacketType) if initPk.NotFound { cproc.Close() - return nil, initPk, fmt.Errorf("mshell-%s command not found on local server", semver.MajorMinor(base.MShellVersion)) + return nil, initPk, fmt.Errorf("mshell client not found", semver.MajorMinor(base.MShellVersion)) } if semver.MajorMinor(initPk.Version) != semver.MajorMinor(base.MShellVersion) { cproc.Close()