1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/lib
Paulo Alcantara 41aa55f492 s3: util: Do not take over stderr when there is no log file
In case we don't have either a /var/log/samba directory, or pass a
non-existent log directory through '-l' option, all commands that are
daemonized with '-D' option hang when executed within a subshell.

An example on how to trigger that:

  # rm -r /var/log/samba
  # s=$(nmbd -D -s /etc/samba/smb.conf -l /foo123)
  (never returns)

So, when the above command is executed within a subshell the following
happens:

  (a) Parent shell creates a pipe, sets write side of it to fd 1
    (stdout), call read() on read-side fd, forks off a new child process
    and then executes nmbd in it.
  (b) nmbd sets up initial logging to go through fd 1 (stdout) by
    calling setup_logging(..., DEBUG_DEFAULT_STDOUT). 'state.fd' is now
    set to 1.
  (c) reopen_logs() is called by the first time which then calls
    reopen_logs_internal()
  (d) in reopen_logs_internal(), it attempts to create log.nmbd file in
    /foo123 directory and fails because directory doesn't exist.
  (e) Regardless whether the log file was created or not, it calls
    dup2(state.fd, 2) which dups fd 1 into fd 2.
  (f) At some point, fd 0 and 1 are closed and set to /dev/null

The problem with that is because parent shell in (a) is still blocked in
read() call and the new write side of the pipe is now fd 2 -- after
dup2() in (e) -- and remains unclosed.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13578

Signed-off-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Jim McDonough <jmcd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Aug 18 01:32:25 CEST 2018 on sn-devel-144
2018-08-18 01:32:25 +02:00
..
addns addns: Fix a typo 2018-06-16 04:21:17 +02:00
afs waf: add --with-fake-kaserver option 2014-06-04 20:09:38 +02:00
async_req lib/async_req/async_sock.c set socket close on exec 2017-12-18 04:38:19 +01:00
audit_logging lib audit_logging: add _WARN_UNUSED_RESULT_ 2018-07-25 09:28:31 +02:00
compression lib/compression/tests: add missing #include "torture/local/proto.h" 2014-04-02 09:03:44 +02:00
crypto lib/crypto: avoid 'return void_function();' which isn't portable 2018-04-03 16:41:09 +02:00
dbwrap dbwrap: Fix a typo 2018-08-17 18:25:08 +02:00
krb5_wrap krb5_wrap: fix keep_old_entries logic for older kerberos libraries 2018-06-23 00:57:47 +02:00
ldb ldb: Release LDB 1.5.1 2018-08-15 07:08:24 +02:00
ldb-samba dns: custom match rule for DNS records to be tombstoned 2018-07-12 04:31:54 +02:00
mscat lib: Add support to parse MS Catalog files 2018-08-09 19:57:02 +02:00
param smb.conf: add dns_zone_scavenging 2018-07-12 04:31:51 +02:00
pthreadpool pthreadpool: reset monitor_fd after calling tevent_fd_set_auto_close() 2018-07-31 11:26:16 +02:00
replace lib/replace: also check for valgrind/helgrind.h 2018-07-24 17:38:27 +02:00
smbconf Correct "occured" typos. 2017-02-22 08:26:21 +01:00
socket lib:socket: Return early if we have only one interface 2018-03-20 23:16:16 +01:00
talloc talloc: version 2.1.14 2018-07-12 04:32:09 +02:00
tdb tdb: test for readonly locks mode on tdbbackup command 2018-08-06 05:37:42 +02:00
tdb_wrap tdb_wrap: Use a struct initializer 2015-07-23 14:39:18 +02:00
tdr lib: Fix 1354521 Unchecked return value 2016-03-01 21:49:44 +01:00
tevent Minor, really small, documentation fix. 2018-08-06 08:46:41 +02:00
texpect lib:texpect: Avoid some compiler warnings 2018-03-01 04:37:41 +01:00
torture selftest: consistently produce high-res UTC time 2018-03-22 13:26:44 +01:00
tsocket tsocket: Fix typos 2018-01-04 00:37:20 +01:00
util s3: util: Do not take over stderr when there is no log file 2018-08-18 01:32:25 +02:00
README build: Move nss_wrapper to third_party 2017-11-25 10:14:13 +01:00
wscript_build Remove 'external' python module support code - use the third_party directory instead. 2015-03-06 04:41:48 +01:00

compression - Various compression algorithms (MSZIP, lzxpress)
dnspython - Python module for working with DNS.
popt - Command-line option parsing library
replace - Provides replacements for standard (POSIX, C99) functions 
          not provided by the host platform.
subunit - Utilities and bindings for working with the Subunit test result 
          reporting protocol.
talloc - Hierarchical pool based memory allocator 
tdb - Simple but fast key/value database library, supporting multiple writers
torture - Simple unit testing helper library