mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-04 18:46:39 +00:00
[Bugfix] 修复动态系统用户执行批量命令的bug
This commit is contained in:
parent
2f9598ba49
commit
00b3c7c945
@ -92,7 +92,7 @@ class JMSInventory(JMSBaseInventory):
|
|||||||
|
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
host = self.convert_to_ansible(asset, run_as_admin=run_as_admin)
|
host = self.convert_to_ansible(asset, run_as_admin=run_as_admin)
|
||||||
if run_as:
|
if run_as is not None:
|
||||||
run_user_info = self.get_run_user_info(host)
|
run_user_info = self.get_run_user_info(host)
|
||||||
host.update(run_user_info)
|
host.update(run_user_info)
|
||||||
if become_info and asset.is_unixlike():
|
if become_info and asset.is_unixlike():
|
||||||
@ -104,7 +104,7 @@ class JMSInventory(JMSBaseInventory):
|
|||||||
def get_run_user_info(self, host):
|
def get_run_user_info(self, host):
|
||||||
from assets.backends import AssetUserManager
|
from assets.backends import AssetUserManager
|
||||||
|
|
||||||
if not self.run_as:
|
if self.run_as is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -33,7 +33,12 @@ class CommandExecution(OrgModelMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def inventory(self):
|
def inventory(self):
|
||||||
return JMSInventory(self.hosts.all(), run_as=self.run_as.username)
|
if self.run_as.username_same_with_user:
|
||||||
|
username = self.user.username
|
||||||
|
else:
|
||||||
|
username = self.run_as.username
|
||||||
|
inv = JMSInventory(self.hosts.all(), run_as=username)
|
||||||
|
return inv
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def result(self):
|
def result(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user