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
|
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 1999 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
export IFS PATH
IFS="
"
PATH="/usr/bin"
# sys: system; user: login name; cdir: current directory;
# tdir: temporary directory; pu: PUBDIR/receive/user;
cdir=`pwd`
dir=""
abs=""
sys=""
var=""
varto=""
varfrom=""
trap "exit 1" 1 2 13 15
# mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
# for this process's temporary files. We set up a trap to remove the
# directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, and
# SIGTERM.
#
mktmpdir() {
tmpdir=/tmp/bnu.$$
trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 15
/usr/bin/mkdir -m 700 $tmpdir || exit 1
}
mktmpdir
# get options
while getopts s: FLAG; do
case $FLAG in
s) sys=$OPTARG
;;
?) gettext "Usage: uupick [-s sysname]\n" 1>&2;
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -gt 0 ]; then
gettext "Usage: uupick [-s sysname]\n" 1>&2;
fi
user=`id | sed -n "/^uid=[0-9]*(\([^)]*\)).*/s//\1/p"`
if test -z "$user"
then gettext "User id required!\n" >&2; exit 1
fi
pu=/var/spool/uucppublic/receive/$user
if test -d $pu -a -s $pu
then
for i in `/usr/bin/ls $pu`
do
if test $sys
then
if test $sys != $i; then continue; fi
fi
if test -d $pu/$i -a -s $pu/$i
then
cd $pu/$i
for j in `/usr/bin/ls -a`
do
if test $j = "." -o $j = ".."; then continue; fi
if test -d $j
then printf "`gettext 'from system %s: directory %s '`" $i $j
else printf "`gettext 'from system %s: file %s '`" $i $j
fi
while true
do
echo '? \c'
if read cmd dir
then
trap ": ;;" 1
case $cmd in
d)
rm -fr $j ; break ;;
"")
break ;;
# options m, a:
# If dir path begins with a slash, use full path for destination;
# otherwise, use path relative to current dir;
# default destination is current dir
#
# As files are transferred, put their names in $tmpdir/$$uupick.
# Only remove those named files from...receive/..dir if cmp
# verifies transfer took place. then find & remove directories
# (separate find is necessary because cpio -v doesn't print dir names)
a|m)
eval dir="$dir"
if test $dir
then abs=`expr "$dir" : '/.*'`
if test $abs != 0
then tdir=$dir
else tdir=$cdir/$dir
fi
else
tdir=$cdir
fi
if [ ! -d $tdir -o ! -w $tdir ]; then
printf "`gettext 'directory %s doesn't exist or isn't writable'`" $tdir >&2
continue
fi
if [ "$cmd" = "a" ]
then
find . -depth -print | \
grep -v '^\.$' > $tmpdir/$$uupick
level=2
else
find $j -depth -print > $tmpdir/$$uupick
level=1
fi
cpio -pdmu $tdir < $tmpdir/$$uupick
for k in `cat $tmpdir/$$uupick`
do
varto="$tdir/$k"
varfrom="$pu/$i/$k"
if test -f $varfrom; then
if cmp $varfrom $varto ; then
rm -f $varfrom
else
printf "`gettext 'file %s not removed'`" $varfrom >&2
fi
else
rmdir $varfrom 2>/dev/null
fi
done
rm -f $tmpdir/$$uupick
break $level;;
p)
if test -d $j
then find $j -print
elif test -s $j
then cat $j
fi;;
q)
break 3;;
!*)
ex=`expr "$cmd $dir" : '!\(.*\)'`
tdir=`pwd`
cd $cdir
sh -c "$ex"
cd $tdir
echo '!';;
*)
gettext "Usage: [d][m dir][a dir][p][q][cntl-d][!cmd][*][new-line]";;
esac
trap "exit 1" 1
else
break 3
fi
done
done
fi
done
fi
|