Add root check

netsetup
Mike Hiretsky 14 years ago
parent b473eb7d6b
commit d0464cb1a0

@ -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:

@ -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():

@ -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():

Loading…
Cancel
Save