Copyright (C) Andrew Tridgell 1992-1997
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
Copyright (C) Paul Ashton 1997
+ Copyright (C) Jeremy Allison 200-2004
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
#define _NT_DOMAIN_H
-struct uuid
-{
- uint32 time_low;
- uint16 time_mid;
- uint16 time_hi_and_version;
- uint8 clock_seq[2];
- uint8 node[6];
+struct uuid {
+ uint32 time_low;
+ uint16 time_mid;
+ uint16 time_hi_and_version;
+ uint8 clock_seq[2];
+ uint8 node[6];
};
#define UUID_SIZE 16
#define UUID_FLAT_SIZE 16
-typedef struct uuid_flat
-{
+typedef struct uuid_flat {
uint8 info[UUID_FLAT_SIZE];
} UUID_FLAT;
* in the NTDOM branch - it didn't belong there.
*/
-typedef struct _prs_struct
-{
+typedef struct _prs_struct {
BOOL io; /* parsing in or out of data stream */
/*
* If the (incoming) data is big-endian. On output we are
} output_data;
typedef struct _input_data {
- /*
- * This is the current incoming pdu. The data here
- * is collected via multiple writes until a complete
- * pdu is seen, then the data is copied into the in_data
- * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
- */
- unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
-
- /*
- * The amount of data needed to complete the in_pdu.
- * If this is zero, then we are at the start of a new
- * pdu.
- */
- uint32 pdu_needed_len;
-
- /*
- * The amount of data received so far in the in_pdu.
- * If this is zero, then we are at the start of a new
- * pdu.
- */
- uint32 pdu_received_len;
-
- /*
- * This is the collection of input data with all
- * the rpc headers and auth footers removed.
- * The maximum length of this (1Mb) is strictly enforced.
- */
- prs_struct data;
+ /*
+ * This is the current incoming pdu. The data here
+ * is collected via multiple writes until a complete
+ * pdu is seen, then the data is copied into the in_data
+ * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
+ */
+ unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
+
+ /*
+ * The amount of data needed to complete the in_pdu.
+ * If this is zero, then we are at the start of a new
+ * pdu.
+ */
+ uint32 pdu_needed_len;
+
+ /*
+ * The amount of data received so far in the in_pdu.
+ * If this is zero, then we are at the start of a new
+ * pdu.
+ */
+ uint32 pdu_received_len;
+
+ /*
+ * This is the collection of input data with all
+ * the rpc headers and auth footers removed.
+ * The maximum length of this (1Mb) is strictly enforced.
+ */
+ prs_struct data;
} input_data;
/*
* Handle database - stored per pipe.
*/
-struct policy
-{
- struct policy *next, *prev;
+struct policy {
+ struct policy *next, *prev;
- POLICY_HND pol_hnd;
-
- void *data_ptr;
- void (*free_fn)(void *);
+ POLICY_HND pol_hnd;
+ void *data_ptr;
+ void (*free_fn)(void *);
};
struct handle_list {
};
/* Domain controller authentication protocol info */
-struct dcinfo
-{
+struct dcinfo {
DOM_CHAL clnt_chal; /* Initial challenge received from client */
DOM_CHAL srv_chal; /* Initial server challenge */
DOM_CRED clnt_cred; /* Last client credential */
* NamedPipes.
*/
-typedef struct pipes_struct
-{
+typedef struct pipes_struct {
struct pipes_struct *next, *prev;
connection_struct *conn;
} pipes_struct;
-typedef struct smb_np_struct
-{
+typedef struct smb_np_struct {
struct smb_np_struct *next, *prev;
int pnum;
connection_struct *conn;
} smb_np_struct;
-struct api_struct
-{
- const char *name;
- uint8 opnum;
- BOOL (*fn) (pipes_struct *);
+struct api_struct {
+ const char *name;
+ uint8 opnum;
+ BOOL (*fn) (pipes_struct *);
};
-typedef struct
-{
+typedef struct {
uint32 rid;
const char *name;
-
} rid_name;
/*
{0, NULL}
};
+char *account_policy_names_list(void)
+{
+ char *nl, *p;
+ int i;
+ size_t len = 0;
+
+ for (i=0; account_policy_names[i].string; i++) {
+ len += strlen(account_policy_names[i].string) + 1;
+ }
+ len++;
+ nl = malloc(len);
+ if (!nl) {
+ return NULL;
+ }
+ p = nl;
+ for (i=0; account_policy_names[i].string; i++) {
+ memcpy(p, account_policy_names[i].string, strlen(account_policy_names[i].string) + 1);
+ p[strlen(account_policy_names[i].string)] = '\n';
+ p += strlen(account_policy_names[i].string) + 1;
+ }
+ *p = '\0';
+ return nl;
+}
+
/****************************************************************************
Get the account policy name as a string from its #define'ed number
****************************************************************************/
}
-
/****************************************************************************
****************************************************************************/
+
BOOL account_policy_get(int field, uint32 *value)
{
fstring name;
return True;
}
-
if ((local_flags & LOCAL_ADD_USER) || (local_flags & LOCAL_DELETE_USER)) {
/* Might not exist in /etc/passwd. Use rid algorithm here */
if (!NT_STATUS_IS_OK(pdb_init_sam_new(&sam_pass, user_name, 0))) {
- slprintf(err_str, err_str_len-1, "Failed to initialise SAM_ACCOUNT for user %s.\n", user_name);
+ slprintf(err_str, err_str_len-1, "Failed to initialise SAM_ACCOUNT for user %s. Does this user exist in the UNIX password database ?\n", user_name);
return False;
}
} else {
/* Change from V1 is addition of password history field. */
account_policy_get(AP_PASSWORD_HISTORY, &pwHistLen);
-
- if (pwHistLen && nt_pw_hist_ptr && ((nt_pw_hist_len % NT_HASH_LEN) == 0)) {
- if (!pdb_set_pw_history(sampass, nt_pw_hist_ptr, nt_pw_hist_len/NT_HASH_LEN, PDB_SET)) {
+ if (pwHistLen) {
+ char *pw_hist = malloc(pwHistLen * NT_HASH_LEN);
+ if (!pw_hist) {
+ ret = False;
+ goto done;
+ }
+ memset(pw_hist, '\0', pwHistLen * NT_HASH_LEN);
+ if (nt_pw_hist_ptr && nt_pw_hist_len) {
+ int i;
+ SMB_ASSERT((nt_pw_hist_len % NT_HASH_LEN) == 0);
+ nt_pw_hist_len /= NT_HASH_LEN;
+ for (i = 0; (i < pwHistLen) && (i < nt_pw_hist_len); i++) {
+ memcpy(&pw_hist[i*NT_HASH_LEN], &nt_pw_hist_ptr[i*NT_HASH_LEN], NT_HASH_LEN);
+ }
+ }
+ if (!pdb_set_pw_history(sampass, pw_hist, pwHistLen, PDB_SET)) {
+ SAFE_FREE(pw_hist);
ret = False;
goto done;
}
+ SAFE_FREE(pw_hist);
} else {
pdb_set_pw_history(sampass, NULL, 0, PDB_SET);
}