Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for instal_api.sh to create symbolic link to htpasswd properly. #205

Merged
merged 2 commits into from
Oct 16, 2018

Conversation

druizz90
Copy link
Contributor

Hi team,

This PR is for issue #203. I updated install_api.sh script to create a symbolic link to /var/ossec/api/node_modules/htpasswd/bin/htpasswd properly.

Best regards,

Demetrio.

install_api.sh Outdated
exec_cmd "ln -s $API_PATH/node_modules/htpasswd/bin/htpasswd $API_PATH/configuration/auth/htpasswd"

# it is necessary to remove htpasswd in order to correctly create the symbolic link
if [ -e $API_PATH/configuration/auth/htpasswd ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [ -e some_file ]; then... returns true when the file some_file exists. This means that this file can be a regular file or a symbolic link. Reading issue #203, I guess that the API breaks when htpasswd becomes in a regular file instead of a symbolic link to $API_PATH/node_modules/htpasswd/bin/htpasswd.

So the proper check is if [ -f some_file ]; then...

install_api.sh Outdated
fi

exec_cmd "ln -s $API_PATH/node_modules/htpasswd/bin/htpasswd $API_PATH/configuration/auth/htpasswd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, you can avoid the check and the rm lines if you add the -f option to ln. This will overwrite the destination file:

ln -fs $API_PATH/node_modules/htpasswd/bin/htpasswd $API_PATH/configuration/auth/htpasswd

Copy link
Contributor

@BraulioV BraulioV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! 😄

@jesuslinares jesuslinares merged commit 7d0c2fc into 3.7 Oct 16, 2018
@jesuslinares jesuslinares deleted the fix-htpasswd branch October 16, 2018 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants