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

Fix deb/rpm integTest not install distribution correctly due to 2.12 security changes #4376

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ RUN apt-get install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
6 changes: 2 additions & 4 deletions src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ def install(self, bundle_name: str) -> None:
logging.info("deb installation requires sudo, script will exit if current user does not have sudo access")
deb_install_cmd = " ".join(
[
'sudo',
'env',
'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!',
'&&',
'sudo',
'dpkg',
'--purge',
self.filename,
'&&',
'sudo',
'env',
'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!',
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@gaiksaya versions less than 2.12.0 will not get affected at all.
Because they dont even care about this env var.

'dpkg',
'--install',
bundle_name,
Expand Down
6 changes: 2 additions & 4 deletions src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ def install(self, bundle_name: str) -> None:
logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access")
rpm_install_cmd = " ".join(
[
'sudo',
'env',
'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!',
'&&',
'sudo',
'yum',
'remove',
'-y',
self.filename,
'&&',
'sudo',
'env',
'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!',
'yum',
'install',
'-y',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def test_install(self, check_call_mock: Mock) -> None:
self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual(
(
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && "
"sudo dpkg --purge opensearch && "
"sudo dpkg --install opensearch.deb && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"dpkg --install opensearch.deb && "
f"sudo chmod 0666 {self.distribution_deb.config_path}"
),
args_list[0][0][0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def test_install(self, check_call_mock: Mock) -> None:
self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual(
(
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && "
"sudo yum remove -y opensearch && "
"sudo yum install -y opensearch.rpm && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"yum install -y opensearch.rpm && "
f"sudo chmod 0666 {self.distribution_rpm.config_path}"
),
args_list[0][0][0],
Expand Down
Loading