This file is indexed.

/etc/pcp.env is in pcp 4.0.1-1.

This file is owned by root:root, with mode 0o644.

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
#
# Copyright (c) 2000,2003 Silicon Graphics, Inc.  All Rights Reserved.
# Copyright (c) 2010 Aconex.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# This file is sourced by PCP scripts to set the environment
# variables defined in the file named $PCP_CONF (or /etc/pcp.conf
# if $PCP_CONF is not defined). Any variable already defined in
# the environment is not changed. 
#
# Note: any variables NOT starting with PCP_ will be ignored.
# This is a security issue so don't change it.
# Note also, this (variant of this) file is not used on Windows.
#
if [ -z "$PCP_ENV_DONE" ]
then
    if [ -n "$PCP_CONF" ]
    then
	__CONF="$PCP_CONF"
    elif [ -n "$PCP_DIR" ]
    then
	__CONF="$PCP_DIR/etc/pcp.conf"
    else
	__CONF=/etc/pcp.conf
    fi
    if [ ! -f "$__CONF" ]
    then
	echo "pcp.env: Fatal Error: \"$__CONF\" not found" >&2
	exit 1
    fi
    eval `sed -e 's/"//g' $__CONF \
    | awk -F= '
/^PCP_/ && NF == 2 {
	    exports=exports" "$1
	    printf "%s=${%s:-\"%s\"}\n", $1, $1, $2
	}
END	{ print "export", exports }'`

    # prevent doing all of this more than once per process ...
    #
    export PCP_ENV_DONE=y
fi

# Always need to set $PATH ... sudo -E leaves $PCP_ENV_DONE set, but
# clears/resets $PATH.  Note that order is important: any paths with
# PCP-specific binaries should end up ahead of more generic paths in
# the final $PATH to avoid conflicts on names of non-pcp binaries.
#
for dir in ${PCP_BIN_DIR} ${PCP_BINADM_DIR} \
	${PCP_SHARE_DIR}/bin ${PCP_PLATFORM_PATHS}
do
    if [ -d $dir ]
    then
	if echo ":$PATH:" | grep ":$dir:" >/dev/null 2>&1
	then
	    :
	else
	    PATH="$dir:$PATH"
	fi
    fi
done
export PATH

# Also need to always do this because it may be resetting things
# that sudo has cleared from the environment, e.g. PERL5LIB
#
# Optionally augment or over-ride settings with per-user configuration
#
if [ -f $HOME/.pcp/pcp.conf ]
then
    eval `sed -e 's/"//g' -e '/^#/d' $HOME/.pcp/pcp.conf \
    | awk -F= '
NF == 2 {
	exports=exports" "$1
	printf "%s=${%s:-\"%s\"}\n", $1, $1, $2
    }
END	{ print "export", exports }'`
fi

