Second part of fix for bug #6235 - domain enumeration breaks if master browser has...
[samba.git] / source3 / libsmb / libsmb_dir.c
index 2255db66170fe872886d0ec9e57658fc4ef74fe2..436b3e8e03d83844cf8a7dec3d92be2a761d3edc 100644 (file)
@@ -615,8 +615,8 @@ SMBC_opendir_ctx(SMBCCTX *context,
                          */
                        if (!srv &&
                             !is_ipaddress(server) &&
-                           (resolve_name(server, &rem_ss, 0x1d) ||   /* LMB */
-                             resolve_name(server, &rem_ss, 0x1b) )) { /* DMB */
+                           (resolve_name(server, &rem_ss, 0x1d, false) ||   /* LMB */
+                             resolve_name(server, &rem_ss, 0x1b, false) )) { /* DMB */
 
                                fstring buserver;
 
@@ -625,7 +625,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
                                /*
                                 * Get the backup list ...
                                 */
-                               if (!name_status_find(server, 00,
+                               if (!name_status_find(server, 0x20, 0x20,
                                                       &rem_ss, buserver)) {
 
                                         DEBUG(0,("Could not get name of "
@@ -675,7 +675,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
                                        return NULL;
                                }
                        } else if (srv ||
-                                   (resolve_name(server, &rem_ss, 0x20))) {
+                                   (resolve_name(server, &rem_ss, 0x20, false))) {
 
                                 /*
                                  * If we hadn't found the server, get one now
@@ -1171,13 +1171,13 @@ SMBC_mkdir_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
-               TALLOC_FREE(frame);
+                errno = ENOENT;
+                TALLOC_FREE(frame);
                return -1;
        }
        /*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/
 
-       if (!cli_mkdir(targetcli, targetpath)) {
-
+       if (!NT_STATUS_IS_OK(cli_mkdir(targetcli, targetpath))) {
                errno = SMBC_errno(context, targetcli);
                TALLOC_FREE(frame);
                return -1;
@@ -1278,13 +1278,13 @@ SMBC_rmdir_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
        /*d_printf(">>>rmdir: resolved path as %s\n", targetpath);*/
 
-
-       if (!cli_rmdir(targetcli, targetpath)) {
+       if (!NT_STATUS_IS_OK(cli_rmdir(targetcli, targetpath))) {
 
                errno = SMBC_errno(context, targetcli);
 
@@ -1561,6 +1561,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1572,7 +1573,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
        if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
        if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;
 
-       if (!cli_setatr(targetcli, targetpath, mode, 0)) {
+       if (!NT_STATUS_IS_OK(cli_setatr(targetcli, targetpath, mode, 0))) {
                errno = SMBC_errno(context, targetcli);
                TALLOC_FREE(frame);
                return -1;
@@ -1753,12 +1754,13 @@ SMBC_unlink_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
        /*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/
 
-       if (!cli_unlink(targetcli, targetpath)) {
+       if (!NT_STATUS_IS_OK(cli_unlink(targetcli, targetpath, aSYSTEM | aHIDDEN))) {
 
                errno = SMBC_errno(context, targetcli);
 
@@ -1927,6 +1929,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
                                path1,
                                &targetcli1, &targetpath1)) {
                d_printf("Could not resolve %s\n", path1);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1944,6 +1947,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
                                path2,
                                &targetcli2, &targetpath2)) {
                d_printf("Could not resolve %s\n", path2);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1958,12 +1962,12 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
                return -1;
        }
 
-       if (!cli_rename(targetcli1, targetpath1, targetpath2)) {
+       if (!NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
                int eno = SMBC_errno(ocontext, targetcli1);
 
                if (eno != EEXIST ||
-                   !cli_unlink(targetcli1, targetpath2) ||
-                   !cli_rename(targetcli1, targetpath1, targetpath2)) {
+                   !NT_STATUS_IS_OK(cli_unlink(targetcli1, targetpath2, aSYSTEM | aHIDDEN)) ||
+                   !NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
 
                        errno = eno;
                        TALLOC_FREE(frame);