summaryrefslogtreecommitdiff
path: root/source/rpc_server
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-12 07:02:35 +0000
committerJeremy Allison <jra@samba.org>2001-04-12 07:02:35 +0000
commit954429d72c3b9e5027cf21617255da0785f4f9be (patch)
treef9ddc137eab2df36dfe6ec676b566fbc0ba6e0cc /source/rpc_server
parent8a4b654b1208896cd43e383f26a9c45f13519f53 (diff)
downloadsamba-954429d72c3b9e5027cf21617255da0785f4f9be.tar.gz
Changed lp_add/delete/enum scripts to use lockdir if spool dir doesn't
exist for printer. Rather than using pid for suffix, use a 16 byte random string. Created generate_random_str() function in genrand.c. Still needs more testing but this is the way to go. Jeremy.
Diffstat (limited to 'source/rpc_server')
-rw-r--r--source/rpc_server/srv_spoolss_nt.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index c75af92902c..f91168d3e42 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -285,7 +285,6 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
if (*lp_deleteprinter_cmd()) {
- pid_t local_pid = sys_getpid();
char *cmd = lp_deleteprinter_cmd();
char *path;
pstring tmp_file;
@@ -296,13 +295,13 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
if (*lp_pathname(lp_servicenumber(PRINTERS_NAME)))
path = lp_pathname(lp_servicenumber(PRINTERS_NAME));
else
- path = tmpdir();
+ path = lp_lockdir();
/* Printer->dev.handlename equals portname equals sharename */
slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd,
Printer->dev.handlename);
dos_to_unix(command, True); /* Convert printername to unix-codepage */
- slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid);
+ slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16));
unlink(tmp_file);
DEBUG(10,("Running [%s > %s]\n", command,tmp_file));
@@ -4133,7 +4132,6 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
****************************************************************************/
static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer)
{
- pid_t local_pid = sys_getpid();
char *cmd = lp_addprinter_cmd();
char *path;
char **qlines;
@@ -4146,15 +4144,15 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer)
if (*lp_pathname(lp_servicenumber(PRINTERS_NAME)))
path = lp_pathname(lp_servicenumber(PRINTERS_NAME));
else
- path = tmpdir();
+ path = lp_lockdir();
/* build driver path... only 9X architecture is needed for legacy reasons */
slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0",
global_myname);
/* change \ to \\ for the shell */
all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring));
-
- slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid);
+
+ slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16));
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
cmd, printer->info_2->printername, printer->info_2->sharename,
printer->info_2->portname, printer->info_2->drivername,
@@ -5418,7 +5416,6 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
int i=0;
if (*lp_enumports_cmd()) {
- pid_t local_pid = sys_getpid();
char *cmd = lp_enumports_cmd();
char *path;
char **qlines;
@@ -5430,9 +5427,9 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (*lp_pathname(lp_servicenumber(PRINTERS_NAME)))
path = lp_pathname(lp_servicenumber(PRINTERS_NAME));
else
- path = tmpdir();
+ path = lp_lockdir();
- slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid);
+ slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16));
slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1);
unlink(tmp_file);
@@ -5516,7 +5513,6 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
int i=0;
if (*lp_enumports_cmd()) {
- pid_t local_pid = sys_getpid();
char *cmd = lp_enumports_cmd();
char *path;
char **qlines;
@@ -5528,9 +5524,9 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (*lp_pathname(lp_servicenumber(PRINTERS_NAME)))
path = lp_pathname(lp_servicenumber(PRINTERS_NAME));
else
- path = tmpdir();
+ path = lp_lockdir();
- slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid);
+ slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16));
slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2);
unlink(tmp_file);