1/*- 2 * Copyright (c) 2002-2003 Networks Associates Technology, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by ThinkSec AS and 6 * Network Associates Laboratories, the Security Research Division of 7 * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 8 * ("CBOSS"), as part of the DARPA CHATS research program. --- 17 unchanged lines hidden (view full) --- 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * |
34 * $P4: //depot/projects/openpam/lib/openpam_borrow_cred.c#11 $ |
35 */ 36 37#include <sys/param.h> 38 39#include <grp.h> 40#include <limits.h> 41#include <pwd.h> 42#include <stdlib.h> --- 9 unchanged lines hidden (view full) --- 52 * Temporarily borrow user credentials 53 */ 54 55int 56openpam_borrow_cred(pam_handle_t *pamh, 57 const struct passwd *pwd) 58{ 59 struct pam_saved_cred *scred; |
60 void *scredp; |
61 int r; 62 63 ENTERI(pwd->pw_uid); |
64 r = pam_get_data(pamh, PAM_SAVED_CRED, &scredp); 65 if (r == PAM_SUCCESS && scredp != NULL) { |
66 openpam_log(PAM_LOG_DEBUG, 67 "already operating under borrowed credentials"); 68 RETURNC(PAM_SYSTEM_ERR); 69 } 70 if (geteuid() != 0 && geteuid() != pwd->pw_uid) { 71 openpam_log(PAM_LOG_DEBUG, "called with non-zero euid: %d", 72 (int)geteuid()); 73 RETURNC(PAM_PERM_DENIED); --- 47 unchanged lines hidden --- |