This file is indexed.

/usr/sbin/emacspeakconfig is in emacspeak 45.0+dfsg-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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
#!/bin/sh
#
#  emacspeakconfig - configuration script for emacspeak
#
#  This script sets values in /etc/emacspeak.conf, which override the
#  defaults compiled into emacspeak TCL scripts and .elc files.
#  Values in the user's environment will override those in
#  /etc/emacspeak.conf
#
#  Written by Jim Van Zandt <jrv@debian.org> for Debian Linux,
#  and hereby placed in the public domain for use by anyone.

set -e

CFG=/etc/emacspeak.conf
GROUPFILE=/etc/group
DRIVERDIR=/usr/lib/emacs/common/emacspeak/drivers
USUAL=/usr/share/emacs/site-lisp/emacspeak

# on a Slackware or Red Hat system, a user may attempt configuration
# with awk missing.
if [ -x /usr/bin/awk -o -x /bin/awk ]; then true; else
cat <<EOF

awk is missing.
Please execute /usr/sbin/emacspeakconfig again after installing it.

EOF
    echo -n "Press Enter: "; read junk;
    exit 1;
fi

set -- `getopt i $*`
if test $? != 0
then
    echo 'Usage: emacspeakconfig [-i]'
    exit 2
fi
initial=no
for i
do
    case "$i"
    in
       	-i)
       		initial=yes; shift;;
       	--)
       		shift; break;;
    esac
done

#echo initial=$initial

# if there is no configuration file, then create one
if [ -s $CFG ]; then
  true
else
cat >$CFG  <<\EOF
# emacspeak configuration file
#
#
if [ "$DTK_PROGRAM" = "" ]; then
  DTK_PROGRAM=
fi
if [ "$DTK_TCL" = "" ]; then
  DTK_TCL=
fi
if [ "$DTK_PORT" = "" ]; then
  DTK_PORT=
fi
if [ "$DTK_DEVICE" = "" ]; then
  DTK_DEVICE=
fi
export DTK_PROGRAM DTK_PORT DTK_DEVICE
if [ "$DTK_TCL" != "" ]; then export DTK_TCL; fi
EOF
fi

# if the configuration file does not set the DTK_DEVICE variable, then
# add that section
if grep 'export.*DTK_DEVICE' $CFG >/dev/null ; then
  true
else
    awk '
    / *export/{
	print "if [ \"$DTK_DEVICE\" = \"\" ]; then";
	print "DTK_DEVICE=";
	print "fi";
	print "export DTK_PROGRAM DTK_PORT DTK_DEVICE";
	print "if [ \"$DTK_TCL\" != \"\" ]; then export DTK_TCL; fi";
	next;}
	{print;}' $CFG > $CFG.TMP && mv $CFG.TMP $CFG
fi

# return success if answer is "yes"
yesno() {
# first argument is question
# second argument is default answer
while true; do
    echo -n "$1 [$2]: "; read ans;
    if [ "$ans" = "" ]; then ans=$2; fi
    if [ "$ans" = "y" -o "$ans" = "Y" -o "$ans" = "yes" ]; then return 0; fi
    if [ "$ans" = "n" -o "$ans" = "N" -o "$ans" = "no" ]; then return 1; fi
done
}

# set TEXT to a string typed by the user
text() {
# first argument is question
# second argument is default answer
echo -n "$1 [$2]: "; read ans;
if [ "$ans" = "" ]; then ans=$2; fi
TEXT=$ans
}

# get parameters for some new synthesizer
request_params() {
    text "Please enter the name of the synthesizer" "$DEVICE"; DEVICE=$TEXT
    if [ "$TCL" = "tcl" ]; then IS_TCL=y; else IS_TCL=n; fi
    if yesno "Is the speech server a TCL script? " $IS_TCL ; then 
	echo "These files in $USUAL/servers appear to be TCL scripts:"
	(cd $USUAL/servers; grep -l dectalk_globals * 2>/dev/null)
        text "Please enter the name (not path) of the $DEVICE speech server" \
	    ${PROGRAM:-$TCL}
        PROGRAM=$TEXT
	TCL=tcl; 
    else 
        text "Please enter the full path name of the $DEVICE speech server" \
	${PROGRAM:-$TCL}
	TCL=$TEXT
	PROGRAM=; 
    fi;
    if echo $PORT|grep '^/dev/ttyS' >/dev/null; then ans=y; else ans=n; fi;
    if yesno "Is the $DEVICE connected to a serial port?" $ans ; then
	true;
    else
	valid=no;
	while [ "$valid" = "no" ]; do
            text "Please enter the device (for example, /dev/lp0): " \
                ${PORT:-/dev/lp0}
	    PORT=$TEXT; 
	    if check_port; then valid=yes; fi
	done
	HAVE_PORT=yes;
    fi;

# echo "PROGRAM=$PROGRAM, TCL=$TCL, PORT=$PORT"
}

