diff options
author | Jeremy Allison <jra@samba.org> | 2001-04-11 23:19:18 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-04-11 23:19:18 +0000 |
commit | 9b4485772ad875ca533899a5d4fca6a1137146e7 (patch) | |
tree | 33d1e05ec3552015d63b22de45b1892aace3d855 /source/client/client.c | |
parent | e09e87fe02865a9b0ce65e45322ef55af63f3cbd (diff) | |
download | samba-9b4485772ad875ca533899a5d4fca6a1137146e7.tar.gz samba-9b4485772ad875ca533899a5d4fca6a1137146e7.tar.xz samba-9b4485772ad875ca533899a5d4fca6a1137146e7.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.
Diffstat (limited to 'source/client/client.c')
-rw-r--r-- | source/client/client.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/source/client/client.c b/source/client/client.c index 5c534c9d20a..3b23b938df6 100644 --- a/source/client/client.c +++ b/source/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; |