- F = None;
- try:
- OldMask = os.umask(0077);
- F = open(File + ".tdb.tmp","w",0600);
- os.umask(OldMask);
-
- # Fetch all the users
- global PasswdAttrs;
-
- I = 0;
- for x in PasswdAttrs:
- if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
- continue;
-
- Pass = GetAttr(x,"userPassword");
- if Pass[0:7] != "{crypt}" or len(Pass) > 50:
- Pass = '*';
- else:
- Pass = Pass[7:];
-
- # If the account is locked, mark it as such in shadow
- # See Debian Bug #308229 for why we set it to 1 instead of 0
- if (GetAttr(x,"userPassword").find("*LK*") != -1) \
- or GetAttr(x,"userPassword").startswith("!"):
- ShadowExpire = '1'
- else:
- ShadowExpire = GetAttr(x,"shadowExpire")
-
- Line = "%s:%s:%s:%s:%s:%s:%s:%s:" % (GetAttr(x,"uid"),\
- Pass,GetAttr(x,"shadowLastChange"),\
- GetAttr(x,"shadowMin"),GetAttr(x,"shadowMax"),\
- GetAttr(x,"shadowWarning"),GetAttr(x,"shadowInactive"),\
- ShadowExpire);
- Line = Sanitize(Line) + "\n";
- F.write("0%u %s" % (I,Line));
- F.write(".%s %s" % (GetAttr(x,"uid"),Line));
- I = I + 1;
-
- # Oops, something unspeakable happened.
- except:
- Die(File,None,F);
- raise;
- Done(File,None,F);
+ F = None
+ try:
+ OldMask = os.umask(0077)
+ F = open(File + ".tdb.tmp","w",0600)
+ os.umask(OldMask)
+
+ # Fetch all the users
+ global PasswdAttrs
+
+ I = 0
+ for x in PasswdAttrs:
+ if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
+ continue
+
+ Pass = GetAttr(x,"userPassword")
+ if Pass[0:7] != "{crypt}" or len(Pass) > 50:
+ Pass = '*'
+ else:
+ Pass = Pass[7:]
+
+ # If the account is locked, mark it as such in shadow
+ # See Debian Bug #308229 for why we set it to 1 instead of 0
+ if (GetAttr(x,"userPassword").find("*LK*") != -1) \
+ or GetAttr(x,"userPassword").startswith("!"):
+ ShadowExpire = '1'
+ else:
+ ShadowExpire = GetAttr(x,"shadowExpire")
+
+ Line = "%s:%s:%s:%s:%s:%s:%s:%s:" % (GetAttr(x,"uid"),\
+ Pass,GetAttr(x,"shadowLastChange"),\
+ GetAttr(x,"shadowMin"),GetAttr(x,"shadowMax"),\
+ GetAttr(x,"shadowWarning"),GetAttr(x,"shadowInactive"),\
+ ShadowExpire)
+ Line = Sanitize(Line) + "\n"
+ F.write("0%u %s" % (I,Line))
+ F.write(".%s %s" % (GetAttr(x,"uid"),Line))
+ I = I + 1
+
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,None,F)
+ raise
+ Done(File,None,F)