pam_rootok.c revision 90229
179476Smarkm/*-
279476Smarkm * Copyright (c) 2001 Mark R V Murray
379476Smarkm * All rights reserved.
487398Sdes * Copyright (c) 2001 Networks Associates Technologies, Inc.
587398Sdes * All rights reserved.
679476Smarkm *
787398Sdes * Portions of this software were developed for the FreeBSD Project by
887398Sdes * ThinkSec AS and NAI Labs, the Security Research Division of Network
987398Sdes * Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035
1087398Sdes * ("CBOSS"), as part of the DARPA CHATS research program.
1187398Sdes *
1279476Smarkm * Redistribution and use in source and binary forms, with or without
1379476Smarkm * modification, are permitted provided that the following conditions
1479476Smarkm * are met:
1579476Smarkm * 1. Redistributions of source code must retain the above copyright
1679476Smarkm *    notice, this list of conditions and the following disclaimer.
1779476Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1879476Smarkm *    notice, this list of conditions and the following disclaimer in the
1979476Smarkm *    documentation and/or other materials provided with the distribution.
2087398Sdes * 3. The name of the author may not be used to endorse or promote
2187398Sdes *    products derived from this software without specific prior written
2287398Sdes *    permission.
2379476Smarkm *
2479476Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2579476Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2679476Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2779476Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2879476Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2979476Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3079476Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3179476Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3279476Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3379476Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3479476Smarkm * SUCH DAMAGE.
3579476Smarkm */
3679476Smarkm
3784218Sdillon#include <sys/cdefs.h>
3884218Sdillon__FBSDID("$FreeBSD: head/lib/libpam/modules/pam_rootok/pam_rootok.c 90229 2002-02-05 06:08:26Z des $");
3984218Sdillon
4079476Smarkm#define _BSD_SOURCE
4179476Smarkm
4279476Smarkm#include <unistd.h>
4379476Smarkm#include <syslog.h>
4479476Smarkm
4579476Smarkm#define PAM_SM_AUTH
4687398Sdes#define PAM_SM_ACCOUNT
4787398Sdes#define PAM_SM_SESSION
4887398Sdes#define PAM_SM_PASSWORD
4979476Smarkm
5090229Sdes#include <security/pam_appl.h>
5179476Smarkm#include <security/pam_modules.h>
5290229Sdes#include <security/pam_mod_misc.h>
5379476Smarkm
5479476SmarkmPAM_EXTERN int
5589760Smarkmpam_sm_authenticate(pam_handle_t *pamh, int flags __unused, int argc, const char **argv)
5679476Smarkm{
5779476Smarkm	struct options options;
5879476Smarkm
5979476Smarkm	pam_std_option(&options, NULL, argc, argv);
6079476Smarkm
6179476Smarkm	PAM_LOG("Options processed");
6279476Smarkm
6381474Smarkm	if (getuid() == 0)
6479476Smarkm		PAM_RETURN(PAM_SUCCESS);
6579476Smarkm
6681474Smarkm	PAM_VERBOSE_ERROR("Refused; not superuser");
6781474Smarkm	PAM_LOG("User is not superuser");
6879476Smarkm
6979476Smarkm	PAM_RETURN(PAM_AUTH_ERR);
7079476Smarkm}
7179476Smarkm
7279476SmarkmPAM_EXTERN int
7389760Smarkmpam_sm_setcred(pam_handle_t *pamh __unused, int flags __unused, int argc, const char **argv)
7479476Smarkm{
7581474Smarkm	struct options options;
7681474Smarkm
7781474Smarkm	pam_std_option(&options, NULL, argc, argv);
7881474Smarkm
7981474Smarkm	PAM_LOG("Options processed");
8081474Smarkm
8181474Smarkm	PAM_RETURN(PAM_SUCCESS);
8279476Smarkm}
8379476Smarkm
8487398SdesPAM_EXTERN int
8589760Smarkmpam_sm_acct_mgmt(pam_handle_t *pamh __unused, int flags __unused, int argc ,const char **argv)
8687398Sdes{
8787398Sdes	struct options options;
8887398Sdes
8987398Sdes	pam_std_option(&options, NULL, argc, argv);
9087398Sdes
9187398Sdes	PAM_LOG("Options processed");
9287398Sdes
9387398Sdes	PAM_RETURN(PAM_IGNORE);
9487398Sdes}
9587398Sdes
9687398SdesPAM_EXTERN int
9789760Smarkmpam_sm_chauthtok(pam_handle_t *pamh __unused, int flags __unused, int argc, const char **argv)
9887398Sdes{
9987398Sdes	struct options options;
10087398Sdes
10187398Sdes	pam_std_option(&options, NULL, argc, argv);
10287398Sdes
10387398Sdes	PAM_LOG("Options processed");
10487398Sdes
10587398Sdes	PAM_RETURN(PAM_IGNORE);
10687398Sdes}
10787398Sdes
10887398SdesPAM_EXTERN int
10989760Smarkmpam_sm_open_session(pam_handle_t *pamh __unused, int flags __unused, int argc, const char **argv)
11087398Sdes{
11187398Sdes	struct options options;
11287398Sdes
11387398Sdes	pam_std_option(&options, NULL, argc, argv);
11487398Sdes
11587398Sdes	PAM_LOG("Options processed");
11687398Sdes
11787398Sdes	PAM_RETURN(PAM_IGNORE);
11887398Sdes}
11987398Sdes
12087398SdesPAM_EXTERN int
12189760Smarkmpam_sm_close_session(pam_handle_t *pamh __unused, int flags __unused, int argc, const char **argv)
12287398Sdes{
12387398Sdes	struct options options;
12487398Sdes
12587398Sdes	pam_std_option(&options, NULL, argc, argv);
12687398Sdes
12787398Sdes	PAM_LOG("Options processed");
12887398Sdes
12987398Sdes	PAM_RETURN(PAM_IGNORE);
13087398Sdes}
13187398Sdes
13279476SmarkmPAM_MODULE_ENTRY("pam_rootok");
133