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))
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)
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)