diff --git a/src/hostinfo/named.py b/src/hostinfo/named.py index 2f1fc5bba6b7cfc7dc4e136bda6d986f33a02194..17496f7af91267a6a1d75c5a12acc8af5c55a7c5 100755 --- a/src/hostinfo/named.py +++ b/src/hostinfo/named.py @@ -122,9 +122,9 @@ def forward(tree, domain): # Find all hosts that belong to this domain for (n, m) in net: if i.ip[0] and aton(i.ip[0]) & m == n: - host[i.name[0:]] = "A %s" % i.ip[0] + host[i.name[1:]] = "A %s" % i.ip[0] for a in i._alias_: - host[a.name[0]] = "CNAME %s" % i.name[0:] + host[a.name[0]] = "CNAME %s" % i.name[1:] # Add a localhost entry result += "localhost IN A 127.0.0.1\n" diff --git a/src/hostinfo/samba.py b/src/hostinfo/samba.py index c6be5ac1e786ba9b552c20e47550b327e6e3eaea..8acfdc03f2f6ffde80eecde3c8bb35d208c37df3 100755 --- a/src/hostinfo/samba.py +++ b/src/hostinfo/samba.py @@ -15,8 +15,8 @@ def share(tree, host): " browseable = no", " path = %s" % a.root[0], " writable = yes", - " create mode = 0664", - " directory mode = 0775" + " create mode = 0644", + " directory mode = 0755" ]) result += "\n\n" return result diff --git a/src/hostinfo/util.py b/src/hostinfo/util.py index 4c3d1defce91a155f0ee8c440da5d635aa1fea69..1f51a3cf5f93a9468a4b5c2b2fdceabed724d598 100755 --- a/src/hostinfo/util.py +++ b/src/hostinfo/util.py @@ -15,7 +15,7 @@ def fqn(tree, host): elif host.ip[0:]: for s in tree._subnet_: if aton(host.ip[0:]) & aton(s.netmask[0]) == aton(s.network[0]): - return "%s.%s." % (host.name[0:],s.domain[0]) + return "%s.%s." % (host.name[1:],s.domain[0]) else: raise Exception("'%s' not FQN, but has no ip" % host.name[0:]) diff --git a/src/hostinfo/yp.py b/src/hostinfo/yp.py index 3761cf5471a578b438d6101e2c09533b42599d36..af1c68a4d08ce5fbea688aa13c22ea1bcd6af589 100755 --- a/src/hostinfo/yp.py +++ b/src/hostinfo/yp.py @@ -40,6 +40,34 @@ def ethers(tree): result += "%-15s %s\n" % (k, h) return result +def adjust_netgroup(netgroup): + limit = 1000 + result = {} + keys = netgroup.keys() + keys.sort() + for g in keys: + entries = netgroup[g] + entries.sort() + length = sum(map(len, entries)) + len(entries) * 5 + if length < limit: + # group is less than max YP length (1024) + result[g] = entries + else: + # group is bigger than max YP length, split it + n = min(length / limit + 1, limit / (len(g) + 5)) + m = len(entries) / n + 1 + tmp = {} + tmp[g] = [] + for i in range(n): + key = "%s__%d" % (g, i) + value = entries[i * m : (i + 1) * m] + if value: + tmp[g].append(key) + tmp[key] = value + for (k, v) in adjust_netgroup(tmp).iteritems(): + result[k] = v + return result + def netgroup(tree): netgroup = {} for m in tree._netgroup_._member_: @@ -68,9 +96,11 @@ def netgroup(tree): except: netgroup["ks-%s" % k.file[0:]] = [ entry ] + netgroup = adjust_netgroup(netgroup) result = "" keys = netgroup.keys() keys.sort() + for g in keys: result += "%s" % g entries = netgroup[g]