/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983-1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include <signal.h>
#include <netdb.h>
#include <syslog.h>
#include <nss_dbdefs.h>
#include <security/pam_appl.h>
#include <deflt.h>
#ifdef SYSV
#include <shadow.h>
#endif /* SYSV */
#ifndef NCARGS
#endif /* NCARGS */
#ifdef SYSV
#else
char *sprintf();
#endif /* SYSV */
#define MAXFD(A, B) ((A) > (B) ? (A) : (B))
static int legalenvvar(char *s);
/* Function decls. for functions not in any header file. (Grrrr.) */
extern int audit_rexecd_setup(void);
extern int audit_rexecd_success(char *, char *, char *);
extern int audit_rexecd_fail(char *, char *, char *, char *);
extern int audit_settid(int); /* set termnal ID */
/* PAM conversation function */
static int rexec_conv(int, struct pam_message **,
struct pam_response **, void *);
};
/*
* remote execute server:
* username\0
* password\0
* command\0
* data
*
* in.rexecd has been modified to run as the user invoking it. Hence there is no
* need to limit any privileges.
*/
/*ARGSUSED*/
int
{
(void) audit_rexecd_setup(); /* BSM */
perror("getpeername");
exit(1);
}
if (audit_settid(0) != 0) {
perror("settid");
exit(1);
}
return (0);
}
static char *envinit[] =
#ifdef SYSV
(char *)0, (char *)0, (char *)0, (char *)0,
(char *)0, (char *)0, (char *)0, (char *)0,
(char *)0, (char *)0, (char *)0, (char *)0,
(char *)0, (char *)0, (char *)0, (char *)0,
(char *)0};
/*
* See PSARC opinion 1992/025
*/
#else
#endif /* SYSV */
static void
{
int s;
char **pam_env;
int pam_flags = 0;
#ifdef DEBUG
{
if (t >= 0) {
#ifdef SYSV
(void) setsid();
#else
#endif /* SYSV */
(void) close(t);
}
}
#endif
fromplen = sizeof (struct sockaddr_in);
fromplen = sizeof (struct sockaddr_in6);
} else {
exit(1);
}
/*
* store common info. for audit record
*/
&ipv4_addr);
sizeof (abuf));
} else {
}
}
}
(void) dup2(f, 0);
(void) dup2(f, 1);
(void) dup2(f, 2);
(void) alarm(60);
port = 0;
for (;;) {
char c;
exit(1);
if (c == 0)
break;
}
(void) alarm(0);
if (port != 0) {
if (s < 0)
exit(1);
exit(1);
(void) alarm(60);
}
exit(1);
(void) alarm(0);
}
cmdbuf); /* BSM */
error("Login incorrect.\n");
exit(1);
}
if (defopen(_PATH_DEFAULT_LOGIN) == 0) {
int flags;
char *p;
strcasecmp(p, "YES") == 0) {
}
}
exit(1);
}
exit(1);
}
switch (status) {
case PAM_USER_UNKNOWN:
error("Login incorrect.\n");
break;
default:
error("Password incorrect.\n");
}
exit(1);
}
(void) audit_rexecd_fail("Account or Password Expired",
switch (status) {
case PAM_NEW_AUTHTOK_REQD:
error("Password Expired.\n");
break;
case PAM_PERM_DENIED:
error("Account Expired.\n");
break;
case PAM_AUTHTOK_EXPIRED:
error("Password Expired.\n");
break;
default:
error("Login incorrect.\n");
break;
}
exit(1);
}
error("setgid");
exit(1);
}
(void) audit_rexecd_fail("Unable to establish credentials",
error("Unable to establish credentials.\n");
}
error("setuid");
exit(1);
}
if (port) {
error("Try again.\n");
exit(1);
}
if (pid) {
/*
* since the daemon is running as the user no need
* to prune privileges.
*/
/* should set s nbio! */
do {
perror("select:");
exit(1);
}
else
}
if (cc <= 0) {
} else
}
exit(0);
}
/* setpgrp(0, getpid()); */
(void) setsid(); /* Should be the same as above. */
}
if (f > 2)
(void) close(f);
/* Change directory only after becoming the appropriate user. */
error("No remote directory.\n");
exit(1);
}
#ifdef SYSV
else
#endif /* SYSV */
/*
* add PAM environment variables set by modules
* -- only allowed 16 (PAM_ENV_ELIM)
* -- check to see if the environment variable is legal
*/
;
if (idx < PAM_ENV_ELIM &&
}
idx++;
}
}
if (cp)
cp++;
else
exit(1);
}
static void
{
char c;
do {
exit(1);
*buf++ = c;
if (--cnt == 0) {
exit(1);
}
} while (c != 0);
}
static void
{
buf[0] = 1;
}
static char *illegal[] = {
"SHELL=",
"HOME=",
"LOGNAME=",
#ifndef NO_MAIL
"MAIL=",
#endif
"CDPATH=",
"IFS=",
"PATH=",
"USER=",
0
};
/*
* legalenvvar - can PAM insert this environmental variable?
*/
static int
legalenvvar(char *s)
{
register char **p;
for (p = illegal; *p; p++)
return (0);
if (s[0] == 'L' && s[1] == 'D' && s[2] == '_')
return (0);
return (1);
}
/*
* rexec_conv - This is the conv (conversation) function called from
* a PAM authentication module to print error messages
* or garner information from the user.
*/
/* ARGSUSED3 */
static int
{
struct pam_message *m;
struct pam_response *r;
int i;
if (num_msg <= 0)
return (PAM_CONV_ERR);
return (PAM_BUF_ERR);
m = *msg;
r = *response;
if (m->msg_style == PAM_PROMPT_ECHO_OFF) {
if (pass[0] != '\0') {
/* free responses */
r = *response;
for (i = 0; i < num_msg; i++, r++) {
if (r->resp)
}
return (PAM_BUF_ERR);
}
}
}
return (PAM_SUCCESS);
}