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

LB-64, Add TLS support #85

Closed
wants to merge 2 commits into from

Conversation

@Shwetajain148
Copy link
Contributor

@Shwetajain148 Shwetajain148 commented Feb 14, 2017

No description provided.

@Shwetajain148 Shwetajain148 deleted the Shwetajain148:Add-TLS-Support branch Feb 14, 2017
@Shwetajain148 Shwetajain148 restored the Shwetajain148:Add-TLS-Support branch Feb 14, 2017
@Shwetajain148 Shwetajain148 reopened this Feb 14, 2017
@Shwetajain148 Shwetajain148 changed the title Add tls support LB-64, Add TLS support Feb 14, 2017
@mchaudhary
Copy link
Contributor

@mchaudhary mchaudhary commented Feb 16, 2017

@Shwetajain148 next time if you want to change the formatting please do it in separate PR. It is very hard to review the code.

@Shwetajain148 Shwetajain148 force-pushed the Shwetajain148:Add-TLS-Support branch from 6704dd1 to 81b1606 Feb 16, 2017
@Shwetajain148
Copy link
Contributor Author

@Shwetajain148 Shwetajain148 commented Feb 16, 2017

@mchaudhary @mostlyjason This PR consists of two commits.
1- Fix formatting
2- Add TLS Support to the script to send logs securely

In the first commit, I have fixed the indentation. You can see the tab changes here: Fix Indentation

In second commit you can compare the actual file changes to support TLS. Please go through link here: Add TLS Support to the script to send logs securely

echo "DOWNLOADING CERTIFICATE"
mkdir -pv /etc/rsyslog.d/keys/ca.d
curl -O https://logdog.loggly.com/media/logs-01.loggly.com_sha12.crt
sudo cp -Prf logs-01.loggly.com_sha12.crt /etc/rsyslog.d/keys/ca.d/logs-01.loggly.com_sha12.crt

This comment has been minimized.

@mostlyjason

mostlyjason Feb 16, 2017
Contributor

DOn't forget to clean up the local directory when done

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

@mostlyjason Done.

@@ -215,18 +219,23 @@ removeLogglyConf()
case "$LINUX_DIST_IN_LOWER_CASE" in
*"ubuntu"* )
echo "INFO: Operating system is Ubuntu."
PKG_MGR="apt-get"

This comment has been minimized.

@mostlyjason

mostlyjason Feb 16, 2017
Contributor

What are these for?

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

@mostlyjason : In the case of Rsyslog version 7, we need to install rsyslog-gnutls package. So I have initialised the package manager variable for each Linux distribution. Please refer: Line-554

This comment has been minimized.

@mostlyjason

mostlyjason Feb 21, 2017
Contributor

Ok thanks

# -------------------------------------------------------
# Define the template used for sending logs to Loggly. Do not change this format.
\$template LogglyFormat,\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [$2@$3] %msg%\n\"
\$template LogglyFormat,\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [$LOGGLY_AUTH_TOKEN@$LOGGLY_DISTRIBUTION_ID tag=\\\"Rsyslog\\\"] %msg%\n\"

This comment has been minimized.

@mostlyjason

mostlyjason Feb 16, 2017
Contributor

Let's use the tag from the tls documentation

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

This tag is in the non-tls configuration. I have used the same tag "RsyslogTLS" for the TLS configurations as mentioned in the tls doc. See Tls configurations here: 7-Conf 8+Conf

exit 1
fi
#This script needs to be run as root
if [[ $EUID -ne 0 ]]; then

This comment has been minimized.

@mostlyjason

mostlyjason Feb 16, 2017
Contributor

What was wrong with the formatting of the indents before? I noticed that you are changing it but is there any particular reason?

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

@mostlyjason Formatting is done by IntelliJ IDE automatically. If you want then I can revert it back to the previous indentation and will only raise PR with actual file changes.

)
# Send messages to Loggly over TCP using the template.
action(type=\"omfwd\" protocol=\"tcp\" target=\"$LOGS_01_HOST\" port=\"$LOGGLY_SYSLOG_TLS_PORT\" template=\"LogglyFormat\" StreamDriver=\"gtls\" StreamDriverMode=\"1\" StreamDriverAuthMode=\"x509/name\" StreamDriverPermittedPeers=\"*.loggly.com\")
"

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

These are the TLS configurations for Rsyslog version 7- and 8+. If user sets up for Non-TLS logging then inputStr_NO_TLS will be installed.

SUPPRESS_PROMPT="true"
;;
--insecure )
LOGGLY_TLS_SENDING="false"

