]> git.ipfire.org Git - thirdparty/squid.git/blame - compat/shm.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / compat / shm.cc
CommitLineData
37be9888 1/*
b8ae064d 2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
37be9888
AJ
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
f7f3304a 9#include "squid.h"
ef8de464
AR
10#include "compat/shm.h"
11
8a09e810
AJ
12#if _SQUID_FREEBSD_ && (__FreeBSD__ >= 7)
13#include <sys/sysctl.h>
ef8de464
AR
14#endif
15
ef8de464
AR
16/*
17 * Some systems have filesystem-based resources and interpret segment names
126efcbb 18 * as file paths. The so-called 'portable' "/name" format does not work well
ef8de464
AR
19 * for them. And, according to Boost::interprocess, recent FreeBSD versions
20 * make this decision depending on whether the shm_open() caller is jailed!
21 */
22bool
23shm_portable_segment_name_is_path()
24{
d33f1b1b 25#if _SQUID_HPUX_ || _SQUID_OSF_ || defined(__vms) || (_SQUID_FREEBSD_ && (__FreeBSD__ < 7)) || _SQUID_DRAGONFLY_
126efcbb 26 return true;
8a09e810 27#elif _SQUID_FREEBSD_
126efcbb
A
28 int jailed = 0;
29 size_t len = sizeof(jailed);
f70cf39b 30 ::sysctlbyname("security.jail.jailed", &jailed, &len, nullptr, 0);
126efcbb 31 return !jailed;
ef8de464
AR
32#else
33 return false;
34#endif
35}
f53969cc 36