本文整理汇总了C++中personality函数的典型用法代码示例。如果您正苦于以下问题:C++ personality函数的具体用法?C++ personality怎么用?C++ personality使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了personality函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: maybe_disable_address_space_randomization
struct cleanup *
maybe_disable_address_space_randomization (int disable_randomization)
{
int personality_orig = 0;
int personality_set = 0;
#ifdef HAVE_PERSONALITY
if (disable_randomization)
{
errno = 0;
personality_orig = personality (0xffffffff);
if (errno == 0 && !(personality_orig & ADDR_NO_RANDOMIZE))
{
personality_set = 1;
personality (personality_orig | ADDR_NO_RANDOMIZE);
}
if (errno != 0 || (personality_set
&& !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
warning (_("Error disabling address space randomization: %s"),
safe_strerror (errno));
}
#endif /* HAVE_PERSONALITY */
return make_disable_asr_cleanup (personality_set,
personality_orig);
}
开发者ID:Caleb1994,项目名称:stewieos-binutils,代码行数:26,代码来源:linux-personality.c
示例2: set_up_process
/**
* This function configures the process for recording/replay. In particular:
* (1) address space randomization is disabled
* (2) rdtsc is disabled
*/
static void set_up_process()
{
/* disable address space randomization */
int orig_pers;
if (0 > (orig_pers = personality(0xffffffff))) {
fatal("error getting personaity");
}
if (0 > personality(orig_pers | ADDR_NO_RANDOMIZE)) {
fatal("error disabling randomization");
}
if (0 > prctl(PR_SET_TSC, PR_TSC_SIGSEGV, 0, 0, 0)) {
fatal("error setting up prctl -- bailing out");
}
/* If rr goes down, there's nothing more useful we can do.
* Time for seppuku.
*
* XXX the tracee can reset or change this ...*/
if (0 > prctl(PR_SET_PDEATHSIG, SIGKILL)) {
fatal("Couldn't set parent-death signal");
}
/* XXX is it faster to mask off a CPU affinity when this
* process is the only intensive one in the system? */
}
开发者ID:smillaedler,项目名称:rr,代码行数:30,代码来源:sys.c
示例3: __initialize_personality
static void __initialize_personality() {
#if !defined(__LP64__)
int old_value = personality(0xffffffff);
if (old_value == -1) {
__libc_fatal("error getting old personality value: %s", strerror(errno));
}
if (personality((static_cast<unsigned int>(old_value) & ~PER_MASK) | PER_LINUX32) == -1) {
__libc_fatal("error setting PER_LINUX32 personality: %s", strerror(errno));
}
#endif
}
开发者ID:jackLi93,项目名称:platform_bionic,代码行数:12,代码来源:libc_init_common.cpp
示例4: set_personality
static int set_personality(unsigned long mask)
{
unsigned long per;
per = personality(0xffffffff) | mask;
logger(3, 0, "Set personality %#10.8lx", per);
if (personality(per) == -1) {
logger(-1, errno, "Unable to set personality PER_LINUX32");
return -1;
}
return 0;
}
开发者ID:kolyshkin,项目名称:vzctl,代码行数:12,代码来源:env.c
示例5: set_personality
static int set_personality(unsigned long mask)
{
unsigned long per;
per = personality(0xffffffff) | mask;
printf("Set personality %#10.8lx", per);
if (personality(per) == -1) {
perror("Unable to set personality PER_LINUX32");
return -1;
}
return 0;
}
开发者ID:skinsbursky,项目名称:utils,代码行数:12,代码来源:fork_enter.c
示例6: SYSCALL_DEFINE1
SYSCALL_DEFINE1(sparc64_personality, unsigned long, personality)
{
int ret;
if (personality(current->personality) == PER_LINUX32 &&
personality(personality) == PER_LINUX)
personality |= PER_LINUX32;
ret = sys_personality(personality);
if (personality(ret) == PER_LINUX32)
ret &= ~PER_LINUX32;
return ret;
}
开发者ID:03199618,项目名称:linux,代码行数:13,代码来源:sys_sparc_64.c
示例7: main
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
int start_pers;
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
setup(); /* global setup */
start_pers = personality(PER_LINUX);
if (start_pers == -1) {
printf("personality01: Test Failed\n");
exit(-1);
}
/* The following checks the looping state if -i option given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
/* reset Tst_count in case we are looping */
Tst_count = 0;
TEST(personality(PER_BAD));
if (TEST_RETURN != 0) {
tst_brkm(TFAIL, cleanup, "call failed - errno = %d "
"- %s", TEST_ERRNO, strerror(TEST_ERRNO));
} else {
tst_resm(TPASS, "call to personality() with a "
"bad personality passed");
}
TEST_ERROR_LOG(TEST_ERRNO);
/*
* set our personality back to PER_LINUX
*/
if (personality(start_pers) == -1) {
tst_brkm(TBROK, cleanup, "personality reset failed");
}
}
cleanup();
/*NOTREACHED*/
return(0);
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:50,代码来源:personality02.c
示例8: disable_aslr
// ---------------------------------------------------------------------------
void disable_aslr() {
if(personality(ADDR_NO_RANDOMIZE) == -1) {
log("{red}Could not turn off ASLR: %s{/red}", strerror(errno));
} else {
log("ASLR turned off successfully");
}
}
开发者ID:misc0110,项目名称:faint,代码行数:8,代码来源:utils.c
示例9: setASLR
// TODO: move into r_util? r_run_... ? with the rest of funcs?
static void setASLR(int enabled) {
#if __linux__
#define RVAS "/proc/sys/kernel/randomize_va_space"
if (enabled) {
system ("echo 2 > "RVAS);
} else {
#if __ANDROID__
system ("echo 0 > "RVAS);
#else
#ifdef ADDR_NO_RANDOMIZE
if (personality (ADDR_NO_RANDOMIZE) == -1)
#endif
system ("echo 0 > "RVAS);
#endif
}
#elif __APPLE__
// TOO OLD setenv ("DYLD_NO_PIE", "1", 1);
// disable this because its
//eprintf ("Patch mach0.hdr.flags with:\n"
// "f MH_PIE=0x00200000; wB-MH_PIE @ 24\n");
// for osxver>=10.7
// "unset the MH_PIE bit in an already linked executable" with --no-pie flag of the script
// the right way is to disable the aslr bit in the spawn call
#else
// not supported for this platform
#endif
}
开发者ID:hidd3ncod3s,项目名称:radare2,代码行数:28,代码来源:run.c
示例10: lookup_exec_domain
static struct exec_domain *
lookup_exec_domain(u_long personality)
{
struct exec_domain * ep;
u_long pers = personality(personality);
read_lock(&exec_domains_lock);
for (ep = exec_domains; ep; ep = ep->next) {
if (pers >= ep->pers_low && pers <= ep->pers_high)
if (try_module_get(ep->module))
goto out;
}
#ifdef CONFIG_KMOD
read_unlock(&exec_domains_lock);
request_module("personality-%ld", pers);
read_lock(&exec_domains_lock);
for (ep = exec_domains; ep; ep = ep->next) {
if (pers >= ep->pers_low && pers <= ep->pers_high)
if (try_module_get(ep->module))
goto out;
}
#endif
ep = &default_exec_domain;
out:
read_unlock(&exec_domains_lock);
return (ep);
}
开发者ID:OS2World,项目名称:DRV-LXAPI32,代码行数:30,代码来源:lk_exec_domain.c
示例11: setarch_main
int setarch_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int pers = -1;
/* Figure out what personality we are supposed to switch to ...
* we can be invoked as either:
* argv[0],argv[1] -> "setarch","personality"
* argv[0] -> "personality"
*/
retry:
if (argv[0][5] == '6') /* linux64 */
pers = PER_LINUX;
else if (argv[0][5] == '3') /* linux32 */
pers = PER_LINUX32;
else if (pers == -1 && argv[1] != NULL) {
pers = PER_LINUX32;
++argv;
goto retry;
}
/* make user actually gave us something to do */
++argv;
if (argv[0] == NULL)
bb_show_usage();
/* Try to set personality */
if (personality(pers) >= 0) {
/* Try to execute the program */
BB_EXECVP(argv[0], argv);
}
bb_simple_perror_msg_and_die(argv[0]);
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:34,代码来源:setarch.c
示例12: SYSCALL_DEFINE1
SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
{
if (personality(personality) == PER_LINUX32 &&
!system_supports_32bit_el0())
return -EINVAL;
return ksys_personality(personality);
}
开发者ID:FireBurn,项目名称:linux,代码行数:7,代码来源:sys.c
示例13: main
int main(void)
{
int ret;
struct stat fstat;
ret = personality(PER_SVR4);
if (ret == -1) {
fprintf(stderr, "Unable to set personality!\n");
return 3;
}
fprintf(stdout, " [+] Personality set to: PER_SVR4\n");
if (stat(PULSEAUDIO_PATH, &fstat)) {
fprintf(stderr, "Pulseaudio does not exist!\n");
return 3;
}
if (!(fstat.st_mode & S_ISUID) || fstat.st_uid != 0) {
fprintf(stderr, "Pulseaudio is not suid root!\n");
return 3;
}
execl(PULSEAUDIO_PATH, PULSEAUDIO_PATH, "--log-level=0", "-L", PATH_TO_EXPLOIT, NULL);
return 3;
}
开发者ID:0xrnair,项目名称:epic-pen-test,代码行数:28,代码来源:pwnkernel.c
示例14: do_test_misc
int do_test_misc(const char *test_parm)
{
(void) test_parm;
char buf[BSIZE];
int rc;
test_check_eq(getpagesize(),4096);
test_check_eq(personality(0xffffffff), 0);
{
struct utsname phantom_uname;
test_check_eq(uname(&phantom_uname), 0);
printf("uland: uname sys '%s'\n\tnode %s\n\trel %s\n\tver %s\n\tmachine %s\n\tdomain %s\n",
phantom_uname.sysname,
phantom_uname.nodename,
phantom_uname.release,
phantom_uname.version,
phantom_uname.machine,
phantom_uname.domainname
);
}
rc = gethostname(buf, BSIZE);
test_check_ge(rc,0);
printf("uland: hostname %s\n", buf );
return 0;
}
开发者ID:NoSuchProcess,项目名称:phantomuserland,代码行数:32,代码来源:test_misc.c
示例15: main
int main(int ac, char **av)
{
int leaked;
leaked = dump_uts();
if (leaked) {
printf("Leaked %d bytes even without UNAME26!?\n", leaked);
return 1;
}
if (personality(PER_LINUX | UNAME26) < 0) {
perror("personality");
exit(1);
}
leaked = dump_uts();
if (leaked) {
printf("Leaked %d bytes!\n", leaked);
return 1;
} else {
printf("Seems safe.\n");
return 0;
}
}
开发者ID:citypw,项目名称:security-regression-testing-for-suse,代码行数:25,代码来源:uname26-kernel-info-leak.c
示例16: setASLR
// TODO: move into r_util? r_run_... ? with the rest of funcs?
static void setASLR(RRunProfile *r, int enabled) {
#if __linux__
if (enabled) {
setRVA ("2\n");
} else {
#if __ANDROID__
setRVA ("0\n");
#else
#if HAVE_DECL_ADDR_NO_RANDOMIZE
if (personality (ADDR_NO_RANDOMIZE) == -1) {
#endif
setRVA ("0\n");
}
#endif
}
#elif __APPLE__
// TOO OLD setenv ("DYLD_NO_PIE", "1", 1);
// disable this because its
const char *argv0 = r->_system ? r->_system
: r->_program ? r->_program
: r->_args[0] ? r->_args[0]
: "/path/to/exec";
eprintf ("To disable aslr patch mach0.hdr.flags with:\n"
"r2 -qwnc 'wx 000000 @ 0x18' %s\n", argv0);
// f MH_PIE=0x00200000; wB-MH_PIE @ 24\n");
// for osxver>=10.7
// "unset the MH_PIE bit in an already linked executable" with --no-pie flag of the script
// the right way is to disable the aslr bit in the spawn call
#else
// not supported for this platform
#endif
}
开发者ID:f0829,项目名称:radare2,代码行数:33,代码来源:run.c
示例17: doc
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false)
{
TiXmlBase::SetCondenseWhiteSpace(false);
wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality());
if (personality.StartsWith(_T("http://")))
{
SwitchToR(personality);
return;
}
cfg = FindConfigFile(personality + _T(".conf"));
if (cfg.IsEmpty())
{
#ifdef __WINDOWS__
cfg = GetPortableConfigDir() + wxFILE_SEP_PATH + personality + _T(".conf");
#else
cfg = wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + personality + _T(".conf");
#endif
doc = new TiXmlDocument();
doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
return;
}
SwitchTo(cfg);
}
开发者ID:Three-DS,项目名称:codeblocks-13.12,代码行数:28,代码来源:configmanager.cpp
示例18: lookup_exec_domain
static struct exec_domain *
lookup_exec_domain(unsigned int personality)
{
unsigned int pers = personality(personality);
struct exec_domain *ep;
read_lock(&exec_domains_lock);
for (ep = exec_domains; ep; ep = ep->next) {
if (pers >= ep->pers_low && pers <= ep->pers_high)
if (try_module_get(ep->module))
goto out;
}
#ifdef CONFIG_MODULES
read_unlock(&exec_domains_lock);
request_module("personality-%d", pers);
read_lock(&exec_domains_lock);
for (ep = exec_domains; ep; ep = ep->next) {
if (pers >= ep->pers_low && pers <= ep->pers_high)
if (try_module_get(ep->module))
goto out;
}
#endif
ep = &default_exec_domain;
out:
read_unlock(&exec_domains_lock);
return ep;
}
开发者ID:Yui-Qi-Tang,项目名称:openwrtPKG,代码行数:30,代码来源:exec_domain.c
示例19: doc
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false)
{
ConfigManager::MigrateFolders();
TiXmlBase::SetCondenseWhiteSpace(false);
wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality());
if (personality.StartsWith(_T("http://")))
{
SwitchToR(personality);
return;
}
cfg = FindConfigFile(personality + _T(".conf"));
if (cfg.IsEmpty())
{
cfg = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + personality + _T(".conf");
doc = new TiXmlDocument();
doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
return;
}
SwitchTo(cfg);
}
开发者ID:alpha0010,项目名称:codeblocks_sf,代码行数:26,代码来源:configmanager.cpp
示例20: c_show
static int c_show(struct seq_file *m, void *v)
{
int i, j;
bool compat = personality(current->personality) == PER_LINUX32;
for_each_online_cpu(i) {
struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
u32 midr = cpuinfo->reg_midr;
/*
* glibc reads /proc/cpuinfo to determine the number of
* online processors, looking for lines beginning with
* "processor". Give glibc what it expects.
*/
seq_printf(m, "processor\t: %d\n", i);
if (compat)
seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n",
MIDR_REVISION(midr), COMPAT_ELF_PLATFORM);
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
loops_per_jiffy / (500000UL/HZ),
loops_per_jiffy / (5000UL/HZ) % 100);
/*
* Dump out the common processor features in a single line.
* Userspace should read the hwcaps with getauxval(AT_HWCAP)
* rather than attempting to parse this, but there's a body of
* software which does already (at least for 32-bit).
*/
seq_puts(m, "Features\t:");
if (compat) {
#ifdef CONFIG_COMPAT
for (j = 0; compat_hwcap_str[j]; j++)
if (compat_elf_hwcap & (1 << j))
seq_printf(m, " %s", compat_hwcap_str[j]);
for (j = 0; compat_hwcap2_str[j]; j++)
if (compat_elf_hwcap2 & (1 << j))
seq_printf(m, " %s", compat_hwcap2_str[j]);
#endif /* CONFIG_COMPAT */
} else {
for (j = 0; hwcap_str[j]; j++)
if (elf_hwcap & (1 << j))
seq_printf(m, " %s", hwcap_str[j]);
}
seq_puts(m, "\n");
seq_printf(m, "CPU implementer\t: 0x%02x\n",
MIDR_IMPLEMENTOR(midr));
seq_printf(m, "CPU architecture: 8\n");
seq_printf(m, "CPU variant\t: 0x%x\n", MIDR_VARIANT(midr));
seq_printf(m, "CPU part\t: 0x%03x\n", MIDR_PARTNUM(midr));
seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
}
return 0;
}
开发者ID:CreatorDev,项目名称:linux,代码行数:57,代码来源:cpuinfo.c
注:本文中的personality函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论