1/* pam_rootok module */ 2 3/* 4 * $Id: pam_rootok.c,v 1.5 2002/03/28 08:43:24 bbraun Exp $ 5 * 6 * Written by Andrew Morgan <morgan@linux.kernel.org> 1996/3/11 7 * 8 * Portions Copyright (C) 2005-2009 Apple Inc. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms of Linux-PAM, with 11 * or without modification, are permitted provided that the following 12 * conditions are met: 13 * 14 * 1. Redistributions of source code must retain any existing copyright 15 * notice, and this entire permission notice in its entirety, 16 * including the disclaimer of warranties. 17 * 18 * 2. Redistributions in binary form must reproduce all prior and current 19 * copyright notices, this list of conditions, and the following 20 * disclaimer in the documentation and/or other materials provided 21 * with the distribution. 22 * 23 * 3. The name of any author may not be used to endorse or promote 24 * products derived from this software without their specific prior 25 * written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 32 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 33 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 35 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 36 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 37 * DAMAGE. 38 */ 39 40#define _GNU_SOURCE 41 42#include <stdio.h> 43#include <unistd.h> 44#include <stdarg.h> 45#include <string.h> 46 47/* 48 * here, we make a definition for the externally accessible function 49 * in this file (this definition is required for static a module 50 * but strongly encouraged generally) it is used to instruct the 51 * modules include file to define the function prototypes. 52 */ 53 54#define PAM_SM_AUTH 55 56#include <security/pam_modules.h> 57 58/* --- authentication management functions (only) --- */ 59 60PAM_EXTERN 61int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc 62 ,const char **argv) 63{ 64 int retval = PAM_AUTH_ERR; 65 66 if (getuid() == 0) 67 retval = PAM_SUCCESS; 68 69 openpam_log(PAM_LOG_DEBUG, "authentication %s", retval==PAM_SUCCESS ? "succeeded":"failed" ); 70 71 return retval; 72} 73 74PAM_EXTERN 75int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc 76 ,const char **argv) 77{ 78 return PAM_SUCCESS; 79} 80 81 82#ifdef PAM_STATIC 83 84/* static module data */ 85 86struct pam_module _pam_rootok_modstruct = { 87 "pam_rootok", 88 pam_sm_authenticate, 89 pam_sm_setcred, 90 NULL, 91 NULL, 92 NULL, 93 NULL, 94}; 95 96#endif 97 98/* end of module definition */ 99