-allowCommands = ["scp", "rsync", "/usr/lib/openssh/sftp-server"]
-commandPaths = ["/usr/bin", "/bin"]
+
+def allowSCP(run, runstr):
+ if len(run) != 3: return False
+ if run[0] != "scp": return False
+ if run[1] not in ("-f", "-t"): return False
+ if run[2].startswith('-'): return False
+ run[0] = "/usr/bin/scp"
+ return True
+
+def allowRSync(run, runstr):
+ if len(run) < 3: return False
+ if run[0] != "rsync": return False
+ if run[1] != "--server": return False
+ run[0] = "/usr/bin/rsync"
+ return True
+
+def allowSFTP(run, runstr):
+ return runstr == "/usr/lib/openssh/sftp-server"
+
+allowCommands = [allowSCP, allowRSync, allowSFTP]