The branch, v4-9-stable has been updated via 7f744ab VERSION: Disable GIT_SNAPSHOT for the 4.9.0rc2 release. via 9fc6a2e WHATSNEW: Add release notes for Samba 4.9.0rc2. via d666a5e ctdb-docs: Update documentation for "ctdb event" command via 8932003 ctdb-event: Implement event tool "script list" command via 792e170 ctdb-event: Change event-tool script enable/disable to chmod file directly via 0c65347 ctdb-common: Use script abstraction in run_event via 4cce86e ctdb-common: Factor out basic script abstraction via 34aba6f ctdb-event: Fix "ctdb event status" usage message via f24f0f13 ctdb-doc: Provide an example script for migrating old configuration via cb1292d WHATSNEW: Add further CTDB updates for 4.9 via d197d11 ctdb-docs: Replace obsolete reference to CTDB_DEBUG_HUNG_SCRIPT option via 5c2513d ctdb-protocol: Fix compilation issue with strncpy() via d4e9454 ctdb-common: Fix compilation issue with strncpy() via eb3f8ae ctdb-common: Fix the TCP packet length check via e4aa9b9 ctdb-tests: Strip all spaces from od output via 23e4131 ctdb-tests: Fix a typo via 0733f13 ctdb-tests: Use errcode to translate ETIMEDOUT via 0be07ae ctdb-tests: Replace md5sum with posix cksum via 862aedc ctdb-tests: Use portable wc -c instead of stat -c "%s" via 55fe4b5 ctdb-scripts: date "+%N" is non-portable via 33df4f9 ctdb-tests: Simplify pattern matching for ctime output via 18aa6548 ctdb-tests: Do not try to match pstree output in eventd tests via eb1279e ctdb-common: Add fd argument to ctdb_connection_list_read() via ea5643f ctdb-protocol: Avoid fgets in ctdb_connection_list_read via b21efa2 ctdb-common: Add line based I/O via fcae5c6 ctdb-tests: Porting tests should ignore unsupported features via 16838f3 ctdb-tests: Use sigcode to match signals via 0ec4783 ctdb-tests: Add signal code matching utility via adc4c78 ctdb-tests: Add ps output filter for freebsd via ed50360 ctdb-client: Switch to ETIMEDOUT instead of ETIME via 60ef296 ctdb-daemon: Switch to using ETIMEDOUT instead of ETIME via 0782860 ctdb-event: Switch to ETIMEDOUT instead of ETIME via 43cd4e4 ctdb-common: Switch to ETIMEDOUT from ETIME via d49d03d ctdb-tests: Add required_error() to match on error codes via 3f75791 ctdb-tests: Add errno matching utility via f6be661 ctdb-tests: Switch some test stubs to use /bin/sh via 58671b0 ctdb-tests: Improve portability by not using mktemp --tmpdir option via ebeecc3 ctdb-tests: Avoid use of non-portable getopt in stubs via 04a9667 ctdb-tests: Avoid use of non-portable getopt in run_tests.sh via e4b703e ctdb-tools: Avoid use of non-portable getopt in onnode via 7d28f01 ctdb-tests: Improve portability by not using /bin/bash directly via 23b5be4 ctdb-tools: Improve portability by not using /bin/bash directly via 4c2e666 s3: smbd: Fix AIX sendfile() for SMB2. Ensure we don't spin on EAGAIN. via a221165 s3: smbd: Fix FreeBSD sendfile() for SMB2. Ensure we don't spin on EAGAIN. via 8b54ad0 s3: smbd: Fix HPUX sendfile() for SMB2. Ensure we don't spin on EAGAIN. via 8652ab1 s3: smbd: Fix Solaris sendfile() for SMB2. Ensure we don't spin on EAGAIN. via 76d3abe s3: smbd: Fix Linux sendfile() for SMB2. Ensure we don't spin on EAGAIN. via a6dab26 dns wildcards: fix BUG 13536 via 1496392 dns wildcards: tests to confirm BUG 13536 via 9ad7af6 s3: smbd: fix path check in smbd_smb2_create_durable_lease_check() via 3b7a39b s4: torture: run test_durable_v2_open_reopen2_lease() in a subdirectory via c775cda ctdb-tests: Loosen match against pstree output in simple test via 5abe6e6 ctdb-tests: Simplify pstree output in eventd unit tests via 0b3e00a samba-tool trust: support discovery via netr_GetDcName via a3c26b3 s3:selftest: run rpc.lsa.lookupsids also with explicit [smb1] and [smb2] via e3e6425 s4:librpc: autonegotiate SMB1/2/3 via 25405ee python/tests: use explicit "client ipc max protocol = NT1" for samba.tests.net_join_no_spnego via 373406a tests/auth_log: Permit SMB2 service description if empty binding is used for kerberos authentication via b1753af s4:libcli: add smb_connect_nego_{send,recv}() via 3d8c4bf s4:libcli: allow a fallback to NTLMSSP if SPNEGO is not supported locally via 02f7b65 s4:libcli: add fallback_to_anonymous to smb2_connect_send() via 4d7023f s4:libcli: allow passing an already negotiated connection to smb2_connect_send() via a3a5797 s4:libcli: split out smb2_connect_session_start() via c85c9b5 s4:libcli: add smb2_transport_raw_init() via f9b685e s4:libcli: allow passing an already negotiated connection to smb_composite_connect() via 71a1355 s4:libcli: use talloc_zero() for struct smb_composite_connect in fetchfile.c via 00e5ea1 s4:libcli: add smbcli_transport_raw_init() via a8cd704 s4:libcli: split out smb_raw_negotiate_fill_transport() via 7e96021 librpc: add binding handle support for [smb1] via d85dd18 python/samba/tests: make sure samba.tests can be imported without SamDB via c6a325c s4-dsdb: only build dsdb Python modules for AD DC via bc280e8 s4-dns_server: Only build dns server Python code for AD DC via 516a440 s3: vfs: bump to version 39, Samba 4.9 will ship with that via ef0cae1 VERSION: Bump version up to 4.9.0rc2... from 7bc8b7f VERSION: Bump version up to 4.9.0rc1...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-9-stable - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: VERSION | 2 +- WHATSNEW.txt | 55 +- ctdb/client/client.h | 2 +- ctdb/client/client_connect.c | 2 +- ctdb/common/event_script.c | 246 ++++++++ ctdb/common/event_script.h | 72 +++ ctdb/common/line.c | 145 +++++ ctdb/common/line.h | 62 ++ ctdb/common/run_event.c | 221 ++----- ctdb/common/run_proc.c | 2 +- ctdb/common/system_socket.c | 6 +- ctdb/config/events/legacy/00.ctdb.script | 2 +- ctdb/config/functions | 9 +- ctdb/doc/ctdb-script.options.5.xml | 5 +- ctdb/doc/ctdb.1.xml | 95 +-- ctdb/doc/examples/config_migrate.sh | 688 +++++++++++++++++++++ ctdb/doc/examples/config_migrate.test_input | 45 ++ ctdb/event/event_cmd.c | 4 +- ctdb/event/event_tool.c | 232 +++++-- ctdb/protocol/protocol_util.c | 92 +-- ctdb/protocol/protocol_util.h | 4 +- ctdb/server/ctdb_client.c | 2 +- ctdb/server/ctdb_monitor.c | 2 +- ctdb/server/ctdb_recover.c | 2 +- ctdb/server/ctdb_takeover.c | 8 +- ctdb/server/eventscript.c | 4 +- ctdb/tests/cunit/event_script_test_001.sh | 125 ++++ ctdb/tests/cunit/line_test_001.sh | 90 +++ ctdb/tests/cunit/pidfile_test_001.sh | 2 +- ctdb/tests/cunit/porting_tests_001.sh | 13 +- ctdb/tests/cunit/run_event_001.sh | 8 +- ctdb/tests/cunit/run_proc_001.sh | 19 +- ctdb/tests/cunit/sock_daemon_test_001.sh | 26 +- ctdb/tests/eventd/etc-ctdb/debug-script.sh | 2 +- .../01.disabled.script => data/03.notalink.script} | 1 - .../data/{01.dummy.script => 02.disabled.script} | 0 .../etc-ctdb/{ => share}/events/empty/README | 0 .../{ => share}/events/random/01.disabled.script | 0 .../{ => share}/events/random/02.enabled.script | 0 .../{ => share}/events/random/README.script | 0 .../etc-ctdb/{ => share}/events/random/a.script | 0 ctdb/tests/eventd/eventd_001.sh | 11 +- ctdb/tests/eventd/eventd_002.sh | 10 +- ctdb/tests/eventd/eventd_003.sh | 20 +- ctdb/tests/eventd/eventd_004.sh | 2 +- ctdb/tests/eventd/eventd_006.sh | 2 +- ctdb/tests/eventd/eventd_007.sh | 4 +- ctdb/tests/eventd/eventd_009.sh | 116 ++++ ctdb/tests/eventd/eventd_011.sh | 4 +- ctdb/tests/eventd/eventd_012.sh | 4 +- ctdb/tests/eventd/eventd_013.sh | 4 +- ctdb/tests/eventd/eventd_021.sh | 2 +- ctdb/tests/eventd/eventd_022.sh | 4 +- ctdb/tests/eventd/eventd_023.sh | 2 +- ctdb/tests/eventd/eventd_024.sh | 4 +- ctdb/tests/eventd/eventd_032.sh | 6 +- ctdb/tests/eventd/eventd_033.sh | 12 +- ctdb/tests/eventd/eventd_042.sh | 2 +- ctdb/tests/eventd/eventd_043.sh | 4 +- ctdb/tests/eventd/eventd_052.sh | 4 +- ctdb/tests/eventd/scripts/local.sh | 6 +- ctdb/tests/eventscripts/00.ctdb.init.009.sh | 1 + ctdb/tests/eventscripts/13.per_ip_routing.024.sh | 2 +- ctdb/tests/eventscripts/scripts/00.ctdb.sh | 3 +- ctdb/tests/eventscripts/scripts/11.natgw.sh | 8 +- ctdb/tests/eventscripts/stubs/ctdb | 38 +- ctdb/tests/eventscripts/stubs/ip | 2 +- ctdb/tests/eventscripts/stubs/rpcinfo | 34 +- ctdb/tests/eventscripts/stubs/smnotify | 17 +- ctdb/tests/eventscripts/stubs/ss | 28 +- ctdb/tests/run_tests.sh | 48 +- ctdb/tests/scripts/integration.bash | 2 +- ctdb/tests/scripts/unit.sh | 7 + ctdb/tests/simple/90_debug_hung_script.sh | 2 +- ctdb/tests/src/dummy_client.c | 2 +- ctdb/tests/src/errcode.c | 189 ++++++ ctdb/tests/src/event_script_test.c | 119 ++++ ctdb/tests/src/line_test.c | 102 +++ ctdb/tests/src/porting_tests.c | 10 +- ctdb/tests/src/protocol_util_test.c | 18 +- ctdb/tests/src/run_event_test.c | 1 + ctdb/tests/src/sigcode.c | 120 ++++ ctdb/tests/takeover_helper/210.sh | 6 +- ctdb/tests/takeover_helper/211.sh | 6 +- ctdb/tests/takeover_helper/220.sh | 6 +- ctdb/tests/takeover_helper/230.sh | 8 +- ctdb/tests/takeover_helper/240.sh | 6 +- ctdb/tests/takeover_helper/250.sh | 6 +- ctdb/tests/takeover_helper/260.sh | 6 +- ctdb/tests/takeover_helper/scripts/local.sh | 4 +- ctdb/tools/ctdb.c | 6 +- ctdb/tools/ctdb_killtcp.c | 2 +- ctdb/tools/onnode | 55 +- ctdb/wscript | 21 +- librpc/rpc/binding.c | 1 + librpc/rpc/rpc_common.h | 2 + python/samba/netcmd/domain.py | 26 +- python/samba/tests/__init__.py | 5 +- python/samba/tests/auth_log.py | 26 +- python/samba/tests/dns_wildcard.py | 48 ++ python/samba/tests/net_join_no_spnego.py | 2 + source3/include/vfs.h | 1 + source3/lib/sendfile.c | 293 ++++++++- source3/selftest/tests.py | 2 +- source3/smbd/smb2_create.c | 16 +- source4/dns_server/dnsserver_common.c | 1 + source4/dns_server/wscript_build | 8 +- source4/dsdb/wscript_build | 11 +- source4/libcli/raw/clitransport.c | 44 ++ source4/libcli/raw/clitree.c | 1 + source4/libcli/raw/rawnegotiate.c | 74 ++- source4/libcli/smb2/connect.c | 69 ++- source4/libcli/smb2/session.c | 35 +- source4/libcli/smb2/transport.c | 35 ++ source4/libcli/smb_composite/connect.c | 48 +- source4/libcli/smb_composite/connect_nego.c | 209 +++++++ source4/libcli/smb_composite/fetchfile.c | 2 +- source4/libcli/smb_composite/smb_composite.h | 23 + source4/libcli/wscript_build | 20 +- source4/librpc/rpc/dcerpc_connect.c | 257 ++++---- source4/ntvfs/cifs/vfs_cifs.c | 1 + source4/torture/smb2/durable_v2_open.c | 11 +- 122 files changed, 3856 insertions(+), 818 deletions(-) create mode 100644 ctdb/common/event_script.c create mode 100644 ctdb/common/event_script.h create mode 100644 ctdb/common/line.c create mode 100644 ctdb/common/line.h create mode 100755 ctdb/doc/examples/config_migrate.sh create mode 100644 ctdb/doc/examples/config_migrate.test_input create mode 100755 ctdb/tests/cunit/event_script_test_001.sh create mode 100755 ctdb/tests/cunit/line_test_001.sh copy ctdb/tests/eventd/etc-ctdb/events/{random/01.disabled.script => data/03.notalink.script} (94%) copy ctdb/tests/eventd/etc-ctdb/share/events/data/{01.dummy.script => 02.disabled.script} (100%) copy ctdb/tests/eventd/etc-ctdb/{ => share}/events/empty/README (100%) copy ctdb/tests/eventd/etc-ctdb/{ => share}/events/random/01.disabled.script (100%) copy ctdb/tests/eventd/etc-ctdb/{ => share}/events/random/02.enabled.script (100%) copy ctdb/tests/eventd/etc-ctdb/{ => share}/events/random/README.script (100%) copy ctdb/tests/eventd/etc-ctdb/{ => share}/events/random/a.script (100%) create mode 100644 ctdb/tests/src/errcode.c create mode 100644 ctdb/tests/src/event_script_test.c create mode 100644 ctdb/tests/src/line_test.c create mode 100644 ctdb/tests/src/sigcode.c create mode 100644 source4/libcli/smb_composite/connect_nego.c Changeset truncated at 500 lines: diff --git a/VERSION b/VERSION index 94eee6c..7da5b10 100644 --- a/VERSION +++ b/VERSION @@ -87,7 +87,7 @@ SAMBA_VERSION_PRE_RELEASE= # e.g. SAMBA_VERSION_RC_RELEASE=1 # # -> "3.0.0rc1" # ######################################################## -SAMBA_VERSION_RC_RELEASE=1 +SAMBA_VERSION_RC_RELEASE=2 ######################################################## # To mark SVN snapshots this should be set to 'yes' # diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 6de49f2..b28cbf4 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -1,7 +1,7 @@ Release Announcements ===================== -This is the first release candidate of Samba 4.9. This is *not* +This is the second release candidate of Samba 4.9. This is *not* intended for production environments and is designed for testing purposes only. Please report any defects via the Samba bug reporting system at https://bugzilla.samba.org/. @@ -286,8 +286,8 @@ There are many changes to CTDB in this release. CTDB_SET_TunableVariable=<value> in the main configuration file is no longer supported. See ctdb-tunables(7) for details. - A script to convert an old-style configuration to a new one will be - available for release but is not yet available. + A example script to migrate an old-style configuration to the new + style is available in ctdb/doc/examples/config_migrate.sh. * The following configuration variables and corresponding ctdbd command-line options have been removed and not replaced with @@ -324,6 +324,20 @@ There are many changes to CTDB in this release. Event scripts must now end with a ".script" suffix. +* The "ctdb event" command has changed in 2 ways: + + - A component is now required for all commands + + In this release the only valid component is "legacy". + + - There is no longer a default event when running "ctdb event status" + + Listing the status of the "monitor" event is now done via: + + ctdb event status legacy monitor + + See ctdb(1) for details. + * The following service-related event script options have been removed: @@ -436,6 +450,41 @@ SMB_VFS_FCHMOD_ACL: Removed: Only FCHMOD is used. Any external VFS modules will need to be updated to match these changes in order to work with 4.9.x. + +CHANGES SINCE 4.9.0rc1 +====================== + +o Jeremy Allison <j...@samba.org> + * BUG 13537: s3: smbd: Using "sendfile = yes" with SMB2 can cause CPU spin. + +o Ralph Boehme <s...@samba.org> + * BUG 13535: s3: smbd: Fix path check in + smbd_smb2_create_durable_lease_check(). + +o Alexander Bokovoy <a...@samba.org> + * BUG 13538: samba-tool trust: Support discovery via netr_GetDcName. + * BUG 13542: s4-dsdb: Only build dsdb Python modules for AD DC. + +o Amitay Isaacs <ami...@gmail.com> + * BUG 13520: Fix portability issues on freebsd. + +o Gary Lockyer <g...@catalyst.net.nz> + * BUG 13536: DNS wildcard search does not handle multiple labels correctly. + +o Stefan Metzmacher <me...@samba.org> + * BUG 13308: samba-tool domain trust: Fix trust compatibility to Windows + Server 1709 and FreeIPA. + +o Martin Schwenke <mar...@meltin.net> + * BUG 13520: Fix portability issues on freebsd. + * BUG 13545: ctdb-protocol: Fix CTDB compilation issues. + * BUG 13546: ctdb-docs: Replace obsolete reference to CTDB_DEBUG_HUNG_SCRIPT + option. + * BUG 13550: ctdb-doc: Provide an example script for migrating old + configuration. + * BUG 13551: ctdb-event: Implement event tool "script list" command. + + KNOWN ISSUES ============ diff --git a/ctdb/client/client.h b/ctdb/client/client.h index 2eec3ea..d4d1450 100644 --- a/ctdb/client/client.h +++ b/ctdb/client/client.h @@ -184,7 +184,7 @@ void ctdb_client_wait(struct tevent_context *ev, bool *done); * @param[in] ev Tevent context * @param[in] done Boolean flag to indicate when to stop waiting * @param[in] timeout How long to wait - * @return 0 on succes, ETIME on timeout, and errno on failure + * @return 0 on succes, ETIMEDOUT on timeout, and errno on failure */ int ctdb_client_wait_timeout(struct tevent_context *ev, bool *done, struct timeval timeout); diff --git a/ctdb/client/client_connect.c b/ctdb/client/client_connect.c index 1e4157e..0977d71 100644 --- a/ctdb/client/client_connect.c +++ b/ctdb/client/client_connect.c @@ -363,7 +363,7 @@ int ctdb_client_wait_timeout(struct tevent_context *ev, bool *done, talloc_free(mem_ctx); if (timed_out) { - return ETIME; + return ETIMEDOUT; } return 0; diff --git a/ctdb/common/event_script.c b/ctdb/common/event_script.c new file mode 100644 index 0000000..8978d14 --- /dev/null +++ b/ctdb/common/event_script.c @@ -0,0 +1,246 @@ +/* + Low level event script handling + + Copyright (C) Amitay Isaacs 2017 + Copyright (C) Martin Schwenke 2018 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "replace.h" +#include "system/filesys.h" +#include "system/dir.h" +#include "system/glob.h" + +#include <talloc.h> + +#include "common/event_script.h" + +static int script_filter(const struct dirent *de) +{ + int ret; + + /* Match a script pattern */ + ret = fnmatch("[0-9][0-9].*.script", de->d_name, 0); + if (ret == 0) { + return 1; + } + + return 0; +} + +int event_script_get_list(TALLOC_CTX *mem_ctx, + const char *script_dir, + struct event_script_list **out) +{ + struct dirent **namelist = NULL; + struct event_script_list *script_list = NULL; + size_t ds_len; + int count, ret; + int i; + + count = scandir(script_dir, &namelist, script_filter, alphasort); + if (count == -1) { + ret = errno; + goto done; + } + + script_list = talloc_zero(mem_ctx, struct event_script_list); + if (script_list == NULL) { + goto nomem; + } + + if (count == 0) { + ret = 0; + *out = script_list; + goto done; + } + + script_list->num_scripts = count; + script_list->script = talloc_zero_array(script_list, + struct event_script *, + count); + if (script_list->script == NULL) { + goto nomem; + } + + ds_len = strlen(".script"); + for (i = 0; i < count; i++) { + struct event_script *s; + struct stat statbuf; + + s = talloc_zero(script_list->script, struct event_script); + if (s == NULL) { + goto nomem; + } + + script_list->script[i] = s; + + s->name = talloc_strndup(script_list->script, + namelist[i]->d_name, + strlen(namelist[i]->d_name) - ds_len); + if (s->name == NULL) { + goto nomem; + } + + s->path = talloc_asprintf(script_list->script, + "%s/%s", + script_dir, + namelist[i]->d_name); + if (s->path == NULL) { + goto nomem; + } + + ret = stat(s->path, &statbuf); + if (ret == 0) { + /* + * If ret != 0 this is either a dangling + * symlink or it has just disappeared. Either + * way, it isn't executable. See the note + * below about things that have disappeared. + */ + if (statbuf.st_mode & S_IXUSR) { + s->enabled = true; + } + } + } + + *out = script_list; + return 0; + +nomem: + ret = ENOMEM; + talloc_free(script_list); + +done: + if (namelist != NULL && count != -1) { + for (i=0; i<count; i++) { + free(namelist[i]); + } + free(namelist); + } + + return ret; +} + +int event_script_chmod(const char *script_dir, + const char *script_name, + bool enable) +{ + const char *dot_script = ".script"; + size_t ds_len = strlen(dot_script); + size_t sn_len = strlen(script_name); + DIR *dirp; + struct dirent *de; + char buf[PATH_MAX]; + const char *script_file; + int ret, new_mode; + char filename[PATH_MAX]; + struct stat st; + bool found; + ino_t found_inode; + int fd = -1; + + /* Allow script_name to already have ".script" suffix */ + if (sn_len > ds_len && + strcmp(&script_name[sn_len - ds_len], dot_script) == 0) { + script_file = script_name; + } else { + ret = snprintf(buf, sizeof(buf), "%s.script", script_name); + if (ret >= sizeof(buf)) { + return ENAMETOOLONG; + } + script_file = buf; + } + + dirp = opendir(script_dir); + if (dirp == NULL) { + return errno; + } + + found = false; + while ((de = readdir(dirp)) != NULL) { + if (strcmp(de->d_name, script_file) == 0) { + /* check for valid script names */ + ret = script_filter(de); + if (ret == 0) { + closedir(dirp); + return EINVAL; + } + + found = true; + found_inode = de->d_ino; + break; + } + } + closedir(dirp); + + if (! found) { + return ENOENT; + } + + ret = snprintf(filename, + sizeof(filename), + "%s/%s", + script_dir, + script_file); + if (ret >= sizeof(filename)) { + return ENAMETOOLONG; + } + + fd = open(filename, O_RDWR); + if (fd == -1) { + ret = errno; + goto done; + } + + ret = fstat(fd, &st); + if (ret != 0) { + ret = errno; + goto done; + } + + /* + * If the directory entry inode number doesn't match the one + * returned by fstat() then this is probably a symlink, so the + * caller should not be calling this function. Note that this + * is a cheap sanity check to catch most programming errors. + * This doesn't cost any extra system calls but can still miss + * the unlikely case where the symlink is to a file on a + * different filesystem with the same inode number as the + * symlink. + */ + if (found && found_inode != st.st_ino) { + ret = EINVAL; + goto done; + } + + if (enable) { + new_mode = st.st_mode | (S_IXUSR | S_IXGRP | S_IXOTH); + } else { + new_mode = st.st_mode & ~(S_IXUSR | S_IXGRP | S_IXOTH); + } + + ret = fchmod(fd, new_mode); + if (ret != 0) { + ret = errno; + goto done; + } + +done: + if (fd != -1) { + close(fd); + } + return ret; +} diff --git a/ctdb/common/event_script.h b/ctdb/common/event_script.h new file mode 100644 index 0000000..bf5a8fd --- /dev/null +++ b/ctdb/common/event_script.h @@ -0,0 +1,72 @@ +/* + Low level event script handling + + Copyright (C) Amitay Isaacs 2017 + Copyright (C) Martin Schwenke 2018 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __CTDB_SCRIPT_H__ +#define __CTDB_SCRIPT_H__ + +#include "replace.h" +#include "system/filesys.h" + +#include <talloc.h> + +/** + * @file script.h + * + * @brief Script listing and manipulation + */ + + +struct event_script { + char *name; + char *path; + bool enabled; +}; + +struct event_script_list { + unsigned int num_scripts; + struct event_script **script; +}; + + +/** + * @brief Retrieve a list of scripts + * + * @param[in] mem_ctx Talloc memory context + * @param[in] script_dir Directory containing scripts + * @param[out] out List of scripts + * @return 0 on success, errno on failure + */ +int event_script_get_list(TALLOC_CTX *mem_ctx, + const char *script_dir, + struct event_script_list **out); + +/** + * @brief Make a script executable or not executable + * + * @param[in] script_dir Directory containing script + * @param[in] script_name Name of the script to enable + * @param[in] executable True if script should be made executable + * @return 0 on success, errno on failure + */ +int event_script_chmod(const char *script_dir, + const char *script_name, + bool executable); + +#endif /* __CTDB_SCRIPT_H__ */ diff --git a/ctdb/common/line.c b/ctdb/common/line.c new file mode 100644 index 0000000..c4c6726 --- /dev/null +++ b/ctdb/common/line.c @@ -0,0 +1,145 @@ +/* + Line based I/O over fds + + Copyright (C) Amitay Isaacs 2018 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "replace.h" + +#include <talloc.h> + +#include "lib/util/sys_rw.h" + +#include "common/line.h" + +struct line_read_state { + line_process_fn_t callback; + void *private_data; + char *buf; + size_t hint, len, offset; + int num_lines; +}; + +static bool line_read_one(char *buf, size_t start, size_t len, size_t *pos) +{ + size_t i; -- Samba Shared Repository