From aee06920eb8a560edef9e486d1a94af691770bd3 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 1 Sep 2023 18:55:34 +0000 Subject: [PATCH] more self signed stuff --- api/tacticalrmm/agents/views.py | 11 ++++++----- api/tacticalrmm/clients/views.py | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/tacticalrmm/agents/views.py b/api/tacticalrmm/agents/views.py index 3153ae052b..45fd989847 100644 --- a/api/tacticalrmm/agents/views.py +++ b/api/tacticalrmm/agents/views.py @@ -570,10 +570,9 @@ def install_agent(request): from agents.utils import get_agent_url from core.utils import token_is_valid - if getattr(settings, "TRMM_INSECURE", False) and request.data["installMethod"] in { - "exe", - "powershell", - }: + insecure = getattr(settings, "TRMM_INSECURE", False) + + if insecure and request.data["installMethod"] in {"exe", "powershell"}: return notify_error( "Not available in insecure mode. Please use the 'Manual' method." ) @@ -680,7 +679,7 @@ def install_agent(request): if int(request.data["power"]): cmd.append("--power") - if getattr(settings, "TRMM_INSECURE", False): + if insecure: cmd.append("--insecure") resp["cmd"] = " ".join(str(i) for i in cmd) @@ -691,6 +690,8 @@ def install_agent(request): resp["cmd"] = ( dl + f" && chmod +x {inno} && " + " ".join(str(i) for i in cmd) ) + if insecure: + resp["cmd"] += " --insecure" resp["url"] = download_url diff --git a/api/tacticalrmm/clients/views.py b/api/tacticalrmm/clients/views.py index e82ec76901..475e8ee876 100644 --- a/api/tacticalrmm/clients/views.py +++ b/api/tacticalrmm/clients/views.py @@ -3,6 +3,7 @@ import uuid from contextlib import suppress +from django.conf import settings from django.db.models import Count, Exists, OuterRef, Prefetch, prefetch_related_objects from django.shortcuts import get_object_or_404 from django.utils import timezone as djangotime @@ -288,6 +289,9 @@ def get(self, request): return Response(DeploymentSerializer(deps, many=True).data) def post(self, request): + if getattr(settings, "TRMM_INSECURE", False): + return notify_error("Not available in insecure mode") + from accounts.models import User site = get_object_or_404(Site, pk=request.data["site"]) @@ -343,6 +347,9 @@ class GenerateAgent(APIView): permission_classes = (AllowAny,) def get(self, request, uid): + if getattr(settings, "TRMM_INSECURE", False): + return notify_error("Not available in insecure mode") + from tacticalrmm.utils import generate_winagent_exe try: