source: trunk/include/sh_extern.h@ 501

Last change on this file since 501 was 481, checked in by katerina, 9 years ago

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File size: 2.9 KB
RevLine 
[1]1#ifndef SH_EXTERN_H
2#define SH_EXTERN_H
3
[415]4#include <stdarg.h>
5
[1]6typedef struct
7{
8 char * command;
9 int argc;
10 char * argv[32];
11 int envc;
12 char * envv[32];
13 char checksum[KEY_LEN + 1];
[169]14#if 0
[1]15 uid_t trusted_users[32];
[169]16#endif
[1]17 uid_t run_user_uid;
18 gid_t run_user_gid;
19 int privileged;
20
21 int pipeFD;
22 SL_TICKET pipeTI;
23 pid_t pid;
24 FILE * pipe;
25 char rw;
26 int exit_status;
27 int fork_twice;
28
29 int com_fd;
30 SL_TICKET com_ti;
31
32} sh_tas_t;
33
34
35/*
36 * -- generic safe popen; returns 0 on success, -1 otherwise
37 */
38int sh_ext_popen (sh_tas_t * task);
39
40/*
[275]41 * -- generic simple safe popen; returns 0 on success, -1 otherwise,
42 * executes shell command
43 */
[481]44int sh_ext_popen_init (sh_tas_t * task, const char * command, char * argv0, ...) SH_GNUC_SENTINEL;
[275]45
46/*
[211]47 * -- Execute command, return first line of output
48 */
[415]49int sh_ext_system (char * command, char * argv0, ...) SH_GNUC_SENTINEL;
[294]50
51/*
52 * -- Execute command, return first line of output
53 */
[481]54char * sh_ext_popen_str (const char * command);
[211]55
56/*
[1]57 * -- close the pipe, clear and return task->exit_status
58 */
59int sh_ext_pclose (sh_tas_t * task);
60
61/*
62 * -- add CL argument, return # of arguments
63 */
[22]64int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val);
[1]65/*
66 * -- remove last CL argument
67 */
68int sh_ext_tas_rm_argv(sh_tas_t * tas);
69/*
70 * -- add environment variable, return # of variables
71 */
[22]72int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val);
[1]73/*
74 * -- set command
75 */
[22]76void sh_ext_tas_command(sh_tas_t * tas, const char * command);
[1]77/*
78 * -- initialize task structure
79 */
80void sh_ext_tas_init (sh_tas_t * tas);
81/*
82 * -- free task structure
83 */
84void sh_ext_tas_free(sh_tas_t * tas);
85
86
87#if defined(WITH_EXTERNAL)
88
89/*
90 * -- start a new external command, and add it to the list
91 */
[22]92int sh_ext_setcommand(const char * cmd);
[1]93
[164]94/*
95 * -- explicitely close a command
96 */
97int sh_ext_close_command (const char * str);
98
[1]99/*
100 * -- clean up the command list
101 */
102int sh_ext_cleanup(void);
103
104/*
105 * -- set deadtime
106 */
[22]107int sh_ext_deadtime (const char * str);
[1]108
109/*
110 * -- add keywords to the OR filter
111 */
[22]112int sh_ext_add_or (const char * str);
[1]113
114/*
115 * -- add keywords to the AND filter
116 */
[22]117int sh_ext_add_and (const char * str);
[1]118
119/*
120 * -- add keywords to the NOT filter
121 */
[22]122int sh_ext_add_not (const char * str);
[1]123
124/*
125 * -- add keywords to the CL argument list
126 */
[22]127int sh_ext_add_argv (const char * str);
[1]128
129/*
130 * -- add a path to the environment
131 */
[22]132int sh_ext_add_default (const char * str);
[1]133
134/*
135 * -- add an environment variable
136 */
[22]137int sh_ext_add_environ (const char * str);
[1]138
139/*
140 * -- define type
141 */
[22]142int sh_ext_type (const char * str);
[1]143
144/*
145 * -- define checksum
146 */
[22]147int sh_ext_checksum (const char * str);
[1]148
149/*
150 * -- choose privileges
151 */
[22]152int sh_ext_priv (const char * c);
[1]153
154/*
155 * -- execute external script/program
156 */
157int sh_ext_execute (char t1, char t2, char t3, /*@null@*/char * message,
158 size_t msg_siz);
159
160#endif
161
162#endif
Note: See TracBrowser for help on using the repository browser.