summaryrefslogtreecommitdiffstats
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-13 00:37:00 +0000
committerJeremy Allison <jra@samba.org>2001-04-13 00:37:00 +0000
commit50e78a9ac8cf0949c2471fafde844c674f97d73d (patch)
tree4b9489a28767ea782a679e4c8c3b93ce5a1f19ba /source3/smbd
parentd85924a028f35e4789c70c068f903d677caf7ca0 (diff)
downloadsamba-50e78a9ac8cf0949c2471fafde844c674f97d73d.tar.gz
samba-50e78a9ac8cf0949c2471fafde844c674f97d73d.tar.xz
samba-50e78a9ac8cf0949c2471fafde844c674f97d73d.zip
As Andrew suggested, make smbrun return a fd for a deleted file which can then
be read. Jeremy. (This used to be commit e7d59d6de89a5fdd201e4b5c6072dab08b1519db)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c26
-rw-r--r--source3/smbd/message.c2
-rw-r--r--source3/smbd/reply.c4
-rw-r--r--source3/smbd/service.c8
4 files changed, 31 insertions, 9 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index c290ee6f894..10c95398345 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -48,17 +48,39 @@ static void check_magic(files_struct *fsp,connection_struct *conn)
int ret;
pstring magic_output;
pstring fname;
- pstrcpy(fname,fsp->fsp_name);
+ SMB_STRUCT_STAT st;
+ int tmp_fd, outfd;
+ pstrcpy(fname,fsp->fsp_name);
if (*lp_magicoutput(SNUM(conn)))
pstrcpy(magic_output,lp_magicoutput(SNUM(conn)));
else
slprintf(magic_output,sizeof(fname)-1, "%s.out",fname);
chmod(fname,0755);
- ret = smbrun(fname,magic_output,False);
+ ret = smbrun(fname,&tmp_fd,magic_output);
DEBUG(3,("Invoking magic command %s gave %d\n",fname,ret));
unlink(fname);
+ if (ret != 0 || tmp_fd == -1) {
+ if (tmp_fd != -1)
+ close(tmp_fd);
+ return;
+ }
+ outfd = open(magic_output, O_CREAT|O_EXCL|O_RDWR, 0600);
+ if (outfd == -1) {
+ close(tmp_fd);
+ return;
+ }
+
+ if (sys_fstat(tmp_fd,&st) == -1) {
+ close(tmp_fd);
+ close(outfd);
+ return;
+ }
+
+ transfer_file(tmp_fd,outfd,st.st_size, NULL,0,0);
+ close(tmp_fd);
+ close(outfd);
}
}
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index 9206442b943..01b5f51acca 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -91,7 +91,7 @@ static void msg_deliver(void)
pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto)));
standard_sub_basic(s);
pstring_sub(s,"%s",name);
- smbrun(s,NULL,False);
+ smbrun(s,NULL,NULL);
}
msgpos = 0;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 4176dd01040..b4e0d490ab2 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -493,7 +493,7 @@ int smb_create_user(char *unix_user, char *homedir)
all_string_sub(add_script, "%u", unix_user, sizeof(pstring));
if (homedir)
all_string_sub(add_script, "%H", homedir, sizeof(pstring));
- ret = smbrun(add_script,NULL,False);
+ ret = smbrun(add_script,NULL,NULL);
DEBUG(3,("smb_create_user: Running the command `%s' gave %d\n",add_script,ret));
return ret;
}
@@ -510,7 +510,7 @@ static int smb_delete_user(char *unix_user)
pstrcpy(del_script, lp_deluser_script());
if (! *del_script) return -1;
all_string_sub(del_script, "%u", unix_user, sizeof(pstring));
- ret = smbrun(del_script,NULL,False);
+ ret = smbrun(del_script,NULL,NULL);
DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret));
return ret;
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 507d07cc42a..375587b539d 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -559,7 +559,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
pstrcpy(cmd,lp_rootpreexec(SNUM(conn)));
standard_sub_conn(conn,cmd);
DEBUG(5,("cmd=%s\n",cmd));
- ret = smbrun(cmd,NULL,False);
+ ret = smbrun(cmd,NULL,NULL);
if (ret != 0 && lp_rootpreexec_close(SNUM(conn))) {
DEBUG(1,("preexec gave %d - failing connection\n", ret));
conn_free(conn);
@@ -611,7 +611,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
pstring cmd;
pstrcpy(cmd,lp_preexec(SNUM(conn)));
standard_sub_conn(conn,cmd);
- ret = smbrun(cmd,NULL,False);
+ ret = smbrun(cmd,NULL,NULL);
if (ret != 0 && lp_preexec_close(SNUM(conn))) {
DEBUG(1,("preexec gave %d - failing connection\n", ret));
conn_free(conn);
@@ -688,7 +688,7 @@ void close_cnum(connection_struct *conn, uint16 vuid)
pstring cmd;
pstrcpy(cmd,lp_postexec(SNUM(conn)));
standard_sub_conn(conn,cmd);
- smbrun(cmd,NULL,False);
+ smbrun(cmd,NULL,NULL);
unbecome_user();
}
@@ -698,7 +698,7 @@ void close_cnum(connection_struct *conn, uint16 vuid)
pstring cmd;
pstrcpy(cmd,lp_rootpostexec(SNUM(conn)));
standard_sub_conn(conn,cmd);
- smbrun(cmd,NULL,False);
+ smbrun(cmd,NULL,NULL);
}
conn_free(conn);
}