Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_gridftp_server_control.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #if !defined(GLOBUS_I_GRIDFTP_SERVER_CONTROL_H)
18 #define GLOBUS_I_GRIDFTP_SERVER_CONTROL_H 1
19 
20 #include "globus_gridftp_server_control.h"
21 #include "globus_xio.h"
22 #include "globus_xio_system.h"
23 #include "globus_xio_tcp_driver.h"
24 #include "globus_xio_pipe_driver.h"
25 #include "globus_xio_telnet.h"
26 #include "globus_xio_gssapi_ftp.h"
27 
28 #define GLOBUS_GRIDFTP_VERSION_CTL 1
29 
30 GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER_CONTROL);
31 
32 #define GlobusGSDebugPrintf(level, message) \
33  GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER_CONTROL, level, message)
34 
35 #define GlobusGridFTPServerDebugEnter() \
36  GlobusGSDebugPrintf( \
37  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_TRACE, \
38  ("[%s] Entering\n", _gridftp_server_name))
39 
40 #define GlobusGridFTPServerDebugExit() \
41  GlobusGSDebugPrintf( \
42  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_TRACE, \
43  ("[%s] Exiting\n", _gridftp_server_name))
44 
45 #define GlobusGridFTPServerDebugExitWithError() \
46  GlobusGSDebugPrintf( \
47  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_TRACE, \
48  ("[%s] Exiting with error\n", _gridftp_server_name))
49 
50 #define GlobusGridFTPServerDebugInternalEnter() \
51  GlobusGSDebugPrintf( \
52  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_INTERNAL_TRACE, \
53  ("[%s] I Entering\n", _gridftp_server_name))
54 
55 #define GlobusGridFTPServerDebugInternalExit() \
56  GlobusGSDebugPrintf( \
57  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_INTERNAL_TRACE, \
58  ("[%s] I Exiting\n", _gridftp_server_name))
59 
60 #define GlobusGridFTPServerDebugInternalExitWithError() \
61  GlobusGSDebugPrintf( \
62  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_INTERNAL_TRACE, \
63  ("[%s] I Exiting with error\n", _gridftp_server_name))
64 
65 #define GlobusGridFTPServerDebugVerboseEnter() \
66  GlobusGSDebugPrintf( \
67  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_VERBOSE, \
68  ("[%s] V Entering\n", _gridftp_server_name))
69 
70 #define GlobusGridFTPServerDebugVerboseExit() \
71  GlobusGSDebugPrintf( \
72  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_VERBOSE, \
73  ("[%s] V Exiting\n", _gridftp_server_name))
74 
75 #define GlobusGridFTPServerDebugVerboseExitWithError() \
76  GlobusGSDebugPrintf( \
77  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_VERBOSE, \
78  ("[%s] V Exiting with error\n", _gridftp_server_name))
79 
80 #define GlobusGridFTPServerDebugCommand(cmd) \
81  GlobusGSDebugPrintf( \
82  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_COMMANDS, \
83  ("### [%s] Received command: %s\n", _gridftp_server_name, cmd))
84 
85 struct globus_i_gs_attr_s;
86 
87 typedef enum globus_i_gsc_debug_levels_e
88 {
89  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_ERROR = 1,
90  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_WARNING = 2,
91  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_TRACE = 4,
92  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_INTERNAL_TRACE = 8,
93  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_COMMANDS = 16,
94  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_VERBOSE = 32,
95  GLOBUS_GRIDFTP_SERVER_CONTROL_DEBUG_STATE = 64
96 } globus_i_gsc_debug_levels_t;
97 
98 typedef enum globus_i_gsc_error_type_e
99 {
100  GLOBUS_GRIDFTP_SERVER_CONTROL_ERROR_PARAMETER,
101  GLOBUS_GRIDFTP_SERVER_CONTROL_ERROR_STATE,
102  GLOBUS_GRIDFTP_SERVER_CONTROL_ERROR_MEMORY,
103  GLOBUS_GRIDFTP_SERVER_CONTROL_NO_AUTH,
104  GLOBUS_GRIDFTP_SERVER_CONTROL_POST_AUTH,
105  GLOBUS_GRIDFTP_SERVER_CONTROL_NO_COMMAND,
106  GLOBUS_GRIDFTP_SERVER_CONTROL_MALFORMED_COMMAND
107 } globus_i_gsc_error_type_t;
108 
109 typedef enum globus_i_gsc_mlsx_fact_e
110 {
111  GLOBUS_GSC_MLSX_FACT_TYPE = 'T',
112  GLOBUS_GSC_MLSX_FACT_MODIFY = 'M',
113  GLOBUS_GSC_MLSX_FACT_CHARSET = 'C',
114  GLOBUS_GSC_MLSX_FACT_SIZE = 'S',
115  GLOBUS_GSC_MLSX_FACT_PERM = 'P',
116  GLOBUS_GSC_MLSX_FACT_UNIXMODE = 'U',
117  GLOBUS_GSC_MLSX_FACT_UNIXOWNER = 'O',
118  GLOBUS_GSC_MLSX_FACT_UNIXGROUP = 'G',
119  GLOBUS_GSC_MLSX_FACT_UNIQUE = 'Q',
120  GLOBUS_GSC_MLSX_FACT_UNIXSLINK = 'L',
121  GLOBUS_GSX_MLSX_FACT_UNIXUID = 'I',
122  GLOBUS_GSX_MLSX_FACT_UNIXGID = 'D',
123  GLOBUS_GSC_MLSX_FACT_XCOUNT = 'N',
124  GLOBUS_GSC_MLSX_FACT_XABSPATH = 'A'
125 } globus_i_gsc_mlsx_fact_t;
126 
127 typedef enum
128 {
129  GLOBUS_L_GSC_DATA_OBJ_READY = 1,
130  GLOBUS_L_GSC_DATA_OBJ_DESTROY_WAIT,
131  GLOBUS_L_GSC_DATA_OBJ_DESTROYING,
132  GLOBUS_L_GSC_DATA_OBJ_INUSE
133 } globus_l_gsc_data_obj_state_t;
134 
135 typedef void
136 (*globus_i_gsc_auth_cb_t)(
137  struct globus_i_gsc_op_s * op,
138  globus_gridftp_server_control_response_t response_type,
139  char * response_msg,
140  void * user_arg);
141 
142 typedef void
143 (*globus_i_gsc_resource_cb_t)(
144  struct globus_i_gsc_op_s * op,
145  globus_gridftp_server_control_response_t response_type,
146  char * response_msg,
147  char * path,
148  char * abs_path,
150  int stat_count,
151  uid_t uid,
152  void * user_arg);
153 
154 typedef void
155 (*globus_i_gsc_passive_cb_t)(
156  struct globus_i_gsc_op_s * op,
157  globus_gridftp_server_control_response_t response_type,
158  char * response_msg,
159  const char ** cs,
160  int addr_count,
161  void * user_arg);
162 
163 typedef void
164 (*globus_i_gsc_port_cb_t)(
165  struct globus_i_gsc_op_s * op,
166  globus_gridftp_server_control_response_t response_type,
167  char * response_msg,
168  void * user_arg);
169 
170 typedef void
171 (*globus_i_gsc_transfer_cb_t)(
172  struct globus_i_gsc_op_s * op,
173  globus_gridftp_server_control_response_t response_type,
174  char * response_msg,
175  void * user_arg);
176 
177 typedef struct globus_i_gsc_data_s
178 {
179  globus_l_gsc_data_obj_state_t state;
180  struct globus_i_gsc_server_handle_s * server_handle;
181  int stripe_count;
182  void * user_handle;
183  globus_gridftp_server_control_data_dir_t dir;
184  globus_bool_t first_use;
185 } globus_i_gsc_data_t;
186 
187 typedef enum globus_i_gsc_op_type_e
188 {
189  GLOBUS_L_GSC_OP_TYPE_AUTH,
190  GLOBUS_L_GSC_OP_TYPE_RESOURCE,
191  GLOBUS_L_GSC_OP_TYPE_CREATE_PASV,
192  GLOBUS_L_GSC_OP_TYPE_CREATE_PORT,
193  GLOBUS_L_GSC_OP_TYPE_SEND,
194  GLOBUS_L_GSC_OP_TYPE_RECV,
195  GLOBUS_L_GSC_OP_TYPE_DESTROY,
196  GLOBUS_L_GSC_OP_TYPE_LIST,
197  GLOBUS_L_GSC_OP_TYPE_NLST,
198  GLOBUS_L_GSC_OP_TYPE_MLSD,
199  GLOBUS_L_GSC_OP_TYPE_MLSR
200 } globus_i_gsc_op_type_t;
201 
202 typedef struct globus_i_gsc_event_data_s
203 {
204  globus_l_gsc_data_obj_state_t state;
205  globus_callback_handle_t periodic_handle;
206  int stripe_count;
207  globus_bool_t perf_running;
208 
209  globus_callback_handle_t restart_handle;
210  globus_bool_t restart_running;
211 
212  int event_mask;
213  globus_gridftp_server_control_event_cb_t user_cb;
214  void * user_arg;
215 
216  globus_off_t * stripe_total;
217 } globus_i_gsc_event_data_t;
218 
219 typedef struct globus_i_gsc_handle_opts_s
220 {
221  char mlsx_fact_str[16];
222  int parallelism;
223  globus_size_t send_buf;
224  globus_size_t receive_buf;
225  globus_bool_t refresh;
226  globus_size_t packet_size;
227  globus_bool_t delayed_passive;
228  globus_bool_t passive_only;
229  int perf_frequency;
230  int retr_perf_frequency;
231  int restart_frequency;
232  globus_gsc_layout_t layout;
233  globus_size_t block_size;
234  int mlsr_traversal_options;
235 } globus_i_gsc_handle_opts_t;
236 
237 typedef struct globus_i_gsc_module_func_s
238 {
239  char * key;
240  globus_gridftp_server_control_transfer_cb_t func;
241  void * user_arg;
242 } globus_i_gsc_module_func_t;
243 
244 typedef struct globus_i_gsc_user_funcs_s
245 {
246  globus_hashtable_t send_cb_table;
247  globus_hashtable_t recv_cb_table;
248  globus_gridftp_server_control_transfer_cb_t default_send_cb;
249  void * default_send_arg;
250  globus_gridftp_server_control_transfer_cb_t default_recv_cb;
251  void * default_recv_arg;
252  globus_gridftp_server_control_auth_cb_t auth_cb;
253  void * auth_arg;
254  globus_gridftp_server_control_passive_connect_cb_t passive_cb;
255  void * passive_arg;
256  globus_gridftp_server_control_active_connect_cb_t active_cb;
257  void * active_arg;
258  globus_gridftp_server_control_data_destroy_cb_t data_destroy_cb;
259  void * data_destroy_arg;
260  globus_gridftp_server_control_list_cb_t list_cb;
261  void * list_arg;
262  globus_gridftp_server_control_resource_cb_t resource_cb;
263  void * resource_arg;
264  globus_gridftp_server_control_cb_t done_cb;
265  void * done_arg;
266  globus_gridftp_server_control_log_cb_t log_func;
267  int log_mask;
268  void * log_arg;
269 } globus_i_gsc_user_funcs_t;
270 
271 typedef struct globus_i_gsc_op_s
272 {
273  globus_i_gsc_op_type_t type;
274 
275  int ref;
276  struct globus_i_gsc_server_handle_s * server_handle;
277 
278  globus_gridftp_server_control_response_t response_type;
279  char * response_msg;
280 
281  globus_list_t * cmd_list;
282  globus_bool_t done;
283 
284  /* stuff for auth */
285  globus_bool_t authenticated;
286  char * username;
287  char * password;
288  globus_i_gsc_auth_cb_t auth_cb;
289  globus_i_gsc_resource_cb_t stat_cb;
290  globus_i_gsc_transfer_cb_t list_cb;
291 
293  int stat_count;
294  globus_mutex_t stat_lock;
295 
296  /* stuff for resource */
297  int uid;
298  int gid_count;
299  int * gid_array;
300  char * path;
301  char * absolute_path;
302  char * glob_match_str;
303  globus_gridftp_server_control_resource_mask_t mask;
304 
305  /* stuff for port/pasv */
306  char ** cs;
307  int max_cs;
308  int net_prt;
309  globus_i_gsc_passive_cb_t passive_cb;
310  globus_i_gsc_port_cb_t port_cb;
311  globus_i_gsc_transfer_cb_t transfer_cb;
312 
313  char * command;
314 
315  /* stuff for transfer */
316  char * mod_name;
317  char * mod_parms;
318  globus_gridftp_server_control_transfer_cb_t user_data_cb;
319  globus_bool_t transfer_started;
320 
321  globus_range_list_t range_list;
322  globus_range_list_t perf_range_list;
323  globus_i_gsc_event_data_t event;
324 
325  globus_bool_t aborted;
326  void * abort_user_arg;
327  void * user_arg;
328 
329  globus_i_gsc_data_t * data_destroy_obj;
330 } globus_i_gsc_op_t;
331 
332 typedef struct globus_i_gsc_attr_s
333 {
334  int version_ctl;
335  char * modes;
336  char * types;
337  char * base_dir;
338  char * post_auth_banner;
339  char * pre_auth_banner;
340  globus_gridftp_server_control_security_type_t security;
341  globus_bool_t epsv_ip;
342  globus_bool_t ipv6;
343 
344  int idle_timeout;
345  int preauth_timeout;
346 
347  globus_i_gsc_user_funcs_t funcs;
348 } globus_i_gsc_attr_t;
349 
350 
351 extern globus_hashtable_t globus_i_gs_default_attr_command_hash;
352 
353 /*
354  * internal functions for adding commands.
355  */
356 
357 /*
358  * 959 Structures
359  */
360 typedef enum globus_l_gsc_state_e
361 {
362  GLOBUS_L_GSC_STATE_NONE,
363  GLOBUS_L_GSC_STATE_OPENING,
364  GLOBUS_L_GSC_STATE_OPEN,
365  GLOBUS_L_GSC_STATE_PROCESSING,
366  GLOBUS_L_GSC_STATE_ABORTING,
367  GLOBUS_L_GSC_STATE_ABORTING_STOPPING,
368  GLOBUS_L_GSC_STATE_STOPPING,
369  GLOBUS_L_GSC_STATE_STOPPED
370 } globus_l_gsc_state_t;
371 
372 
373 typedef struct globus_i_gsc_cmd_wrapper_s
374 {
375  globus_i_gsc_op_t * op;
376  char * strarg;
377  char * mod_name;
378  char * mod_parms;
379  char * path;
380 
381  globus_bool_t transfer_flag;
382  int dc_parsing_alg;
383  int max;
384  globus_gridftp_server_control_network_protocol_t prt;
385 
386  globus_i_gsc_op_type_t type;
387  int cmd_ndx;
388 
389  char ** cs;
390  int cs_count;
391  int reply_code;
392 
393  struct globus_i_gsc_cmd_wrapper_s * transfer_info;
394 } globus_i_gsc_cmd_wrapper_t;
395 
396 /* the server handle */
397 typedef struct globus_i_gsc_server_handle_s
398 {
399  int version_ctl;
400 
401  globus_mutex_t mutex;
402 
403  /*
404  * authentication information
405  */
406  int ref;
407  globus_bool_t timeout;
408 
409  char * username;
410  char * pw;
411  char * subject;
412  char dcau;
413  char * dcau_subject;
414  char prot;
415  globus_bool_t authenticated;
416 
417  char * post_auth_banner;
418  char * pre_auth_banner;
419 
420  gss_ctx_id_t context;
421  gss_cred_id_t cred;
422  gss_cred_id_t del_cred;
423  globus_gridftp_server_control_security_type_t security_type;
424 
425  /*
426  * state information
427  */
428  char * cwd;
429  char * default_cwd;
430  char type;
431  char mode;
432  char * modes;
433  char * types;
434  int stripe_count;
435  char * lang;
436 
437  globus_off_t allocated_bytes;
438 
439  /* force failure on this command */
440  char * fault_cmd;
441 
442  /* opts state */
443  globus_i_gsc_handle_opts_t opts;
444 
445  /*
446  * user function pointers
447  */
448  globus_range_list_t range_list;
449 
450  globus_i_gsc_user_funcs_t funcs;
451 
452  globus_i_gsc_data_t * data_object;
453 
454  globus_result_t cached_res;
455  globus_list_t * feature_list;
456 
457  /*
458  * read.c members
459  */
460  globus_list_t * all_cmd_list;
461  globus_bool_t reply_outstanding;
462  globus_xio_handle_t xio_handle;
463  globus_l_gsc_state_t state;
464  globus_fifo_t read_q;
465  globus_fifo_t reply_q;
466  int abort_cnt;
467  globus_hashtable_t cmd_table;
468  globus_hashtable_t site_cmd_table;
469  globus_hashtable_t data_object_table;
470  struct globus_i_gsc_op_s * outstanding_op;
471 
472  globus_bool_t terminating;
473 
474  int idle_timeout;
475  int preauth_timeout;
476 
477  globus_i_gsc_cmd_wrapper_t * pasv_info;
478  globus_bool_t epsv_ip;
479  globus_bool_t ipv6;
480 
481  globus_bool_t q_backup;
482  int max_q_len;
483 } globus_i_gsc_server_handle_t;
484 
485 
486 void
487 globus_i_gsc_reverse_restart(
488  globus_range_list_t in_range,
489  globus_range_list_t out_range);
490 
491 void
492 globus_i_gsc_op_destroy(
493  globus_i_gsc_op_t * op);
494 
495 void
496 globus_i_gsc_event_start(
497  globus_i_gsc_op_t * op,
498  int event_mask,
499  globus_gridftp_server_control_event_cb_t event_cb,
500  void * user_arg);
501 
502 void
503 globus_i_gsc_event_end(
504  globus_i_gsc_op_t * op);
505 
506 char *
507 globus_i_gsc_get_help(
508  globus_i_gsc_server_handle_t * server_handle,
509  const char * command_name);
510 
512 globus_i_gsc_intermediate_reply(
513  globus_i_gsc_op_t * op,
514  char * reply_msg);
515 
517 globus_i_gsc_authenticate(
518  globus_i_gsc_op_t * op,
519  const char * user,
520  const char * pass,
521  globus_i_gsc_auth_cb_t cb,
522  void * user_arg);
523 
525 globus_i_gsc_list(
526  globus_i_gsc_op_t * op,
527  const char * path,
528  globus_gridftp_server_control_resource_mask_t mask,
529  globus_i_gsc_op_type_t type,
530  globus_i_gsc_transfer_cb_t list_cb,
531  void * user_arg);
532 
534 globus_i_gsc_resource_query(
535  globus_i_gsc_op_t * op,
536  const char * path,
537  globus_gridftp_server_control_resource_mask_t mask,
538  globus_i_gsc_resource_cb_t cb,
539  void * user_arg);
540 
542 globus_i_gsc_passive(
543  globus_i_gsc_op_t * op,
544  int max,
545  int net_prt,
546  const char * pathname,
547  globus_i_gsc_passive_cb_t cb,
548  void * user_arg);
549 
551 globus_i_gsc_port(
552  globus_i_gsc_op_t * op,
553  const char ** contact_strings,
554  int stripe_count,
555  int net_prt,
556  globus_i_gsc_port_cb_t cb,
557  void * user_arg);
558 
560 globus_i_gsc_send(
561  globus_i_gsc_op_t * op,
562  const char * path,
563  const char * mod_name,
564  const char * mod_parms,
565  globus_i_gsc_transfer_cb_t data_cb,
566  void * user_arg);
567 
569 globus_i_gsc_recv(
570  globus_i_gsc_op_t * op,
571  const char * path,
572  const char * mod_name,
573  const char * mod_parms,
574  globus_i_gsc_transfer_cb_t data_cb,
575  void * user_arg);
576 
577 void
578 globus_i_gsc_add_commands(
579  globus_i_gsc_server_handle_t * server_handle);
580 
582 globus_i_gsc_command_panic(
583  globus_i_gsc_op_t * op);
584 
585 char *
586 globus_i_gsc_concat_path(
587  globus_i_gsc_server_handle_t * i_server,
588  const char * in_path);
589 
590 char *
591 globus_i_gsc_list_single_line(
593 
594 char *
595 globus_i_gsc_list_line(
597  int stat_count,
598  const char * glob_match_str);
599 
600 char *
601 globus_i_gsc_nlst_line(
603  int stat_count);
604 
605 char *
606 globus_i_gsc_mlsx_line_single(
607  const char * mlsx_fact_str,
608  int uid,
610  const char * base_path,
611  const char * absolute_path,
612  globus_bool_t mlst);
613 
614 char *
615 globus_i_gsc_mlsx_line(
617  int stat_count,
618  const char * mlsx_fact_string,
619  uid_t uid,
620  const char * base_path,
621  const char * absolute_path,
622  globus_bool_t indent);
623 
624 void
625 globus_i_guc_command_data_destroy(
626  globus_i_gsc_server_handle_t * server_handle);
627 
628 void
629 globus_i_gsc_log(
630  globus_i_gsc_server_handle_t * server_handle,
631  const char * command,
632  int mask);
633 
635 globus_i_guc_data_object_destroy(
636  globus_i_gsc_server_handle_t * server_handle,
637  globus_i_gsc_data_t * data_object);
638 
640 globus_i_gsc_cmd_intermediate_reply(
641  globus_i_gsc_op_t * op,
642  char * reply_msg);
643 
644 void
645 globus_i_gsc_event_start_perf_restart(
646  globus_i_gsc_op_t * op);
647 
648 void
649 globus_gsc_959_terminate(
650  globus_i_gsc_op_t * op,
651  char * reply_msg);
652 
653 #endif
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
int globus_callback_handle_t
Periodic callback handle.
Definition: globus_callback.h:102
struct globus_fifo_s * globus_fifo_t
Definition: globus_fifo.h:48
List data type.
Definition: globus_list.h:44
Header file for XIO TCP Driver.
Mutex.
Definition: globus_thread.h:107
Definition: globus_gridftp_server_control.h:209
XIO Telnet Driver.
size_t globus_size_t
Standard size of memory objectThe globus_size_t is the size of a memory object. It is identical to si...
Definition: globus_types.h:48
uint32_t globus_result_t
Definition: globus_types.h:99