summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-02-20 05:47:02 +0000
committerLuke Leighton <lkcl@samba.org>2000-02-20 05:47:02 +0000
commit807f264eb662a0bb7a57f2cb9f93b26af2b663c0 (patch)
tree1b051c6896a465859264cfb622e0bd5a72a49c32
parent6678f948368302ce7cb83e27b83f441e4e79b134 (diff)
downloadsamba-807f264eb662a0bb7a57f2cb9f93b26af2b663c0.tar.gz
proper job on set secret stuff. added idle function to msrpc fn table.
called during idle or on exit of msrpc daemon.
-rw-r--r--source/browserd/browserd.c3
-rw-r--r--source/include/ntdomain.h1
-rw-r--r--source/include/proto.h87
-rw-r--r--source/include/rpc_client_proto.h87
-rw-r--r--source/lsarpcd/lsarpcd.c118
-rw-r--r--source/msrpc/msrpcd_process.c410
-rw-r--r--source/netlogond/netlogond.c3
-rw-r--r--source/param/loadparm.c1
-rw-r--r--source/rpc_client/msrpc_netlogon.c7
-rw-r--r--source/samrd/samrd.c3
-rw-r--r--source/spoolssd/spoolssd.c3
-rw-r--r--source/srvsvcd/srvsvcd.c3
-rw-r--r--source/svcctld/svcctld.c3
-rw-r--r--source/winregd/winregd.c3
-rw-r--r--source/wkssvcd/wkssvcd.c3
15 files changed, 405 insertions, 330 deletions
diff --git a/source/browserd/browserd.c b/source/browserd/browserd.c
index a08e0f93fec..7d188d3166d 100644
--- a/source/browserd/browserd.c
+++ b/source/browserd/browserd.c
@@ -109,7 +109,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h
index 29351cd2464..4fb0e7c8dbd 100644
--- a/source/include/ntdomain.h
+++ b/source/include/ntdomain.h
@@ -208,6 +208,7 @@ typedef struct msrpc_service_fns
void (*service_init) (char *);
BOOL (*reload_services) (BOOL);
int (*main_init) (int, char *[]);
+ void (*idle) (void);
}
msrpc_service_fns;
diff --git a/source/include/proto.h b/source/include/proto.h
index ffdf1ec8c32..abfd9eb6692 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -2142,48 +2142,43 @@ BOOL event_readeventlog(POLICY_HND *hnd,
/*The following definitions come from rpc_client/cli_login.c */
-uint32 cli_nt_setup_creds( const char* srv_name,
- const char* domain,
- const char* myhostname,
- const char* trust_acct,
- const uchar trust_pwd[16],
- uint16 sec_chan);
-BOOL cli_nt_srv_pwset(const char* srv_name, const char* myhostname,
- const char* trust_acct,
- const uchar *new_hashof_trust_pwd,
- uint16 sec_chan);
-BOOL cli_nt_login_general(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low,
- const char* general,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_login_interactive(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low,
- const uchar *lm_owf_user_pwd,
- const uchar *nt_owf_user_pwd,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_login_network(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low, const char lm_chal[8],
- const char *lm_chal_resp,
- int lm_chal_len,
- const char *nt_chal_resp,
- int nt_chal_len,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_logoff(const char* srv_name, const char* myhostname,
- NET_ID_INFO_CTR *ctr);
-BOOL net_sam_sync(const char* srv_name,
- const char* domain,
- const char* myhostname,
- const char* trust_acct,
- uchar trust_passwd[16],
- SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
- SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
- uint32 *num_deltas);
+uint32 cli_nt_setup_creds(const char *srv_name,
+ const char *domain,
+ const char *myhostname,
+ const char *trust_acct,
+ const uchar trust_pwd[16], uint16 sec_chan);
+BOOL cli_nt_srv_pwset(const char *srv_name, const char *myhostname,
+ const char *trust_acct,
+ const uchar * new_hashof_trust_pwd, uint16 sec_chan);
+BOOL cli_nt_login_general(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low,
+ const char *general,
+ NET_ID_INFO_CTR * ctr, NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_login_interactive(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low,
+ const uchar * lm_owf_user_pwd,
+ const uchar * nt_owf_user_pwd,
+ NET_ID_INFO_CTR * ctr,
+ NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_login_network(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low, const char lm_chal[8],
+ const char *lm_chal_resp,
+ int lm_chal_len,
+ const char *nt_chal_resp,
+ int nt_chal_len,
+ NET_ID_INFO_CTR * ctr, NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_logoff(const char *srv_name, const char *myhostname,
+ NET_ID_INFO_CTR * ctr);
+BOOL net_sam_sync(const char *srv_name,
+ const char *domain,
+ const char *myhostname,
+ const char *trust_acct,
+ uchar trust_passwd[16],
+ SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
+ SAM_DELTA_CTR deltas[MAX_SAM_DELTAS], uint32 * num_deltas);
/*The following definitions come from rpc_client/cli_lsarpc.c */
@@ -2556,10 +2551,10 @@ BOOL msrpc_lsa_query_trust_passwd(const char *srv_name,
/*The following definitions come from rpc_client/msrpc_netlogon.c */
-BOOL modify_trust_password( const char *domain, const char *remote_machine,
- const uchar orig_trust_passwd_hash[16],
- const uchar new_trust_passwd_hash[16],
- uint16 sec_chan);
+BOOL modify_trust_password(const char *domain, const char *remote_machine,
+ const uchar orig_trust_passwd_hash[16],
+ const uchar new_trust_passwd_hash[16],
+ uint16 sec_chan);
uint32 check_domain_security(const char *orig_user, const char *domain,
const uchar * challenge,
const char *smb_apasswd, int smb_apasslen,
diff --git a/source/include/rpc_client_proto.h b/source/include/rpc_client_proto.h
index 2cfc83a1eaf..63cd81a2ca6 100644
--- a/source/include/rpc_client_proto.h
+++ b/source/include/rpc_client_proto.h
@@ -79,48 +79,43 @@ BOOL event_readeventlog(POLICY_HND *hnd,
/*The following definitions come from rpc_client/cli_login.c */
-uint32 cli_nt_setup_creds( const char* srv_name,
- const char* domain,
- const char* myhostname,
- const char* trust_acct,
- const uchar trust_pwd[16],
- uint16 sec_chan);
-BOOL cli_nt_srv_pwset(const char* srv_name, const char* myhostname,
- const char* trust_acct,
- const uchar *new_hashof_trust_pwd,
- uint16 sec_chan);
-BOOL cli_nt_login_general(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low,
- const char* general,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_login_interactive(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low,
- const uchar *lm_owf_user_pwd,
- const uchar *nt_owf_user_pwd,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_login_network(const char* srv_name, const char* myhostname,
- const char *domain, const char *username,
- uint32 luid_low, const char lm_chal[8],
- const char *lm_chal_resp,
- int lm_chal_len,
- const char *nt_chal_resp,
- int nt_chal_len,
- NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_logoff(const char* srv_name, const char* myhostname,
- NET_ID_INFO_CTR *ctr);
-BOOL net_sam_sync(const char* srv_name,
- const char* domain,
- const char* myhostname,
- const char* trust_acct,
- uchar trust_passwd[16],
- SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
- SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
- uint32 *num_deltas);
+uint32 cli_nt_setup_creds(const char *srv_name,
+ const char *domain,
+ const char *myhostname,
+ const char *trust_acct,
+ const uchar trust_pwd[16], uint16 sec_chan);
+BOOL cli_nt_srv_pwset(const char *srv_name, const char *myhostname,
+ const char *trust_acct,
+ const uchar * new_hashof_trust_pwd, uint16 sec_chan);
+BOOL cli_nt_login_general(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low,
+ const char *general,
+ NET_ID_INFO_CTR * ctr, NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_login_interactive(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low,
+ const uchar * lm_owf_user_pwd,
+ const uchar * nt_owf_user_pwd,
+ NET_ID_INFO_CTR * ctr,
+ NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_login_network(const char *srv_name, const char *myhostname,
+ const char *domain, const char *username,
+ uint32 luid_low, const char lm_chal[8],
+ const char *lm_chal_resp,
+ int lm_chal_len,
+ const char *nt_chal_resp,
+ int nt_chal_len,
+ NET_ID_INFO_CTR * ctr, NET_USER_INFO_3 * user_info3);
+BOOL cli_nt_logoff(const char *srv_name, const char *myhostname,
+ NET_ID_INFO_CTR * ctr);
+BOOL net_sam_sync(const char *srv_name,
+ const char *domain,
+ const char *myhostname,
+ const char *trust_acct,
+ uchar trust_passwd[16],
+ SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
+ SAM_DELTA_CTR deltas[MAX_SAM_DELTAS], uint32 * num_deltas);
/*The following definitions come from rpc_client/cli_lsarpc.c */
@@ -489,10 +484,10 @@ BOOL msrpc_lsa_query_trust_passwd(const char *srv_name,
/*The following definitions come from rpc_client/msrpc_netlogon.c */
-BOOL modify_trust_password( const char *domain, const char *remote_machine,
- const uchar orig_trust_passwd_hash[16],
- const uchar new_trust_passwd_hash[16],
- uint16 sec_chan);
+BOOL modify_trust_password(const char *domain, const char *remote_machine,
+ const uchar orig_trust_passwd_hash[16],
+ const uchar new_trust_passwd_hash[16],
+ uint16 sec_chan);
uint32 check_domain_security(const char *orig_user, const char *domain,
const uchar * challenge,
const char *smb_apasswd, int smb_apasslen,
diff --git a/source/lsarpcd/lsarpcd.c b/source/lsarpcd/lsarpcd.c
index 23fc9518bcb..8f584096348 100644
--- a/source/lsarpcd/lsarpcd.c
+++ b/source/lsarpcd/lsarpcd.c
@@ -60,37 +60,76 @@ static void update_trust_account(void)
BOOL trust_pwd_needs_changing = False;
uint8 old_trust[16];
NTTIME ntlct;
- BOOL res = True;
- BOOL res1;
- BOOL res2;
+ uint32 s2 = NT_STATUS_NOPROBLEMO;
+ uint32 s1 = NT_STATUS_NOPROBLEMO;
+ uint32 s = NT_STATUS_NOPROBLEMO;
POLICY_HND pol_sec;
POLICY_HND lsa_pol;
STRING2 secret;
+ STRING2 encsec;
UNISTR2 uni_sec_name;
char *name = "$MACHINE.ACC";
extern fstring global_myworkgroup;
+ time_t cur_time;
+ time_t sec_time;
+ uchar user_sess_key[16];
make_unistr2(&uni_sec_name, name, strlen(name));
- res =
- res ? _lsa_open_policy2(NULL, &lsa_pol, NULL,
- 0x02000000) : False;
+ s = _lsa_open_policy2(NULL, &lsa_pol, NULL, 0x02000000);
- res1 = res ? _lsa_open_secret(&lsa_pol,
- &uni_sec_name, 0x02000000,
- &pol_sec) : False;
+ if (s == NT_STATUS_NOPROBLEMO)
+ {
+ s1 = _lsa_open_secret(&lsa_pol, &uni_sec_name, 0x02000000,
+ &pol_sec);
+ }
+
+ if (s1 == NT_STATUS_NOPROBLEMO)
+ {
+ if (!pol_get_usr_sesskey(get_global_hnd_cache(), &pol_sec,
+ user_sess_key))
+ {
+ s2 = NT_STATUS_INVALID_HANDLE;
+ }
+ }
+ if (s2 == NT_STATUS_NOPROBLEMO)
+ {
+ s2 = _lsa_query_secret(&pol_sec, &encsec, &ntlct, NULL, NULL);
+ }
+ if (s2 == NT_STATUS_NOPROBLEMO)
+ {
+ if (!nt_decrypt_string2(&secret, &encsec, user_sess_key))
+ {
+ s2 = NT_STATUS_INVALID_PARAMETER;
+ }
+ }
+ if (s2 == NT_STATUS_NOPROBLEMO)
+ {
+ if (!secret_get_data(&secret, old_trust, 16))
+ {
+ s2 = NT_STATUS_ACCESS_DENIED;
+ }
+ else
+ {
+ dump_data_pw("$MACHINE.ACC:", old_trust, 16);
+ }
+ }
- res2 =
- res1 ? _lsa_query_secret(&pol_sec, &secret, &ntlct, NULL,
- NULL) : False;
- res2 = res2 ? secret_get_data(&secret, old_trust, 16) : False;
+ cur_time = time(NULL);
+ sec_time = nt_time_to_unix(&ntlct);
+
+ if (DEBUGLVL(100))
+ {
+ DEBUG(100, ("secret time: %s\n", http_timestring(sec_time)));
+ DEBUG(100, ("current time: %s\n", http_timestring(cur_time)));
+ }
- if (res2 && time(NULL) >
- nt_time_to_unix(&ntlct) + lp_machine_password_timeout())
+ if (s2 == NT_STATUS_NOPROBLEMO
+ && cur_time > sec_time + lp_machine_password_timeout())
{
- DEBUG(1,("$MACHINE.ACC password being updated.\n"));
+ DEBUG(1, ("$MACHINE.ACC password being updated.\n"));
trust_pwd_needs_changing = True;
}
@@ -98,29 +137,45 @@ static void update_trust_account(void)
{
unsigned char trust_passwd_hash[16];
fstring srv_name;
+ BOOL res2;
- res2 = res2 ? get_any_dc_name(global_myworkgroup,
- srv_name) : False;
+ res2 = get_any_dc_name(global_myworkgroup, srv_name);
generate_random_buffer(trust_passwd_hash, 16, True);
secret_store_data(&secret, trust_passwd_hash, 16);
- res2 = res2 ? modify_trust_password(global_myworkgroup,
- srv_name, old_trust,
- trust_passwd_hash,
- SEC_CHAN_WKSTA) : False;
+ res2 =
+ res2 ? nt_encrypt_string2(&encsec, &secret,
+ user_sess_key) : False;
- res2 = res2 ? (_lsa_set_secret(&pol_sec, &secret, 0x0) ==
- NT_STATUS_NOPROBLEMO) : False;
- if (!res2)
+ if (!strequal("\\\\.", srv_name))
{
- DEBUG(0,("$MACHINE.ACC password update FAILED\n"));
+ res2 =
+ res2 ?
+ modify_trust_password(global_myworkgroup,
+ srv_name, old_trust,
+ trust_passwd_hash,
+ SEC_CHAN_WKSTA) : False;
}
- }
- res1 = res1 ? _lsa_close(&pol_sec) : False;
+ if (res2)
+ {
+ s2 = _lsa_set_secret(&pol_sec, &encsec, 0x0);
+ }
+ if (s2 != NT_STATUS_NOPROBLEMO)
+ {
+ DEBUG(0, ("$MACHINE.ACC password update FAILED\n"));
+ }
+ }
- res = res ? _lsa_close(&lsa_pol) : False;
+ if (s1 == NT_STATUS_NOPROBLEMO)
+ {
+ _lsa_close(&pol_sec);
+ }
+ if (s == NT_STATUS_NOPROBLEMO)
+ {
+ _lsa_close(&lsa_pol);
+ }
}
/****************************************************************************
@@ -130,8 +185,6 @@ static BOOL reload_msrpc(BOOL test)
{
BOOL ret;
- update_trust_account();
-
if (lp_loaded())
{
pstring fname;
@@ -192,7 +245,8 @@ static msrpc_service_fns fn_table = {
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ update_trust_account
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/msrpc/msrpcd_process.c b/source/msrpc/msrpcd_process.c
index d7f5c48f498..f8dda0b5281 100644
--- a/source/msrpc/msrpcd_process.c
+++ b/source/msrpc/msrpcd_process.c
@@ -64,54 +64,58 @@ extern int max_send;
The timeout is in milli seconds
****************************************************************************/
-static BOOL receive_message_or_msrpc(int c, prs_struct *ps,
- int timeout, BOOL *got_msrpc)
+static BOOL receive_message_or_msrpc(int c, prs_struct * ps,
+ int timeout, BOOL *got_msrpc)
{
- fd_set fds;
- int selrtn;
- struct timeval to;
- int maxfd;
-
- smb_read_error = 0;
-
- *got_msrpc = False;
-
- /*
- * Check to see if we already have a message on the smb queue.
- * If so - copy and return it.
- */
-
- /*
- * Setup the select read fd set.
- */
-
- FD_ZERO(&fds);
- FD_SET(c,&fds);
- maxfd = 0;
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout % 1000) * 1000;
-
- selrtn = sys_select(MAX(maxfd,c)+1,&fds,NULL, timeout>0?&to:NULL);
-
- /* Check if error */
- if(selrtn == -1) {
- /* something is wrong. Maybe the socket is dead? */
- smb_read_error = READ_ERROR;
- return False;
- }
-
- /* Did we timeout ? */
- if (selrtn == 0) {
- smb_read_error = READ_TIMEOUT;
- return False;
- }
-
- if (FD_ISSET(c,&fds))
- {
- *got_msrpc = True;
- return receive_msrpc(c, ps, 0);
- }
+ fd_set fds;
+ int selrtn;
+ struct timeval to;
+ int maxfd;
+
+ smb_read_error = 0;
+
+ *got_msrpc = False;
+
+ /*
+ * Check to see if we already have a message on the smb queue.
+ * If so - copy and return it.
+ */
+
+ /*
+ * Setup the select read fd set.
+ */
+
+ FD_ZERO(&fds);
+ FD_SET(c, &fds);
+ maxfd = 0;
+
+ to.tv_sec = timeout / 1000;
+ to.tv_usec = (timeout % 1000) * 1000;
+
+ selrtn =
+ sys_select(MAX(maxfd, c) + 1, &fds, NULL,
+ timeout > 0 ? &to : NULL);
+
+ /* Check if error */
+ if (selrtn == -1)
+ {
+ /* something is wrong. Maybe the socket is dead? */
+ smb_read_error = READ_ERROR;
+ return False;
+ }
+
+ /* Did we timeout ? */
+ if (selrtn == 0)
+ {
+ smb_read_error = READ_TIMEOUT;
+ return False;
+ }
+
+ if (FD_ISSET(c, &fds))
+ {
+ *got_msrpc = True;
+ return receive_msrpc(c, ps, 0);
+ }
return False;
}
@@ -141,22 +145,22 @@ force write permissions on print services.
process an smb from the client - split out from the process() code so
it can be used by the oplock break code.
****************************************************************************/
-static void process_msrpc(rpcsrv_struct *l, const char* name,
- prs_struct *pdu)
+static void process_msrpc(rpcsrv_struct * l, const char *name,
+ prs_struct * pdu)
{
- static int trans_num;
- int32 len = prs_buf_len(pdu);
+ static int trans_num;
+ int32 len = prs_buf_len(pdu);
- DEBUG( 6, ( "got message of len 0x%x\n", len ) );
+ DEBUG(6, ("got message of len 0x%x\n", len));
dump_data(10, pdu->data, len);
#ifdef WITH_VTP
- if(trans_num == 1 && VT_Check(pdu->data))
- {
- VT_Process();
- return;
- }
+ if (trans_num == 1 && VT_Check(pdu->data))
+ {
+ VT_Process();
+ return;
+ }
#endif
if (rpc_local(l, pdu->data, len, name) &&
@@ -170,47 +174,51 @@ static void process_msrpc(rpcsrv_struct *l, const char* name,
int selrtn;
struct timeval to;
int maxfd;
- int timeout = SMBD_SELECT_LOOP*1000;
+ int timeout = SMBD_SELECT_LOOP * 1000;
smb_read_error = 0;
FD_ZERO(&fds);
- FD_SET(l->c,&fds);
+ FD_SET(l->c, &fds);
maxfd = 0;
to.tv_sec = timeout / 1000;
to.tv_usec = (timeout % 1000) * 1000;
- selrtn = sys_select(MAX(maxfd,l->c)+1,NULL,&fds, timeout>0?&to:NULL);
+ selrtn =
+ sys_select(MAX(maxfd, l->c) + 1, NULL, &fds,
+ timeout > 0 ? &to : NULL);
/* Check if error */
- if(selrtn == -1) {
+ if (selrtn == -1)
+ {
smb_read_error = READ_ERROR;
return;
- }
+ }
/* Did we timeout ? */
- if (selrtn == 0) {
+ if (selrtn == 0)
+ {
smb_read_error = READ_TIMEOUT;
return;
}
- if (FD_ISSET(l->c,&fds))
+ if (FD_ISSET(l->c, &fds))
{
if (!msrpc_send(l->c, &l->rsmb_pdu))
- prs_free_data(&l->rsmb_pdu);
+ prs_free_data(&l->rsmb_pdu);
break;
}
prs_free_data(&l->rsmb_pdu);
}
}
- trans_num++;
+ trans_num++;
}
/****************************************************************************
reads user credentials from the socket
****************************************************************************/
-BOOL get_user_creds(int c, vuser_key *uk)
+BOOL get_user_creds(int c, vuser_key * uk)
{
pstring buf;
int rl;
@@ -223,13 +231,13 @@ BOOL get_user_creds(int c, vuser_key *uk)
ZERO_STRUCT(cmd);
- DEBUG(10,("get_user_creds: first request\n"));
+ DEBUG(10, ("get_user_creds: first request\n"));
rl = read(c, &buf, sizeof(len));
if (rl != sizeof(len))
{
- DEBUG(0,("Unable to read length\n"));
+ DEBUG(0, ("Unable to read length\n"));
dump_data(0, buf, sizeof(len));
return False;
}
@@ -238,7 +246,7 @@ BOOL get_user_creds(int c, vuser_key *uk)
if (len > sizeof(buf))
{
- DEBUG(0,("length %d too long\n", len));
+ DEBUG(0, ("length %d too long\n", len));
return False;
}
@@ -246,28 +254,28 @@ BOOL get_user_creds(int c, vuser_key *uk)
if (rl < 0)
{
- DEBUG(0,("Unable to read from connection\n"));
+ DEBUG(0, ("Unable to read from connection\n"));
return False;
}
-
+
#ifdef DEBUG_PASSWORD
dump_data(100, buf, rl);
#endif
- /* make a static data parsing structure from the api_fd_reply data */
- prs_init(&ps, 0, 4, True);
- prs_add_data(&ps, buf, len);
+ /* make a static data parsing structure from the api_fd_reply data */
+ prs_init(&ps, 0, 4, True);
+ prs_add_data(&ps, buf, len);
if (!creds_io_cmd("creds", &cmd, &ps, 0))
{
- DEBUG(0,("Unable to parse credentials\n"));
+ DEBUG(0, ("Unable to parse credentials\n"));
prs_free_data(&ps);
return False;
}
if (ps.offset != rl)
{
- DEBUG(0,("Buffer size %d %d!\n", ps.offset, rl));
+ DEBUG(0, ("Buffer size %d %d!\n", ps.offset, rl));
prs_free_data(&ps);
return False;
}
@@ -289,7 +297,7 @@ BOOL get_user_creds(int c, vuser_key *uk)
}
default:
{
- DEBUG(0,("unknown command %d\n", cmd.command));
+ DEBUG(0, ("unknown command %d\n", cmd.command));
return False;
}
}
@@ -299,8 +307,7 @@ BOOL get_user_creds(int c, vuser_key *uk)
status = new_con ? 0x0 : 0x1;
- if (write(c, &status, sizeof(status)) !=
- sizeof(status))
+ if (write(c, &status, sizeof(status)) != sizeof(status))
{
return False;
}
@@ -308,40 +315,43 @@ BOOL get_user_creds(int c, vuser_key *uk)
return new_con;
}
-static void free_srv_auth_fns_array(uint32 num_entries, srv_auth_fns **entries)
+static void free_srv_auth_fns_array(uint32 num_entries,
+ srv_auth_fns ** entries)
{
- free_void_array(num_entries, (void**)entries, NULL);
+ free_void_array(num_entries, (void **)entries, NULL);
}
-static srv_auth_fns* add_srv_auth_fns_to_array(uint32 *len,
- srv_auth_fns ***array,
- srv_auth_fns *name)
+static srv_auth_fns *add_srv_auth_fns_to_array(uint32 * len,
+ srv_auth_fns *** array,
+ srv_auth_fns * name)
{
- return (srv_auth_fns*)add_item_to_array(len,
- (void***)array, (void*)name);
+ return (srv_auth_fns *) add_item_to_array(len,
+ (void ***)array,
+ (void *)name);
}
-void close_srv_auth_array(rpcsrv_struct *l)
+void close_srv_auth_array(rpcsrv_struct * l)
{
free_srv_auth_fns_array(l->num_auths, l->auth_fns);
}
-void add_srv_auth_fn(rpcsrv_struct *l, srv_auth_fns *fn)
+void add_srv_auth_fn(rpcsrv_struct * l, srv_auth_fns * fn)
{
add_srv_auth_fns_to_array(&l->num_auths, &l->auth_fns, fn);
- DEBUG(10,("add_srv_auth_fn: %d\n", l->num_auths));
+ DEBUG(10, ("add_srv_auth_fn: %d\n", l->num_auths));
}
+
/****************************************************************************
initialise from pipe
****************************************************************************/
-BOOL msrpcd_init(int c, rpcsrv_struct **l)
+BOOL msrpcd_init(int c, rpcsrv_struct ** l)
{
vuser_key uk;
user_struct *vuser = NULL;
if (!get_user_creds(c, &uk))
{
- DEBUG(0,("authentication failed\n"));
+ DEBUG(0, ("authentication failed\n"));
return False;
}
@@ -381,8 +391,8 @@ BOOL msrpcd_init(int c, rpcsrv_struct **l)
if (vuser != NULL && !vuser->guest)
{
char *user = vuser->name;
- if (!strequal(user,lp_guestaccount(-1)) &&
- lp_servicenumber(user) < 0)
+ if (!strequal(user, lp_guestaccount(-1)) &&
+ lp_servicenumber(user) < 0)
{
int homes = lp_servicenumber(HOMES_NAME);
char *home = get_unixhome_dir(user);
@@ -390,7 +400,7 @@ BOOL msrpcd_init(int c, rpcsrv_struct **l)
{
pstring home_dir;
fstrcpy(home_dir, home);
- lp_add_home(user,homes,home_dir);
+ lp_add_home(user, homes, home_dir);
}
}
}
@@ -403,102 +413,118 @@ BOOL msrpcd_init(int c, rpcsrv_struct **l)
/****************************************************************************
process commands from the client
****************************************************************************/
-void msrpcd_process(msrpc_service_fns *fn, rpcsrv_struct *l, const char* name)
+void msrpcd_process(msrpc_service_fns * fn, rpcsrv_struct * l,
+ const char *name)
{
- extern fstring remote_machine;
- extern fstring local_machine;
- extern pstring global_myname;
-
- max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
-
- /* re-initialise the timezone */
- TimeInit();
-
- fstrcpy(remote_machine, name);
- fstrcpy(local_machine, global_myname);
- local_machine[15] = 0;
- strlower(local_machine);
-
- DEBUG(2, ("msrpc_process: client_name: %s my_name: %s\n",
- remote_machine, local_machine));
-
- fn->reload_services(True);
- reopen_logs();
-
- while (True)
- {
- int counter;
- int service_load_counter = 0;
- BOOL got_msrpc = False;
- prs_struct pdu;
-
- errno = 0;
-
- for (counter=SMBD_SELECT_LOOP;
- !receive_message_or_msrpc(l->c, &pdu,
- SMBD_SELECT_LOOP*1000,&got_msrpc);
- counter += SMBD_SELECT_LOOP)
- {
- time_t t;
-
- if (counter > 365 * 3600) /* big number of seconds. */
- {
- counter = 0;
- service_load_counter = 0;
- }
-
- if (smb_read_error == READ_EOF)
- {
- DEBUG(3,("end of file from client\n"));
- return;
- }
-
- if (smb_read_error == READ_ERROR)
- {
- DEBUG(3,("receive error (%s) exiting\n",
- strerror(errno)));
- return;
- }
-
- t = time(NULL);
-
- /* check for smb.conf reload */
- if (counter >= service_load_counter + SMBD_RELOAD_CHECK)
- {
- service_load_counter = counter;
-
- /* reload services, if files have changed. */
- fn->reload_services(True);
- }
-
- /*
- * If reload_after_sighup == True then we got a SIGHUP
- * and are being asked to reload. Fix from <branko.cibej@hermes.si>
- */
-
- if (reload_after_sighup)
- {
- DEBUG(0,("Reloading services after SIGHUP\n"));
- fn->reload_services(False);
- reload_after_sighup = False;
- /*
- * Use this as an excuse to print some stats.
- */
- }
-
- /* automatic timeout if all connections are closed */
- if (counter >= IDLE_CLOSED_TIMEOUT)
- {
- DEBUG( 2, ( "Closing idle connection\n" ) );
- return;
- }
-
- }
-
- if(got_msrpc)
- {
- process_msrpc(l, name, &pdu);
- }
- prs_free_data(&pdu);
- }
+ extern fstring remote_machine;
+ extern fstring local_machine;
+ extern pstring global_myname;
+
+ max_recv = MIN(lp_maxxmit(), BUFFER_SIZE);
+
+ /* re-initialise the timezone */
+ TimeInit();
+
+ fstrcpy(remote_machine, name);
+ fstrcpy(local_machine, global_myname);
+ local_machine[15] = 0;
+ strlower(local_machine);
+
+ DEBUG(2, ("msrpc_process: client_name: %s my_name: %s\n",
+ remote_machine, local_machine));
+
+ fn->reload_services(True);
+ reopen_logs();
+
+ while (True)
+ {
+ int counter;
+ int service_load_counter = 0;
+ BOOL got_msrpc = False;
+ prs_struct pdu;
+
+ errno = 0;
+
+ for (counter = SMBD_SELECT_LOOP;
+ !receive_message_or_msrpc(l->c, &pdu,
+ SMBD_SELECT_LOOP * 1000,
+ &got_msrpc);
+ counter += SMBD_SELECT_LOOP)
+ {
+ time_t t;
+
+ if (counter > 365 * 3600) /* big number of seconds. */
+ {
+ counter = 0;
+ service_load_counter = 0;
+ }
+
+ if (smb_read_error == READ_EOF)
+ {
+ DEBUG(3, ("end of file from client\n"));
+ if (fn->idle != NULL)
+ {
+ fn->idle();
+ }
+ return;
+ }
+
+ if (smb_read_error == READ_ERROR)
+ {
+ DEBUG(3, ("receive error (%s) exiting\n",
+ strerror(errno)));
+ if (fn->idle != NULL)
+ {
+ fn->idle();
+ }
+ return;
+ }
+
+ t = time(NULL);
+
+ /* check for smb.conf reload */
+ if (counter >=
+ service_load_counter + SMBD_RELOAD_CHECK)
+ {
+ service_load_counter = counter;
+
+ /* reload services, if files have changed. */
+ fn->reload_services(True);
+ }
+
+ /*
+ * If reload_after_sighup == True then we got a SIGHUP
+ * and are being asked to reload. Fix from <branko.cibej@hermes.si>
+ */
+
+ if (reload_after_sighup)
+ {
+ DEBUG(0,
+ ("Reloading services after SIGHUP\n"));
+ fn->reload_services(False);
+ reload_after_sighup = False;
+ /*
+ * Use this as an excuse to print some stats.
+ */
+ }
+
+ /* automatic timeout if all connections are closed */
+ if (counter >= IDLE_CLOSED_TIMEOUT)
+ {
+ DEBUG(2, ("Closing idle connection\n"));
+ if (fn->idle != NULL)
+ {
+ fn->idle();
+ }
+ return;
+ }
+
+ }
+
+ if (got_msrpc)
+ {
+ process_msrpc(l, name, &pdu);
+ }
+ prs_free_data(&pdu);
+ }
}
diff --git a/source/netlogond/netlogond.c b/source/netlogond/netlogond.c
index 8d31c44261a..dcec6fbf110 100644
--- a/source/netlogond/netlogond.c
+++ b/source/netlogond/netlogond.c
@@ -124,7 +124,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 5f6b0b5bdb1..223079bf6d6 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -958,6 +958,7 @@ static void init_globals(void)
Globals.max_wins_ttl = 60*60*24*6; /* 6 days default. */
Globals.min_wins_ttl = 60*60*6; /* 6 hours default. */
Globals.machine_password_timeout = 60*60*24*7; /* 7 days default. */
+ Globals.machine_password_timeout = 60; /* 7 days default. */
Globals.change_notify_timeout = 60; /* 1 minute default. */
Globals.ReadSize = 16*1024;
Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
diff --git a/source/rpc_client/msrpc_netlogon.c b/source/rpc_client/msrpc_netlogon.c
index 8240c9cf4c7..09ade4e3a74 100644
--- a/source/rpc_client/msrpc_netlogon.c
+++ b/source/rpc_client/msrpc_netlogon.c
@@ -37,18 +37,13 @@ extern pstring global_myworkgroup;
Change the domain password on the PDC.
**********************************************************/
-BOOL modify_trust_password(const char *domain, const char *remote_machine,
+BOOL modify_trust_password(const char *domain, const char *srv_name,
const uchar orig_trust_passwd_hash[16],
const uchar new_trust_passwd_hash[16],
uint16 sec_chan)
{
struct nmb_name calling, called;
fstring trust_acct;
- fstring srv_name;
-
- fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, remote_machine);
- strupper(srv_name);
fstrcpy(trust_acct, global_myname);
fstrcat(trust_acct, "$");
diff --git a/source/samrd/samrd.c b/source/samrd/samrd.c
index ec2faa27e23..00e53dd264c 100644
--- a/source/samrd/samrd.c
+++ b/source/samrd/samrd.c
@@ -122,7 +122,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/spoolssd/spoolssd.c b/source/spoolssd/spoolssd.c
index 8e82658f883..5367f7fa820 100644
--- a/source/spoolssd/spoolssd.c
+++ b/source/spoolssd/spoolssd.c
@@ -110,7 +110,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/srvsvcd/srvsvcd.c b/source/srvsvcd/srvsvcd.c
index d084330d479..c85091cb3d2 100644
--- a/source/srvsvcd/srvsvcd.c
+++ b/source/srvsvcd/srvsvcd.c
@@ -108,7 +108,8 @@ static msrpc_service_fns fn_table =
msrpc_auth_init,
msrpc_service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/svcctld/svcctld.c b/source/svcctld/svcctld.c
index 1047202050f..47d6964ca39 100644
--- a/source/svcctld/svcctld.c
+++ b/source/svcctld/svcctld.c
@@ -108,7 +108,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/winregd/winregd.c b/source/winregd/winregd.c
index aedb657d8e7..2165c617893 100644
--- a/source/winregd/winregd.c
+++ b/source/winregd/winregd.c
@@ -108,7 +108,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)
diff --git a/source/wkssvcd/wkssvcd.c b/source/wkssvcd/wkssvcd.c
index d695d10801f..d1fcdeb5944 100644
--- a/source/wkssvcd/wkssvcd.c
+++ b/source/wkssvcd/wkssvcd.c
@@ -108,7 +108,8 @@ static msrpc_service_fns fn_table =
auth_init,
service_init,
reload_msrpc,
- main_init
+ main_init,
+ NULL
};
msrpc_service_fns *get_service_fns(void)