This file is indexed.

/usr/bin/globus-personal-gatekeeper is in globus-gram-job-manager 13.14-5.

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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#!/bin/sh

# 
# Copyright 1999-2006 University of Chicago
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 


PACKAGE=globus_gram_job_manager
VERSION=13.14
DIRT_TIMESTAMP=1028570784
DIRT_BRANCH_ID=23

if test -n "${GLOBUS_LOCATION}" ; then
    prefix="${GLOBUS_LOCATION}"
else
    prefix="/usr"
fi

exec_prefix="${prefix}"
sbindir="${exec_prefix}/sbin"
bindir="${exec_prefix}/bin"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include/globus"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
libexecdir="${datadir}/globus"
sysconfdir="/etc"
sharedstatedir="/var/lib"
localstatedir="/var"
aclocaldir="${datadir}/globus/aclocal"

. ${libexecdir}/globus-script-initializer

globus_source ${libexecdir}/globus-sh-tools.sh

short_usage="globus-personal-gatekeeper [-help] [-start] [-list] [-killall] ..."

long_usage ()
{
    ${GLOBUS_SH_CAT-cat} >&2 <<EOF

Syntax: globus-personal-gatekeeper [options]

    [options]
    -help
    -usage
    Displays usage

    -version
    Displays version

    -debug
    Displays extra output

    -start [-jmtype <type>] [-auditdir <dir>] [-port <port>] [-log[=DIRECTORY]] [-seg] [-acctfile file]
    Starts a new gatekeeper, mapping default service to a
    jobmanager. By default, the jobmanager is configured with
    jmtype=fork. The option -port can be used to restrict the
    gatekeeper to use a particular port. The default is to let the
    system choose a port. The -log switch causes the job manager
    to write log messages to files in DIRECTORY.
    If -seg is used, then the Scheduler Event Generator will be used to 
    poll job state. The -auditdir switch tells the jobmanager where
    to store the audit-records. The -acctfile switch tells the gatekeeper
    where to log accounting records.

    -list
    Scans for active personal gatekeepers. If found, an
    authentication test is made to determine if the gatekeeper is
    still functioning.  If the authentictation test succeeds, the
    contact to that gatekeeper is printed out.

    -directory <contact>
    Returns the temporary directory used by the personal
    gatekeeper associated with <contact>. The directory contains
    grid-mapfile, log file, etc.

    -kill <contact>
    Finds and kills the personal gatekeeper associated with
    <contact>.

    -killall
    Finds all personal gatekeepers running on the local host and
    kills them.

EOF
}


globus_source ${libexecdir}/globus-args-parser-header $*

debug=:

verify_setup ()
{
    hours=""
    ${debug} "verifying setup..."

    if test "$1" != 'kill'; then
        hours="-hours 1"
    fi
    ${bindir}/grid-proxy-info -exists $hours
    
    if [ $? -ne 0 ]; then
        echo "ERROR: no valid proxy, or lifetime to small (one hour)" >&2
        exit 1
    fi

    ${debug} "done."
}


get_jm_arg_value()
{
    desired="$1"
    shift

    while [ "$#" -gt 0 ]; do
        if [ "$1" = "$desired" ]; then
            echo "$2"
            break
        fi
        shift;
    done
}

