lockwait: Allow for zero length key requests
authorAmitay Isaacs <amitay@gmail.com>
Thu, 14 Mar 2013 04:44:44 +0000 (15:44 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Mon, 25 Mar 2013 06:57:02 +0000 (17:57 +1100)
Samba sends zero length key requests for notify database. To support older
Samba behaviour for now, allow zero length key requests. Zero length key is
encoded as "NULL" string.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
server/ctdb_lockwait.c
server/ctdb_lockwait_helper.c

index 3680e3314530c97fd1425ff91494b9011d621ce6..cb5bc1c12a5945b7d9ccfc100e4f4c6a64392560 100644 (file)
@@ -206,7 +206,11 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
        arg0 = talloc_asprintf(result, "ctdb_lock-%s", ctdb_db->db_name);
        arg1 = talloc_asprintf(result, "%d", result->fd[1]);
        arg2 = talloc_strdup(result, ctdb_db->db_path);
-       arg3 = hex_encode_talloc(result, key.dptr, key.dsize);
+       if (key.dsize == 0) {
+               arg3 = talloc_strdup(result, "NULL");
+       } else {
+               arg3 = hex_encode_talloc(result, key.dptr, key.dsize);
+       }
 
        if (!arg0 || !arg1 || !arg2 || !arg3) {
                close(result->fd[0]);
index b300fe434d22a2116288e5ef507e2faefa58a48b..2350e738f88e608280bcb8ff33b57334c27ed34e 100644 (file)
@@ -50,7 +50,12 @@ int main(int argc, char *argv[])
        dbkey = argv[3];
 
        /* Convert hex key to key */
-       key.dptr = hex_decode_talloc(NULL, dbkey, &key.dsize);
+       if (strcmp(dbkey, "NULL") == 0) {
+               key.dptr = NULL;
+               key.dsize = 0;
+       } else {
+               key.dptr = hex_decode_talloc(NULL, dbkey, &key.dsize);
+       }
 
        tdb = tdb_open(dbpath, 0, TDB_DEFAULT, O_RDWR, 0600);
        if (tdb == NULL) {