# print warning if a program does not exist
check_pgm() {
if [ -x $TCL -o -x /usr/bin/$TCL ]; then true; else
    echo
    echo "NOTICE: Before using Emacspeak, please install"
    echo "        $TCL"
    echo
    echo -n "Press Enter to continue: "; read junk;
fi
}

# return success if $PORT is (or will be) a valid character device
check_port() {

if [ -c "$PORT" ]; then return 0; fi
echo "$PORT is not a character device"
yesno "Will $PORT be compiled into the kernel or loaded as a module?" "y"
}

#	give a user a supplementary group ID
#
#       usage:  enroll user1[,user2...]  group1[,group2...]
enroll() {
set -e
awk '
BEGIN {
  FS=":";
  OFS=":";
  if (ARGC<4) {
    print "requires two arguments" >"/dev/stderr";
    exit(1);
  }
  userlist=ARGV[1];
  if (userlist!~/^[a-z][a-z,]*$/) {
    print "invalid user list" >"/dev/stderr"; 
    exit(1);
  }
  nu=split(userlist,user,",");
  grouplist=ARGV[2];
  if (grouplist!~/^[a-z][a-z,]*$/) {
    print "invalid group list" >"/dev/stderr"; 
    exit(1);
  }
  ng=split(grouplist,group,",");
#  printf("%d users: ",nu); 
#  for (i=1; i<=nu; i++) printf("%s ", user[i]); 
#  printf("\n");
#  printf("%d groups: ",ng); 
#  for (i=1; i<=nu; i++) printf("%s ", group[i]); 
#  printf("\n");
  ARGC=2;
  ARGV[1]=ARGV[3];
}
{
  for (i=1; i<=ng; i++) {
    if ($1~group[i]) {
      if (NF==3) {		# no group members yet
	$4=userlist;
      } else {			# already some group members
	delete names;
	delete member;
	split($4,names,",");
	for (j in names) {member[names[j]]=1;}
	for (j=1;j <= nu;j++) {member[user[j]]=1;}
	$4="";
	for (name in member) {$4=$4 "," name;}
	$4=substr($4, 2);
      }
    }
  }
  print;
}' $1 $2 $GROUPFILE >$GROUPFILE.$$ && mv $GROUPFILE.$$ $GROUPFILE
}

#	take a supplementary group ID away from a user
#
#       usage: dismiss  user1[,user2...]  group1[,group2...]
dismiss() {
set -e
awk '
BEGIN {
  FS=":";
  OFS=":";
  if (ARGC<4) {
    print "requires two arguments" >"/dev/stderr";
    exit(1);
  }
  userlist=ARGV[1];
  if (userlist!~/^[a-z][a-z,]*$/) {
    print "invalid user list" >"/dev/stderr"; 
    exit(1);
  }
  nu=split(userlist,user,",");
  grouplist=ARGV[2];
  if (grouplist!~/^[a-z][a-z,]*$/) {
    print "invalid group list" >"/dev/stderr"; 
    exit(1);
  }
  ng=split(grouplist,group,",");
#printf("userlist=%s\n",userlist);
#printf("%d users: ",nu); for (i=1; i<=nu; i++) printf("%s ", user[i]); printf("\n");
#printf("%d groups: ",ng); for (i=1; i<=nu; i++) printf("%s ", group[i]); printf("\n");
  ARGC=2;
  ARGV[1]=ARGV[3];
}
{
  for (i=1; i<=ng; i++) {
    if ($1~group[i]) {
      if (NF==3) {		# no group members yet
      } else {			# already some group members
	delete names;
	delete member;
	split($4,names,",");
	for (j in names) {member[names[j]]=1;}
	for (j=1;j <= nu;j++) {delete member[user[j]];}
	$4="";
	for (name in member) {$4=$4 "," name;}
	$4=substr($4, 2);
      }
    }
  }
  print;
}' $1 $2 $GROUPFILE >$GROUPFILE.$$ && mv $GROUPFILE.$$ $GROUPFILE
}

