]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/shm.cc
d597bb0afde95edc0c01c76f2edf2f7cb46cc853
[thirdparty/squid.git] / compat / shm.cc
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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
9 #include "squid.h"
10 #include "compat/shm.h"
11
12 #if _SQUID_FREEBSD_ && (__FreeBSD__ >= 7)
13 #include <sys/sysctl.h>
14 #endif
15
16 /*
17 * Some systems have filesystem-based resources and interpret segment names
18 * as file paths. The so-called 'portable' "/name" format does not work well
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 */
22 bool
23 shm_portable_segment_name_is_path()
24 {
25 #if _SQUID_HPUX_ || _SQUID_OSF_ || defined(__vms) || (_SQUID_FREEBSD_ && (__FreeBSD__ < 7)) || _SQUID_DRAGONFLY_
26 return true;
27 #elif _SQUID_FREEBSD_
28 int jailed = 0;
29 size_t len = sizeof(jailed);
30 ::sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0);
31 return !jailed;
32 #else
33 return false;
34 #endif
35 }
36