Commit 0510a09a authored by Devaev Maxim's avatar Devaev Maxim

Added methods for get UID variables from login.defs

parent e28fc51f
......@@ -56,6 +56,7 @@
<!-- fmod_system_services -->
<policy context="default">
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.systemServices" send_member="servicesChanged"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.systemService" send_member="realName"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.systemService" send_member="description"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.systemService" send_member="shortDescription"/>
......@@ -66,7 +67,12 @@
<!-- fmod_local_users -->
<policy context="default">
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUsers" send_member="minUid"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUsers" send_member="maxUid"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUsers" send_member="minSystemUid"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUsers" send_member="maxSystemUid"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUsers" send_member="usersChanged"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUser" send_member="realName"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUser" send_member="uid"/>
<allow send_destination="org.etersoft.settingsd" send_interface="org.etersoft.settingsd.functions.localUser" send_member="gid"/>
......
......@@ -18,6 +18,7 @@ import settingsd.validators.os
import settingsd.tools as tools
import settingsd.tools.dbus
import settingsd.tools.process
import settingsd.tools.editors
##### Private constants #####
......@@ -167,6 +168,24 @@ class LocalUsers(service.FunctionObject) :
return tools.process.execProcess("%s %s %s" % (config.value(SERVICE_NAME, "userdel_prog_path"),
remove_data_arg, user_name), False)[2]
###
@service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, out_signature="i")
def minUid(self) :
return self.loginDefsValue("UID_MIN")
@service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, out_signature="i")
def maxUid(self) :
return self.loginDefsValue("UID_MAX")
@service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, out_signature="i")
def minSystemUid(self) :
return self.loginDefsValue("SYS_UID_MIN")
@service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, out_signature="i")
def maxSystemUid(self) :
return self.loginDefsValue("SYS_UID_MAX")
### DBus signals ###
......@@ -175,6 +194,16 @@ class LocalUsers(service.FunctionObject) :
pass
### Private ###
def loginDefsValue(self, variable_name) :
editor = tools.editors.PlainEditor(delimiter = "", quotes_list = [])
editor.open(config.value(SERVICE_NAME, "login_defs_config_file_path"))
values_list = editor.value(variable_name)
editor.close()
return ( int(values_list[-1]) if len(values_list) > 0 else -1 )
##### Public classes #####
class Service(service.Service, pyinotify.ThreadedNotifier) :
def __init__(self) :
......@@ -229,7 +258,8 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
(SERVICE_NAME, "userdel_prog_path", "/usr/sbin/userdel", str),
(SERVICE_NAME, "usermod_prog_path", "/usr/sbin/usermod", str),
(SERVICE_NAME, "passwd_config_file_path", "/etc/passwd", str),
(SERVICE_NAME, "shadow_config_file_path", "/etc/shadow", str)
(SERVICE_NAME, "shadow_config_file_path", "/etc/shadow", str),
(SERVICE_NAME, "login_defs_config_file_path", "/etc/login.defs", str)
]
......@@ -237,7 +267,8 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
def inotifyEvent(self, event) :
if event.dir or not event.pathname in ( config.value(SERVICE_NAME, "passwd_config_file_path"),
config.value(SERVICE_NAME, "shadow_config_file_path") ) :
config.value(SERVICE_NAME, "shadow_config_file_path"),
config.value(SERVICE_NAME, "login_defs_config_file_path") ) :
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment