diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e22142ac7..de98329549 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -223,6 +223,50 @@ jobs: path: gcs_upload_dir/ retention-days: 1 + build-push-docker-base-image: + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + runs-on: ubuntu-22.04 + needs: + - build-centos + - build-ubuntu + - build-osx + - build-windows + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Download installers from GitHub artifacts + id: download + uses: actions/download-artifact@v4 + with: + pattern: '*_installer*' + path: _installers + - name: Login to GitHub Container registry + # if: ${{ github.event_name == 'push' }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + # if: ${{ github.event_name == 'push' }} + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + # if: ${{ github.event_name == 'push' }} + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.base + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + test-ubuntu-e2e: continue-on-error: true # Debug follow up step. runs-on: ubuntu-22.04 diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000000..fad274b0a6 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,62 @@ +FROM ubuntu:22.04 AS builder + +LABEL maintainer="grr-dev@googlegroups.com" + +ENV DEBIAN_FRONTEND noninteractive +# Buffering output (sometimes indefinitely if a thread is stuck in +# a loop) makes for a non-optimal user experience when containers +# are run in the foreground, so we disable that. +ENV PYTHONUNBUFFERED 0 + +RUN apt-get update && \ + apt-get install -y \ + default-jre \ + python-is-python3 \ + python3-dev \ + python3-pip \ + python3-venv \ + python3-mysqldb \ + build-essential \ + linux-headers-generic \ + dh-make \ + rpm + +# Only available when building as part of Github Actions. +COPY _installers* /client_installers + +ENV VIRTUAL_ENV /usr/share/grr-server +ENV GRR_SOURCE /usr/src/grr + +RUN python -m venv --system-site-packages $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN pip install wheel nodeenv grpcio-tools==1.60 + +RUN nodeenv -p --prebuilt --node=16.13.0 + +RUN mkdir ${GRR_SOURCE} +ADD . ${GRR_SOURCE} + +WORKDIR ${GRR_SOURCE} + +RUN cd grr/server/grr_response_server/gui/static && \ + npm ci && npm run gulp compile + +RUN python grr/proto/makefile.py && \ + python grr/core/grr_response_core/artifacts/makefile.py + +RUN pip install grr/proto \ + pip install grr/core \ + pip install grr/client \ + pip install grr/server \ + pip install grr/client_builder \ + pip install api_client/python + +RUN rm -r ${GRR_SOURCE} + +WORKDIR / + +ENTRYPOINT [ "grr_server" ] + + + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000..b0c5085903 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,174 @@ +services: + db: + image: mysql:8.2 + env_file: docker/.env + container_name: grr-db + hostname: mysql-host + command: [ + --max_allowed_packet=40M, + --log_bin_trust_function_creators=1 + ] + restart: always + volumes: + - ./docker_config_files/mysql/init.sh:/docker-entrypoint-initdb.d/init.sh + - db_data:/var/lib/mysql:rw + ports: + - "3306" + expose: + - "3306" + networks: + - server-network + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 5s + retries: 10 + + grr-admin-ui: + build: + dockerfile: Dockerfile.base + context: . + container_name: grr-admin-ui + hostname: admin-ui + restart: always + depends_on: + db: + condition: service_healthy + volumes: + - ./docker_config_files/server:/configs/ + ports: + - "8000" + - "8080" + expose: + - 8080 + - 8000 + networks: + - server-network + tty: true + stdin_open: true + command: + - -component + - admin_ui + - -config + - /configs/grr.server.yaml + - --verbose + + grr-fleetspeak-frontend: + build: + dockerfile: Dockerfile.base + context: . + container_name: grr-fleetspeak-frontend + hostname: grr-fleetspeak-frontend + depends_on: + db: + condition: service_healthy + volumes: + - ./docker_config_files/server/:/configs/ + ports: + - "11111" + restart: always + stdin_open: true + tty: true + networks: + - server-network + command: + - -component + - frontend + - -config + - /configs/grr.server.yaml + - --verbose + + fleetspeak-admin: + image: ghcr.io/google/fleetspeak:master + container_name: fleetspeak-admin + hostname: fleetspeak-admin + depends_on: + db: + condition: service_healthy + networks: + - server-network + ports: + - "4444" + volumes: + - ./docker_config_files/server/:/configs/ + stdin_open: true + tty: true + entrypoint: [ + "server", + "-components_config", + "/configs/admin.components.config", + "-services_config", + "/configs/grr_frontend.service", + "-alsologtostderr", + "-v", + "1000" + ] + + fleetspeak-frontend: + image: ghcr.io/google/fleetspeak:master + container_name: fleetspeak-frontend + hostname: fleetspeak-frontend + depends_on: + db: + condition: service_healthy + networks: + - server-network + ports: + - "4443" + volumes: + - ./docker_config_files/server/:/configs/ + entrypoint: [ + "server", + "-components_config", + "/configs/frontend.components.config", + "-services_config", + "/configs/grr_frontend.service", + "-alsologtostderr", + "-v", + "1000" + ] + + grr-worker: + build: + dockerfile: Dockerfile.base + context: . + container_name: grr-worker + volumes: + - ./docker_config_files/server/:/configs/ + hostname: grr-worker + depends_on: + db: + condition: service_healthy + restart: always + stdin_open: true + tty: true + networks: + - server-network + command: + - -component + - worker + - -config + - /configs/grr.server.yaml + - --verbose + + # linux-client: + # build: + # dockerfile: docker/client/Dockerfile.linux + # container_name: grr-linux-client + # restart: always + # depends_on: + # - db + # - fleetspeak-frontend + # volumes: + # - installers/:/installers/ + # tty: true + # stdin_open: true + # networks: + # - server-network + # entrypoint: /entrypoint.sh + +volumes: + db_data: + installers: +networks: + server-network: + diff --git a/docker/.env b/docker/.env new file mode 100644 index 0000000000..dfceb41e00 --- /dev/null +++ b/docker/.env @@ -0,0 +1,12 @@ +ADMIN_PASSWORD="admin" + +MYSQL_ROOT_PASSWORD='root' +MYSQL_ROOT_HOST="%" + +FLEETSPEAK_DB='fleetspeak' +FLEETSPEAK_DB_USER='fleetspeak-user' +FLEETSPEAK_DB_PASSWORD='fleetspeak-password' + +GRR_DB='grr' +GRR_DB_USER='grru' +GRR_DB_PASSWORD='grrp' \ No newline at end of file diff --git a/docker/client/Dockerfile.linux b/docker/client/Dockerfile.linux new file mode 100644 index 0000000000..c87562be74 --- /dev/null +++ b/docker/client/Dockerfile.linux @@ -0,0 +1,9 @@ +FROM ubuntu:22.04 + +LABEL maintainer="grr-dev@googlegroups.com" + +RUN apt-get update +RUN apt-get install -y iputils-ping + +COPY ./docker/client/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh \ No newline at end of file diff --git a/docker/client/entrypoint.sh b/docker/client/entrypoint.sh new file mode 100644 index 0000000000..0a5e0a7a6d --- /dev/null +++ b/docker/client/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +dpkg -i /installers/*.deb + +./usr/bin/fleetspeak-client \ + -alsologtostderr \ + -std_forward \ + -config /configs/client.config \ No newline at end of file diff --git a/docker_config_files/client/client.config b/docker_config_files/client/client.config new file mode 100644 index 0000000000..35ff97e8c4 --- /dev/null +++ b/docker_config_files/client/client.config @@ -0,0 +1,20 @@ +server: "fleetspeak-frontend:4443" +trusted_certs: | + -----BEGIN CERTIFICATE----- + MIIByjCCAXCgAwIBAgIQRXLVvpuGxHhfDTlZ3drY8TAKBggqhkjOPQQDAjAjMSEw + HwYDVQQDExhGbGVldHNwZWFrIEZsZWV0c3BlYWsgQ0EwHhcNMjMxMjE1MTQyMTQ2 + WhcNMjQxMjE0MTQyMTQ2WjAnMSUwIwYDVQQDExxGbGVldHNwZWFrIEZsZWV0c3Bl + YWsgU2VydmVyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaCG+J04RBhTCTDgr + Ml+KfTLOab/vOsNix+zMzzG8C+7Sz5K3Jf/wqCRlScft3IK0wJo7PMT1+kJTWHxo + bHFD+qOBgTB/MA4GA1UdDwEB/wQEAwIChDAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud + DgQWBBTvdTLzfJCcEx9x6/DQo9u6JErv/jAfBgNVHSMEGDAWgBTDqQ/s7QxdkVU+ + qXUTazg4lzhDUTAcBgNVHREEFTATghFmbGVldHNwZWFrLXNlcnZlcjAKBggqhkjO + PQQDAgNIADBFAiBtWzU2jEBrEIwt2rxfL68KfSAXb1wL1cs4NFqXj0vGUQIhAJJJ + vh+1vmpSS1Az9yxQoZK8Upo4wJe6zg2SfokzY681 + -----END CERTIFICATE----- +client_label: "" +filesystem_handler: { + configuration_directory:"/configs/fleetspeak-config" + state_file:"/fleetspeak-client.state" +} +streaming:true \ No newline at end of file diff --git a/docker_config_files/client/fleetspeak-config/grr_client.service b/docker_config_files/client/fleetspeak-config/grr_client.service new file mode 100644 index 0000000000..4fef40402b --- /dev/null +++ b/docker_config_files/client/fleetspeak-config/grr_client.service @@ -0,0 +1,9 @@ +name: "GRR" +factory: "Daemon" +config: { + [type.googleapis.com/fleetspeak.daemonservice.Config]: { + argv: "/venv/bin/grr_client" + argv: "--config" + argv: "/configs/grr.client.yaml" + } +} \ No newline at end of file diff --git a/docker_config_files/client/grr.client.yaml b/docker_config_files/client/grr.client.yaml new file mode 100644 index 0000000000..f58a508a45 --- /dev/null +++ b/docker_config_files/client/grr.client.yaml @@ -0,0 +1,7 @@ +Client.fleetspeak_enabled: true +Client.foreman_check_frequency: 10 # seconds +Logging.verbose: true +Logging.engines: file,stderr +Logging.path: /tmp/grr-client +Logging.filename: /tmp/grr-client/grr-client.log +Config.writeback: /tmp/grr-client/grr-client.local.yaml \ No newline at end of file diff --git a/docker_config_files/mysql/init.sh b/docker_config_files/mysql/init.sh new file mode 100755 index 0000000000..d49ec2230d --- /dev/null +++ b/docker_config_files/mysql/init.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -ex + +echo "** Creating default DB for GRR and fleetspeak" + +mysql -u root -p$MYSQL_ROOT_PASSWORD --execute \ +"CREATE USER'$GRR_DB_USER'@'$MYSQL_ROOT_HOST' IDENTIFIED BY '$GRR_DB_PASSWORD'; +CREATE DATABASE $GRR_DB; +GRANT ALL ON $GRR_DB.* TO '$GRR_DB_USER'@'$MYSQL_ROOT_HOST'; +CREATE USER '$FLEETSPEAK_DB_USER'@'$MYSQL_ROOT_HOST' IDENTIFIED BY '$FLEETSPEAK_DB_PASSWORD'; +CREATE DATABASE $FLEETSPEAK_DB; +GRANT ALL ON $FLEETSPEAK_DB.* TO '$FLEETSPEAK_DB_USER'@'$MYSQL_ROOT_HOST'; +FLUSH PRIVILEGES;" + +echo "** Finished creating DBs and users" \ No newline at end of file diff --git a/docker_config_files/server/admin.components.config b/docker_config_files/server/admin.components.config new file mode 100644 index 0000000000..0b3c50baf4 --- /dev/null +++ b/docker_config_files/server/admin.components.config @@ -0,0 +1,5 @@ +mysql_data_source_name: "fleetspeak-user:fleetspeak-password@tcp(mysql-host:3306)/fleetspeak" +admin_config: < + listen_address: "0.0.0.0:4444" +> +notification_use_http_notifier: true \ No newline at end of file diff --git a/docker_config_files/server/frontend.components.config b/docker_config_files/server/frontend.components.config new file mode 100644 index 0000000000..a15df69792 --- /dev/null +++ b/docker_config_files/server/frontend.components.config @@ -0,0 +1,8 @@ +mysql_data_source_name: "fleetspeak-user:fleetspeak-password@tcp(mysql-host:3306)/fleetspeak" +https_config: < + listen_address: "fleetspeak-frontend:4443" + certificates: "-----BEGIN CERTIFICATE-----\nMIIByjCCAXCgAwIBAgIQRXLVvpuGxHhfDTlZ3drY8TAKBggqhkjOPQQDAjAjMSEw\nHwYDVQQDExhGbGVldHNwZWFrIEZsZWV0c3BlYWsgQ0EwHhcNMjMxMjE1MTQyMTQ2\nWhcNMjQxMjE0MTQyMTQ2WjAnMSUwIwYDVQQDExxGbGVldHNwZWFrIEZsZWV0c3Bl\nYWsgU2VydmVyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaCG+J04RBhTCTDgr\nMl+KfTLOab/vOsNix+zMzzG8C+7Sz5K3Jf/wqCRlScft3IK0wJo7PMT1+kJTWHxo\nbHFD+qOBgTB/MA4GA1UdDwEB/wQEAwIChDAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\nDgQWBBTvdTLzfJCcEx9x6/DQo9u6JErv/jAfBgNVHSMEGDAWgBTDqQ/s7QxdkVU+\nqXUTazg4lzhDUTAcBgNVHREEFTATghFmbGVldHNwZWFrLXNlcnZlcjAKBggqhkjO\nPQQDAgNIADBFAiBtWzU2jEBrEIwt2rxfL68KfSAXb1wL1cs4NFqXj0vGUQIhAJJJ\nvh+1vmpSS1Az9yxQoZK8Upo4wJe6zg2SfokzY681\n-----END CERTIFICATE-----\n" + key: "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIGjnSoIzlA7spP1jJDXNYT9VSG0Y2FLNqEsatkPfvaOWoAoGCCqGSM49\nAwEHoUQDQgAEaCG+J04RBhTCTDgrMl+KfTLOab/vOsNix+zMzzG8C+7Sz5K3Jf/w\nqCRlScft3IK0wJo7PMT1+kJTWHxobHFD+g==\n-----END EC PRIVATE KEY-----" +> +notification_listen_address: "fleetspeak-frontend:10000" +notification_public_address: "fleetspeak-frontend:10000" \ No newline at end of file diff --git a/docker_config_files/server/grr.server.yaml b/docker_config_files/server/grr.server.yaml new file mode 100644 index 0000000000..7d7bb9ed6c --- /dev/null +++ b/docker_config_files/server/grr.server.yaml @@ -0,0 +1,71 @@ +AdminUI.csrf_secret_key: KPK,_0a_xY&DTeiaokEdsH1uXGobNIhfrr67BTSLlPPv64_UE0nyn8QsD6 + nwNZ-C87mwVLkdrc77AKdoz12hxzmYXsBTT1bC#d7 +AdminUI.url: http://admin-ui:8000 +Blobstore.implementation: DbBlobStore +Client.executable_signing_public_key: | + '-----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx6YQNUwITzi7l+biDnwv + n63Rg3vbfPZexL/0O1XzQw1Z7mFp3uHtnSrkgDmqYIDXwxDXvn8Ck+k8dYt8SZCc + Jq4Jd/YkJXaUiM2E/2Y+Gv33ioVaN7QRyVBGRldK7X6a9Z8tEBE8jF3mlzlO2Z16 + ZCgMLD1I6ZJpHfQFcDGJP7idHY1TVHJ7j9YG8PObi2k9r5E9UBg6DcFD3Rqg5CP/ + OUtE56B7VW3y8q49c8pw+ZfiQaXd11xMLuMOX9Brlsp/RqFC6wvM1RJc9oR08Bq8 + je7ZmTVuwGEUR8snL2eqPqhM1UAvelbEF4IVG9E7A043Fhh7qVPxVGqKSkgfwXS0 + 0QIDAQAB + -----END PUBLIC KEY-----' +Client.fleetspeak_enabled: true +Client.server_urls: +- ADMIN_UI_URL +ClientBuilder.fleetspeak_bundled: true +Database.implementation: MysqlDB +FleetspeakFrontend Context: + Server.fleetspeak_message_listen_address: grr-fleetspeak-frontend:11111 +Logging.domain: fleetspeak-server +Monitoring.alert_email: grr-monitoring@fleetspeak-server +Monitoring.emergency_access_email: grr-emergency@fleetspeak-server + +Mysql.host: mysql-host +Mysql.port: 3306 +Mysql.database_name: fleetspeak +Mysql.database_password: fleetspeak-password +Mysql.database_username: fleetspeak-user +Mysql.database: grr +Mysql.password: grrp +Mysql.username: grru + +PrivateKeys.executable_signing_private_key: | + '-----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAx6YQNUwITzi7l+biDnwvn63Rg3vbfPZexL/0O1XzQw1Z7mFp + 3uHtnSrkgDmqYIDXwxDXvn8Ck+k8dYt8SZCcJq4Jd/YkJXaUiM2E/2Y+Gv33ioVa + N7QRyVBGRldK7X6a9Z8tEBE8jF3mlzlO2Z16ZCgMLD1I6ZJpHfQFcDGJP7idHY1T + VHJ7j9YG8PObi2k9r5E9UBg6DcFD3Rqg5CP/OUtE56B7VW3y8q49c8pw+ZfiQaXd + 11xMLuMOX9Brlsp/RqFC6wvM1RJc9oR08Bq8je7ZmTVuwGEUR8snL2eqPqhM1UAv + elbEF4IVG9E7A043Fhh7qVPxVGqKSkgfwXS00QIDAQABAoIBAQCi51KEWoTRN4aC + PMcpcJVfYnH5Kj/+5/yN596957T1elhuFRhQ3+KFgrEuG191HMxxAzY23uXYkNBf + TTBdylxPh2R8eOAnnWk3cxLZXrDAT4gDhCoIF6sHq7Obw7CEtvB0CKy5VockNZ5o + uD8pe8CZJsA//MWYqHmTEkC5ugG2dlde7FcYHsqVU7NlGHhz5UqPpzrgvdTfnWwj + GOd2zL+BuUKbs8ZIVGEDbgtr8ILNN9MMK8nDioIB29SMWP/Jfb2Z7HSRkn2HK7Jf + bkv/eTJlOJnAlB5BbDDvQ8vUPgk0j0cMjcapoyoENGmbsgSvydG2O7RyBnkeGmud + vEExNZHBAoGBAPgGmD3A07pTYGzd7RytJJZ1u+so4IlWPg2Jp9p0WmP6D6vbB2dl + 1lIdtzII5hh/wbd2FNZJ5X2iV93gQsffRBGeOJ8b5No91q/EdmCZpFGu7LJQqWVO + 1+Nft/xW6Kkog811KwYNgQpE241ZRCGoD/KzZpOfb9n+EW+hVYbjOfiZAoGBAM4R + S56AFXKHIoZQOgX1drsWr6DKDH8Za7BNsGT1nDi1ROmNZxzx8I9avF4ZSwUMmiXR + AXMY69CjqFFwTtWhrZ8UHhl5x7zWAffQdof4jKtdCJ8G4CyYDCZ31Cbi7Gfo4tUP + FmLmN59o3l69887y1vgyFnDevSGuCzJ9hJ1LSij5AoGAGKjvMhSd+ISZrblS/erp + HFyQVo015fHBMa9iFQJEinQuYrPgRJOHf5qcwEjKN91b8VW4NKYcPyWI/vJxMVYt + emL01jz7wAct9UPfUTN1dvmhZwlGDmCMbnrx3BD4CPmSQTdJE8z76311JtSdRYtk + KolTxZGwmUf9i8/KpSKqfOECgYB8Kj23TpQdw0FRTwv3RTV6e6vtpXEsMGQMAnPU + EY5FOSxB0hscfMeniVPRG0pxy2sieDJ4aL7Go6YrFBHcdaQJI3UTgqaQqR7cdHbH + bUNNiixErj7rf95qW2+w0rEB13i+Sm4Bv5gqbGT5D1nWC8ruGDgfYIbzwUwr6ye6 + I4CW+QKBgQC9xKPizqJoi375rDeLVSc/bN3fidyj+Ti87YQa9sDSyXxSF2uk2HUF + xCjMJcqyIOhPSze9wpip6edj8p6N3pvKEMLdFrRJR9Gkv/V9+kJffJbLwyH6Ta/x + v89V954580cna0V/lZYpZM/DDdhVv3hCaGIm+uAHA1mYtxzBBTKX3Q== + -----END RSA PRIVATE KEY-----' +Server.fleetspeak_enabled: true +Server.fleetspeak_server: fleetspeak-admin:4444 +Server.initialized: true +Target:Darwin: + ClientBuilder.fleetspeak_client_config: /mount/fleetspeak/darwin.client.config +Target:Linux: + ClientBuilder.fleetspeak_client_config: /mount/fleetspeak/linux.client.config +Target:Windows: + ClientBuilder.fleetspeak_client_config: /mount/fleetspeak/windows.client.config diff --git a/docker_config_files/server/grr_frontend.service b/docker_config_files/server/grr_frontend.service new file mode 100644 index 0000000000..e39cc182a6 --- /dev/null +++ b/docker_config_files/server/grr_frontend.service @@ -0,0 +1,13 @@ +services { + name: "GRR" + factory: "GRPC" + config: { + [type.googleapis.com/fleetspeak.grpcservice.Config] { + target: "grr-fleetspeak-frontend:11111" + insecure: true + } + } +} +broadcast_poll_time { + seconds: 1 +} \ No newline at end of file diff --git a/grr/client_builder/setup.py b/grr/client_builder/setup.py index a6f4392af3..ae304db52c 100644 --- a/grr/client_builder/setup.py +++ b/grr/client_builder/setup.py @@ -16,17 +16,19 @@ def get_config(): """Get INI parser with version.ini data.""" ini_path = os.path.join(THIS_DIRECTORY, "version.ini") + rel_ini_path = "version.ini" if not os.path.exists(ini_path): ini_path = os.path.join(THIS_DIRECTORY, "../../version.ini") + rel_ini_path = "../../version.ini" if not os.path.exists(ini_path): raise RuntimeError("Couldn't find version.ini") config = configparser.ConfigParser() config.read(ini_path) - return config + return rel_ini_path, config -VERSION = get_config() +REL_INI_PATH, VERSION = get_config() class Sdist(sdist): @@ -41,7 +43,7 @@ def make_release_tree(self, base_dir, files): os.path.join(THIS_DIRECTORY, "../../version.ini"), sdist_version_ini) -data_files = ["version.ini"] +data_files = [REL_INI_PATH] setup_args = dict( name="grr-response-client-builder", diff --git a/grr/core/setup.py b/grr/core/setup.py index 387fe948ea..514e6284f6 100644 --- a/grr/core/setup.py +++ b/grr/core/setup.py @@ -41,18 +41,19 @@ def sync_artifacts(): def get_config(): """Get INI parser with version.ini data.""" ini_path = os.path.join(THIS_DIRECTORY, "version.ini") + rel_ini_path = "version.ini" if not os.path.exists(ini_path): ini_path = os.path.join(THIS_DIRECTORY, "../../version.ini") + rel_ini_path = "../../version.ini" if not os.path.exists(ini_path): raise RuntimeError("Couldn't find version.ini") config = configparser.ConfigParser() config.read(ini_path) - return config + return rel_ini_path, config -VERSION = get_config() - +INI_PATH, VERSION = get_config() class Develop(develop): @@ -97,7 +98,7 @@ def make_release_tree(self, base_dir, files): find_data_files("install_data"), find_data_files("scripts"), find_data_files("grr_response_core/artifacts"), - ["version.ini"], + [INI_PATH], )) setup_args = dict( diff --git a/grr/server/setup.py b/grr/server/setup.py index 289e59e2bc..285b224052 100644 --- a/grr/server/setup.py +++ b/grr/server/setup.py @@ -50,14 +50,16 @@ def make_ui_files(): def get_config(): """Get INI parser with version.ini data.""" ini_path = os.path.join(THIS_DIRECTORY, "version.ini") + rel_ini_path = "version.ini" if not os.path.exists(ini_path): ini_path = os.path.join(THIS_DIRECTORY, "../../version.ini") + rel_ini_path = "../../version.ini" if not os.path.exists(ini_path): raise RuntimeError("Couldn't find version.ini") config = configparser.ConfigParser() config.read(ini_path) - return config + return rel_ini_path, config IGNORE_GUI_DIRS = ["node_modules", "tmp"] @@ -69,7 +71,7 @@ def get_config(): # package dir. os.chdir(THIS_DIRECTORY) -VERSION = get_config() +REL_INI_PATH, VERSION = get_config() class Develop(develop): @@ -134,7 +136,7 @@ def make_release_tree(self, base_dir, files): find_data_files( "grr_response_server/gui/local/static", ignore_dirs=IGNORE_GUI_DIRS), - ["version.ini"], + [REL_INI_PATH], )) setup_args = dict(