]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbcontrol: improve destination resolution using names db
authorjule <janger@samba.org>
Mon, 6 Feb 2023 13:28:36 +0000 (13:28 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 Jul 2023 20:04:29 +0000 (20:04 +0000)
With this change it's possible to use 'smbcontrol ldap_server ...'
instead of 'smbcontrol prefork-master-ldap ...'

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/utils/smbcontrol.c

index ab57bd4804248ae3f857244aa6b43c4105a99662..b85dceca60565e61981871065f0664e7dcad6d7f 100644 (file)
@@ -35,6 +35,7 @@
 #include "util_tdb.h"
 #include "../lib/util/pidfile.h"
 #include "serverid.h"
+#include "lib/util/server_id_db.h"
 #include "cmdline_contexts.h"
 #include "lib/util/string_wrappers.h"
 #include "lib/global_contexts.h"
@@ -1642,6 +1643,8 @@ static struct server_id parse_dest(struct messaging_context *msg,
                .pid = (uint64_t)-1,
        };
        pid_t pid;
+       struct server_id_db *names_db = NULL;
+       bool ok;
 
        /* Zero is a special return value for broadcast to all processes */
 
@@ -1674,6 +1677,16 @@ static struct server_id parse_dest(struct messaging_context *msg,
                return pid_to_procid(pid);
        }
 
+       names_db = messaging_names_db(msg);
+       if (names_db == NULL) {
+               goto fail;
+       }
+       ok = server_id_db_lookup_one(names_db, dest, &result);
+       if (ok) {
+               return result;
+       }
+
+fail:
        fprintf(stderr,"Can't find pid for destination '%s'\n", dest);
 
        return result;