4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/param.h>
30 #include <security/pam_appl.h>
31 #include <security/pam_modules.h>
35 #include <rpc/types.h>
41 extern int ruserok(const char *, int, const char *, const char *);
44 * pam_sm_authenticate - Checks if the user is allowed remote access
54 char *host
= NULL
, *lusername
= NULL
;
57 char pwd_buffer
[1024];
63 for (i
= 0; i
< argc
; i
++) {
64 if (strcasecmp(argv
[i
], "debug") == 0)
67 syslog(LOG_DEBUG
, "illegal option %s", argv
[i
]);
70 if (pam_get_item(pamh
, PAM_USER
, (void **) &lusername
) != PAM_SUCCESS
)
71 return (PAM_SERVICE_ERR
);
72 if (pam_get_item(pamh
, PAM_RHOST
, (void **) &host
) != PAM_SUCCESS
)
73 return (PAM_SERVICE_ERR
);
74 if (pam_get_item(pamh
, PAM_RUSER
, (void **)&rusername
) != PAM_SUCCESS
)
75 return (PAM_SERVICE_ERR
);
77 if (lusername
== NULL
|| *lusername
== '\0')
78 return (PAM_USER_UNKNOWN
);
79 if (rusername
== NULL
|| *rusername
== '\0')
80 return (PAM_AUTH_ERR
);
81 if (host
== NULL
|| *host
== '\0')
82 return (PAM_AUTH_ERR
);
86 "rhosts authenticate: user = %s, host = %s",
90 getpwnam_r(lusername
, &pwd
, pwd_buffer
, sizeof (pwd_buffer
), &pwdp
);
92 return (PAM_USER_UNKNOWN
);
99 return (ruserok(host
, is_superuser
, rusername
, lusername
)
100 == -1 ? PAM_AUTH_ERR
: PAM_SUCCESS
);
105 * dummy pam_sm_setcred - does nothing