plugins/python: various portability improvements
This commit is contained in:

committed by
Todd C. Miller

parent
f3b7f3c0d4
commit
b66ecf6e13
7
aclocal.m4
vendored
7
aclocal.m4
vendored
@@ -47,8 +47,11 @@ AC_DEFUN([AM_PATH_PYTHON],
|
|||||||
dnl supported. (2.0 was released on October 16, 2000).
|
dnl supported. (2.0 was released on October 16, 2000).
|
||||||
dnl FIXME: Remove the need to hard-code Python versions here.
|
dnl FIXME: Remove the need to hard-code Python versions here.
|
||||||
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
|
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
|
||||||
[python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
|
[python python2 python3 dnl
|
||||||
python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
|
python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
|
||||||
|
python3.2 python3.1 python3.0 dnl
|
||||||
|
python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
|
||||||
|
python2.0])
|
||||||
|
|
||||||
AC_ARG_VAR([PYTHON], [the Python interpreter])
|
AC_ARG_VAR([PYTHON], [the Python interpreter])
|
||||||
|
|
||||||
|
6
configure
vendored
6
configure
vendored
@@ -19101,7 +19101,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
|
|||||||
$as_echo_n "(cached) " >&6
|
$as_echo_n "(cached) " >&6
|
||||||
else
|
else
|
||||||
|
|
||||||
for am_cv_pathless_PYTHON in python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
|
for am_cv_pathless_PYTHON in python python2 python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
|
||||||
test "$am_cv_pathless_PYTHON" = none && break
|
test "$am_cv_pathless_PYTHON" = none && break
|
||||||
prog="import sys
|
prog="import sys
|
||||||
# split strings by '.' and convert to numeric. Append some zeros
|
# split strings by '.' and convert to numeric. Append some zeros
|
||||||
@@ -19388,7 +19388,7 @@ fi
|
|||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking python include flags" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking python include flags" >&5
|
||||||
$as_echo_n "checking python include flags... " >&6; }
|
$as_echo_n "checking python include flags... " >&6; }
|
||||||
PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
|
PYTHON_INCLUDE=`$PYTHON_CONFIG --cflags`
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_INCLUDE" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_INCLUDE" >&5
|
||||||
$as_echo "$PYTHON_INCLUDE" >&6; }
|
$as_echo "$PYTHON_INCLUDE" >&6; }
|
||||||
|
|
||||||
@@ -19398,7 +19398,7 @@ fi
|
|||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking python linker flags" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking python linker flags" >&5
|
||||||
$as_echo_n "checking python linker flags... " >&6; }
|
$as_echo_n "checking python linker flags... " >&6; }
|
||||||
PYTHON_LIBS=`$PYTHON_CONFIG --libs`
|
PYTHON_LIBS=`$PYTHON_CONFIG --ldflags`
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LIBS" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LIBS" >&5
|
||||||
$as_echo "$PYTHON_LIBS" >&6; }
|
$as_echo "$PYTHON_LIBS" >&6; }
|
||||||
|
|
||||||
|
@@ -2546,13 +2546,13 @@ if test ${USE_PYTHON-'no'} = "yes"; then
|
|||||||
|
|
||||||
AS_IF([test -z "$PYTHON_INCLUDE"], [
|
AS_IF([test -z "$PYTHON_INCLUDE"], [
|
||||||
AC_MSG_CHECKING([python include flags])
|
AC_MSG_CHECKING([python include flags])
|
||||||
PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
|
PYTHON_INCLUDE=`$PYTHON_CONFIG --cflags`
|
||||||
AC_MSG_RESULT([$PYTHON_INCLUDE])
|
AC_MSG_RESULT([$PYTHON_INCLUDE])
|
||||||
])
|
])
|
||||||
|
|
||||||
AS_IF([test -z "$PYTHON_LIBS"], [
|
AS_IF([test -z "$PYTHON_LIBS"], [
|
||||||
AC_MSG_CHECKING([python linker flags])
|
AC_MSG_CHECKING([python linker flags])
|
||||||
PYTHON_LIBS=`$PYTHON_CONFIG --libs`
|
PYTHON_LIBS=`$PYTHON_CONFIG --ldflags`
|
||||||
AC_MSG_RESULT([$PYTHON_LIBS])
|
AC_MSG_RESULT([$PYTHON_LIBS])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@@ -6,6 +6,8 @@ static struct io_plugin *python_io = NULL;
|
|||||||
static struct policy_plugin *python_policy = NULL;
|
static struct policy_plugin *python_policy = NULL;
|
||||||
static struct sudoers_group_plugin *group_plugin = NULL;
|
static struct sudoers_group_plugin *group_plugin = NULL;
|
||||||
|
|
||||||
|
static struct passwd example_pwd;
|
||||||
|
|
||||||
void
|
void
|
||||||
create_io_plugin_options(const char *log_path)
|
create_io_plugin_options(const char *log_path)
|
||||||
{
|
{
|
||||||
@@ -80,12 +82,22 @@ init(void)
|
|||||||
// always start each test from clean state
|
// always start each test from clean state
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
|
|
||||||
|
memset(&example_pwd, 0, sizeof(example_pwd));
|
||||||
|
example_pwd.pw_name = "pw_name";
|
||||||
|
example_pwd.pw_passwd = "pw_passwd";
|
||||||
|
example_pwd.pw_gecos = "pw_gecos";
|
||||||
|
example_pwd.pw_shell ="pw_shell";
|
||||||
|
example_pwd.pw_dir = "pw_dir";
|
||||||
|
example_pwd.pw_uid = (uid_t)1001;
|
||||||
|
example_pwd.pw_gid = (gid_t)101;
|
||||||
|
|
||||||
VERIFY_TRUE(asprintf(&data.tmp_dir, TEMP_PATH_TEMPLATE) >= 0);
|
VERIFY_TRUE(asprintf(&data.tmp_dir, TEMP_PATH_TEMPLATE) >= 0);
|
||||||
VERIFY_NOT_NULL(mkdtemp(data.tmp_dir));
|
VERIFY_NOT_NULL(mkdtemp(data.tmp_dir));
|
||||||
|
|
||||||
// by default we test in developer mode, so the python plugin can be loaded
|
// by default we test in developer mode, so the python plugin can be loaded
|
||||||
sudo_conf_clear_paths();
|
sudo_conf_clear_paths();
|
||||||
VERIFY_INT(sudo_conf_read(sudo_conf_developer_mode, SUDO_CONF_ALL), true);
|
VERIFY_INT(sudo_conf_read(sudo_conf_developer_mode, SUDO_CONF_ALL), true);
|
||||||
|
VERIFY_TRUE(sudo_conf_developer_mode());
|
||||||
|
|
||||||
// some default values for the plugin open:
|
// some default values for the plugin open:
|
||||||
data.settings = create_str_array(1, NULL);
|
data.settings = create_str_array(1, NULL);
|
||||||
|
@@ -3,16 +3,6 @@
|
|||||||
const char *sudo_conf_developer_mode = TESTDATA_DIR "sudo.conf.developer_mode";
|
const char *sudo_conf_developer_mode = TESTDATA_DIR "sudo.conf.developer_mode";
|
||||||
const char *sudo_conf_normal_mode = TESTDATA_DIR "sudo.conf.normal_mode";
|
const char *sudo_conf_normal_mode = TESTDATA_DIR "sudo.conf.normal_mode";
|
||||||
|
|
||||||
struct passwd example_pwd = {
|
|
||||||
"pw_name",
|
|
||||||
"pw_passwd",
|
|
||||||
(uid_t)1001,
|
|
||||||
(gid_t)101,
|
|
||||||
"pw_gecos",
|
|
||||||
"pw_dir",
|
|
||||||
"pw_shell"
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TestData data;
|
struct TestData data;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
extern const char *sudo_conf_developer_mode;
|
extern const char *sudo_conf_developer_mode;
|
||||||
extern const char *sudo_conf_normal_mode;
|
extern const char *sudo_conf_normal_mode;
|
||||||
|
|
||||||
extern struct passwd example_pwd;
|
|
||||||
|
|
||||||
#define TEMP_PATH_TEMPLATE "/tmp/sudo_check_python_exampleXXXXXX"
|
#define TEMP_PATH_TEMPLATE "/tmp/sudo_check_python_exampleXXXXXX"
|
||||||
|
|
||||||
extern struct TestData {
|
extern struct TestData {
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#ifndef SUDO_PYTHON_DEBUG_H
|
#ifndef SUDO_PYTHON_DEBUG_H
|
||||||
#define SUDO_PYTHON_DEBUG_H
|
#define SUDO_PYTHON_DEBUG_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include "sudo_debug.h"
|
#include "sudo_debug.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user