s3:nmbd: make use of cli_session_setup_anon()
[samba.git] / source3 / nmbd / nmbd_synclists.c
index 7a256a35efe516d5f469b280be5ee08c55db19d2..f3e524d932a292a7d697d0170266cd75869154ec 100644 (file)
@@ -31,7 +31,7 @@
 #include "nmbd/nmbd.h"
 #include "libsmb/libsmb.h"
 #include "libsmb/clirap.h"
-#include "smbprofile.h"
+#include "../libcli/smb/smbXcli_base.h"
 
 struct sync_record {
        struct sync_record *next, *prev;
@@ -52,7 +52,7 @@ static XFILE *fp;
   Note sname and comment are in UNIX codepage format.
   ******************************************************************/
 
-static void callback(const char *sname, uint32 stype, 
+static void callback(const char *sname, uint32_t stype,
                      const char *comment, void *state)
 {
        x_fprintf(fp,"\"%s\" %08X \"%s\"\n", sname, stype, comment);
@@ -71,7 +71,7 @@ static void sync_child(char *name, int nm_type,
 {
        fstring unix_workgroup;
        struct cli_state *cli;
-       uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
+       uint32_t local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
        struct sockaddr_storage ss;
        NTSTATUS status;
 
@@ -81,26 +81,27 @@ static void sync_child(char *name, int nm_type,
 
        in_addr_to_sockaddr_storage(&ss, ip);
 
-       status = cli_connect_nb(name, &ss, 139, nm_type,
-                               get_local_machine_name(), Undefined, 0,
-                               &cli);
+       status = cli_connect_nb(name, &ss, NBT_SMB_PORT, nm_type,
+                               get_local_machine_name(), SMB_SIGNING_DEFAULT,
+                               0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return;
        }
 
-       status = cli_negprot(cli, PROTOCOL_NT1);
+       status = smbXcli_negprot(cli->conn, cli->timeout, PROTOCOL_CORE,
+                                PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                cli_shutdown(cli);
                return;
        }
 
-       if (!NT_STATUS_IS_OK(cli_session_setup(cli, "", "", 1, "", 0,
-                                              workgroup))) {
+       status = cli_session_setup_anon(cli);
+       if (!NT_STATUS_IS_OK(status)) {
                cli_shutdown(cli);
                return;
        }
 
-       if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, "IPC$", "IPC", "", 1))) {
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", "", 1))) {
                cli_shutdown(cli);
                return;
        }
@@ -137,12 +138,10 @@ void sync_browse_lists(struct work_record *work,
        struct sync_record *s;
        static int counter;
 
-       START_PROFILE(sync_browse_lists);
        /* Check we're not trying to sync with ourselves. This can
           happen if we are a domain *and* a local master browser. */
        if (ismyip_v4(ip)) {
 done:
-               END_PROFILE(sync_browse_lists);
                return;
        }
 
@@ -155,7 +154,7 @@ done:
        unstrcpy(s->server, name);
        s->ip = ip;
 
-       if (asprintf(&s->fname, "%s/sync.%d", lp_lockdir(), counter++) < 0) {
+       if (asprintf(&s->fname, "%s/sync.%d", lp_lock_directory(), counter++) < 0) {
                SAFE_FREE(s);
                goto done;
        }
@@ -165,9 +164,9 @@ done:
        DLIST_ADD(syncs, s);
 
        /* the parent forks and returns, leaving the child to do the
-          actual sync and call END_PROFILE*/
+          actual sync */
        CatchChild();
-       if ((s->pid = sys_fork())) return;
+       if ((s->pid = fork())) return;
 
        BlockSignals( False, SIGTERM );
 
@@ -176,7 +175,6 @@ done:
 
        fp = x_fopen(s->fname,O_WRONLY|O_CREAT|O_TRUNC, 0644);
        if (!fp) {
-               END_PROFILE(sync_browse_lists);
                _exit(1);
        }
 
@@ -184,7 +182,6 @@ done:
                   s->fname);
 
        x_fclose(fp);
-       END_PROFILE(sync_browse_lists);
        _exit(0);
 }
 
@@ -193,7 +190,7 @@ done:
  **********************************************************************/
 
 static void complete_one(struct sync_record *s,
-                        char *sname, uint32 stype, char *comment)
+                        char *sname, uint32_t stype, char *comment)
 {
        struct work_record *work;
        struct server_record *servrec;