This file is indexed.

/usr/bin/add_netatalk_printer is in netatalk 2.2.6-1.

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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#! /bin/sh
#
# $Id: add_netatalk_printer,v 1.7 2003-02-23 03:16:34 srittau Exp $
#
# A lovely script to add netatalk printers 
#
#ident  "@(#)netatalk   0.5     99/06/22 job@uchicago.edu"  /* Netatalk 1.4*/
#
# This File is released under the Perl Artistic Licence.
# See http://www.perl.org for details
#
# Or you can use it under the licence that accompanies Netatalk 1.3 =)
#
# This file is maintained by Job Bogan <job@uchicago.edu>
# Please contact me at this address for bug reports, problems, etc.
# Please do not bother the netatalk  maintainers with problems from
# this program.
#
#
#
# Exit Codes ...  1 for missed path or user input
# 2 for an aborted run (by not saying yes to a 'are you sure?'
# 3 for failed lpadmin commands
# 4 for possible security problem

# make base name for temp files.

TMP_STUFF="/tmp/`basename $0`.$$"
export TMP_STUFF
rm -rf ${TMP_STUFF}
mkdir -m 700 ${TMP_STUFF} || exit 4
trap 'rm -f $TMP_STUFF > /dev/null 2>&1' 0
trap 'exit' 1 2 3

# grab the pathname the script was called w/
# if it was run by ./add...  then make the path == `pwd`

RUNHOME=`dirname $0`

if [ "$RUNHOME" = "." ]; then
 	RUNHOME=`pwd`
fi

# allow for the env NETATALKHOME to override the guessed one from above

NETATALKHOME=${NETATALKHOME:-$RUNHOME}
export NETATALKHOME

PATH=/bin:${PATH}:${NETATALKHOME}/bin:${NETATALKHOME}/etc:${NETATALKHOME}/libexec:/usr/lib:/usr/sbin

if [ ! -x ${NETATALKHOME}/bin/pap ]; then
	echo "OOPS:	I don't see ${NETATALKHOME}/bin/pap ,"
	echo '	Check that it is executable or set ${NETATALKHOME}'
	echo '	so i can find pap at ${NETATALKHOME}/bin/pap'
	echo '[We are guessing the location of the binary from the'
	echo 'path that was used to run this script or $NETATALKHOME]'
	exit 1
fi

# get the user to tell us where to look for things, and list things there.

echo ''
printf 'Enter Appletalk zone [default: local]: \c'

read ZONE

echo ""
echo "Looking for LaserWriters in Zone ${ZONE} ..."
${NETATALKHOME}/bin/nbplkup ":LaserWriter@${ZONE}"

echo ""
printf 'Enter AppleTalk printer name: \c'

read DEST

if [ "$DEST" = "" ]; then
	echo "OOPS: you need to tell me a printer name"
	exit 1
fi

echo "checking nbplkup ${DEST}:LaserWriter@${ZONE}"
echo ""
TestDEST=`${NETATALKHOME}/bin/nbplkup "${DEST}:LaserWriter@${ZONE}"`
echo "${TestDEST}"
echo ""

if [ "${TestDEST}" = "" ]; then
    echo "I don't see that printer on the network.  You may have entered an incorrect"
    echo "printer name - if so, exit and restart."
    echo "[You should only enter the printer name, not the :LaserWriter portion]"
    sleep 3
fi

unset TestDEST

NBPNAME="${DEST}@${ZONE}"

echo ""
echo ""

# scrunch all of the whitespace and / out of the appletalk name and suggest
# that as the unix name

SUGGEST=`echo "$DEST" | cut -d: -f1 | sed 's/ //g' | sed 's#/##g'` ; export SUGGEST

# truncate the suggested name to 14 chars to conform to lp specs.

SUGGEST1=`expr ${SUGGEST} : '\(..............\)'`
SUGGEST=${SUGGEST1:-$SUGGEST}

echo "Enter Unix printer name - [default: ${SUGGEST}] : \c"
read UNIXPRINT
echo ''
if [ "${UNIXPRINT}" = "" ]; then
	UNIXPRINT="${SUGGEST}"
fi
export UNIXPRINT

#####
# Here we check for legal names again. >14 chars
#####

UNIXPRINT1=`expr "${UNIXPRINT}" : '\(..............\)'`

# if UNIXPRINT is shorter than 14chars, UNIXPRINT1 ends up null ("")
# if UNIXPRINT was longer, then we get a 14char version of it.  bleah.

if [ "${UNIXPRINT1}" = "" ]; then
	UNIXPRINT1="${UNIXPRINT}"
else
#if [ "${UNIXPRINT1}" != "${UNIXPRINT}" ]; then
    echo "Oops, that name was too long...  Truncating to 14 chars."
    echo "setting printer name to '${UNIXPRINT}'"
    UNIXPRINT="${UNIXPRINT1}"
