tests: Switch to user bob in setup
This makes sure we can apply options correctly. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
1729d4a168
Коммит
cbd75c3e35
@ -25,6 +25,10 @@
|
|||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
static int sshd_setup(void **state)
|
static int sshd_setup(void **state)
|
||||||
{
|
{
|
||||||
torture_setup_sshd_server(state);
|
torture_setup_sshd_server(state);
|
||||||
@ -41,6 +45,14 @@ static int sshd_teardown(void **state) {
|
|||||||
static int session_setup(void **state) {
|
static int session_setup(void **state) {
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
int verbosity = torture_libssh_verbosity();
|
int verbosity = torture_libssh_verbosity();
|
||||||
|
struct passwd *pwd;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
pwd = getpwnam("bob");
|
||||||
|
assert_non_null(pwd);
|
||||||
|
|
||||||
|
rc = setuid(pwd->pw_uid);
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
/* Should work until Apnic decides to assign it :) */
|
/* Should work until Apnic decides to assign it :) */
|
||||||
#define BLACKHOLE "1.1.1.1"
|
#define BLACKHOLE "1.1.1.1"
|
||||||
@ -49,6 +51,14 @@ static int session_setup(void **state)
|
|||||||
{
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
int verbosity = torture_libssh_verbosity();
|
int verbosity = torture_libssh_verbosity();
|
||||||
|
struct passwd *pwd;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
pwd = getpwnam("bob");
|
||||||
|
assert_non_null(pwd);
|
||||||
|
|
||||||
|
rc = setuid(pwd->pw_uid);
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
|
||||||
s->ssh.session = ssh_new();
|
s->ssh.session = ssh_new();
|
||||||
assert_non_null(s->ssh.session);
|
assert_non_null(s->ssh.session);
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
static int sshd_setup(void **state)
|
static int sshd_setup(void **state)
|
||||||
{
|
{
|
||||||
torture_setup_sshd_server(state);
|
torture_setup_sshd_server(state);
|
||||||
@ -40,6 +44,14 @@ static int sshd_teardown(void **state) {
|
|||||||
static int session_setup(void **state)
|
static int session_setup(void **state)
|
||||||
{
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
|
struct passwd *pwd;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
pwd = getpwnam("bob");
|
||||||
|
assert_non_null(pwd);
|
||||||
|
|
||||||
|
rc = setuid(pwd->pw_uid);
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
|
||||||
s->ssh.session = torture_ssh_session(TORTURE_SSH_SERVER,
|
s->ssh.session = torture_ssh_session(TORTURE_SSH_SERVER,
|
||||||
NULL,
|
NULL,
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user