Add g_setallusercontext() for *BSD systems
This commit is contained in:
parent
cd58d14cef
commit
48e46d183a
@ -61,6 +61,9 @@
|
||||
#include <time.h>
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_SETUSERCONTEXT
|
||||
#include <login_cap.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -2878,6 +2881,31 @@ g_setlogin(const char *name)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#ifdef HAVE_SETUSERCONTEXT
|
||||
int
|
||||
g_set_allusercontext(int uid)
|
||||
{
|
||||
int rv;
|
||||
struct passwd *pwd = getpwuid(uid);
|
||||
if (pwd == NULL)
|
||||
{
|
||||
LOG(LOG_LEVEL_ERROR, "No password entry for UID %d", uid);
|
||||
rv = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = setusercontext(NULL, pwd, uid, LOGIN_SETALL);
|
||||
if (rv != 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_ERROR, "setusercontext(%d) failed [%s]",
|
||||
uid, g_get_strerror());
|
||||
}
|
||||
}
|
||||
|
||||
return (rv != 0); /* Return 0 or 1 */
|
||||
}
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
/* does not work in win32
|
||||
returns pid of process that exits or zero if signal occurred */
|
||||
|
@ -93,6 +93,7 @@ int g_sck_socket_ok(int sck);
|
||||
int g_sck_can_send(int sck, int millis);
|
||||
int g_sck_can_recv(int sck, int millis);
|
||||
int g_sck_select(int sck1, int sck2);
|
||||
|
||||
/**
|
||||
* Gets the IP address of a connected peer, if it has one
|
||||
* @param sck File descriptor for peer
|
||||
@ -183,6 +184,13 @@ int g_setuid(int pid);
|
||||
int g_setsid(void);
|
||||
int g_getlogin(char *name, unsigned int len);
|
||||
int g_setlogin(const char *name);
|
||||
#ifdef HAVE_SETUSERCONTEXT
|
||||
/** Sets the login user context (BSD systems only)
|
||||
* @param uid UID of suer
|
||||
* @return 0 for success
|
||||
*/
|
||||
int g_set_allusercontext(int uid);
|
||||
#endif
|
||||
int g_waitchild(void);
|
||||
int g_waitpid(int pid);
|
||||
struct exit_status g_waitpid_status(int pid);
|
||||
|
@ -213,6 +213,12 @@ AM_COND_IF([DEVEL_DEBUG],
|
||||
[AX_APPEND_COMPILE_FLAGS([-g -O0])],
|
||||
[AX_APPEND_COMPILE_FLAGS([-O2])])
|
||||
|
||||
# Function setusercontext() is in BSD -lutil but N/A on Solaris or GNU systems
|
||||
AC_SEARCH_LIBS([setusercontext], [util])
|
||||
|
||||
# Define HAVE_XXXXX macros for some system functions
|
||||
AC_CHECK_FUNCS([setusercontext])
|
||||
|
||||
# Don't fail without working nasm if rfxcodec is not enabled
|
||||
if test "x$enable_rfxcodec" != xyes; then
|
||||
with_simd=no
|
||||
|
Loading…
Reference in New Issue
Block a user