fi

echo "Enter a description for this printer.  [The Appletalk name will"
echo "be included by default, and must be included for the printing"
echo "filters to work.] : \c"
read DESC

DESC="${DESC} [${NBPNAME}]"

echo ""
echo "Do you want all print jobs to print out in reversed page order?"
echo "This is usually only desired if this printer stacks jobs"
echo "face up in the output bin. [N/y] \c"
read REV
case ${REV} in		[Yy]*) 	REV="Netatalk-R" ;;
			*)	REV="Netatalk"   ;;
esac
export REV

if lpstat -p ${UNIXPRINT} >/dev/null 2>&1 ; then
	echo ''
	echo "OOPS:	There already exists a printer named '${UNIXPRINT}'"
	echo "		here are the comments from /etc/lp/printers/${UNIXPRINT}/comment"
	cat /etc/lp/printers/${UNIXPRINT}/comment
	echo ""
	echo "Do you still want to do this? This will flush "
	echo "all pending jobs!  [Y/n]? \c"
	read DOTHIS
	case ${DOTHIS} in	[Yy]*)         ;;
				*)	exit 2 ;;
	esac

	echo "Rejecting all new jobs for ${UNIXPRINT}"
	reject -r "Making ${UNIXPRINT} a netatalk printer" ${UNIXPRINT}
	echo "Disabling and Flushing the ${UNIXPRINT} queue"
	disable -c -r "Making ${UNIXPRINT} a netatalk printer" ${UNIXPRINT}
fi

#####
# Check if we need to do silly tricks to share the printer... only on 5.5.1 or older
#####

if [ "`uname -r`" -lt "5.6" ]; then
    echo ""
    echo "Do you want to share this printer with other machines [Y/n]?\c"
    read SHARE
else
    echo "You're running SunOS 5.6 or higher... skipping 'sacadm' and 'pmadm'"
fi

if nistest printers.org_dir; then
    echo "Do you want to add this printer to your NIS printer map? [y/N]"
    echo "(You will need to share this printer with other machines)"
    read NIS
    case ${NIS} in 	[Yy]*)    ADD_NIS=1 ;;
			    *)              ;;
    esac
fi

echo "Do you want to save the error messages from pap in"
echo "'/var/spool/lp/tmp/Netatalk/${UNIXPRINT}' [y/N]"
echo "(If you answer N, error messages will go to /dev/null.)"
read SAVEerr
case ${SAVEerr} in      [Yy]*)     SAVEerr=1 ;;
			    *)     unset SAVEerr ;;
esac

echo "Making ${UNIXPRINT} print to ${DEST} via netatalk"

if [ "${SAVEerr}" = "" ]; then
    LOCKDEV=/dev/null
else
    LOCKS=/var/spool/lp/tmp/Netatalk
    if [ ! -d ${LOCKS} ]; then
	    mkdir -m 0771	${LOCKS}
	    chown lp	${LOCKS}
	    chgrp lp	${LOCKS}
    fi
    LOCKDEV=${LOCKS}/${UNIXPRINT}
    touch		${LOCKDEV}
    chown lp:lp	${LOCKDEV}
    chmod 600	${LOCKDEV}
fi

echo ""

if [ ! -r /etc/lp/filter.table ]; then
        echo "Setting up the existing print filters..."
        for i in `ls /etc/lp/fd | sed 's/.fd$//'`; do
                lpfilter -f ${i} -F/etc/lp/fd/${i}.fd
        done
fi
if lpfilter -f netatalk -l > /dev/null 2>&1 ; then
	echo 'Looks like you have a Netatalk printer filter defined. Good!'
else
	echo "Humm... You need a Netatalk printer filter..."
	echo "... making you one ..."
	cat > /etc/lp/fd/netatalk.fd << EOF
#ident  "@(#)netatalk.fd 0.2 97/09/04 job@uchicago.edu"      /* Netatalk 1.4 */

Input types: postscript
Output types: PS
Printer types: Netatalk
Printers: any
Filter type: fast
Command: ${NETATALKHOME}/libexec/ifpap 2>&1 > /dev/null
EOF
	chown lp:lp /etc/lp/fd/netatalk.fd
	chmod 664   /etc/lp/fd/netatalk.fd
	lpfilter -f netatalk -F /etc/lp/fd/netatalk.fd
fi

if lpfilter -f netatalk-r -l 2>&1 > /dev/null ; then
	echo 'Looks like you have a Reverse Netatalk printer filter defined. Good!'
else
	echo "Humm... You need a Reverse Netatalk printer filter..."
	echo "... making you one ..."
	cat > /etc/lp/fd/netatalk-r.fd << EOF
#ident  "@(#)netatalk-r.fd 0.2 97/09/04 job@uchicago.edu"      /* Netatalk 1.4 */

