Represents a user requesting authentication to the salt master
| 831 | |
| 832 | |
| 833 | class AuthUser: |
| 834 | """ |
| 835 | Represents a user requesting authentication to the salt master |
| 836 | """ |
| 837 | |
| 838 | def __init__(self, user): |
| 839 | """ |
| 840 | Instantiate an AuthUser object. |
| 841 | |
| 842 | Takes a user to represent, as a string. |
| 843 | """ |
| 844 | self.user = user |
| 845 | |
| 846 | def is_sudo(self): |
| 847 | """ |
| 848 | Determines if the user is running with sudo |
| 849 | |
| 850 | Returns True if the user is running with sudo and False if the |
| 851 | user is not running with sudo |
| 852 | """ |
| 853 | return self.user.startswith("sudo_") |
| 854 | |
| 855 | def is_running_user(self): |
| 856 | """ |
| 857 | Determines if the user is the same user as the one running |
| 858 | this process |
| 859 | |
| 860 | Returns True if the user is the same user as the one running |
| 861 | this process and False if not. |
| 862 | """ |
| 863 | return self.user == salt.utils.user.get_user() |
| 864 | |
| 865 | def sudo_name(self): |
| 866 | """ |
| 867 | Returns the username of the sudoer, i.e. self.user without the |
| 868 | 'sudo_' prefix. |
| 869 | """ |
| 870 | return self.user.split("_", 1)[-1] |
no outgoing calls
no test coverage detected