This file is indexed.

/usr/bin/lcp is in lsh-client 2.1-12.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#! /bin/bash

# rcp-like copying program. Uses bash, for the noclobber feature.
# Unless -f is used, bash is required also on the remote machine, but
# no other special programs.

# lsh, an implementation of the ssh protocol
# 
# Copyright (C) 2001 Niels Möller
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

set -e

verbose=no
dry_run=no
force=no

RSH=${LCP_RSH:-lsh}

function werror () {
  if [ "x$verbose" = xyes ] ; then
    echo 1>&2 "$@"
  fi
}

function usage () {
  echo "Usage: lcp [OPTIONS] SOURCE DESTINATION"
  echo
  echo "Both SOURCE and DESTINATION can be files on remote machines."
  echo "Valid file specifications are:"
  echo
  echo "  file"
  echo "  machine:file"
  echo "  user@machine:file"
  echo
  echo "Valid options are:"
  echo
  echo "  --help         display this message"
  echo "  -f, --force    overwrite existing files"
  echo "  -v, --verbose  display commands before they are executed"
  echo "  -n, --dry-run  don't execute any commands. Implies -v"
}

# FIXME: This isn't failsafe at all. We could do somthing simple, like
# inserting a backslash before each character, or do something more
# sophisticated whichat doesn't quote filenames that don't need it.

function quote () {
  echo '"'"$1"'"'
}

# Splits an argument of the form [[user@]host:]file
function split_spec () {
  host=''
  user=''
  file="$1"
  case "$file" in
    *:*)
      host=${1%:*}
      file=${1#*:}
	  case "$host" in
	    *@*)
	      user=${host%@*}
	      host=${host#*@}
	    ;;
	  esac
    ;;
  esac
}

# Arguments USER HOST FILE
function read_src () {
  local user="${1:+-l}$1"
  local host="$2"
  local file="$3"
  local qfile="`quote "$file"`"

  if [ -z "$host" ]; then
    werror 'From: cat "'"$file"'"'
    if [ "x$dry_run" = xno ] ; then
      cat "$file"
    fi
  else
    werror "From: " $RSH $user "$host" cat "$qfile"
    if [ "x$dry_run" = xno ] ; then
      $RSH $user "$host" cat "$qfile"
    fi
  fi
}

# Arguments USER HOST DST SRC_FILE
function write_dst () {
  local user="${1:+-l}$1"
  local host="$2"
  local dst="$3"
  local src_file="$4"
  local qdst="`quote "$file"`"
  local qsrc="`quote "$src_file"`"
  
  if [ -z "$host" ]; then
    werror 'To: if [ -d "'"$dst"'" ] ; then cat > "'"$dst/$src_file"'" ; else cat > "'"$dst"'"; fi'
    if [ "x$dry_run" = xno ] ; then
      if [ -d "$dst" ] ; then cat > "$dst/$src_file" ; else cat > "$dst"; fi 
    fi
  else
    command="$rset_clobber"' if [ -d "'"$dst"'" ] ; then cat > "'"$dst/$src_file"'" ; else cat > "'"$dst"'" ; fi'

    werror "To: " $RSH $user '"'"$host"'"' "bash -c '$command'"

    if [ x$dry_run = xno ] ; then
      $RSH $user "$host" bash -c "'$command'"
    fi
  fi
}

function foo ()
{
  split_spec "$1"
  echo user: `quote "$user"`
  echo host: `quote "$host"`
  echo file: `quote "$file"`
}

while [ $# -ge 1 ]; do
  case "$1" in
    --usage|--help)
      usage
      exit 1;
    ;;
    -v|--verbose)
      verbose=yes
    ;;
    -n|--dry-run)
      dry_run=yes
      verbose=yes
    ;;
    -f|--force)
      force=yes
    ;;
    --)
      shift
      if [ $# != 2 ] ; then
        usage
	exit 1
      fi
      break
    ;;
    -*)
      echo "lcp: unrecognized option \`$1'"
      echo "Try \`lcp --help' or \`lcp --usage' for more information."
      exit 1;
    ;;
    *)
      break
    ;;
  esac
  shift
done

if [ $# != 2 ] ; then
  usage
  exit 1
fi

split_spec "$1"
src_user="$user"
src_host="$host"
src_file="$file"

split_spec "$2"
dst_user="$user"
dst_host="$host"
dst_file="$file"

# echo dry_run: $dry_run
# echo verbose: $verbose

if [ "x$force" = xyes ] ; then
  set +C
  rset_clobber=''
  SHELL_PROGRAM=sh
else
  set -C
  rset_clobber='set -C ;'
  SHELL_PROGRAM=bash
fi

file=`basename $src_file`

if [ "x$dry_run" = xyes ] ; then
  read_src "$src_user" "$src_host" "$src_file" 
  write_dst "$dst_user" "$dst_host" "$dst_file" "$file"
else
  read_src "$src_user" "$src_host" "$src_file" \
  | write_dst "$dst_user" "$dst_host" "$dst_file" "$file"
fi