mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
chmod() errors may not be fatal, e.g. if the permissions are already sufficient but the user pihole-FTL is started by is not the owner
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -14,7 +14,7 @@ DNSMASQOPTS = -DHAVE_DNSSEC -DHAVE_DNSSEC_STATIC
|
||||
# Flags for compiling with libidn2: -DHAVE_LIBIDN2 -DIDN2_VERSION_NUMBER=0x02000003
|
||||
|
||||
FTLDEPS = FTL.h routines.h version.h api.h dnsmasq_interface.h shmem.h
|
||||
FTLOBJ = main.o memory.o log.o daemon.o datastructure.o signals.o socket.o request.o misc.o setupVars.o args.o gc.o config.o database.o msgpack.o api.o dnsmasq_interface.o resolve.o regex.o shmem.o capabilities.o networktable.o overTime.o gravity.o
|
||||
FTLOBJ = main.o memory.o log.o daemon.o datastructure.o signals.o socket.o request.o files.o setupVars.o args.o gc.o config.o database.o msgpack.o api.o dnsmasq_interface.o resolve.o regex.o shmem.o capabilities.o networktable.o overTime.o gravity.o
|
||||
|
||||
DNSMASQDEPS = config.h dhcp-protocol.h dns-protocol.h radv-protocol.h dhcp6-protocol.h dnsmasq.h ip6addr.h metrics.h ../dnsmasq_interface.h
|
||||
DNSMASQOBJ = arp.o dbus.o domain.o lease.o outpacket.o rrfilter.o auth.o dhcp6.o edns0.o log.o poll.o slaac.o blockdata.o dhcp.o forward.o loop.o radv.o tables.o bpf.o dhcp-common.o helper.o netlink.o rfc1035.o tftp.o cache.o dnsmasq.o inotify.o network.o rfc2131.o util.o conntrack.o dnssec.o ipset.o option.o rfc3315.o crypto.o dump.o ubus.o metrics.o
|
||||
|
||||
+7
-5
@@ -126,27 +126,29 @@ void check_blocking_status(void)
|
||||
logg("Blocking status is %s", message);
|
||||
}
|
||||
|
||||
// chmod a given file
|
||||
// chmod_file() changes the file mode bits of a given file (relative
|
||||
// to the directory file descriptor) according to mode. mode is an
|
||||
// octal number representing the bit pattern for the new mode bits
|
||||
bool chmod_file(const char *filename, const mode_t mode)
|
||||
{
|
||||
if(chmod(filename, mode) < 0)
|
||||
{
|
||||
logg("ERROR: chmod(%s, %d): chmod() failed: %s (%d)", filename, mode, strerror(errno), errno);
|
||||
logg("WARNING: chmod(%s, %d): chmod() failed: %s (%d)", filename, mode, strerror(errno), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
if(stat(filename, &st) < 0)
|
||||
{
|
||||
logg("ERROR: chmod(%s, %d): stat() failed: %s (%d)", filename, mode, strerror(errno), errno);
|
||||
logg("WARNING: chmod(%s, %d): stat() failed: %s (%d)", filename, mode, strerror(errno), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to apply a bitmask on st.st_mode as the upper bits may contain random data
|
||||
// 0x1FF = 0b111_111_111
|
||||
// 0x1FF = 0b111_111_111 corresponding to the three-digit octal mode number
|
||||
if((st.st_mode & 0x1FF) != mode)
|
||||
{
|
||||
logg("ERROR: chmod(%s, %d): Verification failed, %d != %d", filename, mode, st.st_mode, mode);
|
||||
logg("WARNING: chmod(%s, %d): Verification failed, %d != %d", filename, mode, st.st_mode, mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user