File: sudo-t.c

package info (click to toggle)
remctl 3.18-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,612 kB
  • sloc: ansic: 19,504; sh: 5,386; perl: 1,778; java: 740; makefile: 715; xml: 502; python: 430
file content (51 lines) | stat: -rw-r--r-- 1,286 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Test suite for running commands with sudo.
 *
 * Written by Russ Allbery <eagle@eyrie.org>
 * Copyright 2016 Dropbox, Inc.
 *
 * SPDX-License-Identifier: MIT
 */

#include <config.h>
#include <portable/event.h>
#include <portable/system.h>

#include <server/internal.h>
#include <tests/tap/basic.h>
#include <util/messages.h>


int
main(void)
{
    struct config *config;
    struct iovec **command;
    struct client *client;

    /* Suppress normal logging. */
    message_handlers_notice(0);

    /* Load the test configuration. */
    if (chdir(getenv("C_TAP_BUILD")) < 0)
        sysbail("can't chdir to C_TAP_BUILD");
    config = server_config_load("data/conf-simple");
    if (config == NULL)
        bail("server_config_load returned NULL");

    /* Create the command we're going to run. */
    command = server_ssh_parse_command("sudo foo bar stdin baz");
    putenv((char *) "REMCTL_USER=test@EXAMPLE.ORG");
    putenv((char *) "SSH_CONNECTION=127.0.0.1 34537 127.0.0.1 4373");
    client = server_ssh_new_client(NULL);

    /* Run the command. */
    server_run_command(client, config, command);

    /* Clean up. */
    server_free_command(command);
    server_ssh_free_client(client);
    server_config_free(config);
    libevent_global_shutdown();
    return 0;
}