Skip to content

ENT-14982: Changed cf-net getdir to not copy remote permissions by default - #6514

Open
victormlg wants to merge 3 commits into
cfengine:masterfrom
victormlg:cf-net-harder-sec
Open

victormlg wants to merge 3 commits into
cfengine:masterfrom
victormlg:cf-net-harder-sec

Conversation

@victormlg

Copy link
Copy Markdown
Contributor

No description provided.

MakeParentDirectoryPerms() rejects relative paths, so creating
subdirectories failed. Bug already present on master.

Signed-off-by: Victor Moene <victor.moene@northern.tech>
It was only created as a side effect of downloading a subdirectory, so
files in the remote directory failed. Bug already present on master.

Signed-off-by: Victor Moene <victor.moene@northern.tech>
Files are created 0600 and directories 0700 unless -p/--preserve-perms is given,
so a server can no longer set setuid/setgid bits locally.

Changelog: Title
Ticket: ENT-14982
Signed-off-by: Victor Moene <victor.moene@northern.tech>

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 please improve / add change log entries

Comment thread cf-net/cf-net.c
Comment on lines +1246 to +1247
/* MakeParentDirectoryPerms() only accepts absolute paths, so a relative
* output path is resolved against the current working directory */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  /* MakeParentDirectoryPerms() rejects relative paths.
   * Make a relative -o path absolute by prefixing the cwd. */

I was a bit confused by that comment, maybe this reads better?


This commit deserves a change log entry.


Bug already present on master.

It goes without saying.

Comment thread cf-net/cf-net.c

tmp = local_dir;
local_dir = StringFormat("%s/%s/", (specified_path ? local_dir : cwd), base);
if (!specified_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you treat "no -o as -o ., then maybe this logic could be simpler. IDK

Comment thread cf-net/cf-net.c Outdated
/* Subdirectories are created as they are found, but files directly in
* remote_dir need the top-level local directory to exist already */
bool force = false;
if (!MakeParentDirectoryPerms(local_dir, force, NULL, sb.st_mode))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also deserves a change log entry

Comment thread cf-net/cf-net.c
@@ -102,7 +102,7 @@ static const Description COMMANDS[] =
{"opendir", "List files and folders in a directory",
"cf-net opendir masterfiles"},
{"getdir", "Recursively downloads files and folders in a directory",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

Changelog: Files and directories copied by `cf-net getdir` are now created with permissions `0600` / `0700` receptively. Use the `-p` / `--preserve-perms` option to preserve the remote permissions.

@larsewi larsewi added the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick? Fixes which may need to be cherry-picked to LTS branches

Development

Successfully merging this pull request may close these issues.

2 participants