# Find PIDs by matching the name ($1)
# Executable alias name avoidance algorithm ...
# - if name contains a / use it literally and consider nothing else
# - if name matches an executable in $PCP_BIN_DIR, use that full pathname
# - if name matches an executable in $PCP_BINADM_DIR, use that full pathname
# - if find(1) can locate name on this week's $PATH, use that full pathname
# - if name matches an executable in $PCP_BIN_DIR and/or $PCP_BINADM_DIR
#   and/or find(1) matches name, use _all_ of the pathnames in the order
#   above (needed e.g. for pmlogger in $PCP_BIN_DIR and symlink in
#   $PCP_BINADM_DIR)
# - if -a is specified also match on /name (this was the original behaviour
#   before the pathname matching was added)
# - otherwise use name as is
#
_get_pids_by_name()
{
    if [ $# -eq 2 -a "X$1" = X-a ]
    then
	__all=true
	shift
    else
	__all=false
    fi
    if [ $# -ne 1 ]
    then
	echo "Usage: _get_pids_by_name [-a] process-name" >&2
	exit 1
    fi
    if [ "X$tmp" = X ]
    then
	echo "_get_pids_by_name requires a \$tmp setting" >&2
	exit 1
    elif [ -d "$tmp" ]
    then
	__tmp="$tmp/pcp.env"	# from mktemp
    else
	__tmp=$tmp.pcp.env	# from PCP QA
    fi

    __name="$1"
    rm -f $__tmp.*
    touch $__tmp.path
    case "$1"
    in
	*/*)
	    rm -f $__tmp.path
	    ;;
	*)
	    if [ -n "$PCP_BIN_DIR" -a -x "$PCP_BIN_DIR/$1" ]
	    then
		if ! grep "$PCP_BIN_DIR/$1" $__tmp.path >/dev/null
		then
		    echo "$PCP_BIN_DIR/$1" >>$__tmp.path
		fi
	    fi
	    if [ -n "$PCP_BINADM_DIR" -a -x "$PCP_BINADM_DIR/$1" ]
	    then
		if ! grep "$PCP_BINADM_DIR/$1" $__tmp.path >/dev/null
		then
		    echo "$PCP_BINADM_DIR/$1" >>$__tmp.path
		fi
	    fi
	    __which="`which "$1" 2>/dev/null`"
	    if [ -n "$__which" ]
	    then
		if ! grep "$__which" $__tmp.path >/dev/null
		then
		    echo "$__which" >>$__tmp.path
		fi
	    fi
	    ;;
    esac

    # Algorithm ... all ps(1) variants have a time of the form MM:SS
    # or HH:MM:SS or HH:MM.SS before the psargs field, so we're using
    # this as the search anchor.
    #
    # Matches with $1 (process-name) occur if the first psarg is one
    # of the paths identified above or ends in /$1 (if -a specified)
    # or starts ($1) (blame Mac OS X for the last one)
    # ... the matching uses sed's regular expressions, so passing a
    # regex into $1 will work.

    # some preprocessing to condition the ps(1) output lines
    #
    cat <<End-of-File >$__tmp.sed
s/$/ /
s/[ 	][ 	]*/ /g
s/^ //
s/^[^ ]* //
End-of-File
    if [ -f $__tmp.path ]
    then
	# not a literal use of $1, at least one matching pathname found
	#
	sed <$__tmp.path >>$__tmp.sed \
	    -e 's/\//\\\//g' \
	    -e 's/.*/\/[0-9][:\\.][0-9][0-9]  *& \/s\/ .*\/\/p/'
    fi
    # optionally add -a case
    #
    if $__all
    then
	echo "$1" | sed >>$__tmp.sed \
	    -e 's/\//\\\//g' \
	    -e 's/.*/\/[0-9][:\\.][0-9][0-9]  *[^ ]*\\\/& \/s\/ .*\/\/p/'
    fi
    # add literal cases
    #
    # exact match
    echo "$1" | sed >>$__tmp.sed \
	-e 's/\//\\\//g' \
	-e 's/.*/\/[0-9][:\\.][0-9][0-9]  *& \/s\/ .*\/\/p/'
    # Mac OS X variant
    echo "$1" | sed >>$__tmp.sed \
	-e 's/\//\\\//g' \
	-e 's/.*/\/[0-9][:\\.][0-9][0-9]  *(&) \/s\/ .*\/\/p/'

    # need to sort in case of multiple matches from the sed(1) patterns
    #
    $PCP_PS_PROG $PCP_PS_ALL_FLAGS \
    | sed -n -f $__tmp.sed \
    | sort -n -u
    rm -f $__tmp.*
}

# Redundant now ... use _get_pids_by_name -a ...
# Maintained here for backwards compatibility.
#
_get_pids_by_args()
{
    if [ $# -lt 1 ]
    then
	echo "Usage: _get_pids_by_args process-name [args...]" >&2
	exit 1
    fi
    # Matches on command and its arguments ... note escaping any / in
    # the process name happens in _get_pids_by_name()
    #
    _get_pids_by_name -a "$@"
}