minor updates/bugfixes

This commit is contained in:
sawka 2023-04-02 23:00:55 -07:00
parent 963bef8425
commit 01a99cba03
3 changed files with 23 additions and 4 deletions

View File

@ -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))
}

View File

@ -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

View File

@ -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()