diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py index 33adea0b..9c6329c7 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py @@ -16,36 +16,19 @@ import Utils def getUid(userName): - try: - fp = open(Globals.CIFS_USER_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - - for line in content.strip().split(): - tokens = line.split(":") + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) + for line in lines: + tokens = line.strip().split(":") if tokens[1] == userName: return int(tokens[0]) return None def getLastUid(): - if not os.path.exists(Globals.CIFS_USER_FILE): - return Globals.DEFAULT_UID - try: - fp = open(Globals.CIFS_USER_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - - lines = content.strip().split() + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) if not lines: return Globals.DEFAULT_UID - return int(lines[-1].split(":")[0]) + return int([line.strip().split(':')[0] for line in lines if line.strip()][-1]) def setUid(uid, userName): |