summaryrefslogtreecommitdiffstats
path: root/src/sss_client/sudo_plugin/sss_sudo_cli.h
blob: 097b8aaf0073f794f08f838344f328cf28bf80fa (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
    SSSD

    sss_sudo_cli.h

    Authors:
        Arun Scaria <arunscaria91@gmail.com>

    Copyright (C) 2011 Arun Scaria <arunscaria91@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef _SSS_SUDO_CLI_H_
#define _SSS_SUDO_CLI_H_


#ifndef SSS_SUDO_SERVICE_PIPE
#define SSS_SUDO_SERVICE_PIPE "unix:path=" PIPE_PATH "/sudo"
#endif

#undef SSS_SUDO_TIMEOUT
#define SSS_SUDO_TIMEOUT 60

#ifndef SUDO_SERVER_INTERFACE
#define SUDO_SERVER_INTERFACE "org.freedesktop.sssd.sudo"
#endif

#ifndef SUDO_SERVER_PATH
#define SUDO_SERVER_PATH "/org/freedesktop/sssd/sudo"
#endif

#ifndef SUDO_METHOD_QUERY
#define SUDO_METHOD_QUERY "queryService"
#endif

#ifndef CHECK_AND_RETURN_PI_STRING
#define CHECK_AND_RETURN_PI_STRING(s) ((s != NULL && *s != '\0')? s : "(not available)")
#endif

#define INIT_SETTINGS_TABLE_SIZE 15

#define INIT_ENV_TABLE_SIZE 10

#ifndef _SSSCLI_H

/* If sss_cli.h is not included */
struct sss_cli_req_data {
    size_t len;
    const void *data;
};

enum sss_status {
    SSS_STATUS_SUCCESS,
    SSS_STATUS_FAILED,
    SSS_STATUS_TRYAGAIN,
    SSS_STATUS_UNAVAIL

};

#endif 



enum error_types_sudo{

    SSS_SUDO_SUCCESS = 0x01,
    SSS_SUDO_FAILED,
    SSS_SUDO_BUF_ERR,
    SSS_SUDO_CONNECTION_ERR,
    SSS_SUDO_SYSTEM_ERR,
    SSS_SUDO_LOG_ERR,
    SSS_SUDO_LOG_NOTICE,
    SSS_SUDO_MESSAGE_ERR,
    SSS_SUDO_REPLY_ERR

};

enum sss_sudo_validation_status {
    SSS_SUDO_VALIDATION_SUCCESS = 0x00,
    SSS_SUDO_VALIDATION_ERR
};


struct sss_sudo_msg_contents
{

    /* from user_info */
    uid_t userid;
    char *cwd;
    char *tty;

    /* from settings */
    char * runas_user;
    char * runas_group;
    char * prompt;
    char * network_addrs;
    int use_sudoedit;
    int use_set_home;
    int use_preserve_environment;
    int use_implied_shell;
    int use_login_shell;
    int use_run_shell;
    int use_preserve_groups;
    int use_ignore_ticket;
    int use_noninteractive;
    int debug_level;

    /*from user_env*/
    char * const * user_env;

    /* command with arguments */
    char * fq_command;
    char ** command;
    int command_count;

    /* Clients pid */
    int cli_pid;

    hash_table_t *settings_table;
    hash_table_t *env_table;
};

#define  SSS_SUDO_ITEM_RUSER                "runas_user"
#define  SSS_SUDO_ITEM_RGROUP               "runas_group"
#define  SSS_SUDO_ITEM_PROMPT               "prompt"
#define  SSS_SUDO_ITEM_NETADDR              "net_addr"
#define  SSS_SUDO_ITEM_USE_SUDOEDIT         "use_sudoedit"
#define  SSS_SUDO_ITEM_USE_SETHOME          "use_sethome"
#define  SSS_SUDO_ITEM_USE_PRESERV_ENV      "use_preserve_env"
#define  SSS_SUDO_ITEM_USE_IMPLIED_SHELL    "use_implied_shell"
#define  SSS_SUDO_ITEM_USE_LOGIN_SHELL      "use_login_shell"
#define  SSS_SUDO_ITEM_USE_RUN_SHELL        "use_run_shell"
#define  SSS_SUDO_ITEM_USE_PRE_GROUPS       "use_preserve_groups"
#define  SSS_SUDO_ITEM_USE_IGNORE_TICKET    "use_ignore_ticket"
#define  SSS_SUDO_ITEM_USE_NON_INTERACTIVE  "use_non_interactive"
#define  SSS_SUDO_ITEM_DEBUG_LEVEL          "use_debug_level"
#define  SSS_SUDO_ITEM_CLI_PID              "client_pid"



#endif  /* _SSS_SUDO_CLI_H_ */