killem ()
{
    found=false
    foundit=false

    if test -z "${GLOBUS_SH_WHOAMI}"; then
	if test -z "${LOGNAME}"; then
	    user=$USER
	else
	    user=$LOGNAME
	fi
    else
	user=`${GLOBUS_SH_WHOAMI}`
    fi
    for dir in `ls -1d ${file_location}/${file_prefix}* 2> /dev/null`
    do
        if [ -n "${dir}" ]; then
            found=true
            if [ -r ${dir}/gatekeeper.log ]; then
                contact="`${GLOBUS_SH_GREP-grep} 'GRAM contact' ${dir}/gatekeeper.log |
                    ${GLOBUS_SH_TAIL-tail} -1 |
                    ${GLOBUS_SH_SED-sed} 's/^.*GRAM contact: //'`"
                ${debug} "found contact= [${contact}]"
            fi

            dokill=false
            if [ -z "$1" ]; then
                dokill=true
            else
                if [ "$1" = "$contact" ]; then
                    dokill=true
                    foundit=true
                fi
            fi

            if [ $dokill = true ]; then

                echo "killing gatekeeper: \"${contact}\""
                if [ -r ${dir}/gatekeeper.pid ]; then
                    pid=`${GLOBUS_SH_CAT-cat} ${dir}/gatekeeper.pid`
                    ${GLOBUS_SH_KILL-kill} -9 $pid &
                fi
                cd
		statedir="${TMPDIR:-/tmp}/${user}/`echo \"${dir}\" | sed -e 's|.*/||'`"
                if [ -r ${dir}/jobmanager.conf ]; then
                    host=`${bindir}/globus-hostname | ${GLOBUS_SH_CUT-cut} -d. -f1`
                    args=`cat "${dir}/jobmanager.conf"`
                    service_tag="`eval get_jm_arg_value -service-tag $args`"
                    if [ "$service_tag" = "" ]; then
                        service_tag=untagged
                    fi
                    lrm="`eval get_jm_arg_value -type $args`"
                    tagged="$HOME/.globus/job/$host/$lrm.$service_tag"
                    pidfile="$tagged.pid"
                    sockfile="$tagged.sock"
                    lockfile="$tagged.lock"
                    credfile="$tagged.cred"
                    jmpid=""
                    if [ -r "$pidfile" ]; then
                        read jmpid < "$pidfile"
                    fi
                    if [ "$jmpid" != "" ]; then
                        kill $jmpid
                    fi
                    [ -e "$pidfile" ] && ${GLOBUS_SH_RM-rm} "$pidfile"
                    [ -e "$sockfile" ] && ${GLOBUS_SH_RM-rm} "$sockfile"
                    [ -e "$lockfile" ] && ${GLOBUS_SH_RM-rm} "$lockfile"
                    [ -e "$credfile" ] && ${GLOBUS_SH_RM-rm} "$credfile"
                fi

                ${GLOBUS_SH_RM-rm} -rf ${dir} &
		${GLOBUS_SH_RM-rm} -rf "${statedir}" &
            fi
        fi
    done

    if [ $found = false ]; then
        echo "No personal gatekeepers found on this host."
    fi

    if [ -n "$1" -a ${foundit} = false ]; then
        echo "Could not find the personal gatekeeper you specified."
    fi
}


