Debian Codegraph @

src/session/session-utils.h

raw
1 /*
2 * Copyright (C) 2013 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 #pragma once
7
8 #include "config.h"
9
10 #include <assert.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <err.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdnoreturn.h>
17 #include <string.h>
18 #include <pwd.h>
19 #include <grp.h>
20 #include <errno.h>
21 #include <unistd.h>
22 #include <signal.h>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <sys/wait.h>
26
27 #include "common/cockpitauthorize.h"
28 #include "common/cockpitmemory.h"
29
30 #define DEBUG_SESSION 0
31
32 #if DEBUG_SESSION
33 #define debug(fmt, ...) (fprintf (stderr, "%s: " fmt "\n", program_name, ##__VA_ARGS__))
34 #else
35 #define debug(...)
36 #endif
37
38 #define EX 127
39
40 extern const char *program_name;
41 extern struct passwd *pwd;
42 extern int want_session;
43 extern pid_t child;
44
45 void build_string (char **buf, size_t *size, const char *str, size_t len);
46 void authorize_logger (const char *data);
47 void utmp_log (int login, const char *rhost, FILE *messages);
48 void btmp_log (const char *username, const char *rhost);
49
50 char* read_authorize_response (const char *what);
51 char* get_authorize_key (const char *json, const char *key, bool required);
52 void write_authorize_begin (void);
53 void write_control_string (const char *field, const char *str);
54 void write_control_bool (const char *field, bool val);
55 void write_control_end (void);
56
57 __attribute__((__noreturn__)) void exit_init_problem (const char *problem, const char *message);
58
59 int
60 spawn_and_wait (const char **argv,
61 const char **envp,
62 const int *remap_fds,
63 int n_remap_fds,
64 uid_t uid,
65 gid_t gid);