1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

Remove smb_mkstemp() - libreplace will now provide a secure mkstemp() if

the system one is broken.
This commit is contained in:
Jelmer Vernooij 2009-04-20 23:58:26 +02:00
parent 6fc40ce0d3
commit 4c32978d97
9 changed files with 10 additions and 28 deletions

View File

@ -1281,7 +1281,7 @@ static int cmd_more(void)
if (!lname) {
return 1;
}
fd = smb_mkstemp(lname);
fd = mkstemp(lname);
if (fd == -1) {
d_printf("failed to create temporary file for more\n");
return 1;

View File

@ -42,7 +42,7 @@ static int setup_out_fd(void)
}
/* now create the file */
fd = smb_mkstemp(path);
fd = mkstemp(path);
if (fd == -1) {
DEBUG(0,("setup_out_fd: Failed to create file %s. (%s)\n",

View File

@ -2113,24 +2113,6 @@ int set_maxfiles(int requested_max)
#endif
}
/*****************************************************************
Possibly replace mkstemp if it is broken.
*****************************************************************/
int smb_mkstemp(char *name_template)
{
#if HAVE_SECURE_MKSTEMP
return mkstemp(name_template);
#else
/* have a reasonable go at emulating it. Hope that
the system mktemp() isn't completly hopeless */
char *p = mktemp(name_template);
if (!p)
return -1;
return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
#endif
}
/*****************************************************************
malloc that aborts with smb_panic on fail or zero size.
*****************************************************************/

View File

@ -874,7 +874,7 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
flen = strlen(file_contents);
fd = smb_mkstemp(tmpname);
fd = mkstemp(tmpname);
if (fd == -1) {
DEBUG(0,("create_local_private_krb5_conf_for_domain: smb_mkstemp failed,"
" for file %s. Errno %s\n",

View File

@ -948,12 +948,12 @@ static NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx,
}
/* Open the add and mod ldif files */
if (!(r->add_file = fdopen(smb_mkstemp(r->add_name),"w"))) {
if (!(r->add_file = fdopen(mkstemp(r->add_name),"w"))) {
DEBUG(1, ("Could not open %s\n", r->add_name));
status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
if (!(r->mod_file = fdopen(smb_mkstemp(r->mod_name),"w"))) {
if (!(r->mod_file = fdopen(mkstemp(r->mod_name),"w"))) {
DEBUG(1, ("Could not open %s\n", r->mod_name));
status = NT_STATUS_UNSUCCESSFUL;
goto done;

View File

@ -2476,7 +2476,7 @@ uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum,
/* we have a job entry - now create the spool file */
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.8u.XXXXXX",
path, PRINT_SPOOL_PREFIX, (unsigned int)jobid);
pjob.fd = smb_mkstemp(pjob.filename);
pjob.fd = mkstemp(pjob.filename);
if (pjob.fd == -1) {
if (errno == EACCES) {

View File

@ -59,7 +59,7 @@ static void msg_deliver(struct msg_state *state)
if (!name) {
goto done;
}
fd = smb_mkstemp(name);
fd = mkstemp(name);
if (fd == -1) {
DEBUG(1, ("can't open message file %s: %s\n", name,

View File

@ -2214,7 +2214,7 @@ void reply_ctemp(struct smb_request *req)
return;
}
tmpfd = smb_mkstemp(fname);
tmpfd = mkstemp(fname);
if (tmpfd == -1) {
reply_unixerror(req, ERRDOS, ERRnoaccess);
END_PROFILE(SMBctemp);
@ -2244,7 +2244,7 @@ void reply_ctemp(struct smb_request *req)
NULL, /* pinfo */
&sbuf); /* psbuf */
/* close fd from smb_mkstemp() */
/* close fd from mkstemp() */
close(tmpfd);
if (!NT_STATUS_IS_OK(status)) {

View File

@ -859,7 +859,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
}
/* Create a temporary filename for this share. */
tmpfd = smb_mkstemp(full_path_tmp);
tmpfd = mkstemp(full_path_tmp);
if (tmpfd == -1) {
d_fprintf(stderr, "net usershare add: cannot create tmp file %s\n",