diff --git a/pym/cl_share_cmd.py b/pym/cl_share_cmd.py index 5b8ba51..0fbfdf3 100644 --- a/pym/cl_share_cmd.py +++ b/pym/cl_share_cmd.py @@ -15,6 +15,7 @@ # limitations under the License. import sys +import os from cl_print import color_print from cl_utils import _error @@ -25,6 +26,15 @@ lang().setLanguage(sys.modules[__name__]) class share_cmd(color_print, _error): """Класс общих методов обработки опций командной строки""" + def isRoot(self, printError=True): + """Detect root user""" + if os.getuid() == 0 and os.getgid() == 0: + return True + else: + if printError: + self.printERROR(_("The user is not root")) + return False + def printVars(self, optObj): """Process displaying variables""" if optObj.v: diff --git a/scripts/cl-install b/scripts/cl-install index aeda513..faaeb7c 100644 --- a/scripts/cl-install +++ b/scripts/cl-install @@ -54,6 +54,9 @@ if __name__ == "__main__": if options.v or options.filter or options.xml: install.printVars(options) sys.exit(0) + # check root + if not install.isRoot(): + sys.exit(1) # configurate current system if options.live: if not install.configureSystem(): diff --git a/scripts/cl-template b/scripts/cl-template index 10cc3c3..797db5e 100644 --- a/scripts/cl-template +++ b/scripts/cl-template @@ -39,6 +39,9 @@ if __name__ == "__main__": # Печать переменных if options.v: obj.printVars(options) + # check root + if not obj.isRoot(): + sys.exit(1) if options.all: # apply all templates if not obj.applyAllTemplates():