Skip to content

Commit

Permalink
Refactor: libcrmcommon: Drop pcmk__valid_script()
Browse files Browse the repository at this point in the history
Unused since 73a5d63.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
  • Loading branch information
nrwahl2 committed Mar 26, 2024
1 parent 057cd28 commit b1a5381
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
1 change: 0 additions & 1 deletion include/crm/common/options_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ bool pcmk__valid_int(const char *value);
bool pcmk__valid_positive_int(const char *value);
bool pcmk__valid_no_quorum_policy(const char *value);
bool pcmk__valid_percentage(const char *value);
bool pcmk__valid_script(const char *value);
bool pcmk__valid_placement_strategy(const char *value);

// from watchdog.c
Expand Down
37 changes: 0 additions & 37 deletions lib/common/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,43 +1313,6 @@ pcmk__valid_percentage(const char *value)
return ((end == NULL) || (end[0] == '%')) && (number >= 0);
}

/*!
* \internal
* \brief Check whether a string represents a valid script
*
* Valid values include \c /dev/null and paths of executable regular files
*
* \param[in] value String to validate
*
* \return \c true if \p value is a valid script, or \c false otherwise
*/
bool
pcmk__valid_script(const char *value)
{
struct stat st;

if (pcmk__str_eq(value, "/dev/null", pcmk__str_none)) {
return true;
}

if (stat(value, &st) != 0) {
crm_err("Script %s does not exist", value);
return false;
}

if (S_ISREG(st.st_mode) == 0) {
crm_err("Script %s is not a regular file", value);
return false;
}

if ((st.st_mode & (S_IXUSR | S_IXGRP)) == 0) {
crm_err("Script %s is not executable", value);
return false;
}

return true;
}

/*!
* \internal
* \brief Check whether a string represents a valid placement strategy
Expand Down

0 comments on commit b1a5381

Please sign in to comment.