# get the current parameter values (if any) from the configuration file
if [ -s $CFG ]; then
   PORT=`awk 'BEGIN{FS="="}/^ *DTK_PORT/{print $2}' $CFG`
   TCL=`awk 'BEGIN{FS="="}/^ *DTK_TCL/{print $2}' $CFG`
   PROGRAM=`awk 'BEGIN{FS="="}/^ *DTK_PROGRAM/{print $2}' $CFG`
   DEVICE=`awk '
   / *DTK_DEVICE="?.*"?/{
	word=substr($0,index($0,"=")+1);
	gsub(/\"/,"",word);
	if (length(word) == 0) word="DECtalk Express";
	print word;
   }' $CFG`
fi
HAVE_PORT=no;

#echo initial values are: PROGRAM=$PROGRAM TCL=$TCL PORT=$PORT DEVICE=$DEVICE
#echo getting speech server choice

# There must be a file foo.blurb in $BLURBS for each distinct
# combination of speech server and hardware device.  It contains lines
# beginning with a single word and a colon (anything else is ignored).
# The valid words are
#   blurb: the description to print
#   device: value for DTK_DEVICE (supplies default for next time)
#   tcl: value for DTK_TCL
#   program: value for DTK_PROGRAM

# get synthesizer name
if [ $initial = no -o "$PROGRAM" = "" -o "$TCL" = "" ]; then
    valid=no
    while [ $valid = no ]; do

	# first pass: print menu
    	awk '
    	BEGIN {
    	  printf("Please enter the number of your choice:\n\n");
    	  ARGC=1;
    	  cmd = "ls " ARGV[1] "/blurbs/*.blurb";
    	  while (cmd|getline >0){bname[++n] = $1;}
    	  for (i = 1; i <= n; i++){
    	    while (getline < bname[i] > 0){
    	      if ($0 ~ /^blurb:/){$1 = ""; blurb[i] = $0;}
    	      if ($0 ~ /^program:/){program[i] = $2;}
    	      if ($0 ~ /^tcl:/){tcl[i] = $2;}
    	      if ($0 ~ /^device:/){$1 = ""; device[i] = $0;}
    	    }
    	    close(bname[i]);
    	    printf("  %2d %s\n", i, blurb[i]);
    	  }
    	  printf("   o  other.  I can provide the filename\n");
    	  printf("   a  abort, and restart configuration after\n");
	  printf("      installation of another speech server package\n"); 
    	}' $USUAL "$DEVICE"

	# second pass: determine default choice
    	area=`awk '
    	BEGIN {
    	  ARGC=1;
    	  cmd = "ls " ARGV[1] "/blurbs/*.blurb";
    	  while (cmd|getline >0){bname[++n] = $1;}
    	  for (i = 1; i <= n; i++){
    	    while (getline < bname[i] > 0){
    	      if ($0 ~ /^blurb:/){$1 = ""; blurb[i] = $0;}
    	      if ($0 ~ /^program:/){program[i] = $2;}
    	      if ($0 ~ /^tcl:/){tcl[i] = $2;}
    	      if ($0 ~ /^device:/){$1 = ""; device[i] = $0;}
    	    }
    	    if (index(device[i],ARGV[2])){deflt=i;}
    	    if (index(device[i],"DECtalk Express")){decexp=i;}
    	    close(bname[i]);
    	  }
    	  if (deflt == 0) print decexp;
    	  print deflt;
    	}' $USUAL "$DEVICE" `

	# get answer from user
	text "Number" $area; area=$TEXT

	# third pass: set shell variables according to his choice
        eval `awk '
        BEGIN {
          ARGC=1;
          cmd = "ls " ARGV[1] "/blurbs/*.blurb";
          while (cmd|getline >0){bname[++n] = $1;}
          for (i = 1; i <= n; i++){
            while (getline < bname[i] > 0){
              if ($0 ~ /^blurb:/){$1 = ""; blurb[i] = $0;}
              if ($0 ~ /^program:/){program[i] = $2;}
              if ($0 ~ /^tcl:/){tcl[i] = $2;}
              if ($0 ~ /^device:/){$1 = ""; device[i] = $0;}
            }
            if (i == ARGV[2]){
              sub(/^ */,"",device[i]);
              printf("PROGRAM=%s; TCL=%s; DEVICE=\"%s\"; valid=yes;\n", \
        	     program[i], tcl[i], device[i]);
            }
          }
        }' $USUAL $area`
	if [ "$area" = "a" ]; then exit 0; fi
	if [ "$area" = "0" -o "$area" = "o" -o "$area" = "O" ]; then
	    request_params;
	fi
	if [ "$PROGRAM" = "none" -o "$PROGRAM" = "" ]; then check_pgm; fi
    done
