summaryrefslogtreecommitdiffstats
path: root/fooconf-unix-passwd
blob: a39fa9b95a1cbd5c9f67dc6fbb3b0ecbc96066a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# Hey Emacs, this is -*-python-*- code!

from fooconflib import *

def generateUnixPasswdFragment(ctx = FooConfContext()) :
      cursor = ctx.db.cursor()
      cursor.execute("SELECT name, id, enabled"+
                     " FROM account")
      
      while 1:
            row = cursor.fetchone()
            if row is None: break

            if row["enabled"] :
                  pw = "xxx"
                  shell = "/bin/sh"
            else:
                  pw = ""
                  shell = "/bin/false"

            print "%s:%s:%u:%u:%s,Fooconf User:%s:%s" % (ctx.makeSysUserName(row["name"]),
                                                         pw,   
                                                         ctx.makeSysUID(row["id"]),
                                                         ctx.makeSysGID(row["id"]),
                                                         row["name"],
                                                         ctx.makeHomeDir(row["name"]),
                                                         shell)

if __name__ == "__main__":
      generateUnixPasswdFragment()