cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

settings.h (8900B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUAC_SSH_SETTINGS_H
     21#define GUAC_SSH_SETTINGS_H
     22
     23#include "config.h"
     24
     25#include <guacamole/user.h>
     26
     27#include <stdbool.h>
     28
     29/**
     30 * The port to connect to when initiating any SSH connection, if no other port
     31 * is specified.
     32 */
     33#define GUAC_SSH_DEFAULT_PORT "22"
     34
     35/**
     36 * The filename to use for the typescript, if not specified.
     37 */
     38#define GUAC_SSH_DEFAULT_TYPESCRIPT_NAME "typescript" 
     39
     40/**
     41 * The filename to use for the screen recording, if not specified.
     42 */
     43#define GUAC_SSH_DEFAULT_RECORDING_NAME "recording"
     44
     45/**
     46 * The default polling timeout for SSH activity in milliseconds.
     47 */
     48#define GUAC_SSH_DEFAULT_POLL_TIMEOUT 1000
     49
     50/**
     51 * Settings for the SSH connection. The values for this structure are parsed
     52 * from the arguments given during the Guacamole protocol handshake using the
     53 * guac_ssh_parse_args() function.
     54 */
     55typedef struct guac_ssh_settings {
     56
     57    /**
     58     * The hostname of the SSH server to connect to.
     59     */
     60    char* hostname;
     61
     62    /**
     63     * The public SSH host key.
     64     */
     65    char* host_key;
     66
     67    /**
     68     * The port of the SSH server to connect to.
     69     */
     70    char* port;
     71
     72    /**
     73     * The name of the user to login as, if any. If no username is specified,
     74     * this will be NULL.
     75     */
     76    char* username;
     77
     78    /**
     79     * The password to give when authenticating, if any. If no password is
     80     * specified, this will be NULL.
     81     */
     82    char* password;
     83
     84    /**
     85     * The private key, encoded as base64, if any. If no private key is
     86     * specified, this will be NULL.
     87     */
     88    char* key_base64;
     89
     90    /**
     91     * The passphrase to use to decrypt the given private key, if any. If no
     92     * passphrase is specified, this will be NULL.
     93     */
     94    char* key_passphrase;
     95
     96    /**
     97     * Whether this connection is read-only, and user input should be dropped.
     98     */
     99    bool read_only;
    100
    101    /**
    102     * The command to run instead of the default shell. If a normal shell
    103     * session is desired, this will be NULL.
    104     */
    105    char* command;
    106
    107    /**
    108     * The maximum size of the scrollback buffer in rows.
    109     */
    110    int max_scrollback;
    111
    112    /**
    113     * The name of the font to use for display rendering.
    114     */
    115    char* font_name;
    116
    117    /**
    118     * The size of the font to use, in points.
    119     */
    120    int font_size;
    121
    122    /**
    123     * The name of the color scheme to use.
    124     */
    125    char* color_scheme; 
    126
    127    /**
    128     * The desired width of the terminal display, in pixels.
    129     */
    130    int width;
    131
    132    /**
    133     * The desired height of the terminal display, in pixels.
    134     */
    135    int height;
    136
    137    /**
    138     * The desired screen resolution, in DPI.
    139     */
    140    int resolution;
    141
    142    /**
    143     * Whether outbound clipboard access should be blocked. If set, it will not
    144     * be possible to copy data from the terminal to the client using the
    145     * clipboard.
    146     */
    147    bool disable_copy;
    148
    149    /**
    150     * Whether inbound clipboard access should be blocked. If set, it will not
    151     * be possible to paste data from the client to the terminal using the
    152     * clipboard.
    153     */
    154    bool disable_paste;
    155
    156    /**
    157     * Whether SFTP is enabled.
    158     */
    159    bool enable_sftp;
    160
    161    /**
    162     * The path of the directory within the SSH server to expose as a
    163     * filesystem guac_object.
    164     */
    165    char* sftp_root_directory;
    166    
    167    /**
    168     * Whether file download over SFTP should be disabled.  If set to true, file
    169     * downloads will not be allowed over SFTP.  If not set or set to false, file
    170     * downloads will be allowed.
    171     */
    172    bool sftp_disable_download;
    173    
    174    /**
    175     * Whether file uploads over SFTP should be disabled.  If set to true, file
    176     * uploads will not be allowed over SFTP.  If not set or set to false, file
    177     * uploads will be allowed.
    178     */
    179    bool sftp_disable_upload;
    180
    181#ifdef ENABLE_SSH_AGENT
    182    /**
    183     * Whether the SSH agent is enabled.
    184     */
    185    bool enable_agent;
    186#endif
    187
    188    /**
    189     * The path in which the typescript should be saved, if enabled. If no
    190     * typescript should be saved, this will be NULL.
    191     */
    192    char* typescript_path;
    193
    194    /**
    195     * The filename to use for the typescript, if enabled.
    196     */
    197    char* typescript_name;
    198
    199    /**
    200     * Whether the typescript path should be automatically created if it does
    201     * not already exist.
    202     */
    203    bool create_typescript_path;
    204
    205    /**
    206     * The path in which the screen recording should be saved, if enabled. If
    207     * no screen recording should be saved, this will be NULL.
    208     */
    209    char* recording_path;
    210
    211    /**
    212     * The filename to use for the screen recording, if enabled.
    213     */
    214    char* recording_name;
    215
    216    /**
    217     * Whether the screen recording path should be automatically created if it
    218     * does not already exist.
    219     */
    220    bool create_recording_path;
    221
    222    /**
    223     * Whether output which is broadcast to each connected client (graphics,
    224     * streams, etc.) should NOT be included in the session recording. Output
    225     * is included by default, as it is necessary for any recording which must
    226     * later be viewable as video.
    227     */
    228    bool recording_exclude_output;
    229
    230    /**
    231     * Whether changes to mouse state, such as position and buttons pressed or
    232     * released, should NOT be included in the session recording. Mouse state
    233     * is included by default, as it is necessary for the mouse cursor to be
    234     * rendered in any resulting video.
    235     */
    236    bool recording_exclude_mouse;
    237
    238    /**
    239     * Whether keys pressed and released should be included in the session
    240     * recording. Key events are NOT included by default within the recording,
    241     * as doing so has privacy and security implications.  Including key events
    242     * may be necessary in certain auditing contexts, but should only be done
    243     * with caution. Key events can easily contain sensitive information, such
    244     * as passwords, credit card numbers, etc.
    245     */
    246    bool recording_include_keys;
    247
    248    /**
    249     * The number of seconds between sending server alive messages.
    250     */
    251    int server_alive_interval;
    252
    253    /**
    254     * The integer ASCII code of the command to send for backspace.
    255     */
    256    int backspace;
    257
    258    /**
    259     * The terminal emulator type that is passed to the remote system.
    260     */
    261    char* terminal_type;
    262
    263    /**
    264     * The locale that should be forwarded to the remote system via the LANG
    265     * environment variable.
    266     */
    267    char* locale;
    268
    269    /** 
    270     * The client timezone to pass to the remote system.
    271     */
    272    char* timezone;
    273    
    274    /**
    275     * Whether or not to send the Wake-on-LAN magic packet.
    276     */
    277    bool wol_send_packet;
    278    
    279    /**
    280     * The MAC address to put in the magic WoL packet for the host to wake.
    281     */
    282    char* wol_mac_addr;
    283    
    284    /**
    285     * The broadcast address to which to send the magic WoL packet.
    286     */
    287    char* wol_broadcast_addr;
    288    
    289    /**
    290     * The UDP port to use when sending the magic WoL packet.
    291     */
    292    unsigned short wol_udp_port;
    293    
    294    /**
    295     * The amount of time to wait for the system to wake after sending the packet.
    296     */
    297    int wol_wait_time;
    298
    299} guac_ssh_settings;
    300
    301/**
    302 * Parses all given args, storing them in a newly-allocated settings object. If
    303 * the args fail to parse, NULL is returned.
    304 *
    305 * @param user
    306 *     The user who submitted the given arguments while joining the
    307 *     connection.
    308 *
    309 * @param argc
    310 *     The number of arguments within the argv array.
    311 *
    312 * @param argv
    313 *     The values of all arguments provided by the user.
    314 *
    315 * @return
    316 *     A newly-allocated settings object which must be freed with
    317 *     guac_ssh_settings_free() when no longer needed. If the arguments fail
    318 *     to parse, NULL is returned.
    319 */
    320guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
    321        int argc, const char** argv);
    322
    323/**
    324 * Frees the given guac_ssh_settings object, having been previously allocated
    325 * via guac_ssh_parse_args().
    326 *
    327 * @param settings
    328 *     The settings object to free.
    329 */
    330void guac_ssh_settings_free(guac_ssh_settings* settings);
    331
    332/**
    333 * NULL-terminated array of accepted client args.
    334 */
    335extern const char* GUAC_SSH_CLIENT_ARGS[];
    336
    337#endif
    338