mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
system.c: fall back to become_root if CAP_DAC_OVERRIDE isn't usable
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15093 Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
This commit is contained in:
parent
4481a67c1b
commit
a1738e8265
@ -643,18 +643,45 @@ static bool set_process_capability(enum smbd_capability capability,
|
||||
Gain the oplock capability from the kernel if possible.
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(HAVE_POSIX_CAPABILITIES) && defined(CAP_DAC_OVERRIDE)
|
||||
static bool have_cap_dac_override = true;
|
||||
#else
|
||||
static bool have_cap_dac_override = false;
|
||||
#endif
|
||||
|
||||
void set_effective_capability(enum smbd_capability capability)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (capability != DAC_OVERRIDE_CAPABILITY || have_cap_dac_override) {
|
||||
#if defined(HAVE_POSIX_CAPABILITIES)
|
||||
set_process_capability(capability, True);
|
||||
ret = set_process_capability(capability, True);
|
||||
#endif /* HAVE_POSIX_CAPABILITIES */
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback to become_root() if CAP_DAC_OVERRIDE is not
|
||||
* available.
|
||||
*/
|
||||
if (capability == DAC_OVERRIDE_CAPABILITY) {
|
||||
if (!ret) {
|
||||
have_cap_dac_override = false;
|
||||
}
|
||||
if (!have_cap_dac_override) {
|
||||
become_root();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drop_effective_capability(enum smbd_capability capability)
|
||||
{
|
||||
if (capability != DAC_OVERRIDE_CAPABILITY || have_cap_dac_override) {
|
||||
#if defined(HAVE_POSIX_CAPABILITIES)
|
||||
set_process_capability(capability, False);
|
||||
set_process_capability(capability, False);
|
||||
#endif /* HAVE_POSIX_CAPABILITIES */
|
||||
} else {
|
||||
unbecome_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user