perf: 支持 super 方式的切换用户

pull/10079/head
Eric 2023-03-27 18:06:30 +08:00
parent 017682b383
commit 118d33fa02
2 changed files with 12 additions and 5 deletions

View File

@ -16,7 +16,7 @@ class DeviceTypes(BaseType):
'charset_enabled': False,
'domain_enabled': True,
'su_enabled': True,
'su_methods': ['enable']
'su_methods': ['enable', 'super', 'super_level']
}
}

View File

@ -85,6 +85,14 @@ class PlatformProtocolSerializer(serializers.ModelSerializer):
class PlatformSerializer(WritableNestedModelSerializer):
SU_METHOD_CHOICES = [
("sudo", "sudo su -"),
("su", "su - "),
("enable", "enable"),
("super", "super 15"),
("super_level", "super level 15")
]
charset = LabeledChoiceField(
choices=Platform.CharsetChoices.choices, label=_("Charset")
)
@ -94,10 +102,9 @@ class PlatformSerializer(WritableNestedModelSerializer):
label=_("Protocols"), many=True, required=False
)
automation = PlatformAutomationSerializer(label=_("Automation"), required=False)
su_method = LabeledChoiceField(
choices=[("sudo", "sudo su -"), ("su", "su - "), ("enable", "enable")],
label=_("Su method"), required=False, default="sudo", allow_null=True
)
su_method = LabeledChoiceField(choices=SU_METHOD_CHOICES,
label=_("Su method"), required=False, default="sudo", allow_null=True
)
class Meta:
model = Platform