/***************************************************************************
*
* util_helper.c - HAL utilities for helper (as e.g. prober/addons) et al.
*
* Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
*
* Licensed under the Academic Free License version 2.1
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <grp.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <pwd.h>
#include <unistd.h>
#include "logger.h"
#include "util_helper.h"
#ifdef __linux__
extern char **environ;
#endif
#ifdef sun
#include <priv.h>
void
{
/*
* Start with the 'basic' privilege set and then remove any
* of the 'basic' privileges that will not be needed.
*/
return;
}
/*
* Establish the basic set of privileges.
* interfaces are included in the basic set.
*/
/* Clear privileges we will not need from the 'basic' set */
/* for sysevent need to be root and have this privilege */
/* need proc_audit privilege */
/* Set the permitted privilege set. */
/* Set the limit privilege set. */
}
#else /* !sun */
/** Drop root privileges: Set the running user id to HAL_USER and
* group to HAL_GROUP, and optionally retain auxiliary groups of HAL_USER.
*/
void
{
/* determine user id */
if (!pw) {
exit (-1);
}
/* determine primary group id */
if (!gr) {
exit (-1);
}
if (keep_auxgroups) {
HAL_DEBUG(("drop_privileges: could not initialize groups"));
exit (-1);
}
}
HAL_DEBUG (("drop_privileges: could not set group id"));
exit (-1);
}
HAL_DEBUG (("drop_privileges: could not set user id"));
exit (-1);
}
}
#endif /* !sun */