Remove smb_mkstemp() - libreplace will now provide a secure mkstemp() if
authorJelmer Vernooij <jelmer@samba.org>
Mon, 20 Apr 2009 21:58:26 +0000 (23:58 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 20 Apr 2009 21:58:26 +0000 (23:58 +0200)
the system one is broken.

source3/client/client.c
source3/lib/smbrun.c
source3/lib/util.c
source3/libads/kerberos.c
source3/libnet/libnet_samsync_ldif.c
source3/printing/printing.c
source3/smbd/message.c
source3/smbd/reply.c
source3/utils/net_usershare.c

index a6f31bcf173b6382c33b4915d0b03efe2542f9c1..fcb9b27f1fa571e590514fad543cb8029bd45bf5 100644 (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;
index fdccd9ec9765363c99e8d54a26924f504f7bf3de..14e6a7690c812d98c0b6c712a420aa7a71d6cc39 100644 (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",
index 75fd82709a881a3b98983f50d708ef88093e9036..c86f259ce3fd00871cdf26e8d59622282db09bfc 100644 (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.
  *****************************************************************/  
index c476f59ff52fdeeb204b4308afdcdee89703d656..e1618636e1d7848990dbfab2a6095f756b51dc18 100644 (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",
index dc3bc75541c11ecb2a2c569a3e4f67cbb969825d..931107946ea7a6b5cba64166c5f7ab815f6f3307 100644 (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;
index 8524cfb2bd834fc7a2f13a944dc5bf43e4de6427..a661d3dbdc97609d29d1a28ba1871256b9bc14ff 100644 (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) {
index dbc833f091f09a1c397a5565e77d6263ae26271f..e6d5f451cd5d687697f5c26f1bbd8b28e2218b14 100644 (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,
index e1364f2462027780c40e0d94647d9c2bbdcb0521..d2e1f8be5fae949f6edf7768115e6aac70892edc 100644 (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)) {
index 7d3cb287a84c756bfcfb9652eabe7291c80bd889..dadb88303b583b42a6bef068d50e1a60fc33b345 100644 (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",