-
Notifications
You must be signed in to change notification settings - Fork 30
AIDE migration #537
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
AIDE migration #537
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,6 +161,31 @@ else | |
| $(eval OPENSHIFT_USER = $(shell oc whoami)) | ||
| endif | ||
|
|
||
|
|
||
| .PHONY: aide-0.18 | ||
| aide-0.18: | ||
| cd build && \ | ||
| rm -rf aide && \ | ||
| git clone https://github.com/aide/aide.git && \ | ||
| cd aide && \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a |
||
| git checkout v0.18.8 && \ | ||
| sh ./autogen.sh && \ | ||
| ./configure \ | ||
| --with-zlib \ | ||
| --disable-static \ | ||
| --with-posix-acl \ | ||
| --with-gcrypt \ | ||
| --with-selinux \ | ||
| --with-xattr \ | ||
| --with-e2fsattrs \ | ||
| --with-audit && \ | ||
| $(MAKE) && \ | ||
| chmod +x ./aide && \ | ||
| cd .. && \ | ||
| cd .. && \ | ||
| cp ./build/aide/aide ./build/bin/aide-0.18 | ||
|
|
||
|
|
||
| .PHONY: check-operator-version | ||
| check-operator-version: | ||
| ifndef VERSION | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,38 @@ | ||
| # Step one: build file-integrity-operator | ||
| FROM golang:1.22 as builder | ||
| FROM registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.22-openshift-4.17 AS builder | ||
| USER root | ||
|
|
||
| WORKDIR /go/src/github.com/openshift/file-integrity-operator | ||
|
|
||
| ENV GOFLAGS="-mod=vendor" | ||
|
|
||
| RUN dnf -y install git make gcc automake autoconf libtool flex gettext-devel e2fsprogs-devel audit-libs-devel libattr-devel flex bison zlib-devel libgcrypt-devel audit-libs-devel libacl-devel libselinux-devel libtool && dnf clean all | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN git clone https://github.com/autoconf-archive/autoconf-archive.git && \ | ||
| cp autoconf-archive/m4/*.m4 /usr/share/aclocal/ | ||
|
|
||
| RUN make build | ||
|
|
||
| RUN make aide-0.18 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another alternative we talked about earlier was to build this using a separate ubi8 base image container and then copying it over, too. Or, at least in this case, we could just copy it out of the fedora 40 image and see how that works. |
||
|
|
||
| # Step two: containerize file-integrity-operator and AIDE together | ||
| FROM registry.fedoraproject.org/fedora-minimal:37 | ||
| RUN microdnf -y install aide-0.16 | ||
| RUN microdnf -y install aide golang && microdnf clean all | ||
|
|
||
| # Install AIDE 0.16 and dependencies | ||
| RUN microdnf -y install aide-0.16 golang && microdnf clean all | ||
|
|
||
| ENV OPERATOR=/usr/local/bin/file-integrity-operator \ | ||
| USER_UID=1001 \ | ||
| USER_NAME=file-integrity-operator | ||
|
|
||
| RUN mkdir -p /usr/local/libs | ||
|
|
||
| # install operator binary | ||
| COPY --from=builder /go/src/github.com/openshift/file-integrity-operator/build/bin/manager ${OPERATOR} | ||
| COPY build/bin /usr/local/bin | ||
| COPY --from=builder /go/src/github.com/openshift/file-integrity-operator/build/bin/aide-0.18 /usr/sbin/aide-0.18 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we don't need to pollute the builder container image with utilities and code unrelated to golang, or building FIO. |
||
| RUN /usr/local/bin/user_setup | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,43 @@ func aideLoop(ctx context.Context, rt *daemonRuntime, conf *daemonConfig, errCha | |
| } | ||
| } | ||
|
|
||
| // The migrationCheckLoop checks if the migrated AIDE config file exists and if the new AIDE config works. | ||
| func migrationCheckLoop(ctx context.Context, rt *daemonRuntime, conf *daemonConfig, errChan chan<- error, wg *sync.WaitGroup) { | ||
| defer wg.Done() | ||
| migrateCtx, migrateCancel := context.WithCancel(ctx) | ||
| defer migrateCancel() | ||
|
|
||
| for { | ||
| select { | ||
| case <-migrateCtx.Done(): | ||
| DBG("Migration loop cancelled by the main routine!") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case - has the operation been aborted due to an error? Can, or should, the user do anything to restart the migration? |
||
| return | ||
| default: | ||
| output, err := runAideMigrationCheckCmdSaveOutput(migrateCtx, conf) | ||
| aideResult := common.GetAideExitCode(err) | ||
| if aideResult == 0 { | ||
| LOG("AIDE migration check passed. The configuration is safe to run using AIDE 0.18") | ||
| if err := reportOK(migrateCtx, conf, rt); err != nil { | ||
| // Considering this a non-fatal error right now. | ||
| LOG("Failed reporting migration check result: %v", err) | ||
| } | ||
| return | ||
| } else if aideResult == 17 { | ||
| // This is an AIDE config line error. | ||
| newErr := fmt.Sprintf("Detected configuration error during the migration check for AIDE 0.18: %s, output: %s ", common.GetAideErrorMessage(aideResult), output) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool - this error moves us in the right direction I think by giving users the information they need to update AIDE configs. Curious to see how this renders in the logs with an actual AIDE error. |
||
| logAndTryReportingDaemonError(migrateCtx, rt, conf, newErr, nil) | ||
| errChan <- err | ||
| return | ||
| } else { | ||
| logAndTryReportingDaemonError(ctx, rt, conf, fmt.Sprintf("Error running migration check: %s", | ||
| common.GetAideErrorMessage(aideResult)), err) | ||
| errChan <- err | ||
| } | ||
| time.Sleep(time.Second * time.Duration(conf.Interval)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // The holdoff file is the signal from the node controller to pause the aide scan. | ||
| // We do not make this pause the logCollector loop, and we might want to. | ||
| func holdOffLoop(ctx context.Context, rt *daemonRuntime, conf *daemonConfig, errChan chan<- error, wg *sync.WaitGroup) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a dependency for building AIDE 0.18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think rhel might has rpm for this, but this builder does not