File: plinkfs

package info (click to toggle)
putty 0.83-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,216 kB
  • sloc: ansic: 148,476; python: 8,466; perl: 1,830; makefile: 128; sh: 117
file content (41 lines) | stat: -rwxr-xr-x 1,129 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3

# Wrapper around the FUSE 'sshfs' client, which arranges to use Plink
# as the SSH transport subcommand.
#
# This is not totally trivial because sshfs assumes slightly more of
# OpenSSH's command-line syntax than Plink supports. So we actually
# give sshfs a subcommand which is this script itself, re-invoked with
# the --helper option.

import sys
import os
import shlex

if sys.argv[1:2] == ["--helper"]:
    # Helper mode. Strip OpenSSH-specific '-o' options from the
    # command line, and invoke Plink.
    plink_command = ["plink"]

    it = iter(sys.argv)
    next(it) # discard command name
    next(it) # discard --helper

    for arg in it:
        if arg == "-o":
            next(it) # discard -o option
        elif arg.startswith("-o"):
            pass
        else:
            plink_command.append(arg)

    os.execvp(plink_command[0], plink_command)

else:
    # Normal mode, invoked by the user.
    sshfs_command = [
        "sshfs", "-o", "ssh_command={} --helper".format(
            os.path.realpath(__file__))
    ] + sys.argv[1:]

    os.execvp(sshfs_command[0], sshfs_command)