Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENT-11988: Atomic copy_from in files promise (3.21.x) #5614

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install dependencies (C)
if: ${{ matrix.language == 'cpp' }}
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl libpcre3-dev

- name: Build (C)
if: ${{ matrix.language == 'cpp' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/job-static-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Prepare Environment
run: |
sudo apt-get update && \
sudo apt-get install -y dpkg-dev debhelper g++ libncurses5 pkg-config \
sudo apt-get install -y dpkg-dev debhelper g++ libncurses6 pkg-config \
build-essential libpam0g-dev fakeroot gcc make autoconf buildah \
liblmdb-dev libacl1-dev libcurl4-openssl-dev libyaml-dev libxml2-dev \
libssl-dev libpcre3-dev
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v3

- name: install cf-remote
run: pip install cf-remote
run: pip install cf-remote --break-system-packages

# Note that msiexec can't install packages when running under msys;
# But cf-remote currently can't run under powershell
Expand Down
4 changes: 2 additions & 2 deletions cf-agent/verify_files_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
}

if (!CopyRegularFileNet(source, ToChangesPath(new),
sstat->st_size, attr->copy.encrypt, conn))
sstat->st_size, attr->copy.encrypt, conn, sstat->st_mode))
{
RecordFailure(ctx, pp, attr, "Failed to copy file '%s' from '%s'",
source, conn->remoteip);
Expand Down Expand Up @@ -1712,7 +1712,7 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
}
}

if (rename(dest, changes_backup) == 0)
if (CopyRegularFileDisk(dest, changes_backup))
{
RecordChange(ctx, pp, attr, "Backed up '%s' as '%s'", dest, backup);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
Expand Down
4 changes: 2 additions & 2 deletions libcfnet/client_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ static void FlushFileStream(int sd, int toget)
/* TODO finalise socket or TLS session in all cases that this function fails
* and the transaction protocol is out of sync. */
bool CopyRegularFileNet(const char *source, const char *dest, off_t size,
bool encrypt, AgentConnection *conn)
bool encrypt, AgentConnection *conn, mode_t mode)
{
char *buf, workbuf[CF_BUFSIZE], cfchangedstr[265];
const int buf_size = 2048;
Expand All @@ -775,7 +775,7 @@ bool CopyRegularFileNet(const char *source, const char *dest, off_t size,

unlink(dest); /* To avoid link attacks */

int dd = safe_open_create_perms(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | O_BINARY, CF_PERMS_DEFAULT);
int dd = safe_open_create_perms(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | O_BINARY, mode);
if (dd == -1)
{
Log(LOG_LEVEL_ERR,
Expand Down
2 changes: 1 addition & 1 deletion libcfnet/client_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void DisconnectServer(AgentConnection *conn);

bool CompareHashNet(const char *file1, const char *file2, bool encrypt, AgentConnection *conn);
bool CopyRegularFileNet(const char *source, const char *dest, off_t size,
bool encrypt, AgentConnection *conn);
bool encrypt, AgentConnection *conn, mode_t mode);
Item *RemoteDirList(const char *dirname, bool encrypt, AgentConnection *conn);

int TLSConnectCallCollect(ConnectionInfo *conn_info, const char *username);
Expand Down
2 changes: 2 additions & 0 deletions tests/static-check/run_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function check_with_clang() {

function check_with_cppcheck() {
rm -f config.cache
make clean
make -C libpromises/ bootstrap.inc # needed by libpromises/bootstrap.c
./configure -C --enable-debug

# cppcheck options:
Expand Down
Loading