+### END of options data produced by the cull-options script. ###
+
+if ($short_disabled ne '') {
+ $short_no_arg =~ s/[$short_disabled]//go;
+ $short_with_num =~ s/[$short_disabled]//go;
+}
+
+my $write_log = -f LOGFILE && open(LOG, '>>', LOGFILE);
+
+chdir($subdir) or die "$0: Unable to chdir to restricted dir: $!\n";
+
+my(@opts, @args);
+my $in_options = 1;
+my $last_opt = '';
+my $check_type;
+foreach (split(/(?<!\\)\s+/, $command)) {
+ if ($check_type) {
+ s/\\(.)/$1/g;
+ push(@opts, check_arg($last_opt, $_, $check_type));
+ $check_type = 0;
+ } elsif ($in_options) {
+ s/\\(.)/$1/g;
+ push(@opts, $_);
+ if ($_ eq '.') {
+ $in_options = 0;
+ } else {
+ next if /^-[$short_no_arg]+$/o || /^-[$short_with_num]\d+$/o;
+
+ my($opt,$arg) = /^--([^=]+)(?:=(.*))?$/;
+ my $disabled;
+ if (defined $arg) {
+ my $ct = $long_with_arg{$opt};
+ if ($ct) {
+ $arg = check_arg($opt, $arg, $ct);
+ $opts[-1] =~ s/=.*/=$arg/;
+ next;
+ }
+ $disabled = defined $long_with_arg{$opt};
+ $opt = "--$opt";
+ } elsif (defined $opt) {
+ if (defined $long_no_arg{$opt}) {
+ next if $long_no_arg{$opt};
+ $disabled = 1;
+ } else {
+ $check_type = $long_before_arg{$opt};
+ if ($check_type) {
+ $last_opt = $opt;
+ next;
+ }
+ $disabled = defined $check_type;
+ }
+ $opt = "--$opt";
+ } elsif ($short_disabled ne '') {
+ $disabled = /^-[$short_no_arg]*([$short_disabled])/o;
+ $opt = "-$1" if $disabled;
+ }
+
+ die "$0: option $opt has been disabled on this server.\n" if $disabled;
+ last;
+ }
+ } else {
+ if ($subdir ne '/') {
+ # Validate args to ensure they don't try to leave our restricted dir.
+ s#//+#/#g;
+ s#^/##;
+ s#^$#.#;
+ die "Do not use .. in any path!\n" if m#(^|/)\\?\.\\?\.(\\?/|$)#;
+ }
+ push(@args, bsd_glob($_, GLOB_LIMIT|GLOB_NOCHECK|GLOB_BRACE|GLOB_QUOTE));
+ }
+}
+die "$0: invalid rsync-command syntax or options\n" if $in_options;
+
+@args = ( '.' ) if !@args;
+
+if ($write_log) {