-allowCommands = ["scp", "rsync", "/usr/lib/openssh/sftp-server"]
-commandPaths = ["/usr/bin", "/bin"]
+rrsync = "/usr/local/bin/schsh-rrsync" # path to the restricted rsync script - if available, it will be used to further restrict rsync access
+
+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
+ if rrsync is None:
+ # rrsync is not available, let's hope this is enough protection
+ run[0] = "/usr/bin/rsync"
+ return True
+ run[:] = [rrsync, "/", runstr] # allow access to the entire chroot
+ return True
+
+def allowSFTP(run, runstr):
+ return runstr == "/usr/lib/openssh/sftp-server"
+
+allowCommands = [allowSCP, allowRSync, allowSFTP]