summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-10-15 10:15:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:44:46 -0500
commitc3c26c90088141272affb591702f3c2124eec89f (patch)
tree8bca1ba93e5f244425b23fc0eeee677b1484efce
parentdab2b6858315909cd26fa5ce5aba84b6b4c3e62e (diff)
downloadsamba-c3c26c90088141272affb591702f3c2124eec89f.tar.gz
samba-c3c26c90088141272affb591702f3c2124eec89f.tar.bz2
samba-c3c26c90088141272affb591702f3c2124eec89f.zip
r11087: - add type,name,scope as attributes to winsRecords,
so you can use them in search filters, only for administration not used inside the winserver code - fix the samba3 ugrade scripts to create a correct samba4 wins.ldb metze (This used to be commit 9f3b6746d86583c48097da48c28f50f075bbd3e3)
-rw-r--r--source4/nbt_server/wins/winsdb.c7
-rw-r--r--source4/scripting/libjs/upgrade.js65
-rwxr-xr-xsource4/setup/upgrade2
3 files changed, 66 insertions, 8 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 7ab8216837..d3f10aa9a4 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -513,6 +513,13 @@ struct ldb_message *winsdb_message(struct ldb_context *ldb,
msg->dn = winsdb_dn(msg, rec->name);
if (msg->dn == NULL) goto failed;
+ ret |= ldb_msg_add_fmt(msg, "type", "0x%02X", rec->name->type);
+ if (rec->name->name) {
+ ret |= ldb_msg_add_string(msg, "name", rec->name->name);
+ }
+ if (rec->name->scope) {
+ ret |= ldb_msg_add_string(msg, "scope", rec->name->scope);
+ }
ret |= ldb_msg_add_fmt(msg, "objectClass", "winsRecord");
ret |= ldb_msg_add_fmt(msg, "recordType", "%u", rec->type);
ret |= ldb_msg_add_fmt(msg, "recordState", "%u", rec->state);
diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js
index 6109371338..60a9725b43 100644
--- a/source4/scripting/libjs/upgrade.js
+++ b/source4/scripting/libjs/upgrade.js
@@ -228,22 +228,73 @@ unixID: %d", m.sid, domaindn, m.sid, m.type, m.unix_id);
function upgrade_wins(samba3)
{
var ldif = "";
+ var version_id = 0;
+
for (i in samba3.winsentries) {
+ var rType;
+ var rState;
+ var nType;
+ var numIPs = 0;
var e = samba3.winsentries[i];
-
+ var now = sys.nttime();
+ var ttl = sys.unix2nttime(e.ttl);
+
+ version_id++;
+
+ for (var i in e.ips) {
+ numIPs++;
+ }
+
+ if (e.type == 0x1C) {
+ rType = 0x2;
+ } else if (sys.bitAND(e.type, 0x80)) {
+ if (numIPs > 1) {
+ rType = 0x2;
+ } else {
+ rType = 0x1;
+ }
+ } else {
+ if (numIPs > 1) {
+ rType = 0x3;
+ } else {
+ rType = 0x0;
+ }
+ }
+
+ if (ttl > now) {
+ rState = 0x0;/* active */
+ } else {
+ rState = 0x1;/* released */
+ }
+
+ nType = (sys.bitAND(e.nb_flags,0x60)>>5);
+
ldif = ldif + sprintf("
-dn: type=%d,name=%s
+dn: name:%s,type=0x%02X
+type: 0x%02X
name: %s
-objectClass: wins
-nbFlags: %x
-expires: %s
-", e.type, e.name, e.name, e.type, e.nb_flags, sys.ldaptime(e.ttl));
+objectClass: winsRecord
+recordType: %u
+recordState: %u
+nodeType: %u
+isStatic: 0
+expireTime: %s
+versionID: %llu
+", e.name, e.type, e.type, e.name,
+ rType, rState, nType,
+ sys.ldaptime(ttl), version_id);
for (var i in e.ips) {
ldif = ldif + sprintf("address: %s\n", e.ips[i]);
}
}
+ ldif = ldif + sprintf("
+dn: CN=VERSION
+objectClass: winsMaxVersion
+maxVersion: %llu
+", version_id);
+
return ldif;
}
@@ -569,7 +620,7 @@ data: %d
dn: @MODULES
changetype: modify
replace: @LIST
-@LIST: samldb,timestamps,objectguid,rdn_name,samba3sam
+@LIST: samldb,operational,objectguid,rdn_name,samba3sam
");
if (!ok) {
message("Error enabling samba3sam module: " + samdb.errstring() + "\n");
diff --git a/source4/setup/upgrade b/source4/setup/upgrade
index 8dc10caa3f..251b9663a7 100755
--- a/source4/setup/upgrade
+++ b/source4/setup/upgrade
@@ -75,7 +75,7 @@ var paths;
if (options.targetdir != undefined) {
paths = new Object();
paths.smbconf = sprintf("%s/smb.conf", options.targetdir);
- var ldbs = new Array("hklm","hkcr","hku","hkcu","hkpd","hkpt","samdb","rootdse","secrets","winsdb");
+ var ldbs = new Array("hklm","hkcr","hku","hkcu","hkpd","hkpt","samdb","rootdse","secrets","wins");
for (var i in ldbs) {
var n = ldbs[i];
paths[n] = sprintf("tdb://%s/%s.ldb", options.targetdir, n);