The branch, master has been updated
       via  8d96a28 messaging_dgm: Factor out messaging_dgm_lockfile_name
       via  8deb851 messaging_dgm: Use %ju to fill lockfile
      from  5cbda7e libcli/security: add better detection of 
SECINFO_[UN]PROTECTED_[D|S]ACL in get_sec_info()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 8d96a280f6174b54fe2674be6065c5b16f7ec04d
Author: Volker Lendecke <[email protected]>
Date:   Sat Aug 2 13:26:44 2014 +0200

    messaging_dgm: Factor out messaging_dgm_lockfile_name
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Fri Aug 22 05:20:43 CEST 2014 on sn-devel-104

commit 8deb851200e5938a393932e7c50607f4180798ca
Author: Volker Lendecke <[email protected]>
Date:   Sat Aug 2 13:57:43 2014 +0200

    messaging_dgm: Use %ju to fill lockfile
    
    ... much nicer than PRIu64
    
    Also, append a \n. Makes it better readable when looking at the lockfile
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/messages_dgm.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index e2ee751..659b835 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -47,6 +47,14 @@ static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
                               uint8_t *msg, size_t msg_len,
                               void *private_data);
 
+static char *messaging_dgm_lockfile_name(TALLOC_CTX *mem_ctx,
+                                        const char *cache_dir,
+                                        pid_t pid)
+{
+       return talloc_asprintf(mem_ctx, "%s/lck/%u", cache_dir,
+                              (unsigned)pid);
+}
+
 static int messaging_dgm_context_destructor(struct messaging_dgm_context *c);
 
 static int messaging_dgm_lockfile_create(TALLOC_CTX *tmp_ctx,
@@ -69,19 +77,17 @@ static int messaging_dgm_lockfile_create(TALLOC_CTX 
*tmp_ctx,
        }
 
        ok = directory_create_or_exist_strict(dir, dir_owner, 0755);
+       TALLOC_FREE(dir);
        if (!ok) {
                ret = errno;
                DEBUG(1, ("%s: Could not create lock directory: %s\n",
                          __func__, strerror(ret)));
-               TALLOC_FREE(dir);
                return ret;
        }
 
-       lockfile_name = talloc_asprintf(tmp_ctx, "%s/%u", dir,
-                                       (unsigned)pid);
-       TALLOC_FREE(dir);
+       lockfile_name = messaging_dgm_lockfile_name(tmp_ctx, cache_dir,
+                                                   (unsigned)pid);
        if (lockfile_name == NULL) {
-               DEBUG(1, ("%s: talloc_asprintf failed\n", __func__));
                return ENOMEM;
        }
 
@@ -106,7 +112,7 @@ static int messaging_dgm_lockfile_create(TALLOC_CTX 
*tmp_ctx,
                goto fail_close;
        }
 
-       unique_len = snprintf(buf, sizeof(buf), "%"PRIu64, unique);
+       unique_len = snprintf(buf, sizeof(buf), "%ju\n", (uintmax_t)unique);
 
        /* shorten a potentially preexisting file */
 
@@ -144,8 +150,8 @@ static int messaging_dgm_lockfile_remove(TALLOC_CTX 
*tmp_ctx,
        char *lockfile_name;
        int ret;
 
-       lockfile_name = talloc_asprintf(
-               tmp_ctx, "%s/lck/%u", cache_dir, (unsigned)pid);
+       lockfile_name = messaging_dgm_lockfile_name(
+               tmp_ctx, cache_dir, pid);
        if (lockfile_name == NULL) {
                return ENOMEM;
        }
@@ -320,8 +326,8 @@ int messaging_dgm_cleanup(struct messaging_dgm_context 
*ctx, pid_t pid)
        int fd, ret;
        struct flock lck = {};
 
-       lockfile_name = talloc_asprintf(talloc_tos(), "%s/lck/%u",
-                                       ctx->cache_dir, (unsigned)pid);
+       lockfile_name = messaging_dgm_lockfile_name(
+               talloc_tos(), ctx->cache_dir, pid);
        if (lockfile_name == NULL) {
                return ENOMEM;
        }


-- 
Samba Shared Repository

Reply via email to