summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-09-27 21:30:01 -0400
committerScott Moser <smoser@ubuntu.com>2012-09-27 21:30:01 -0400
commitec910564e00498f5c545a227bee56eb25233e270 (patch)
treea256e433675284c2ae2f61e1ddf642bf284d25b3 /cloudinit/util.py
parent317f442445fc40a666e9566e1f2739324cc99a2e (diff)
parent56d0585fd7d9804b82a1eb22faff8a6554b100b8 (diff)
downloadvyos-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.py16
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??