spec-defined users and groups.

master
Luka Vandervelden 2020-01-04 16:15:44 +01:00
parent 0572fc1647
commit 5347ec4a62
2 changed files with 9 additions and 1 deletions

View File

@ -670,9 +670,15 @@ class Service
@context.services.select(&.consumes?(token, self))
end
def user_name
def default_user_name
full_id.sub('/', '.')
end
def user_name
@reference.user || default_user_name
end
def group_name
@reference.group || default_user_name
end
def get_uid_gid
passwd = Passwd.new("/etc/passwd", "/etc/group")

View File

@ -81,6 +81,7 @@ class ServiceDefinition
getter readiness_check_command : String?
getter directory : String?
getter user : String?
getter group : String?
getter provides : String?
getter consumes : Array(Consumes)
getter environment_variables : Array(String)
@ -101,6 +102,7 @@ class ServiceDefinition
@readiness_check_command = specs["readiness-check-command"]?.try &.as_s
@directory = specs["directory"]?.try &.as_s
@user = specs["user"]?.try &.as_s
@group = specs["group"]?.try &.as_s
@provides = specs["provides"]?.try &.as_a_or_s.map { |x| Provides.new x } || Array(Provides).new
@consumes = specs["consumes"]?.try &.as_a_or_s.map { |x| Consumes.new x } || Array(Consumes).new
@environment_variables = specs["environment-variables"]?.try &.as_a_or_s || Array(String).new