findit ()
{
    foundit=false
    for dir in `ls -1d ${file_location}/${file_prefix}* 2>/dev/null`
    do
        if [ -n "${dir}" ]; then
            found=true
            if [ -r ${dir}/gatekeeper.log ]; then
                contact="`${GLOBUS_SH_GREP-grep} 'GRAM contact' ${dir}/gatekeeper.log |
                    ${GLOBUS_SH_TAIL-tail} -1 |
                    ${GLOBUS_SH_SED-sed} 's/^.*GRAM contact: //'`"

                if [ "$1" = "$contact" ]; then
                    foundit=true
                    echo "${dir}"
                fi
            fi
        fi
    done

    if [ ${foundit} = false ]; then
        echo "Could not find the personal gatekeeper you specified."
    fi
}


listem ()
{
    found=false
    foundold=false
    for dir in `ls -1d ${file_location}/${file_prefix}* 2> /dev/null`
    do
        if [ -n "${dir}" ]; then
            found=true
            if [ -r ${dir}/gatekeeper.log ]; then
                contact="`${GLOBUS_SH_GREP-grep} 'GRAM contact' ${dir}/gatekeeper.log |
                    ${GLOBUS_SH_TAIL-tail} -1 |
                    ${GLOBUS_SH_SED-sed} 's/^.*GRAM contact: //'`"
                ${debug} "found contact= [${contact}]"
                ${bindir}/globusrun -a -r "${contact}" 1>/dev/null 2>/dev/null
                if [ $? -eq 0 ]; then
                    echo "${contact}"
                else
                    ${debug} "could not authenticate to the contact -- old"
                    foundold=true
                fi
            fi
        fi
    done

    if [ $found = false ]; then
        echo ""
        echo "no personal gatekeepers found on this host"
    fi

    if [ $foundold = true ]; then
        echo ""
        echo "Found old non-functioning personal gatekeeper(s). Please use"
        echo "this command with the -killall option to clean them up."
    fi
}


cleanup ()
{
    if [ ${docleanup} = true ]; then
        ${GLOBUS_SH_RM-rm} -rf ${scratch}
        ${GLOBUS_SH_RM-rm} -rf ${statefiledir}
        docleanup=false
    fi
}



jmtype=fork
port=
docleanup=false
startnew=false
host=`${bindir}/globus-hostname| ${GLOBUS_SH_CUT-cut} -d. -f1`
file_location="$HOME/.globus/."
file_prefix="gram.$host"
log=never
seg=0
startargs=''
single=''
logdir=""
valgrind=0

while [ -n "$1" ]; do
    case "$1" in
    -kill)
    verify_setup kill
    killem "$2"
    exit 0
    ;;
    -killall)
    verify_setup kill
    killem ""
    exit 0
    ;;
    -list)
    listem
    exit 0
    ;;
    -directory)
    findit "$2"
    exit 0
    ;;
    -start)
    startnew=true
    shift
    while [ -n "$1" ]; do
        case $1 in
	    -jmtype)
		jmtype="$2"
		shift
		;;
	-log*)
                logdir=`expr "$1" : "-log=\(.*\)"`
                if [ "$logdir" = "" ]; then
                    logdir="$HOME"
                fi
		;;
        -single)
                single="$1"
                ;;
        -valgrind)
                valgrind=1
                ;;
	-port)
		port="$2"
		shift
		;;
        -seg)
                seg=1
                ;;
	-auditdir)
                auditdir="$2"
                shift
                ;;
        -acctfile)
                acctfile="$2"
                shift;
                ;;
        *)
		startargs="$startargs $1"
		;;
	esac
	shift
    done
    break
    ;;
    -debug)
    debug=echo
    ;;
    *)  
    globus_args_unrecognized_option "$1"
    ;;
    esac
    shift
done

if [ $startnew != true ]; then
    globus_args_short_usage
    exit 1
fi

if test -z "${GLOBUS_SH_WHOAMI}"; then
    if test -z "${LOGNAME}"; then
        user=$USER
    else
        user=$LOGNAME
    fi
else
    user=`${GLOBUS_SH_WHOAMI}`
fi

if test -z "${user}"; then
    echo "ERROR: globus-personal-gatekeeper: can not determine user name" >&2
    exit 1
fi

verify_setup

scratch="${file_location}/${file_prefix}.$$"
statefiledir="${TMPDIR:-/tmp}/${user}/${file_prefix}.$$"

trap cleanup 0 1 2 3 6 9 12 15


docleanup=true
${GLOBUS_SH_MKDIR-mkdir} -p ${scratch}
${GLOBUS_SH_MKDIR-mkdir} -p "${statefiledir}"

if test $? != 0; then
    echo "Error making state file dir (${statefiledir})." 1>&2
    exit 1
fi

for file in gridmap services.conf gatekeeper.conf jobmanager.conf gatekeeper.log ; do
    ${GLOBUS_SH_RM-rm} -f ${scratch}/${file}
done

subject=`${bindir}/grid-proxy-info -identity`

${GLOBUS_SH_CAT-cat} > ${scratch}/gridmap <<EOF
"${subject}" ${user}
EOF

if [ $valgrind -eq 1 ]; then
    valgrind=`which valgrind`
    if [ $? -ne 0 ]; then
        echo "Error: can't find valgrind" 1>&2
        exit 1
    fi
${GLOBUS_SH_CAT-cat} > ${scratch}/jobmanager <<EOF
stderr_log,local_cred - $valgrind valgrind --leak-check=full --leak-resolution=high --show-reachable=yes --log-file=${HOME}/valgrind.%p.log ${sbindir}/globus-job-manager -conf ${scratch}/jobmanager.conf
EOF
else
${GLOBUS_SH_CAT-cat} > ${scratch}/jobmanager <<EOF
stderr_log,local_cred - ${sbindir}/globus-job-manager globus-job-manager -conf ${scratch}/jobmanager.conf
EOF
fi

${GLOBUS_SH_CAT-cat} > ${scratch}/gatekeeper.conf <<EOF
-gridmap ${scratch}/gridmap
-home ${GLOBUS_LOCATION:-${prefix}}
-e ${sbindir}
-logfile ${scratch}/gatekeeper.log
-grid_services ${scratch}
-d 
EOF

if [ -n "$port" ]; then
    echo "-port $port" >> ${scratch}/gatekeeper.conf
fi

if [ ! -z "${acctfile}" ]; then
    echo "-acctfile $acctfile" >> ${scratch}/gatekeeper.conf
fi


host_info=`${libexecdir}/config.guess`
host_cputype=`echo $host_info | ${GLOBUS_SH_AWK-awk} -F'-' '{print $1}'`
host_manufacturer=`echo $host_info | ${GLOBUS_SH_AWK-awk} -F'-' '{print $2}'`
host_osname=`${GLOBUS_SH_UNAME-uname} -s`
host_osversion=`${GLOBUS_SH_UNAME-uname} -r`
if [ "$logdir" != "" ]; then
    log_line=`echo "-stdio-log \"$logdir\""`
    log_levels="-log-levels 'FATAL|ERROR'"
fi

if [ -x "${bindir}/globus-version" ]; then
  globus_toolkit_version="`${bindir}/globus-version`"
else
  globus_toolkit_version="Unknown"
fi

${GLOBUS_SH_CAT-cat} > ${scratch}/jobmanager.conf <<EOF
-home ${GLOBUS_LOCATION:-${prefix}}
-type ${jmtype}
-globus-gatekeeper-subject "${subject}"
-globus-host-cputype ${host_cputype}
-globus-host-manufacturer ${host_manufacturer}
-globus-host-osname ${host_osname}
-globus-host-osversion ${host_osversion}
$log_line
$log_levels
-state-file-dir ${statefiledir}
${startargs}
$single
${X509_CERT_DIR:+-x509-cert-dir "$X509_CERT_DIR"}
-globus-toolkit-version "$globus_toolkit_version"
-service-tag "${file_prefix}.$$"
EOF


if [ ! -z "${auditdir}" ]; then
    ${GLOBUS_SH_CAT-cat} >> ${scratch}/jobmanager.conf <<EOF
-audit-directory ${auditdir}
EOF
fi

if test $seg -eq 1; then
    echo "-seg-module $jmtype" >> ${scratch}/jobmanager.conf
fi

echo "-globus-job-dir ${TMPDIR:-/tmp}/${LOGNAME}/" >> ${scratch}/jobmanager.conf

docleanup=false
 
${sbindir}/globus-gatekeeper -c ${scratch}/gatekeeper.conf -test \
    1>/dev/null 2>/dev/null
x=$?
if [ $x -ne 0 ]; then
    echo "ERROR: gatekeeper was not properly configured" >&2
    docleanup=true
    exit 1
fi

${sbindir}/globus-gatekeeper -c ${scratch}/gatekeeper.conf < /dev/null > /dev/null 2>/dev/null  &
x=$?
pid=$!
if [ $x -ne 0 ]; then
    echo "ERROR: gatekeeper did not start up properly" >&2
    docleanup=true
    exit 1
fi
echo "$pid" > ${scratch}/gatekeeper.pid

contact=
shallexit=
count=0
while [ ${count} -lt 10 -a -z "${contact}" -a -z "${shallexit}" ]; do
    ${GLOBUS_SH_SLEEP-sleep} 1
    contact="`${GLOBUS_SH_GREP-grep} 'GRAM contact' ${scratch}/gatekeeper.log`"
    shallexit="`${GLOBUS_SH_GREP-grep} FAILED_PLEASE_EXIT ${scratch}/gatekeeper.log`"
    count=`${GLOBUS_SH_EXPR-expr} ${count} + 1`
done

if [ ${count} -ge 10 -o -n "${shallexit}" ]; then
    echo "ERROR: gatekeeper did not start up properly" >&2
    docleanup=true
    exit 1
else
    host=`echo "$contact" | ${GLOBUS_SH_CUT-cut} -d: -f5`
    port=`echo "$contact" | ${GLOBUS_SH_CUT-cut} -d: -f6`

    ${GLOBUS_SH_CAT-cat} >> ${scratch}/jobmanager.conf <<EOF
-globus-gatekeeper-host $host
-globus-gatekeeper-port $port
EOF
    echo "$contact" | ${GLOBUS_SH_SED-sed} -e 's/^.*GRAM contact:/GRAM contact:/'
fi


exit 0