fi

#echo new values are: DEVICE=$DEVICE PROGRAM=$PROGRAM TCL=$TCL PORT=$PORT

# get unix device
if [ "$DEVICE" = "DoubleTalk PC" ]; then
    IN_PORT=/dev/dtlk
else
    IN_PORT=$PORT
    if [ "$IN_PORT" = "" -o "$IN_PORT" = "/dev/dtlk" ]; then
	IN_PORT=/dev/ttyS0;
    fi
fi
if [ $HAVE_PORT = no ]; then
    if [ $initial = no -o "$PORT" = "" ]; then
    	valid=no
    	while [ $valid = no ]; do
    	    text "
    Your speech synthesizer is connected to which port, if any?
    (The first serial port would be /dev/ttyS0.
    This is ignored for a software synthesizer)" $IN_PORT
    	    PORT=$TEXT
    	    if check_port $PORT; then valid=yes; fi
    	done
    fi
fi

#echo " "
#echo emacspeak is configured for $DEVICE attached to $PORT

# adjust unix device group membership if needed
if [ -c "$PORT" ]; then
    DEVICEGROUP=`ls -l -L $PORT|awk '{print $4}'`
else
    if [ "$DEVICE" = "DoubleTalk PC" -a -f /etc/makedev.cfg ]; then
	DEVICEGROUP=`awk '/audio:/{print $4}' /etc/makedev.cfg`
    else 
	DEVICEGROUP=audio
    fi
    echo "$PORT is assumed to be in group: $DEVICEGROUP"
fi

if [ $DEVICEGROUP = root ];
then
    echo "$PORT is in group: root"
    echo "please move it to another group with chown,"
    echo "then repeat emacspeak configuration"
    exit 1
fi

# skip the enrolling of additional users if there is already at least
# one user, and it's the initial installation
MEMBERS=`grep ^${DEVICEGROUP} $GROUPFILE|awk 'BEGIN{FS=":"}{print $4}'`
if [ "$MEMBERS" = "" -o $initial = no ];
then
    echo " "
    echo $PORT can be accessed by members of the group: $DEVICEGROUP.
    if [ "$MEMBERS" = "" ]; 
    then echo "Currently, no users are in group $DEVICEGROUP";
    else echo "Currently, these users are in group $DEVICEGROUP: $MEMBERS";
    fi
    finished=no
    while [ $finished = no ]; do
	echo " "
	echo "If you wish to enroll any other users into group $DEVICEGROUP,"
	echo "(even if their accounts have not been created yet),"
	echo -n "please list their usernames here separated by commas: "
	read USERS
	if [ "$USERS" = "" ] || enroll $USERS $DEVICEGROUP; then 
	    finished=yes; 
	fi
    done
    finished=no
    while [ $finished = no ]; do
	echo " "
	echo "If you wish to remove any users from group $DEVICEGROUP,"
	echo -n "please list their usernames here separated by commas: "
	read USERS
	if [ "$USERS" = "" ] || dismiss $USERS $DEVICEGROUP; then 
	    finished=yes; 
	fi
    done
fi

echo " "
echo "You may reconfigure emacspeak at any time by running emacspeakconfig as root"

# make sure the group has both read and write permissions
if [ -e "$PORT" ]; then chmod g+rw $PORT; fi

# update the configuration file    
sed -e "s@^ *DTK_PROGRAM=.*@  DTK_PROGRAM=$PROGRAM@" \
    -e "s@^ *DTK_PORT=.*@  DTK_PORT=$PORT@" \
    -e "s@^ *DTK_TCL=.*@  DTK_TCL=$TCL@" \
    -e "s@^ *DTK_DEVICE=.*@  DTK_DEVICE=\"$DEVICE\"@" \
    $CFG > $CFG.TMP && mv $CFG.TMP $CFG