diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index 1295b7684..efeaca27e 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -40,21 +40,15 @@ RUN echo '{}' >/tmp/usr/local/etc/xray/11_geodata.json RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json -# Create log files -RUN mkdir -p /tmp/var/log/xray && touch \ - /tmp/var/log/xray/access.log \ - /tmp/var/log/xray/error.log - # Build finally image FROM gcr.io/distroless/static:nonroot COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ -COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray -COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ -COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray -COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/ +COPY --from=build --chown=0:65532 --chmod=750 /tmp/empty /usr/local/etc/xray +COPY --from=build --chown=0:65532 --chmod=640 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ +COPY --from=build --chown=65532:65532 --chmod=700 /tmp/empty /var/log/xray VOLUME /usr/local/etc/xray VOLUME /var/log/xray diff --git a/.github/docker/Dockerfile.usa b/.github/docker/Dockerfile.usa index 09e5da816..57786876c 100644 --- a/.github/docker/Dockerfile.usa +++ b/.github/docker/Dockerfile.usa @@ -40,11 +40,6 @@ RUN echo '{}' >/tmp/usr/local/etc/xray/11_geodata.json RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json -# Create log files -RUN mkdir -p /tmp/var/log/xray && touch \ - /tmp/var/log/xray/access.log \ - /tmp/var/log/xray/error.log - # Build finally image # Note on Distroless Base Image and Architecture Support: # - The official 'gcr.io/distroless/static' image provided by Google only supports a limited set of architectures for Linux: @@ -60,10 +55,9 @@ FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ -COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray -COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ -COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray -COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/ +COPY --from=build --chown=0:65532 --chmod=750 /tmp/empty /usr/local/etc/xray +COPY --from=build --chown=0:65532 --chmod=640 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ +COPY --from=build --chown=65532:65532 --chmod=700 /tmp/empty /var/log/xray VOLUME /usr/local/etc/xray VOLUME /var/log/xray diff --git a/transport/internet/reality/config.go b/transport/internet/reality/config.go index 6709ae2c8..4e1b625dc 100644 --- a/transport/internet/reality/config.go +++ b/transport/internet/reality/config.go @@ -68,7 +68,7 @@ func KeyLogWriterFromConfig(c *Config) io.Writer { return nil } - writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o644) + writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o600) if err != nil { errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log") } diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 6fbe59320..71bd6cec8 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -466,7 +466,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { } if len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none" { - writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o644) + writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o600) if err != nil { errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log") } else {