This comment has been minimized.

@Shwetajain148

Shwetajain148 Feb 20, 2017
Author Contributor

Command line parameter to setup non-tls sending.

logMsgToConfigSysLog "INFO" "INFO: Initiating Configure Loggly for Linux."

if [ "$LINUX_ENV_VALIDATED" = "false" ]; then
checkLinuxLogglyCompatibility

This comment has been minimized.

@psquickitprageet

psquickitprageet Feb 21, 2017

@Shwetajain148: This statement should appear inside the IF block. Make the same change at all the places where this kind of indentation problem is present.

@Shwetajain148 Shwetajain148 force-pushed the Shwetajain148:Add-TLS-Support branch 2 times, most recently from 674792d to b87a32d Feb 23, 2017
@Shwetajain148 Shwetajain148 force-pushed the Shwetajain148:Add-TLS-Support branch from b87a32d to b2c917d Mar 2, 2017
@Shwetajain148
Copy link
Contributor Author

@Shwetajain148 Shwetajain148 commented Mar 2, 2017

@mchaudhary @mostlyjason Please review the script.

  • Added the TLS Support.
  • Implemented the port accessibility for port 6514 by default
  • If the user adds the --insecure in his command then the accessibility of port 514 will be checked
curl -O https://logdog.loggly.com/media/logs-01.loggly.com_sha12.crt
sudo cp -Prf logs-01.loggly.com_sha12.crt /etc/rsyslog.d/keys/ca.d/logs-01.loggly.com_sha12.crt
sudo rm logs-01.loggly.com_sha12.crt
}

This comment has been minimized.

@mostlyjason

mostlyjason Mar 8, 2017
Contributor

Can we log an error message if the certificate cannot be downloaded?

This comment has been minimized.

@mostlyjason

mostlyjason Mar 8, 2017
Contributor

@Shwetajain148 sorry I had this review in pending for several days and forgot to submit it

"
"
if [ "$RSYSLOG_VERSION_TMP" -le "7" ]; then
/bin/bash -c "sudo $PKG_MGR install rsyslog-gnutls -y"

This comment has been minimized.

@mostlyjason

mostlyjason Mar 8, 2017
Contributor

Can we log an error message if the package installation fails?

This comment has been minimized.

@Shwetajain148

Shwetajain148 Mar 9, 2017
Author Contributor

@mostlyjason Added the error message. Please review.

This comment has been minimized.

@mostlyjason

mostlyjason Mar 9, 2017
Contributor

Will this also pass if the package has been previously installed and they are running the script again?

This comment has been minimized.

@mchaudhary

mchaudhary Mar 9, 2017
Contributor

Yes that should work. I will let @Shwetajain148 comment and then merge this tomorrow morning.

This comment has been minimized.

@Shwetajain148

Shwetajain148 Mar 10, 2017
Author Contributor

@mchaudhary @mostlyjason Yes. In the case of already installed package, when script will try to install it, will get the following output:

"rsyslog-gnutls is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 47 not upgraded."

And then the script will go for the next steps.

This comment has been minimized.

@mostlyjason

mostlyjason Mar 10, 2017
Contributor

Okay great

then
logMsgToConfigSysLog "ERROR" "ERROR: The rsyslog-gnutls package was not downloaded. Please download it and then run the script again."
exit 1
fi

This comment has been minimized.

@Shwetajain148

Shwetajain148 Mar 9, 2017
Author Contributor

@mostlyjason I could observe that TLS logging requires the rsyslog-gnutls package in case of rsyslog version 8 as well. Otherwise, logging didn't work.
Also, I have added the error message in case package doesn't install successfully.

This comment has been minimized.

@mostlyjason

mostlyjason Mar 9, 2017
Contributor

Okay please test on all the various distributions as well

logMsgToConfigSysLog "ERROR" "ERROR: Certificate could not be downloaded."
exit 1
fi
}

This comment has been minimized.

@Shwetajain148

Shwetajain148 Mar 9, 2017
Author Contributor

@mostlyjason I have added the error message in the case when the certificate could not be found.

@mostlyjason
Copy link
Contributor

@mostlyjason mostlyjason commented Mar 10, 2017

@mchaudhary I believe she has addressed all my comments so please merge whenever you're ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.