Skip to content

Commit

Permalink
Release 0.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Mar 29, 2024
2 parents 7284d9f + 4aa413e commit 6ab39d6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ assignees: ''

**Installation Method:**
- [ ] Standard
- [ ] Standard with `--insecure` flag at install
- [ ] Docker

**Agent Info (please complete the following information):**
- Agent version (as shown in the 'Summary' tab of the agent from web UI):
- Agent OS: [e.g. Win 10 v2004, Server 2012 R2]
- Agent OS: [e.g. Win 10 v2004, Server 2016]

**Describe the bug**
A clear and concise description of what the bug is.
Expand Down
35 changes: 12 additions & 23 deletions api/tacticalrmm/core/mesh_utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import asyncio
import json
import re
import secrets
import string
import traceback
from typing import TYPE_CHECKING, Any

import websockets

from accounts.utils import is_superuser
from tacticalrmm.constants import TRMM_WS_MAX_SIZE
from tacticalrmm.helpers import make_random_password
from tacticalrmm.logger import logger

if TYPE_CHECKING:
Expand Down Expand Up @@ -40,6 +41,14 @@ def has_mesh_perms(*, user: "User") -> bool:
return user.role and getattr(user.role, "can_use_mesh")


def make_mesh_password() -> str:
alpha = string.ascii_letters + string.digits
nonalpha = "!@#$"
passwd = [secrets.choice(alpha) for _ in range(29)] + [secrets.choice(nonalpha)]
secrets.SystemRandom().shuffle(passwd)
return "".join(passwd)


def transform_trmm(obj):
ret = []
try:
Expand Down Expand Up @@ -128,7 +137,7 @@ def add_users_to_node(self, *, node_id: str, user_ids: list[str]):
"action": "adddeviceuser",
"nodeid": node_id,
"usernames": [s.replace("user//", "") for s in user_ids],
"rights": 72,
"rights": 3563736,
"remove": False,
}
self.mesh_action(payload=payload, wait=False)
Expand Down Expand Up @@ -156,7 +165,7 @@ def add_user_to_mesh(self, *, user_info: dict[str, Any]) -> None:
"action": "adduser",
"username": user_info["username"],
"email": user_info["email"],
"pass": make_random_password(len=30),
"pass": make_mesh_password(),
"resetNextLogin": False,
"randomPassword": False,
"removeEvents": False,
Expand All @@ -172,23 +181,3 @@ def delete_user_from_mesh(self, *, mesh_user_id: str) -> None:
"userid": mesh_user_id,
}
self.mesh_action(payload=payload, wait=False)

def add_agent_to_user(self, *, user_id: str, node_id: str) -> None:
payload = {
"action": "adddeviceuser",
"nodeid": node_id,
"userids": [user_id],
"rights": 72,
"remove": False,
}
self.mesh_action(payload=payload, wait=False)

def remove_agent_from_user(self, *, user_id: str, node_id: str) -> None:
payload = {
"action": "adddeviceuser",
"nodeid": node_id,
"userids": [user_id],
"rights": 0,
"remove": True,
}
self.mesh_action(payload=payload, wait=False)
8 changes: 6 additions & 2 deletions api/tacticalrmm/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
transform_trmm,
)
from core.models import CoreSettings
from core.utils import get_core_settings, get_mesh_ws_url
from core.utils import get_core_settings, get_mesh_ws_url, make_alpha_numeric
from logs.models import PendingAction
from logs.tasks import prune_audit_log, prune_debug_log
from tacticalrmm.celery import app
Expand Down Expand Up @@ -444,7 +444,9 @@ def sync_mesh_perms_task(self):
# make sure that doesn't happen by making a random email
rand_str1 = make_random_password(len=6)
rand_str2 = make_random_password(len=5)
email = f"{user.username}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local"
# for trmm users whos usernames are emails
email_prefix = make_alpha_numeric(user.username)
email = f"{email_prefix}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local"
mesh_users_dict[user.mesh_user_id] = {
"_id": user.mesh_user_id,
"username": user.mesh_username,
Expand All @@ -454,6 +456,8 @@ def sync_mesh_perms_task(self):

new_trmm_agents = []
for agent in Agent.objects.defer(*AGENT_DEFER):
if not agent.mesh_node_id:
continue
agent_dict = {
"node_id": f"node//{agent.hex_mesh_node_id}",
"hostname": agent.hostname,
Expand Down
4 changes: 4 additions & 0 deletions api/tacticalrmm/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,7 @@ def get_meshagent_url(
}

return base + "/meshagents?" + urllib.parse.urlencode(params)


def make_alpha_numeric(s: str):
return "".join(filter(str.isalnum, s))
2 changes: 1 addition & 1 deletion api/tacticalrmm/tacticalrmm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
AUTH_USER_MODEL = "accounts.User"

# latest release
TRMM_VERSION = "0.18.0"
TRMM_VERSION = "0.18.1"

# https://github.com/amidaware/tacticalrmm-web
WEB_VERSION = "0.101.43"
Expand Down

0 comments on commit 6ab39d6

Please sign in to comment.