ClusterLabs / ClusterLabs/resource-agents
Tempfiles should always be created using mktemp, not using PID or hard-coded filenames
- Dominant language
- Shell
- Stars
- 519
- Forks
- 608
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 7
Description
This was flagged by the SUSE security team:
There are various problems with tmp-races. Some of them may be used
for LPE:
sapdb-nosha.sh:
```
143 oracle_stop() {
144 echo '#!/bin/sh
145 LOG=$HOME/stopdb.log
146 date > $LOG
147
148 if [ -x "${ORACLE_HOME}/bin/sqlplus" ]
149 then
150 SRVMGRDBA_EXE="${ORACLE_HOME}/bin/sqlplus"
151 else
152 echo "Can not find executable sqlplus" >> $LOG
153 exit 1
154 fi
155
156 $SRVMGRDBA_EXE /NOLOG >> $LOG << !
157 connect / as sysdba
158 shutdown immediate
159 exit
160 !
161 rc=$?
162 cat $LOG
163 exit $rc' > $TEMPFILE
164
165 chmod 700 $TEMPFILE
166 chown $sidadm $TEMPFILE
167
168 su - $sidadm -c $TEMPFILE
...
743 TEMPFILE="/tmp/SAPDatabase.$$.tmp"
```
and more occurrences of this.
mysql:
```
987 DEBUG_LOG="/tmp/mysql.ocf.ra.debug/log"
988 if [ "${DEBUG_LOG}" -a -w "${DEBUG_LOG}" -a ! -L "${DEBUG_LOG}" ]; then
989 DEBUG_LOG_DIR="${DEBUG_LOG%/*}"
990 if [ -d "${DEBUG_LOG_DIR}" ]; then
991 exec 9>>"$DEBUG_LOG"
992 exec 2>&9
993 date >&9
994 echo "$*" >&9
995 env | grep OCF_ | sort >&9
996 set -x
997 else
998 exec 9>/dev/null
999 fi
1000 fi
```
ClusterMon:
```
235 : ${OCF_RESKEY_update:="15000"}
236 : ${OCF_RESKEY_pidfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
237 : ${OCF_RESKEY_htmlfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
```
All these should better use mktemp.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the temporary-file handling in sapdb-nosha.sh, the mysql resource agent, and ClusterMon, then search the repository for similar PID-based or hard-coded paths under /tmp. Confirm that each affected path uses secure temporary-file creation without changing the agents’ existing behavior, and run the relevant resource-agent checks available in the repository.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100