privs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Least privilege support functions.
*/
#include "config.h"
#ifdef SOLARIS_PRIVS
#include <priv.h>
#ifdef HAVE_SYS_SYSLOG_H
#endif
#include <syslog.h>
#endif
#endif /* SOLARIS_PRIVS */
#include "proto.h"
#ifdef SOLARIS_PRIVS
/*
* Before becoming privilege aware in init_privs(), no explicit privilege
* manipulation using priv_on()/priv_off() is necessary as seteuid(0) sets
* the effective privilege set to the limit set. Thus these are all
* initialized to TRUE.
*/
#endif /* SOLARIS_PRIVS */
#ifdef SOLARIS_PRIVS
#ifdef PRIVS_DEBUG
{
char *privstr;
return;
}
#endif /* PRIVS_DEBUG */
{
/* no need to add the privilege if already have it */
if (already_have)
return;
}
{
/* don't remove the privilege if already had it */
if (already_had)
return;
}
#endif /* SOLARIS_PRIVS */
/*
* init_privs() is called after a user has logged in to drop from the
* permitted privilege set those privileges which are no longer required.
*/
/*ARGSUSED*/
void init_privs(const char *username)
{
#ifdef SOLARIS_PRIVS
/*
* The FTP server runs with "basic" inheritable privileges, which are
* reset in pam_setcred() for non anonymous users. The seteuid() call in
* pass() sets the effective privileges to the inheritable privileges.
*/
dologout(1);
}
dologout(1);
}
/*
* Set the permitted privilege set to the effective privileges plus
* those required after init_privs() is called. Keep note of which
* effective privileges we already had so we don't turn them off.
*/
}
}
}
}
}
#if defined(SOLARIS_BSM_AUDIT) && !defined(SOLARIS_NO_AUDIT_FTPD_LOGOUT)
/* needed for audit_ftpd_logout() */
#endif
"unable to set privileges for %s: setppriv(permitted): %m",
username);
dologout(1);
}
/*
* setppriv() has made us privilege aware, so the effective privileges
* are no longer modified by user ID changes.
*/
/* set the real, effective and saved group ID's */
setid_priv_on(0);
dologout(1);
}
/*
* Set the real and effective user ID's, leaving the saved user ID set
* to 0 so seteuid(0) succeeds.
*/
(void) seteuid(0);
dologout(1);
}
dologout(1);
}
#ifdef PRIVS_DEBUG
#endif /* PRIVS_DEBUG */
#endif /* SOLARIS_PRIVS */
}
/* allow a process to bind to a privileged port */
/*ARGSUSED*/
{
#ifdef SOLARIS_PRIVS
#else
#endif
}
/*ARGSUSED*/
{
#ifdef SOLARIS_PRIVS
#else
#endif
}
/* allow a process to read any file or directory and to search any directory */
{
#ifdef SOLARIS_PRIVS
#endif
/* necessary on Solaris for access over NFS */
}
{
#ifdef SOLARIS_PRIVS
#endif
}
/* allow a process to set its user IDs and group IDs */
/*ARGSUSED*/
{
#ifdef SOLARIS_PRIVS
#else
#endif
}
/*ARGSUSED*/
{
#ifdef SOLARIS_PRIVS
#else
#endif
}
/* allow a process to change the ownership of files and directories */
{
#ifdef SOLARIS_PRIVS
#endif
/* necessary on Solaris for chown over NFS */
}
{
#ifdef SOLARIS_PRIVS
#endif
}