diff options
| author | Michael E Brown <michael_e_brown@dell.com> | 2007-10-16 23:31:44 -0500 |
|---|---|---|
| committer | Michael E Brown <michael_e_brown@dell.com> | 2007-10-16 23:31:44 -0500 |
| commit | e2a06707ac8ed1acc6b21eb6ac9c7534a2ca0cda (patch) | |
| tree | ec2ac1d6eb388cd6e438ab713679df8ced1399b4 /src | |
| parent | b63b38e5a0efce4e44c35800cf64bd7434a50da0 (diff) | |
| download | mock-e2a06707ac8ed1acc6b21eb6ac9c7534a2ca0cda.tar.gz mock-e2a06707ac8ed1acc6b21eb6ac9c7534a2ca0cda.tar.xz mock-e2a06707ac8ed1acc6b21eb6ac9c7534a2ca0cda.zip | |
add new py files to build
Diffstat (limited to 'src')
| -rw-r--r-- | src/py-libs/uid.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/py-libs/uid.py b/src/py-libs/uid.py new file mode 100644 index 0000000..57142ff --- /dev/null +++ b/src/py-libs/uid.py @@ -0,0 +1,56 @@ +#!/usr/bin/python -tt +# vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0: +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Written by Seth Vidal +# Sections taken from Mach by Thomas Vander Stichele +# revised and adapted by Michael Brown + +# python library imports +import os + +# our imports +from mock.trace_decorator import trace + +# functions + +origruid=os.getruid() # 500 +origeuid=os.geteuid() # 0 + +@trace +def savePerms(): + global origruid + global origeuid + origruid = os.getruid() + origeuid = os.geteuid() + +@trace +def elevatePerms(): + os.setreuid(0, 0) + +@trace +def dropPermsTemp(): + elevatePerms() + os.setreuid(0, origruid) + +@trace +def dropPermsForever(): + elevatePerms() + os.setreuid(origruid, origruid) + +@trace +def becomeUser(uid): + elevatePerms() + os.setreuid(0, uid) |
