Skip to content

Commit 14be193

Browse files
ShashikanthRaoTGitHub Enterprise
authored andcommitted
Fix htpassword update logic (#547)
* Fix htpassword update logic * Delete mq.htpasswd.default file
1 parent 13dfa57 commit 14be193

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

Dockerfile-server

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ LABEL summary="IBM MQ Advanced for Developers Server" \
182182
USER 0
183183
COPY --from=cbuilder /opt/app-root/src/authservice/mqhtpass/build/mqhtpass.so /opt/mqm/lib64/
184184
COPY etc/mqm/qm-service-component.ini /run
185-
COPY etc/mqm/mq.htpasswd.default /etc/mqm/
186185
COPY incubating/mqadvanced-server-dev/install-extra-packages.sh /usr/local/bin/
187186
RUN chmod u+x /usr/local/bin/install-extra-packages.sh \
188187
&& sleep 1 \
@@ -197,7 +196,6 @@ RUN ln -s /run/10-dev.mqsc /etc/mqm/10-dev.mqsc \
197196
RUN chown -R 1001:root /etc/mqm/* \
198197
&& chmod -R g+w /etc/mqm/web \
199198
&& chmod +x /usr/local/bin/runmq* \
200-
&& chmod 0660 /etc/mqm/mq.htpasswd.default \
201199
# Allow contents of qm-service-component.ini to be cleaned if MQ_CONNAUTH_USE_HTP is not set to true
202200
&& chmod 0660 /run/qm-service-component.ini \
203201
&& ln -s /run/qm-service-component.ini /etc/mqm/qm-service-component.ini

cmd/runmqdevserver/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strings"
2222
"syscall"
2323

24-
"github.com/ibm-messaging/mq-container/internal/copy"
2524
"github.com/ibm-messaging/mq-container/internal/htpasswd"
2625
"github.com/ibm-messaging/mq-container/pkg/containerruntimelogger"
2726
"github.com/ibm-messaging/mq-container/pkg/logger"
@@ -136,8 +135,9 @@ func doMain() error {
136135
appPassword, appPwdset := os.LookupEnv("MQ_APP_PASSWORD")
137136
if set && strings.EqualFold(enableHtPwd, "true") &&
138137
(adminPwdset && len(strings.TrimSpace(adminPassword)) > 0 || appPwdset && len(strings.TrimSpace(appPassword)) > 0) {
139-
// Copy default mq.htpasswd file to ephemeral volume
140-
err = copy.CopyFile("/etc/mqm/mq.htpasswd.default", "/run/mq.htpasswd")
138+
// Create an empty mq.htpasswd file on ephemeral volume
139+
// #nosec G306 - its a write by owner/s group, and pose no harm.
140+
err = os.WriteFile("/run/mq.htpasswd", []byte(""), 0660)
141141
if err != nil {
142142
logTermination(err)
143143
return err

docs/pluggable-connauth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This pluggable authentication mode is to allow developers using the mq-container
1212

1313
### Preparing htpasswd file
1414

15-
1. A default `mq.htpasswd.default` file is provided and placed under /etc/mqm/ directory inside the container.
15+
1. The `mq.htpasswd` file gets generated and placed under /run/ directory inside the container when the password for `admin` or `app` users is set via environment variables. No default password is set for these users.
1616
2. You can set the password for user `admin` by setting the environment variable `MQ_ADMIN_PASSWORD`.
1717
3. You can add user `app` into mq.htpasswd file by setting the environment variable `MQ_APP_PASSWORD`. This user `app` can be used to access `DEV.*` objects of the queue manager.
1818

etc/mqm/mq.htpasswd.default

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)