~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/bugpoint/RemoteRunSafely.sh

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Program:  RemoteRunSafely.sh
 
4
#
 
5
# Synopsis: This script simply runs another program remotely using ssh.
 
6
#           It always returns the another program exit code or exit with
 
7
#           code 255 which indicates that the program could not be executed.
 
8
#
 
9
# Syntax: 
 
10
#
 
11
#   RemoteRunSafely.sh <hostname> [-l <login_name>] [-p <port>]
 
12
#                <program> <args...>
 
13
#
 
14
#   where:
 
15
#     <hostname>    is the remote host to execute the program,
 
16
#     <login_name>  is the username on the remote host,
 
17
#     <port>        is the port used by the remote client,
 
18
#     <program>     is the path to the program to run,
 
19
#     <args...>     are the arguments to pass to the program.
 
20
#
 
21
 
 
22
printUsageAndExit()
 
23
{
 
24
  echo "Usage:"
 
25
  echo "./RemoteRunSafely.sh <hostname> [-l <login_name>] [-p <port>] " \
 
26
       "<program> <args...>"
 
27
  exit 255
 
28
}
 
29
 
 
30
moreArgsExpected()
 
31
{
 
32
  # $1 - remaining number of arguments
 
33
  # $2 - number of arguments to shift
 
34
  if [ $1 -lt $2 ]
 
35
  then
 
36
    echo "Error: Wrong number of argumants."
 
37
    printUsageAndExit
 
38
  fi
 
39
}
 
40
 
 
41
# Save a copy of the original arguments in a string before we
 
42
# clobber them with the shift command.
 
43
ORIG_ARGS="$*"
 
44
#DEBUG: echo 'GOT: '$ORIG_ARGS
 
45
 
 
46
moreArgsExpected $# 1
 
47
RHOST=$1
 
48
shift 1
 
49
 
 
50
RUSER=`id -un`
 
51
RCLIENT=ssh
 
52
RPORT=
 
53
WORKING_DIR=
 
54
 
 
55
moreArgsExpected $# 1
 
56
if [ $1 = "-l" ]; then
 
57
  moreArgsExpected $# 2
 
58
  RUSER=$2
 
59
  shift 2
 
60
fi
 
61
moreArgsExpected $# 1
 
62
if [ $1 = "-p" ]; then
 
63
  moreArgsExpected $# 2
 
64
  RPORT="-p $2"
 
65
  shift 2
 
66
fi
 
67
 
 
68
moreArgsExpected $# 1
 
69
PROGRAM=$(basename $1)
 
70
WORKING_DIR=$(dirname $1)
 
71
shift 1
 
72
 
 
73
#DEBUG: echo 'DIR='${0%%`basename $0`}
 
74
#DEBUG: echo 'RHOST='$RHOST
 
75
#DEBUG: echo 'RUSER='$RUSER
 
76
#DEBUG: echo 'PROGRAM='$PROGRAM
 
77
#DEBUG: echo 'WORKING_DIR='$WORKING_DIR
 
78
#DEBUG: echo 'ARGS='$*
 
79
 
 
80
# Sanity check
 
81
if [ "$RHOST" = "" -o "$PROGRAM" = "" ]; then
 
82
  printUsageAndExit
 
83
fi
 
84
 
 
85
# Local program file must exist and be execuatble
 
86
local_program=$WORKING_DIR"/"$PROGRAM
 
87
if [ ! -x "$local_program" ]; then
 
88
  echo "File "$local_program" does not exist or is not an executable.."
 
89
  exit 255
 
90
fi
 
91
 
 
92
connection=$RUSER'@'$RHOST
 
93
remote="./"$PROGRAM
 
94
(
 
95
  cat $local_program |        \
 
96
  $RCLIENT $connection $RPORT \
 
97
   'rm -f '$remote' ; '       \
 
98
   'cat > '$remote' ; chmod +x '$remote' ; '$remote' '$*' ; ' \
 
99
   'err=$? ; rm -f '$remote' ; exit $err'
 
100
)
 
101
err=$?
 
102
 
 
103
#DEBUG: echo script exit $err
 
104
exit $err
 
105