# Rclone, SeBackupPrivilege, & FILE\_FLAG\_BACKUP\_SEMANTICS

**URL:** <https://forum.rclone.org/t/rclone-sebackupprivilege-file-flag-backup-semantics/45339>\
**Category:** Feature\
**Created:** [March 30, 2024, 6:27pm UTC](https://forum.rclone.org/t/rclone-sebackupprivilege-file-flag-backup-semantics/45339 "2024-03-30T18:27:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamilton-ccn](https://forum.rclone.org/user_avatar/forum.rclone.org/chamilton-ccn/32/17707_2.png) [@chamilton-ccn](https://forum.rclone.org/u/chamilton-ccn)\
**Post date:** [March 30, 2024, 6:27pm UTC](https://forum.rclone.org/t/rclone-sebackupprivilege-file-flag-backup-semantics/45339/1 "2024-03-30T18:27:33Z")

</div>

I've written a Windows service that runs within the security context of a [gMSA](https://learn.microsoft.com/en-us/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview) who is a member of the `BUILTIN\Backup Operators` group. The service enables the `SeBackupPrivilege` and then executes Rclone according to predefined parameters (contained within the service's config), which then backs up whatever data is specified. Since the service does not run as a privileged user (e.g., local admin or otherwise), it can read files it hasn't explicitly been granted access to _only_ if the following conditions have been met:

- The user running the service must be granted the token privilege: `SeBackupPrivilege` -- which can be accomplished by adding the user to the `BUILTIN\Backup Operators` group.
- The token privilege: `SeBackupPrivilege` must also be _enabled_ within the security context that calls `rclone.exe`.
- `rclone.exe` must include the `FILE_FLAG_BACKUP_SEMANTICS` syscall when it opens files for reading. (Simply having and enabling the token privilege is not sufficient).

The aforementioned service handles the first two items in the list, but for the third, the following change must be made to `rclone`:

> <https://github.com/ccn-support-services/rclone/commit/51021b33f980a99891df778a13f7d4aeb749218d>

Confession: I have only the most surface-level knowledge of Go. Learning it has been on my todo list for a while, so this is a perfect opportunity I suppose, but I digress ... I would like to discuss potentially implementing this syscall in Rclone. While the change above works perfectly for _my_ use case, I'm almost certain it's wrong for just about any other scenario.

Rclone also doesn't handle enabling any token privileges, but as a data backup tool, it might be a worthwhile to explore the pros/cons of adding a feature that:

- Checks for / enables the `SeBackupPrivilege` and `SeRestorePrivilege` token privileges.
- Includes the `FILE_FLAG_BACKUP_SEMANTICS` syscall when opening files for reading
- Falls back to it's present functionality if any of the above fail.

As previously stated, these features are extremely valuable to me, and I would be more than happy to work on contributing them to the main Rclone project if others found them valuable as well.

If Rclone had these features, then it would be able to leverage the `BUILTIN\Backup Operators` group to securely execute backups -- i.e., your "backup user" would not have to be a member of the local admins group and/or have other admin rights to the machine where it is responsible for running backups.

What are your thoughts on this?

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [May 29, 2024, 6:28pm UTC](https://forum.rclone.org/t/rclone-sebackupprivilege-file-flag-backup-semantics/45339/2 "2024-05-29T18:28:29Z")

</div>

Closed on May 29, 2024, 6:28pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
