Skip to content

Commit 3d3b7bd

Browse files
authored
Update comments
1 parent 6b20c54 commit 3d3b7bd

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

fastcgi_ops_root.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,23 @@ find_create_includedir() {
187187
fi
188188
else
189189
# We need to add @includedir or #includedir to main sudoers file
190+
190191
# --> Workflow <--
191-
# Create sudoers backup/tmp files
192-
# Modify sudoers tmp file according to sudo version
193-
# Create includedir path before test tmp via visudo
194-
# Test tmp before replacement with original
195-
# Replace original with tmp
196-
# Test original before remove backup, if we get error return from backup
197-
# Clean up tmp/backup
198-
# Assign custom_includedir to includedir
199-
200-
# Create sudoers backup/tmp files
192+
# 1. Create sudoers backup/tmp files
193+
# 2. Modify sudoers tmp file according to sudo version
194+
# 3. Create includedir path before testing tmp file via visudo
195+
# 4. Test tmp file before replacing the original sudoers file
196+
# 5. Replace the original sudoers file with the tmp file
197+
# 6. Test the updated sudoers file and restore from backup if there is an error
198+
# 7. Clean up tmp and backup files
199+
# 8. Assign custom_includedir to includedir
200+
201+
# 1. Create sudoers backup/tmp files
201202
cp "${SUDOERS_FILE}" "${TEMP_FILE}" || { echo -e "\e[91mFailed to create sudoers tmp file\e[0m"; return 1; }
202203
cp "${SUDOERS_FILE}" "${BACKUP_FILE}" || { echo -e "\e[91mFailed to create sudoers backup file\e[0m"; return 1; }
203204

204-
# Modify sudoers tmp file
205-
# Get the version of sudo that we need to find
206-
# accepted includedir syntax @ or # according to sudo version.
205+
# 2. Modify sudoers tmp file according to sudo version
206+
# Get the version of sudo to determine the correct includedir syntax (@ or #)
207207
SUDO_VERSION="$(sudo -V | grep 'Sudo version' | awk '{print $3}')"
208208
VERSION_MAJOR="$(echo "$SUDO_VERSION" | cut -d. -f1)"
209209
VERSION_MINOR="$(echo "$SUDO_VERSION" | cut -d. -f2)"
@@ -221,26 +221,26 @@ find_create_includedir() {
221221
echo "#includedir ${CUSTOM_INCLUDEDIR_PATH}" | sudo EDITOR='tee -a' visudo -f "${TEMP_FILE}" > /dev/null 2>&1 || { echo -e "\e[91mFailed to add includedir to sudoers file\e[0m"; return 1; }
222222
fi
223223

224-
# Create includedir path before test tmp via visudo
224+
# 3. Create includedir path before testing tmp file via visudo
225225
mkdir -p "${CUSTOM_INCLUDEDIR_PATH}" || { echo -e "\e[91mFailed to create /etc/sudoers.npp\e[0m"; return 1; }
226226

227-
# Test tmp before replacement with original
227+
# 4. Test tmp file before replacing the original sudoers file
228228
if visudo -c -f "${TEMP_FILE}" > /dev/null 2>&1; then
229-
# Replace original with tmp
229+
# 5. Replace the original sudoers file with the tmp file
230230
cp "${TEMP_FILE}" "${SUDOERS_FILE}" || { echo -e "\e[91mFailed to update sudoers file\e[0m"; return 1; }
231231
fi
232232

233-
# Test original before remove backup, if we get error return from backup
233+
# 6. Test the updated sudoers file and restore from backup if there is an error
234234
if ! visudo -c -f "${SUDOERS_FILE}" > /dev/null 2>&1; then
235235
cp "${BACKUP_FILE}" "${SUDOERS_FILE}" || { echo -e "\e[91mFailed to return from sudoers backup file\e[0m"; return 1; }
236236
return 1
237237
fi
238238

239-
# Clean up tmp/backup
239+
# 7. Clean up tmp and backup files
240240
rm -f "${TEMP_FILE:?}"
241241
rm -f "${BACKUP_FILE:?}"
242242

243-
# Assign custom_includedir to includedir
243+
# 8. Assign custom_includedir_path to includedir_path
244244
includedir_path="${CUSTOM_INCLUDEDIR_PATH}"
245245
fi
246246
else

0 commit comments

Comments
 (0)