Input types: postscript
Output types: PS
Printer types: Netatalk-R
Printers: any
Filter type: fast
Command: "/usr/lib/lp/postscript/postreverse | ${NETATALKHOME}/libexec/ifpap 2>&1 >/dev/null"
EOF
	chown lp:lp /etc/lp/fd/netatalk-r.fd
	chmod 664   /etc/lp/fd/netatalk-r.fd
	lpfilter -f netatalk-r -F /etc/lp/fd/netatalk-r.fd
fi

if [ ! -r /usr/share/lib/terminfo/N/Netatalk ]; then
	echo "Making a Terminfo entry for Netatalk printers"
	cat > ${TMP_STUFF}/terminfo << EOF
Netatalk,
	cols#80, lines#66,
	cpi=null, csnm=^D, lpi=null, scs=^D, slines=^D, u9=^D,
EOF
	tic ${TMP_STUFF}/terminfo
	chown bin:bin /usr/share/lib/terminfo/N/Netatalk
	chmod 644     /usr/share/lib/terminfo/N/Netatalk
fi

if [ ! -r /usr/share/lib/terminfo/N/Netatalk-R ]; then
	echo "Making a Terminfo entry for Reversed Netatalk printers"
	cat > ${TMP_STUFF}/terminfoR << EOF
Netatalk-R,
	cols#80, lines#66,
	cpi=null, csnm=^D, lpi=null, scs=^D, slines=^D, u9=^D,
EOF
	tic "${TMP_STUFF}/terminfoR"
	chown bin:bin /usr/share/lib/terminfo/N/Netatalk-R
	chmod 644     /usr/share/lib/terminfo/N/Netatalk-R
fi

###
# this is old cruft...  we should not have done this in the 1st place.
# we need to edit the template interface file to point to the local netatalk bins
#cat ${RUNHOME}/etc/netatalk.template | sed "s#DEFAULT_NETATALK_HOME#${RUNHOME}#g" \
#	> "/etc/lp/interfaces/${UNIXPRINT}"
#chown lp:lp	/etc/lp/interfaces/${UNIXPRINT}
#chmod 0775	/etc/lp/interfaces/${UNIXPRINT}
# below is the correct way.
###

echo "Setting up ${UNIXPRINT} ...  Edit options later as you see fit."
lpadmin -p ${UNIXPRINT} -D "${DESC}" -T ${REV} \
    -i ${RUNHOME}/netatalk.template -I PS -v ${LOCKDEV} -A none || exit 3
accept ${UNIXPRINT} || exit 3
enable ${UNIXPRINT} || exit 3

case ${SHARE} in	[Nn]*)	exit; ;;
			*)	      ;;
esac

echo "Setting up network sharing for ${UNIXPRINT}"

# from p925 in the Solaris Administration Guide, Vol. II (2.5)

echo ""
if sacadm -l -p tcp > /dev/null; then
   echo "already running a tcp listener"
else
   echo "Defining tcp listener ..."
   sacadm -a -p tcp -t listen -c "/usr/lib/saf/listen tcp" \
          -v `nlsadmin -V` -n 999
fi

# this is extra, but a good idea...

LPD_ADDR="\\x`lpsystem -A`" ; export LPD_ADDR
ADDR_0=`echo $LPD_ADDR | sed -e 's/\\x00020203/\\x00020ACE/g'`; export ADDR_0

if pmadm -l -p tcp -s 0 > /dev/null; then
   echo "<0> service is already defined."
else
   echo "Defining <0>/tcp service ..."
   pmadm -a -p tcp -s 0 -i root \
         -m `nlsadmin -c /usr/lib/saf/nlps_server -A ${ADDR_0}` \
         -v `nlsadmin -V`
fi

# again from the solaris book noted above.

if pmadm -l -p tcp -s lp > /dev/null; then
   echo "<lp> service is already defined."
else
   echo "Defining <lp>/tcp service ..."
   pmadm -a -p tcp -s lp -i root \
         -m `nlsadmin -o /var/spool/lp/fifos/listenS5` \
         -v `nlsadmin -V`
fi

if pmadm -l -p tcp -s lpd > /dev/null; then
   echo "<lpd> service is already defined."
else
   echo "Defining <lpd>/tcp service ..."
   pmadm -a -p tcp -s lpd -i root \
         -m `nlsadmin -o /var/spool/lp/fifos/listenBSD -A ${LPD_ADDR}` \
         -v `nlsadmin -V`
fi

if [ "${ADD_NIS}" = 1 ] ; then
    if nistest "[printer_name=${UNIXPRINT}]printers.org_dir"; then
	nistbladm -m	printer_host=`uname -n` \
	"[printer_name=${UNIXPRINT}]printers.org_dir"  description="$DESC"
    else
	nistbladm -a	printer_name=${UNIXPRINT} \
	description="$DESC" printer_host=`uname -n` printers.org_dir
    fi
fi