[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Tue Jun 15 19:03:02 UTC 2021
The branch, master has been updated
via 7d0b6904cc4 docs: Improve wording, fix a typo
via 5f5c45a12d3 libsmbclient: Avoid a call to SMBC_errno() in SMBC_mkdir_ctx()
via f877d832095 libsmb: Factor out cli_status_to_errno() from cli_errno()
via 35a43de18d5 rpc_server: Make get_domain_userlist() independent of errno
via 76c1b77e79c rpc_server: Make errno return of get_logged_on_userlist explicit
via aa147153c10 rpc_server: Don't rely on TCP-bind() to return EADDRINUSE
from 582030bae25 s3: torture: Add POSIX-SYMLINK-GETPATHINFO regression test.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7d0b6904cc4d5e66860f0f851ca1ccf539423c9d
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jun 12 08:33:42 2021 +0200
docs: Improve wording, fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Tue Jun 15 19:02:18 UTC 2021 on sn-devel-184
commit 5f5c45a12d3f8a083bd6ee4e832b33d3518b05b3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 15 17:15:21 2020 +0100
libsmbclient: Avoid a call to SMBC_errno() in SMBC_mkdir_ctx()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit f877d832095fdaacd3b871966b9189faf8420f5f
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 15 17:05:34 2020 +0100
libsmb: Factor out cli_status_to_errno() from cli_errno()
cli_errno() calls far too many trivial but subtle functions, all
referencing cli->raw_status. This might be the first step towards
getting rid of that.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 35a43de18d541968a5a0de721b4ec429e61ad23b
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jun 12 20:46:20 2021 +0200
rpc_server: Make get_domain_userlist() independent of errno
In the "num_users==0" case (previously just return NULL) we depended
on errno==0 implicitly. When list_sessions() above in this routine had
to open smbXsrv_session_global, it could however happen that errno was
set. If then there were no users, get_domain_userlist() returned NULL
with errno set, which the callers interpreted then as a real error.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 76c1b77e79c273db4c768a899fa8383e9630dc59
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jun 12 20:39:49 2021 +0200
rpc_server: Make errno return of get_logged_on_userlist explicit
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit aa147153c10b94e2db40d772677efacd5d0b31ee
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jun 12 12:45:30 2021 +0200
rpc_server: Don't rely on TCP-bind() to return EADDRINUSE
socket_wrapper can't do EADDRINUSE because unix domain sockets don't
do it.
This currently works correctly because right now all RPC servers
either use explicit ports or all listen on the same socket.
The new code uses a static variable, so it only helps if a single
process listens for multiple RPC sockets. It won't work if multiple
processes start listening. But in case samba-dcerpcd goes in this will
be exactly the right thing to do.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
.../domain/dnszonetransferclientsallow.xml | 2 +-
.../domain/dnszonetransferclientsdeny.xml | 4 +-
source3/libsmb/clierror.c | 57 ++++++++++-------
source3/libsmb/libsmb_dir.c | 5 +-
source3/libsmb/proto.h | 1 +
source3/rpc_server/rpc_sock_helper.c | 8 ++-
source3/rpc_server/wkssvc/srv_wkssvc_nt.c | 74 ++++++++++++++--------
7 files changed, 94 insertions(+), 57 deletions(-)
Changeset truncated at 500 lines:
diff --git a/docs-xml/smbdotconf/domain/dnszonetransferclientsallow.xml b/docs-xml/smbdotconf/domain/dnszonetransferclientsallow.xml
index 902b6082379..cf017428c16 100644
--- a/docs-xml/smbdotconf/domain/dnszonetransferclientsallow.xml
+++ b/docs-xml/smbdotconf/domain/dnszonetransferclientsallow.xml
@@ -3,7 +3,7 @@
type="cmdlist"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
- <para>This option specifies the list IPs authorized to ask for dns zone
+ <para>This option specifies the list of IPs authorized to ask for dns zone
transfer from bind DLZ module.
</para>
diff --git a/docs-xml/smbdotconf/domain/dnszonetransferclientsdeny.xml b/docs-xml/smbdotconf/domain/dnszonetransferclientsdeny.xml
index f88b15bf1ca..8ff8531e977 100644
--- a/docs-xml/smbdotconf/domain/dnszonetransferclientsdeny.xml
+++ b/docs-xml/smbdotconf/domain/dnszonetransferclientsdeny.xml
@@ -3,7 +3,7 @@
type="cmdlist"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
- <para>This option specifies the list IPs denied to ask for dns zone
+ <para>This option specifies the list of IPs denied to ask for dns zone
transfer from bind DLZ module.
</para>
@@ -17,7 +17,7 @@
<para>If a client identified in this list sends a zone transfer request, it will always
be denied, even if they are in <smbconfoption name="dns zone transfer clients allow"/>.
- This allows the definition of sepcific denied clients within an authorized subnet.
+ This allows the definition of specific denied clients within an authorized subnet.
</para>
</description>
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index b92b3160174..cb75878bba3 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -66,39 +66,48 @@ void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode)
*ecode = NT_STATUS_DOS_CODE(cli->raw_status);
}
+int cli_status_to_errno(NTSTATUS status)
+{
+ int err;
+
+ if (NT_STATUS_IS_DOS(status)) {
+ uint8_t eclass = NT_STATUS_DOS_CLASS(status);
+ uint32_t ecode = NT_STATUS_DOS_CODE(status);
+ status = dos_to_ntstatus(eclass, ecode);
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INACCESSIBLE_SYSTEM_SHORTCUT)) {
+ /*
+ * Legacy code from cli_errno, see Samba up to 4.13: A
+ * special case for this Vista error. Since its
+ * high-order byte isn't 0xc0, it won't match
+ * correctly in map_errno_from_nt_status().
+ */
+ err = EACCES;
+ } else {
+ err = map_errno_from_nt_status(status);
+ }
+
+ DBG_NOTICE("0x%"PRIx32" -> %d\n", NT_STATUS_V(status), err);
+
+ return err;
+}
/* Return a UNIX errno appropriate for the error received in the last
packet. */
int cli_errno(struct cli_state *cli)
{
- NTSTATUS status;
+ bool connected;
+ int err;
- if (cli_is_nt_error(cli)) {
- status = cli_nt_error(cli);
- return map_errno_from_nt_status(status);
+ connected = cli_state_is_connected(cli);
+ if (!connected) {
+ return EPIPE;
}
- if (cli_is_dos_error(cli)) {
- uint8_t eclass;
- uint32_t ecode;
-
- cli_dos_error(cli, &eclass, &ecode);
- status = dos_to_ntstatus(eclass, ecode);
- return map_errno_from_nt_status(status);
- }
-
- /*
- * Yuck! A special case for this Vista error. Since its high-order
- * byte isn't 0xc0, it doesn't match cli_is_nt_error() above.
- */
- status = cli_nt_error(cli);
- if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INACCESSIBLE_SYSTEM_SHORTCUT)) {
- return EACCES;
- }
-
- /* for other cases */
- return EINVAL;
+ err = cli_status_to_errno(cli->raw_status);
+ return err;
}
/* Return true if the last packet was in error */
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 026eababca1..b7a5c2504e6 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1619,9 +1619,10 @@ SMBC_mkdir_ctx(SMBCCTX *context,
}
/*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/
- if (!NT_STATUS_IS_OK(cli_mkdir(targetcli, targetpath))) {
- errno = SMBC_errno(context, targetcli);
+ status = cli_mkdir(targetcli, targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(frame);
+ errno = cli_status_to_errno(status);
return -1;
}
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index e560e6697b8..bd67e56b60f 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -203,6 +203,7 @@ NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
NTSTATUS cli_nt_error(struct cli_state *cli);
void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode);
+int cli_status_to_errno(NTSTATUS status);
int cli_errno(struct cli_state *cli);
bool cli_is_error(struct cli_state *cli);
bool cli_is_nt_error(struct cli_state *cli);
diff --git a/source3/rpc_server/rpc_sock_helper.c b/source3/rpc_server/rpc_sock_helper.c
index 22a0cd17aeb..8ae637a71b4 100644
--- a/source3/rpc_server/rpc_sock_helper.c
+++ b/source3/rpc_server/rpc_sock_helper.c
@@ -117,12 +117,18 @@ static NTSTATUS dcesrv_create_ncacn_ip_tcp_socket(
int fd = -1;
if (*port == 0) {
+ static uint16_t low = 0;
uint16_t i;
- for (i = lp_rpc_low_port(); i <= lp_rpc_high_port(); i++) {
+ if (low == 0) {
+ low = lp_rpc_low_port();
+ }
+
+ for (i = low; i <= lp_rpc_high_port(); i++) {
fd = open_socket_in(SOCK_STREAM, ifss, i, false);
if (fd >= 0) {
*port = i;
+ low = i+1;
break;
}
}
diff --git a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
index 120993dbfae..6b787ad8b32 100644
--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
@@ -65,7 +65,7 @@ static int usr_info_cmp(const struct usrinfo *usr1, const struct usrinfo *usr2)
Get a list of the names of all users logged into this machine
********************************************************************/
-static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
+static int get_logged_on_userlist(TALLOC_CTX *mem_ctx, char ***pusers)
{
char **users;
int i, num_users = 0;
@@ -94,7 +94,7 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
if (tmp == NULL) {
TALLOC_FREE(tmp);
endutxent();
- return NULL;
+ return ENOMEM;
}
usr_infos = tmp;
usr_infos[num_users].name = talloc_strdup(usr_infos,
@@ -102,7 +102,7 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
if (usr_infos[num_users].name == NULL) {
TALLOC_FREE(usr_infos);
endutxent();
- return NULL;
+ return ENOMEM;
}
usr_infos[num_users].login_time.tv_sec = u->ut_tv.tv_sec;
usr_infos[num_users].login_time.tv_usec = u->ut_tv.tv_usec;
@@ -120,15 +120,16 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
}
TALLOC_FREE(usr_infos);
endutxent();
- errno = 0;
- return users;
+ *pusers = users;
+ return 0;
}
#else
-static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
+static int get_logged_on_userlist(TALLOC_CTX *mem_ctx, char ***pusers)
{
- return NULL;
+ *pusers = NULL;
+ return 0;
}
#endif
@@ -159,7 +160,7 @@ static int dom_user_cmp(const struct dom_usr *usr1, const struct dom_usr *usr2)
in this list.
********************************************************************/
-static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
+static int get_domain_userlist(TALLOC_CTX *mem_ctx, struct dom_usr **pusers)
{
struct sessionid *session_list = NULL;
char *machine_name, *p, *nm;
@@ -174,14 +175,14 @@ static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
num_sessions = list_sessions(mem_ctx, &session_list);
if (num_sessions == 0) {
- errno = 0;
- return NULL;
+ *pusers = NULL;
+ return 0;
}
users = talloc_array(mem_ctx, struct dom_usr, num_sessions);
if (users == NULL) {
TALLOC_FREE(session_list);
- return NULL;
+ return ENOMEM;
}
for (i=num_users=0; i<num_sessions; i++) {
@@ -231,17 +232,24 @@ static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
}
TALLOC_FREE(session_list);
+ if (num_users == 0) {
+ TALLOC_FREE(users);
+ *pusers = NULL;
+ return 0;
+ }
+
tmp = talloc_realloc(mem_ctx, users, struct dom_usr, num_users);
if (tmp == NULL) {
- return NULL;
+ TALLOC_FREE(users);
+ return ENOMEM;
}
users = tmp;
/* Sort the user list by time, oldest first */
TYPESAFE_QSORT(users, num_users, dom_user_cmp);
- errno = 0;
- return users;
+ *pusers = users;
+ return 0;
}
/*******************************************************************
@@ -316,6 +324,7 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaInfo102 *info102;
char **users;
+ int ret;
info102 = talloc(mem_ctx, struct wkssvc_NetWkstaInfo102);
if (info102 == NULL) {
@@ -332,7 +341,12 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
info102, "%s", lp_workgroup());
info102->lan_root = "";
- users = get_logged_on_userlist(talloc_tos());
+ ret = get_logged_on_userlist(talloc_tos(), &users);
+ if (ret != 0) {
+ TALLOC_FREE(info102);
+ errno = ret;
+ return NULL;
+ }
info102->logged_on_users = talloc_array_length(users);
TALLOC_FREE(users);
@@ -428,18 +442,20 @@ static struct wkssvc_NetWkstaEnumUsersCtr0 *create_enum_users0(
{
struct wkssvc_NetWkstaEnumUsersCtr0 *ctr0;
char **users;
- int i, num_users;
+ int i, num_users, ret;
ctr0 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr0);
if (ctr0 == NULL) {
return NULL;
}
- users = get_logged_on_userlist(talloc_tos());
- if (users == NULL && errno != 0) {
- DEBUG(1,("get_logged_on_userlist error %d: %s\n",
- errno, strerror(errno)));
+ ret = get_logged_on_userlist(talloc_tos(), &users);
+ if (ret != 0) {
+ DBG_WARNING("get_logged_on_userlist error %d: %s\n",
+ ret,
+ strerror(ret));
TALLOC_FREE(ctr0);
+ errno = ret;
return NULL;
}
@@ -478,26 +494,29 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
struct dom_usr *dom_users;
const char *pwd_server;
char *pwd_tmp;
- int i, j, num_users, num_dom_users;
+ int i, j, num_users, num_dom_users, ret;
ctr1 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr1);
if (ctr1 == NULL) {
return NULL;
}
- users = get_logged_on_userlist(talloc_tos());
- if (users == NULL && errno != 0) {
- DEBUG(1,("get_logged_on_userlist error %d: %s\n",
- errno, strerror(errno)));
+ ret = get_logged_on_userlist(talloc_tos(), &users);
+ if (ret != 0) {
+ DBG_WARNING("get_logged_on_userlist error %d: %s\n",
+ ret,
+ strerror(ret));
TALLOC_FREE(ctr1);
+ errno = ret;
return NULL;
}
num_users = talloc_array_length(users);
- dom_users = get_domain_userlist(talloc_tos());
- if (dom_users == NULL && errno != 0) {
+ ret = get_domain_userlist(talloc_tos(), &dom_users);
+ if (ret != 0) {
TALLOC_FREE(ctr1);
TALLOC_FREE(users);
+ errno = ret;
return NULL;
}
num_dom_users = talloc_array_length(dom_users);
@@ -508,6 +527,7 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
TALLOC_FREE(ctr1);
TALLOC_FREE(users);
TALLOC_FREE(dom_users);
+ errno = ENOMEM;
return NULL;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list