summaryrefslogtreecommitdiffstats
path: root/source/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source/smbd')
-rw-r--r--source/smbd/conn.c4
-rw-r--r--source/smbd/ipc.c6
-rw-r--r--source/smbd/lanman.c2
-rw-r--r--source/smbd/message.c8
-rw-r--r--source/smbd/process.c15
-rw-r--r--source/smbd/server.c36
-rw-r--r--source/smbd/service.c37
7 files changed, 55 insertions, 53 deletions
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index 6b5942f7f66..26529c77a1f 100644
--- a/source/smbd/conn.c
+++ b/source/smbd/conn.c
@@ -250,6 +250,10 @@ void conn_free(connection_struct *conn)
conn->ngroups = 0;
}
+ if (conn->nt_user_token) {
+ delete_nt_token(&(conn->nt_user_token));
+ }
+
free_namearray(conn->veto_list);
free_namearray(conn->hide_list);
free_namearray(conn->veto_oplock_list);
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index 9fcd39b5002..3f21a2ac6ad 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -269,7 +269,7 @@ static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
/* First find out the name of this file. */
if (suwcnt != 2) {
DEBUG(0,("Unexpected named pipe transaction.\n"));
- return(-1);
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
}
/* Get the file handle and hence the file name. */
@@ -290,7 +290,7 @@ static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
}
DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", pnum));
- return api_no_reply(outbuf, mdrcnt);
+ return ERROR_NT(NT_STATUS_INVALID_HANDLE);
}
DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n", subcommand, p->name, pnum));
@@ -315,6 +315,8 @@ static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
/* Set Named Pipe Handle state */
reply = api_SNPHS(outbuf, p, params, tpscnt);
break;
+ default:
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
}
if (!reply)
diff --git a/source/smbd/lanman.c b/source/smbd/lanman.c
index 4af11da7844..9f2cd214259 100644
--- a/source/smbd/lanman.c
+++ b/source/smbd/lanman.c
@@ -1874,7 +1874,7 @@ static BOOL api_RNetUserEnum(connection_struct *conn,uint16 vuid, char *param,ch
/* Open the passgrp file - not for update. */
become_root();
- if(!pdb_setsampwent(False)) {
+ if(!pdb_setsampwent(False, 0)) {
DEBUG(0, ("api_RNetUserEnum:unable to open sam database.\n"));
unbecome_root();
return False;
diff --git a/source/smbd/message.c b/source/smbd/message.c
index f853a914753..5af7d3e451e 100644
--- a/source/smbd/message.c
+++ b/source/smbd/message.c
@@ -127,8 +127,8 @@ int reply_sends(connection_struct *conn,
outsize = set_message(outbuf,0,0,True);
p = smb_buf(inbuf)+1;
- p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1;
- p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1;
+ p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1;
+ p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1;
msg = p;
@@ -169,8 +169,8 @@ int reply_sendstrt(connection_struct *conn,
msgpos = 0;
p = smb_buf(inbuf)+1;
- p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1;
- p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1;
+ p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1;
+ p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1;
DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) );
diff --git a/source/smbd/process.c b/source/smbd/process.c
index 1372ebbf458..54837c3b9ae 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -1282,7 +1282,7 @@ static int setup_select_timeout(void)
void check_reload(int t)
{
static time_t last_smb_conf_reload_time = 0;
- static time_t last_load_printers_reload_time = 0;
+ static time_t last_printer_reload_time = 0;
time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
if(last_smb_conf_reload_time == 0) {
@@ -1291,9 +1291,9 @@ void check_reload(int t)
Then no printer is available till the first printers check
is performed. A lower initial interval circumvents this. */
if ( printcap_cache_time > 60 )
- last_load_printers_reload_time = t - printcap_cache_time + 60;
+ last_printer_reload_time = t - printcap_cache_time + 60;
else
- last_load_printers_reload_time = t;
+ last_printer_reload_time = t;
}
if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) {
@@ -1308,13 +1308,12 @@ void check_reload(int t)
{
/* see if it's time to reload or if the clock has been set back */
- if ( (t >= last_load_printers_reload_time+printcap_cache_time)
- || (t-last_load_printers_reload_time < 0) )
+ if ( (t >= last_printer_reload_time+printcap_cache_time)
+ || (t-last_printer_reload_time < 0) )
{
DEBUG( 3,( "Printcap cache time expired.\n"));
- remove_stale_printers();
- load_printers();
- last_load_printers_reload_time = t;
+ reload_printers();
+ last_printer_reload_time = t;
}
}
}
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 724a49321a2..7f7d55c7e3a 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -464,6 +464,39 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
}
/****************************************************************************
+ Reload printers
+**************************************************************************/
+void reload_printers(void)
+{
+ int snum;
+ int n_services = lp_numservices();
+ int pnum = lp_servicenumber(PRINTERS_NAME);
+ const char *pname;
+
+ pcap_cache_reload();
+
+ /* remove stale printers */
+ for (snum = 0; snum < n_services; snum++) {
+ /* avoid removing PRINTERS_NAME or non-autoloaded printers */
+ if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
+ lp_autoloaded(snum)))
+ continue;
+
+ pname = lp_printername(snum);
+ if (!pcap_printername_ok(pname)) {
+ DEBUG(3, ("removing stale printer %s\n", pname));
+
+ if (is_printer_published(NULL, snum, NULL))
+ nt_printer_publish(NULL, snum, SPOOL_DS_UNPUBLISH);
+ del_a_printer(pname);
+ lp_killservice(snum);
+ }
+ }
+
+ load_printers();
+}
+
+/****************************************************************************
Reload the services file.
**************************************************************************/
@@ -490,8 +523,7 @@ BOOL reload_services(BOOL test)
ret = lp_load(dyn_CONFIGFILE, False, False, True);
- remove_stale_printers();
- load_printers();
+ reload_printers();
/* perhaps the config filename is now set */
if (!test)
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 3dcd803a7ce..2e60adc6366 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -152,10 +152,8 @@ int find_service(fstring service)
int iPrinterService;
if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0) {
- const char *pszTemp = lp_printcapname();
-
DEBUG(3,("checking whether %s is a valid printer name...\n", service));
- if ((pszTemp != NULL) && pcap_printername_ok(service, pszTemp)) {
+ if (pcap_printername_ok(service)) {
DEBUG(3,("%s is a valid printer name\n", service));
DEBUG(3,("adding %s as a printer service\n", service));
lp_add_printer(service, iPrinterService);
@@ -863,36 +861,3 @@ void close_cnum(connection_struct *conn, uint16 vuid)
conn_free(conn);
}
-
-/****************************************************************************
- Remove stale printers
-****************************************************************************/
-
-void remove_stale_printers( void )
-{
- int snum, iNumServices, printersServiceNum;
- const char *pname;
-
- iNumServices = lp_numservices();
- printersServiceNum = lp_servicenumber( PRINTERS_NAME);
- for( snum = 0; snum < iNumServices; snum++) {
-
- /* Never remove PRINTERS_NAME */
-
- if ( snum == printersServiceNum)
- continue;
- pname = lp_printername( snum);
-
- /* Is snum an autoloaded print service and still
- in the printing subsystem? */
-
- if ( lp_snum_ok(snum)
- && lp_print_ok(snum)
- && lp_autoloaded(snum)
- && !pcap_printername_ok( pname, NULL))
- {
- DEBUG( 3, ( "Removing printer: %s\n", pname));
- lp_killservice( snum);
- }
- }
-}