#include "includes.h"
-extern int DEBUGLEVEL;
-
struct timeval smb_last_time;
static char *InBuffer = NULL;
extern int last_message;
extern int global_oplock_break;
extern userdom_struct current_user_info;
-extern char *last_inbuf;
-extern char *InBuffer;
-extern char *OutBuffer;
extern int smb_read_error;
extern VOLATILE sig_atomic_t reload_after_sighup;
extern BOOL global_machine_password_needs_changing;
if(msg->msg_buf == NULL)
{
DEBUG(0,("push_message: malloc fail (2)\n"));
- free((char *)msg);
+ SAFE_FREE(msg);
return False;
}
/* check for sighup processing */
if (reload_after_sighup) {
- unbecome_user();
+ change_to_root_user();
DEBUG(1,("Reloading services after SIGHUP\n"));
reload_services(False);
reload_after_sighup = False;
memcpy(buffer, msg->msg_buf, MIN(buffer_len, msg->msg_len));
/* Free the message we just copied. */
- free((char *)msg->msg_buf);
- free((char *)msg);
+ SAFE_FREE(msg->msg_buf);
+ SAFE_FREE(msg);
DEBUG(5,("receive_message_or_smb: returning queued smb message.\n"));
return True;
signals */
if (selrtn == -1 && errno == EINTR) {
async_processing(&fds, buffer, buffer_len);
+ /*
+ * After async processing we must go and do the select again, as
+ * the state of the flag in fds for the server file descriptor is
+ * indeterminate - we may have done I/O on it in the oplock processing. JRA.
+ */
goto again;
}
if (oplock_message_waiting(&fds)) {
async_processing(&fds, buffer, buffer_len);
- if (!FD_ISSET(smbd_server_fd(),&fds)) goto again;
+ /*
+ * After async processing we must go and do the select again, as
+ * the state of the flag in fds for the server file descriptor is
+ * indeterminate - we may have done I/O on it in the oplock processing. JRA.
+ */
+ goto again;
}
return receive_smb(smbd_server_fd(), buffer, 0);
do {
ret = receive_message_or_smb(inbuf,bufsize,timeout);
- got_keepalive = (ret && (CVAL(inbuf,0) == 0x85));
+ got_keepalive = (ret && (CVAL(inbuf,0) == SMBkeepalive));
} while (ret && got_keepalive);
return ret;
functions. Any message that has a NULL function is unimplemented -
please feel free to contribute implementations!
*/
-struct smb_message_struct
+static struct smb_message_struct
{
char *name;
int (*fn)(connection_struct *conn, char *, char *, int, int);
/* 0x19 */ { NULL, NULL, 0 },
/* 0x1a */ { "SMBreadbraw",reply_readbraw,AS_USER},
/* 0x1b */ { "SMBreadBmpx",reply_readbmpx,AS_USER},
-/* 0x1c */ { "SMBreadBs",NULL,AS_USER},
+/* 0x1c */ { "SMBreadBs",NULL,0 },
/* 0x1d */ { "SMBwritebraw",reply_writebraw,AS_USER},
-/* 0x1e */ { NULL,NULL,0},
-/* 0x1f */ { NULL,NULL,0},
-/* 0x20 */ { NULL,NULL,0},
+/* 0x1e */ { "SMBwriteBmpx",reply_writebmpx,AS_USER},
+/* 0x1f */ { "SMBwriteBs",reply_writebs,AS_USER},
+/* 0x20 */ { "SMBwritec",NULL,0},
/* 0x21 */ { NULL, NULL, 0 },
/* 0x22 */ { "SMBsetattrE",reply_setattrE,AS_USER | NEED_WRITE },
/* 0x23 */ { "SMBgetattrE",reply_getattrE,AS_USER },
/* does this protocol need to be run as root? */
if (!(flags & AS_USER))
- unbecome_user();
+ change_to_root_user();
/* does this protocol need a valid tree connection? */
if ((flags & AS_USER) && !conn) {
/* does this protocol need to be run as the connected user? */
- if ((flags & AS_USER) && !become_user(conn,session_tag)) {
+ if ((flags & AS_USER) && !change_to_user(conn,session_tag)) {
if (flags & AS_GUEST)
flags &= ~AS_USER;
else
}
/* load service specific parameters */
- if (conn && !become_service(conn,(flags & AS_USER)?True:False)) {
+ if (conn && !set_current_service(conn,(flags & AS_USER)?True:False)) {
return(ERROR_DOS(ERRSRV,ERRaccess));
}
/* does this protocol need to be run as guest? */
if ((flags & AS_GUEST) &&
- (!become_guest() ||
+ (!change_to_guest() ||
!check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1)))) {
return(ERROR_DOS(ERRSRV,ERRaccess));
}
total_smbds = 1; /* In case we need to create the entry. */
+ if (!conn_tdb_ctx()) {
+ DEBUG(0,("smbd_process_limit: max smbd processes parameter set with status parameter not \
+set. Ignoring max smbd restriction.\n"));
+ return False;
+ }
+
if (tdb_change_int_atomic(conn_tdb_ctx(), "INFO/total_smbds", &total_smbds, 1) == -1)
return True;
if (msg_type == 0)
show_msg(inbuf);
- else if(msg_type == 0x85)
+ else if(msg_type == SMBkeepalive)
return; /* Keepalive packet. */
nread = construct_reply(inbuf,outbuf,nread,max_send);
}
else
if (!send_smb(smbd_server_fd(),outbuf))
- exit_server("process_smb: send_smb failed.\n");
+ exit_server("process_smb: send_smb failed.");
}
trans_num++;
}
void construct_reply_common(char *inbuf,char *outbuf)
{
- memset(outbuf,'\0',smb_size);
-
- set_message(outbuf,0,0,True);
- CVAL(outbuf,smb_com) = CVAL(inbuf,smb_com);
-
- memcpy(outbuf+4,inbuf+4,4);
- CVAL(outbuf,smb_rcls) = SMB_SUCCESS;
- CVAL(outbuf,smb_reh) = 0;
- SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); /* bit 7 set
- means a reply */
- SSVAL(outbuf,smb_flg2,
- (SVAL(inbuf,smb_flg2)&FLAGS2_UNICODE_STRINGS) | FLAGS2_LONG_PATH_COMPONENTS);
- /* say we support long filenames */
-
- SSVAL(outbuf,smb_err,SMB_SUCCESS);
- SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid));
- SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid));
- SSVAL(outbuf,smb_uid,SVAL(inbuf,smb_uid));
- SSVAL(outbuf,smb_mid,SVAL(inbuf,smb_mid));
+ memset(outbuf,'\0',smb_size);
+
+ set_message(outbuf,0,0,True);
+ CVAL(outbuf,smb_com) = CVAL(inbuf,smb_com);
+
+ memcpy(outbuf+4,inbuf+4,4);
+ CVAL(outbuf,smb_rcls) = SMB_SUCCESS;
+ CVAL(outbuf,smb_reh) = 0;
+ SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES));
+ SSVAL(outbuf,smb_flg2,
+ FLAGS2_UNICODE_STRINGS | FLAGS2_LONG_PATH_COMPONENTS |
+ FLAGS2_32_BIT_ERROR_CODES | FLAGS2_EXTENDED_SECURITY);
+
+ SSVAL(outbuf,smb_err,SMB_SUCCESS);
+ SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid));
+ SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid));
+ SSVAL(outbuf,smb_uid,SVAL(inbuf,smb_uid));
+ SSVAL(outbuf,smb_mid,SVAL(inbuf,smb_mid));
}
/****************************************************************************
last_idle_closed_check = t;
/* become root again if waiting */
- unbecome_user();
+ change_to_root_user();
/* check if we need to reload services */
check_reload(t);
if (keepalive && (t - last_keepalive_sent_time)>keepalive)
{
- struct cli_state *cli = server_client();
- if (!send_keepalive(smbd_server_fd())) {
- DEBUG( 2, ( "Keepalive failed - exiting.\n" ) );
- return False;
- }
- /* also send a keepalive to the password server if its still
- connected */
- if (cli && cli->initialised)
- if (!send_keepalive(cli->fd)) {
- DEBUG( 2, ( "password server keepalive failed.\n"));
- cli_shutdown(cli);
- }
- last_keepalive_sent_time = t;
+ extern auth_authsupplied_info *negprot_global_auth_info;
+ if (!send_keepalive(smbd_server_fd())) {
+ DEBUG( 2, ( "Keepalive failed - exiting.\n" ) );
+ return False;
+ }
+
+ /* send a keepalive for a password server or the like.
+ This is attached to the auth_info created in the
+ negprot */
+ if (negprot_global_auth_info
+ && negprot_global_auth_info->challenge_set_method
+ && negprot_global_auth_info->challenge_set_method->send_keepalive) {
+ negprot_global_auth_info->challenge_set_method->send_keepalive
+ (&negprot_global_auth_info->challenge_set_method->private_data);
+ }
+
+ last_keepalive_sent_time = t;
}
/* check for connection timeouts */
return False;
}
- if(global_machine_password_needs_changing)
+ if(global_machine_password_needs_changing &&
+ /* for ADS we need to do a regular ADS password change, not a domain
+ password change */
+ lp_security() == SEC_DOMAIN)
{
unsigned char trust_passwd_hash[16];
time_t lct;
/* register our message handlers */
message_register(MSG_SMB_FORCE_TDIS, msg_force_tdis);
+ talloc_init_named("dummy!");
while (True) {
int deadtime = lp_deadtime()*60;