product-config: add open_secret_lockfile
We need this for things like shadow.json.lock. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
26922d1796
commit
c12bbf6241
@ -142,3 +142,22 @@ pub fn open_api_lockfile<P: AsRef<Path>>(
|
||||
let file = proxmox_sys::fs::open_file_locked(&path, timeout, exclusive, options)?;
|
||||
Ok(ApiLockGuard(Some(file)))
|
||||
}
|
||||
///
|
||||
/// Open or create a lock file owned by root and lock it.
|
||||
///
|
||||
/// File mode is `0600`.
|
||||
/// Default timeout is 10 seconds.
|
||||
///
|
||||
/// The lock is released as soon as you drop the returned lock guard.
|
||||
///
|
||||
/// Note: This method needs to be called by user `root`.
|
||||
pub fn open_secret_lockfile<P: AsRef<Path>>(
|
||||
path: P,
|
||||
timeout: Option<std::time::Duration>,
|
||||
exclusive: bool,
|
||||
) -> Result<ApiLockGuard, Error> {
|
||||
let options = secret_create_options();
|
||||
let timeout = timeout.unwrap_or(std::time::Duration::new(10, 0));
|
||||
let file = proxmox_sys::fs::open_file_locked(&path, timeout, exclusive, options)?;
|
||||
Ok(ApiLockGuard(Some(file)))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user