summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-11 23:19:08 +0000
committerJeremy Allison <jra@samba.org>2001-04-11 23:19:08 +0000
commit6578fd874283ee97c2896bcf7257db7f3e37c2ec (patch)
treea5e9ee2ed36b4b0ba1521edbe961f3e2f9026f13 /source3/client
parent0ca9f5c023df2ee498dcd1bdb2f29abc632a5d60 (diff)
downloadsamba-6578fd874283ee97c2896bcf7257db7f3e37c2ec.tar.gz
samba-6578fd874283ee97c2896bcf7257db7f3e37c2ec.tar.bz2
samba-6578fd874283ee97c2896bcf7257db7f3e37c2ec.zip
To stop people complaining about the mktemp call, move it into lib/util.c. Thanks
to Andrew for all this code. Fixed extra line in lib/sysacls.c that broke XFS ACL code. Jeremy. (This used to be commit 9b32b8a8cfc8ddb93c14d5581f433d2e93f89ed2)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 65f3a7a75e..592f911fe0 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -842,18 +842,24 @@ view the file using the pager
****************************************************************************/
static void cmd_more(void)
{
- fstring rname,lname,tmpname,pager_cmd;
+ fstring rname,lname,pager_cmd;
char *pager;
+ int fd;
fstrcpy(rname,cur_dir);
fstrcat(rname,"\\");
- slprintf(tmpname,
- sizeof(fstring)-1,
- "%s/smbmore.%d",tmpdir(),(int)sys_getpid());
- fstrcpy(lname,tmpname);
+ slprintf(lname,sizeof(lname)-1, "%s/smbmore.XXXXXX",tmpdir());
+ fd = smb_mkstemp(lname);
+ if (fd == -1) {
+ DEBUG(0,("failed to create temporary file for more\n"));
+ return;
+ }
+ close(fd);
+
if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
DEBUG(0,("more <filename>\n"));
+ unlink(lname);
return;
}
dos_clean_name(rname);
@@ -863,9 +869,9 @@ static void cmd_more(void)
pager=getenv("PAGER");
slprintf(pager_cmd,sizeof(pager_cmd)-1,
- "%s %s",(pager? pager:PAGER), tmpname);
+ "%s %s",(pager? pager:PAGER), lname);
system(pager_cmd);
- unlink(tmpname);
+ unlink(lname);
}
@@ -1157,9 +1163,17 @@ static void cmd_mput(void)
pstring cmd;
pstring tmpname;
FILE *f;
-
- slprintf(tmpname,sizeof(pstring)-1,
- "%s/ls.smb.%d",tmpdir(),(int)sys_getpid());
+ int fd;
+
+ slprintf(tmpname,sizeof(tmpname)-1, "%s/ls.smb.XXXXXX",
+ tmpdir());
+ fd = smb_mkstemp(tmpname);
+
+ if (fd == -1) {
+ DEBUG(0,("Failed to create temporary file %s\n", tmpname));
+ continue;
+ }
+
if (recurse)
slprintf(cmd,sizeof(pstring)-1,
"find . -name \"%s\" -print > %s",p,tmpname);
@@ -1167,6 +1181,7 @@ static void cmd_mput(void)
slprintf(cmd,sizeof(pstring)-1,
"find . -maxdepth 1 -name \"%s\" -print > %s",p,tmpname);
system(cmd);
+ close(fd);
f = sys_fopen(tmpname,"r");
if (!f) continue;