From 6578fd874283ee97c2896bcf7257db7f3e37c2ec Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Apr 2001 23:19:08 +0000 Subject: 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) --- source3/client/client.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'source3/client') 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 \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; -- cgit