The branch, master has been updated
       via  9971061 s3: Pass logonHours through pdb_ads
       via  943aac2 s3: Add "len" to pdb_set_hours
       via  6f3008e s3: Let pdb_ads write accountExpires
       via  478d74f s3: Fix pdb_ads_pull_time
      from  464c696 vfs_smb_traffic_analyzer shall also transfer the clients IP 
address.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9971061a9d17c2eb4bf1e8ea5691bec2b127072e
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 16 16:33:21 2011 +0100

    s3: Pass logonHours through pdb_ads
    
    Autobuild-User: Volker Lendecke <[email protected]>
    Autobuild-Date: Sat Feb 19 12:22:08 CET 2011 on sn-devel-104

commit 943aac2e366b781136cfff467b7ea5631890ebdd
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 16 16:47:23 2011 +0100

    s3: Add "len" to pdb_set_hours

commit 6f3008e62714d46beed96e0f834340f81fa3c0c0
Author: Volker Lendecke <[email protected]>
Date:   Tue Feb 15 21:42:35 2011 +0100

    s3: Let pdb_ads write accountExpires

commit 478d74fe1447c4588b14ef7040c8c13339d54026
Author: Volker Lendecke <[email protected]>
Date:   Tue Feb 15 21:41:58 2011 +0100

    s3: Fix pdb_ads_pull_time

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h                 |    3 +-
 source3/libnet/libnet_dssync_passdb.c   |    3 +-
 source3/libnet/libnet_samsync_passdb.c  |    3 +-
 source3/passdb/passdb.c                 |    8 +++---
 source3/passdb/pdb_ads.c                |   42 ++++++++++++++++++++++++++++++-
 source3/passdb/pdb_get_set.c            |   11 ++++++--
 source3/passdb/pdb_ldap.c               |    2 +-
 source3/rpc_server/samr/srv_samr_util.c |    4 ++-
 source3/utils/pdbedit.c                 |    2 +-
 9 files changed, 64 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 0885053..a2cc222 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3770,7 +3770,8 @@ bool pdb_set_country_code(struct samu *sampass, uint16_t 
country_code,
 bool pdb_set_code_page(struct samu *sampass, uint16_t code_page,
                       enum pdb_value_state flag);
 bool pdb_set_unknown_6(struct samu *sampass, uint32_t unkn, enum 
pdb_value_state flag);
-bool pdb_set_hours(struct samu *sampass, const uint8_t *hours, enum 
pdb_value_state flag);
+bool pdb_set_hours(struct samu *sampass, const uint8 *hours, int hours_len,
+                  enum pdb_value_state flag);
 bool pdb_set_backend_private_data(struct samu *sampass, void *private_data, 
                                   void (*free_fn)(void **), 
                                   const struct pdb_methods *my_methods, 
diff --git a/source3/libnet/libnet_dssync_passdb.c 
b/source3/libnet/libnet_dssync_passdb.c
index 4b66c39..df99e40 100644
--- a/source3/libnet/libnet_dssync_passdb.c
+++ b/source3/libnet/libnet_dssync_passdb.c
@@ -1263,7 +1263,8 @@ static NTSTATUS sam_account_from_object(struct samu 
*account,
                pdb_sethexhours(oldstr, pdb_get_hours(account));
                pdb_sethexhours(newstr, logonHours.data);
                if (!strequal(oldstr, newstr)) {
-                       pdb_set_hours(account, logonHours.data, PDB_CHANGED);
+                       pdb_set_hours(account, logonHours.data,
+                                     logonHours.length, PDB_CHANGED);
                }
        }
 
diff --git a/source3/libnet/libnet_samsync_passdb.c 
b/source3/libnet/libnet_samsync_passdb.c
index 9d72194..cfcdb7c 100644
--- a/source3/libnet/libnet_samsync_passdb.c
+++ b/source3/libnet/libnet_samsync_passdb.c
@@ -179,7 +179,8 @@ static NTSTATUS sam_account_from_delta(struct samu *account,
                pdb_sethexhours(oldstr, pdb_get_hours(account));
                pdb_sethexhours(newstr, r->logon_hours.bits);
                if (!strequal(oldstr, newstr))
-                       pdb_set_hours(account, r->logon_hours.bits, 
PDB_CHANGED);
+                       pdb_set_hours(account, r->logon_hours.bits,
+                                     pdb_get_hours_len(account), PDB_CHANGED);
        }
 
        if (pdb_get_bad_password_count(account) != r->bad_password_count)
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index dafe55e..fdc4bdc 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -1086,7 +1086,7 @@ static bool init_samu_from_buffer_v0(struct samu 
*sampass, uint8_t *buf, uint32_
        pdb_set_unknown_6(sampass, unknown_6, PDB_SET);
        pdb_set_acct_ctrl(sampass, acct_ctrl, PDB_SET);
        pdb_set_logon_divs(sampass, logon_divs, PDB_SET);
-       pdb_set_hours(sampass, hours, PDB_SET);
+       pdb_set_hours(sampass, hours, hours_len, PDB_SET);
 
 done:
 
@@ -1278,7 +1278,7 @@ static bool init_samu_from_buffer_v1(struct samu 
*sampass, uint8_t *buf, uint32_
        pdb_set_unknown_6(sampass, unknown_6, PDB_SET);
        pdb_set_acct_ctrl(sampass, acct_ctrl, PDB_SET);
        pdb_set_logon_divs(sampass, logon_divs, PDB_SET);
-       pdb_set_hours(sampass, hours, PDB_SET);
+       pdb_set_hours(sampass, hours, hours_len, PDB_SET);
 
 done:
 
@@ -1509,7 +1509,7 @@ static bool init_samu_from_buffer_v2(struct samu 
*sampass, uint8_t *buf, uint32_
        pdb_set_unknown_6(sampass, unknown_6, PDB_SET);
        pdb_set_acct_ctrl(sampass, acct_ctrl, PDB_SET);
        pdb_set_logon_divs(sampass, logon_divs, PDB_SET);
-       pdb_set_hours(sampass, hours, PDB_SET);
+       pdb_set_hours(sampass, hours, hours_len, PDB_SET);
 
 done:
 
@@ -1744,7 +1744,7 @@ static bool init_samu_from_buffer_v3(struct samu 
*sampass, uint8_t *buf, uint32_
        /* Change from V2 is the uint32_t acct_ctrl */
        pdb_set_acct_ctrl(sampass, acct_ctrl, PDB_SET);
        pdb_set_logon_divs(sampass, logon_divs, PDB_SET);
-       pdb_set_hours(sampass, hours, PDB_SET);
+       pdb_set_hours(sampass, hours, hours_len, PDB_SET);
 
 done:
 
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 1dcf5ad..bcb803b 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -67,7 +67,7 @@ static bool pdb_ads_pull_time(struct tldap_message *msg, 
const char *attr,
        if (!tldap_pull_uint64(msg, attr, &tmp)) {
                return false;
        }
-       *ptime = uint64s_nt_time_to_unix_abs(&tmp);
+       *ptime = nt_time_to_unix(tmp);
        return true;
 }
 
@@ -313,12 +313,44 @@ static NTSTATUS pdb_ads_init_sam_from_priv(struct 
pdb_methods *m,
                pdb_set_code_page(sam, i, PDB_SET);
        }
 
+       if (tldap_get_single_valueblob(entry, "logonHours", &blob)) {
+
+               if (blob.length > MAX_HOURS_LEN) {
+                       status = NT_STATUS_INVALID_PARAMETER;
+                       goto fail;
+               }
+               pdb_set_logon_divs(sam, blob.length * 8, PDB_SET);
+               pdb_set_hours_len(sam, blob.length, PDB_SET);
+               pdb_set_hours(sam, blob.data, blob.length, PDB_SET);
+
+       } else {
+               uint8_t hours[21];
+               pdb_set_logon_divs(sam, sizeof(hours)/8, PDB_SET);
+               pdb_set_hours_len(sam, sizeof(hours), PDB_SET);
+               memset(hours, 0xff, sizeof(hours));
+               pdb_set_hours(sam, hours, sizeof(hours), PDB_SET);
+       }
+
        status = NT_STATUS_OK;
 fail:
        TALLOC_FREE(frame);
        return status;
 }
 
+static bool pdb_ads_make_time_mod(struct tldap_message *existing,
+                                 TALLOC_CTX *mem_ctx,
+                                 struct tldap_mod **pmods, int *pnum_mods,
+                                 const char *attrib, time_t t)
+{
+       uint64_t nt_time;
+
+       unix_to_nt_time(&nt_time, t);
+
+       return tldap_make_mod_fmt(
+               existing, mem_ctx, pmods, pnum_mods, attrib,
+               "%llu", nt_time);
+}
+
 static bool pdb_ads_init_ads_from_sam(struct pdb_ads_state *state,
                                      struct tldap_message *existing,
                                      TALLOC_CTX *mem_ctx,
@@ -412,6 +444,14 @@ static bool pdb_ads_init_ads_from_sam(struct pdb_ads_state 
*state,
                existing, mem_ctx, pmods, pnum_mods, "codePage",
                "%i", (int)pdb_get_code_page(sam));
 
+       ret &= pdb_ads_make_time_mod(
+               existing, mem_ctx, pmods, pnum_mods, "accountExpires",
+               (int)pdb_get_kickoff_time(sam));
+
+       ret &= tldap_make_mod_blob(
+               existing, mem_ctx, pmods, pnum_mods, "logonHours",
+               data_blob_const(pdb_get_hours(sam), pdb_get_hours_len(sam)));
+
 fail:
        return ret;
 }
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 07a63e2..e572c3d 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -918,12 +918,17 @@ bool pdb_set_unknown_6(struct samu *sampass, uint32_t 
unkn, enum pdb_value_state
        return pdb_set_init_flags(sampass, PDB_UNKNOWN6, flag);
 }
 
-bool pdb_set_hours(struct samu *sampass, const uint8 *hours, enum 
pdb_value_state flag)
+bool pdb_set_hours(struct samu *sampass, const uint8 *hours, int hours_len,
+                  enum pdb_value_state flag)
 {
+       if (hours_len > sizeof(sampass->hours)) {
+               return false;
+       }
+
        if (!hours) {
-               memset ((char *)sampass->hours, 0, MAX_HOURS_LEN);
+               memset ((char *)sampass->hours, 0, hours_len);
        } else {
-               memcpy (sampass->hours, hours, MAX_HOURS_LEN);
+               memcpy (sampass->hours, hours, hours_len);
        }
 
        return pdb_set_init_flags(sampass, PDB_HOURS, flag);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index a884b30..573c505 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1027,7 +1027,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates 
*ldap_state,
        if (temp) {
                pdb_gethexhours(temp, hours);
                memset((char *)temp, '\0', strlen(temp) +1);
-               pdb_set_hours(sampass, hours, PDB_SET);
+               pdb_set_hours(sampass, hours, hours_len, PDB_SET);
                ZERO_STRUCT(hours);
        }
 
diff --git a/source3/rpc_server/samr/srv_samr_util.c 
b/source3/rpc_server/samr/srv_samr_util.c
index 0bab127..8dfeae1 100644
--- a/source3/rpc_server/samr/srv_samr_util.c
+++ b/source3/rpc_server/samr/srv_samr_util.c
@@ -580,7 +580,9 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
                pdb_sethexhours(oldstr, pdb_get_hours(to));
                pdb_sethexhours(newstr, from->logon_hours.bits);
                if (!strequal(oldstr, newstr)) {
-                       pdb_set_hours(to, from->logon_hours.bits, PDB_CHANGED);
+                       pdb_set_hours(to, from->logon_hours.bits,
+                                     from->logon_hours.units_per_week/8,
+                                     PDB_CHANGED);
                }
        }
 
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 4008053..ec324cd 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -526,7 +526,7 @@ static int set_user_info(const char *username, const char 
*fullname,
                hours_len = pdb_get_hours_len(sam_pwent);
                memset(hours_array, 0xff, hours_len);
 
-               pdb_set_hours(sam_pwent, hours_array, PDB_CHANGED);
+               pdb_set_hours(sam_pwent, hours_array, hours_len, PDB_CHANGED);
        }
 
        if (!pdb_update_autolock_flag(sam_pwent, &updated_autolock)) {


-- 
Samba Shared Repository

Reply via email to