1167857Simp/*- 2167857Simp * Copyright (c) 2011 Xin Li <delphij@FreeBSD.org> 3167857Simp * All rights reserved. 4167857Simp * 5167857Simp * Redistribution and use in source and binary forms, with or without 6167857Simp * modification, are permitted provided that the following conditions 7167857Simp * are met: 8167857Simp * 1. Redistributions of source code must retain the above copyright 9167857Simp * notice, this list of conditions and the following disclaimer. 10167857Simp * 2. Redistributions in binary form must reproduce the above copyright 11167857Simp * notice, this list of conditions and the following disclaimer in the 12167857Simp * documentation and/or other materials provided with the distribution. 13167857Simp * 14167857Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15167857Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16167857Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17167857Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18167857Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19167857Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20167857Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21167857Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22167857Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23167857Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24167857Simp * SUCH DAMAGE. 25167857Simp * 26167857Simp * $FreeBSD: releng/10.3/lib/libc/gen/libc_dlopen.c 228843 2011-12-23 15:00:37Z cperciva $ 27167857Simp */ 28167857Simp 29167857Simp#include <sys/cdefs.h> 30167857Simp__FBSDID("$FreeBSD: releng/10.3/lib/libc/gen/libc_dlopen.c 228843 2011-12-23 15:00:37Z cperciva $"); 31167857Simp 32167857Simp#include <dlfcn.h> 33167857Simp#include <stddef.h> 34167857Simp#include <unistd.h> 35167857Simp 36167857Simp#include "libc_private.h" 37181305Sjhb 38167857Simp/* 39167857Simp * Whether we want to restrict dlopen()s. 40167857Simp */ 41167857Simpstatic int __libc_restricted_mode = 0; 42167857Simp 43167857Simpvoid * 44167857Simplibc_dlopen(const char *path, int mode) 45167857Simp{ 46167857Simp 47167857Simp if (__libc_restricted_mode) { 48167857Simp _rtld_error("Service unavailable -- libc in restricted mode"); 49167857Simp return (NULL); 50167857Simp } else 51181305Sjhb return (dlopen(path, mode)); 52167857Simp} 53167857Simp 54167857Simpvoid 55167857Simp__FreeBSD_libc_enter_restricted_mode(void) 56167857Simp{ 57167857Simp 58167857Simp __libc_restricted_mode = 1; 59167857Simp return; 60181305Sjhb} 61181305Sjhb 62181305Sjhb