diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-27 21:30:01 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-09-27 21:30:01 -0400 |
commit | ec910564e00498f5c545a227bee56eb25233e270 (patch) | |
tree | a256e433675284c2ae2f61e1ddf642bf284d25b3 /cloudinit/util.py | |
parent | 317f442445fc40a666e9566e1f2739324cc99a2e (diff) | |
parent | 56d0585fd7d9804b82a1eb22faff8a6554b100b8 (diff) | |
download | vyos-cloud-init-ec910564e00498f5c545a227bee56eb25233e270.tar.gz vyos-cloud-init-ec910564e00498f5c545a227bee56eb25233e270.zip |
cleanup the user/group lists
The primary utility here is normalize_user_groups, which would
be called by config modules to get a list of users or groups.
This centralizes what was copied code into this one location.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 33da73eb..94b17dfa 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1104,6 +1104,22 @@ def hash_blob(blob, routine, mlen=None): return digest +def is_user(name): + try: + if pwd.getpwnam(name): + return True + except KeyError: + return False + + +def is_group(name): + try: + if grp.getgrnam(name): + return True + except KeyError: + return False + + def rename(src, dest): LOG.debug("Renaming %s to %s", src, dest) # TODO(harlowja) use a se guard here?? |