diff options
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 0312231933..128b3ab570 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -1735,3 +1735,19 @@ def environment(**envvars): | |||
| 1735 | os.environ[var] = backup[var] | 1735 | os.environ[var] = backup[var] |
| 1736 | else: | 1736 | else: |
| 1737 | del os.environ[var] | 1737 | del os.environ[var] |
| 1738 | |||
| 1739 | def is_local_uid(uid=''): | ||
| 1740 | """ | ||
| 1741 | Check whether uid is a local one or not. | ||
| 1742 | Can't use pwd module since it gets all UIDs, not local ones only. | ||
| 1743 | """ | ||
| 1744 | if not uid: | ||
| 1745 | uid = os.getuid() | ||
| 1746 | with open('/etc/passwd', 'r') as f: | ||
| 1747 | for line in f: | ||
| 1748 | line_split = line.split(':') | ||
| 1749 | if len(line_split) < 3: | ||
| 1750 | continue | ||
| 1751 | if str(uid) == line_split[2]: | ||
| 1752 | return True | ||
| 1753 | return False | ||
