Bug 12817 - [PATCH] Allow daemon itself to chroot
Summary: [PATCH] Allow daemon itself to chroot
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.2
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-04 21:13 UTC by Ben RUBSON
Modified: 2017-09-04 21:30 UTC (History)
0 users

See Also:


Attachments
rsync_daemon_chroot (3.84 KB, patch)
2017-06-04 21:13 UTC, Ben RUBSON
no flags Details
rsync_daemon_chroot (3.89 KB, patch)
2017-06-05 09:27 UTC, Ben RUBSON
no flags Details
rsync_daemon_chroot (3.89 KB, patch)
2017-06-05 09:46 UTC, Ben RUBSON
no flags Details
rsync_daemon_chroot (4.18 KB, patch)
2017-06-05 13:31 UTC, Ben RUBSON
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben RUBSON 2017-06-04 21:13:37 UTC
Created attachment 13248 [details]
rsync_daemon_chroot

Hello,

Here is a patch which adds 3 new parameters to rsyncd.conf :
daemon chroot
daemon gid
daemon uid

The first one is a path to a directory the daemon itself will chroot to before beginning communication with clients.
The 2 others are the uid/gid the daemon itself will switch to before beginning communication with clients.

These parameters can improve security.
For example, using daemon via a restricted remote-shell connection, for security reasons, if we want whole rsync to be chrooted, we can now use :

daemon chroot = /home/%SUDO_USER%/rsync/
daemon uid = %SUDO_UID%
daemon gid = %SUDO_GID%

With of course rsync being sudo-called by the restricted shell (to configure properly).

We could already do this without this patch, using the "use chroot" parameter, but then the daemon itself is not chrooted and remains run by root.

Thank you !

Ben
Comment 1 Ben RUBSON 2017-06-05 09:27:03 UTC
Created attachment 13249 [details]
rsync_daemon_chroot

Minor issue corrected : do not forget to init log before chrooting.
Comment 2 Ben RUBSON 2017-06-05 09:46:25 UTC
Created attachment 13250 [details]
rsync_daemon_chroot

Minor issue corrected : do not forget to init log before chrooting + typo.
Comment 3 Ben RUBSON 2017-06-05 13:31:00 UTC
Created attachment 13251 [details]
rsync_daemon_chroot

Minor issue corrected : do not forget to not sanitize_paths if daemon is chrooted.
Comment 4 Wayne Davison 2017-09-04 21:23:40 UTC
Thanks for the patch! I've tweaked it a little bit and committed it to git.
Comment 5 Ben RUBSON 2017-09-04 21:30:44 UTC
Many thanks Wayne for having reworked & merged it !