Пример #1
0
    def _userdb_merge(old_etc, new_etc):
        old_passwd = join(old_etc, "passwd")
        new_passwd = join(new_etc, "passwd")

        old_group = join(old_etc, "group")
        new_group = join(new_etc, "group")

        def r(path):
            return file(path).read()

        return userdb.merge(r(old_passwd), r(old_group),
                            r(new_passwd), r(new_group))
Пример #2
0
    def _userdb_merge(old_etc, new_etc):
        old_passwd = join(old_etc, "passwd")
        new_passwd = join(new_etc, "passwd")

        old_group = join(old_etc, "group")
        new_group = join(new_etc, "group")

        def r(path):
            return file(path).read()

        return userdb.merge(r(old_passwd), r(old_group), r(new_passwd),
                            r(new_group))
Пример #3
0
def main():
    args = sys.argv[1:]
    if len(args) != 6:
        usage()

    old_passwd, old_group = args[:2]
    new_passwd, new_group = args[2:4]
    merged_passwd, merged_group = args[4:6]

    def r(path):
        return file(path).read()

    passwd, group, uidmap, gidmap = userdb.merge(r(old_passwd), r(old_group),
                                                 r(new_passwd), r(new_group))

    print >> file(merged_passwd, "w"), passwd
    print >> file(merged_group, "w"), group

    def fmt_map(m):
        return ":".join(["%d,%d" % (key, val) for key, val in m.items()])

    print fmt_map(uidmap)
    print fmt_map(gidmap)
Пример #4
0
def main():
    args = sys.argv[1:]
    if len(args) != 6:
        usage()

    old_passwd, old_group = args[:2]
    new_passwd, new_group = args[2:4]
    merged_passwd, merged_group = args[4:6]

    def r(path):
        return file(path).read()

    passwd, group, uidmap, gidmap = userdb.merge(r(old_passwd), r(old_group),
                                                 r(new_passwd), r(new_group))

    print >> file(merged_passwd, "w"), passwd
    print >> file(merged_group, "w"), group

    def fmt_map(m):
         return ":".join([ "%d,%d" % (key, val) for key,val in m.items() ])

    print fmt_map(uidmap)
    print fmt_map(gidmap)