+# Generate the rtcPassword list
+def GenRtcPassword(accounts, File):
+ F = None
+ try:
+ OldMask = os.umask(0077)
+ F = open(File, "w", 0600)
+ os.umask(OldMask)
+
+ for a in accounts:
+ if a.is_guest_account(): continue
+ if 'rtcPassword' not in a: continue
+ if not a.pw_active(): continue
+
+ Line = "%s%s:%s:%s:AUTHORIZED" % (a['uid'], rtc_append, str(a['rtcPassword']), rtc_realm)
+ Line = Sanitize(Line) + "\n"
+ F.write("%s" % (Line))
+
+ except:
+ Die(File, None, F)
+ raise
+
+# Generate the TOTP auth file
+def GenTOTPSeed(accounts, File):
+ F = None
+ try:
+ OldMask = os.umask(0077)
+ F = open(File, "w", 0600)
+ os.umask(OldMask)
+
+ F.write("# Option User Prefix Seed\n")
+ for a in accounts:
+ if a.is_guest_account(): continue
+ if 'totpSeed' not in a: continue
+ if not a.pw_active(): continue
+
+ Line = "HOTP/T30/6 %s - %s" % (a['uid'], a['totpSeed'])
+ Line = Sanitize(Line) + "\n"
+ F.write("%s" % (Line))
+ except:
+ Die(File, None, F)
+ raise
+
+