kiwi.privileges
1# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved. 2# 3# This file is part of kiwi. 4# 5# kiwi is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# kiwi is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with kiwi. If not, see <http://www.gnu.org/licenses/> 17# 18import os 19 20# project 21from .exceptions import ( 22 KiwiPrivilegesError 23) 24 25 26class Privileges: 27 """ 28 **Implements check for root privileges** 29 """ 30 @staticmethod 31 def check_for_root_permissions(): 32 """ 33 Check if we are effectively root on the system. If not 34 an exception is thrown 35 36 :return: True or raise an Exception 37 38 :rtype: bool 39 """ 40 if os.geteuid() != 0: 41 raise KiwiPrivilegesError( 42 'operation requires root permissions' 43 ) 44 return True
class
Privileges:
27class Privileges: 28 """ 29 **Implements check for root privileges** 30 """ 31 @staticmethod 32 def check_for_root_permissions(): 33 """ 34 Check if we are effectively root on the system. If not 35 an exception is thrown 36 37 :return: True or raise an Exception 38 39 :rtype: bool 40 """ 41 if os.geteuid() != 0: 42 raise KiwiPrivilegesError( 43 'operation requires root permissions' 44 ) 45 return True
Implements check for root privileges
@staticmethod
def
check_for_root_permissions():
31 @staticmethod 32 def check_for_root_permissions(): 33 """ 34 Check if we are effectively root on the system. If not 35 an exception is thrown 36 37 :return: True or raise an Exception 38 39 :rtype: bool 40 """ 41 if os.geteuid() != 0: 42 raise KiwiPrivilegesError( 43 'operation requires root permissions' 44 ) 45 return True
Check if we are effectively root on the system. If not an exception is thrown
Returns
True or raise an Exception