$74 GRAYBYTE WORDPRESS FILE MANAGER $15

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 91.108.106.154 | ADMIN IP 216.73.216.21
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/include/

HOME
Current File : /usr/include//lscapi.h
/*
 * Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 *
 * The part the support library for lsapi & proxy_lsapi Apache modules
 * author Alexander Demeshko <ademeshko@cloudlinux.com>
 *
 * Here you define exportable functions for libscapi clients.
 */

#ifndef _LSCAPI_H_
#define _LSCAPI_H_

#define LSCAPI_PATH_PREFIX "lsapi_"

/* LSAPI_PRO_ONLY:BEGIN */
#ifdef WITH_CRIU

#ifdef LSCAPI_DEFAULT_CRIU_SOCKET_PATH
#undef LSCAPI_DEFAULT_CRIU_SOCKET_PATH
#endif
#define LSCAPI_DEFAULT_CRIU_SOCKET_PATH "/var/run/criu/criu_service.socket"

#define CRIU_IMGS_SUFFIX "_criu_imgs"
#define CRIU_IMGS_RESET_FLAG "mod_lsapi_reset_me"
#define CRIU_IMGS_RESET_GLOBAL_FLAG "/usr/share/criu/mod_lsapi/lsphp.criu.reset"

#endif //WITH_CRIU
/* LSAPI_PRO_ONLY:END */

#include <sys/uio.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>

#include <lsapidef.h>
#include <lscapi_config.h>

#include <liblsapi-sha1.h>

#define LSCAPI_SECRET_SIZE 16
#define LSCAPI_SALT_SIZE 16
#define LSCAPI_SHA1_SIGN_SIZE (LSCAPI_SALT_SIZE + SHA1_DIGEST_SIZE)
#define LSCAPI_ENCODED_SHA1_SIGN_SIZE (2*LSCAPI_SHA1_SIGN_SIZE + 1)
#define LSCAPI_ENCODED_SHA1_SIGN_WITHOUT_SALT_SIZE (2*SHA1_DIGEST_SIZE + 1)

/* LSAPI_PRO_ONLY:BEGIN */
enum
{
    PFL_RESEND_IF_CRASHED = 0,

    PFL_SOCKET_FAILED,

    PFL_BACKEND_CONNECT_FATAL_ERROR,
    PFL_BACKEND_WARM_CONNECT,
    PFL_BACKEND_WARM_CONNECT_MS,
    PFL_BACKEND_COLD_CONNECT,
    PFL_BACKEND_COLD_CONNECT_MS,
    PFL_BACKEND_CONNECT_FAILED,

    PFL_BACKEND_SPAWN_FAILED,
    PFL_BACKEND_SPAWN_SUCCESS,
    PFL_BACKEND_SPAWN_DELAYED,


/*
    PFL_MODLS_NORM_REQ_MS,          // 0
    PFL_MODLS_NORM_REQ_NUM,         // 0
    PFL_MODLS_REQ_HAS_BODY_MS,      // 0
    PFL_MODLS_REQ_HAS_BODY_NUM,     // 0
    PFL_MODLS_REQ_WO_BODY_MS,       // 0
    PFL_MODLS_REQ_WO_BODY_NUM,      // 0
*/
    PFL_LAST
};

#ifdef WITH_LIBPERFLOG
#include <perf_log.h>

extern pfl_handle_t* lsapi_perf_handle;
void lsapi_init_libperflog(void);

static inline void lsapi_perf_inc(int event_id)
{
    perf_inc(lsapi_perf_handle, event_id);
}

static inline void lsapi_perf_add(int event_id, pfl_event_count_t diff)
{
    perf_add(lsapi_perf_handle, event_id, diff);
}

#else //WITH_LIBPERFLOG

#define lsapi_perf_inc(event_id)
#define lsapi_perf_add(event_id, diff)

#endif //WITH_LIBPERFLOG

/* LSAPI_PRO_ONLY:END */

// lsapi structs
typedef struct lsapi_req_header lsapi_req_header_t;
typedef struct lsapi_http_header_index lsapi_http_header_index_t;
typedef struct lsapi_header_offset lsapi_header_offset_t;
typedef struct lsapi_packet_header lsapi_packet_header_t;
typedef struct lsapi_resp_info lsapi_resp_info;

// lscapi opaque structures
struct lscapi_rec;
struct lsphp_conn_t;

typedef struct lscapi_rec lscapi_rec;
typedef struct lsphp_conn_t lsphp_conn_t;

// allocator function pointer type
typedef void *(*lscapi_alloc_fn)(size_t size, void *user_data);

typedef long (*lscapi_user_get_body_fn)(char *buf, size_t bufLen, void *user_data);

typedef int (*lscapi_should_get_block_fn)(void *user_data);

typedef void (*lscapi_log_fn)(const char *file, int line, int level, int errcode,
                                const void *user_data, const char *fmt, ...);

typedef void (*lscapi_random_fn)(void *buf, size_t size);

typedef int(*lsphp_conn_failed_fn)(lsphp_conn_t *conn);

#ifndef WITHOUT_LVE
typedef void* (*lscapi_lve_alloc_t)(size_t sz, void* user_data);
typedef void (*lscapi_lve_register_t)(void* user_data, void* data, int (*destroy_fn)());
#endif

struct lscapi_var_t
{
    const char *key;
    int keyLen;
    const char *val;
    int valLen;
    int perdir;
};
typedef struct lscapi_var_t lscapi_var_t;


struct lscapi_header_index_t
{
    unsigned keyOff;
    unsigned keyLen;
    unsigned valOff;
    unsigned valLen;
};
typedef struct lscapi_header_index_t lscapi_header_index_t;


/*
  From lsapilib.h of Litespeed API 6.11
  In Litespeed API 7.4.2 increased to 1000

  DEPRECATED
  For backward compatibility only.
  It it needed only for deprecated lscapi_resphdr_t
*/
#define LSAPI_MAX_RESP_HEADERS  100

/* LSAPI_PRO_ONLY:BEGIN */
/*
  DEPRECATED
  For backward compatibility only.
  Updated with lscapi_resphdr_t
*/
struct lscapi_resphdr_info_t
{
    char buf[LSAPI_MAX_DATA_PACKET_LEN];
    size_t dataLen;
    uint16_t *hdrSizes;
    int hdrNum;
    int respStatus;
};
typedef struct lscapi_resphdr_info_t lscapi_resphdr_info_t;
/* LSAPI_PRO_ONLY:END */

/*
  DEPRECATED
  For backward compatibility only.
  It it needed only for deprecated lscapi_receive_response_hdr function
*/
struct lscapi_resphdr_t
{
    char buf[LSAPI_MAX_RESP_HEADERS * (LSAPI_RESP_HTTP_HEADER_MAX+2) + 1024];
    size_t dataLen;
    uint16_t *hdrSizes;
    int hdrNum;
    int respStatus;
};
typedef struct lscapi_resphdr_t lscapi_resphdr_t;

struct lscapi_resp_hdr_t
{
    char *respBuffer;
    size_t dataLen;
    uint16_t *hdrSizes;
    int hdrNum;
    int respStatus;
};
typedef struct lscapi_resp_hdr_t lscapi_resp_hdr_t;

struct lscapi_backend_info_t
{
    uint32_t connect_tries;
    uint32_t connect_timeout;

    uint32_t backend_children;
    uint32_t backend_pgrp_max_idle;
    uint32_t backend_max_idle;
    uint32_t backend_max_process_time;
    uint32_t backend_max_reqs;
    uint32_t backend_pgrp_max_reqs;
    uint32_t backend_pgrp_max_crashes;


    uint32_t backend_initial_start;
    uint32_t poll_timeout;

    int32_t backend_oom_score_adj;

    unsigned backend_coredump: 1;
    unsigned dump_backend_debug_info: 1;
    unsigned use_suexec: 1;
    unsigned enable_user_ini: 1;
    unsigned per_user: 1;
    unsigned user_ini_homedir: 1;

    unsigned backend_coredump_was_set: 1;
    unsigned dump_backend_debug_info_was_set: 1;
    unsigned use_suexec_was_set: 1;
    unsigned enable_user_ini_was_set: 1;
    unsigned per_user_was_set: 1;
    unsigned user_ini_homedir_was_set: 1;

    unsigned avoid_zombies: 1;
    unsigned avoid_zombies_was_set: 1;

    unsigned disable_reject_mode: 1;
    unsigned disable_reject_mode_was_set: 1;
/* LSAPI_PRO_ONLY:BEGIN */
    unsigned use_criu: 1;
    unsigned use_criu_was_set: 1;

    unsigned criu_debug: 1;
    unsigned criu_debug_was_set: 1;

    unsigned use_criu_signals: 2;
    unsigned use_criu_signals_was_set: 1;
/* LSAPI_PRO_ONLY:END */

    unsigned use_own_log: 1;
    unsigned use_own_log_was_set: 1;

/* LSAPI_PRO_ONLY:BEGIN */
    unsigned backend_semtimedwait: 1;
    unsigned backend_semtimedwait_was_set: 1;

/* LSAPI_PRO_ONLY:END */
    unsigned common_own_log: 1;
    unsigned common_own_log_was_set: 1;

    unsigned pwd_disabled: 1;
    unsigned pwd_disabled_was_set: 1;
/* LSAPI_PRO_ONLY:BEGIN */
    // This flag is global, not intended to change via tree config. So without _was_set
    unsigned change_cgroup: 1;

/* LSAPI_PRO_ONLY:END */

    unsigned backend_loglevel_info: 1;
    unsigned backend_loglevel_info_was_set: 1;

    unsigned backend_oom_score_adj_was_set: 1;

};
typedef struct lscapi_backend_info_t lscapi_backend_info_t;


#define LSCAPI_PATH_MAX 128
#define LSCAPI_PHPRC_MAX 128
/*
 struct sockaddr_un in <sys/un.h> contains integer constant
 instead of promised by unix(7) UNIX_PATH_MAX
 So we will use our own macro.
*/
#define LSCAPI_SOCKET_MAX 108

/* LSAPI_PRO_ONLY:BEGIN */
struct criu_info_t
{
    char     socket_name[4086];    /* Path to CRIU service socket */
    char     images_dir[4086];     /* Path to dir for CRIU images */
    int      sock_sulsphp;         /* Socket for sulsphp to talk to lsphp */
    int      sock_lsphp;           /* Socket for lsphp to talk to sulsphp */
    int      pipe_pid_read;        /* Pipe end for dumper to read lsphp pid from */
    int      pipe_pid_write;       /* Pipe end for sulsphp to write lsphp pid to */
};

/* LSAPI_PRO_ONLY:END */
typedef struct spawn_info_t
{
    unsigned backend_children;
    int backend_oom_score_adj;
    unsigned backend_pgrp_max_idle;
    unsigned backend_max_idle;
    unsigned backend_max_process_time;
    unsigned backend_max_reqs;
    unsigned backend_pgrp_max_reqs;
    unsigned backend_pgrp_max_crashes;
    unsigned backend_initial_start;
    uid_t uid;
    gid_t gid;
    unsigned backend_coredump: 1;
    unsigned dump_backend_debug_info: 1;
    unsigned use_suexec: 1;
    unsigned backend_accept_notify: 1;
    unsigned use_own_log: 1;
    unsigned enable_user_ini: 1;
    unsigned common_own_log: 1;
    unsigned user_ini_homedir: 1;
    char phprc[LSCAPI_PHPRC_MAX];
    char cmd[LSCAPI_PATH_MAX];
    char socket_name[LSCAPI_SOCKET_MAX];
/* LSAPI_PRO_ONLY:BEGIN */
    unsigned use_criu: 1;
    unsigned criu_debug: 1;
    unsigned use_criu_signals: 2;
/* LSAPI_PRO_ONLY:END */
    unsigned pwd_disabled: 1;
    unsigned avoid_zombies: 1;
    unsigned disable_reject_mode: 1;
/* LSAPI_PRO_ONLY:BEGIN */
    unsigned change_cgroup: 1;
/* LSAPI_PRO_ONLY:END */
    char uniq_socket_name[LSCAPI_SOCKET_MAX];
/* LSAPI_PRO_ONLY:BEGIN */
    struct criu_info_t criu;
/* LSAPI_PRO_ONLY:END */
} spawn_info_t;

typedef struct spawn_context_t
{
    int log_sock;
    int restore;
} spawn_context_t;


typedef pid_t (*lscapi_spawn_backend_fn)(const spawn_info_t *spawn_info,
                                         void *user_data, int force_start);

// Event masks

/* LSAPI_PRO_ONLY:BEGIN */
// DEPRECATED
#define LSCAPI_BACKEND_LOG_RECEIVED    (1u << 0)
/* LSAPI_PRO_ONLY:END */
#define LSCAPI_RESPONSE_FINISHED       (1u << 1)

/* LSAPI_PRO_ONLY:BEGIN */
// DEPRECATED
#define LSCAPI_BACKEND_LOG_FATAL       (1u << 2)

/* LSAPI_PRO_ONLY:END */
#define LSCAPI_SENDREQ_INTERNAL_ERROR  (1u << 3)
#define LSCAPI_SENDREQ_BACKEND_ERROR   (1u << 4)
#define LSCAPI_SENDREQ_CLIENT_ERROR    (1u << 5)
#define LSCAPI_CONNECT_REJECTED        (1u << 6)
#define LSCAPI_CONNECT_GENERIC_ERROR   (1u << 7)
#define LSCAPI_CONNECT_RESET_ERROR     (1u << 8)

enum lscapi_create_flags
{
	LSCAPI_CREATE_WITH_LVE	= 1 << 0,
	LSCAPI_OUT_ALREADY_INSIDE_LVE	= 1 << 16,
	LSCAPI_OUT_RESOURCE_LIMIT_LVE	= 1 << 17,
};

/*
 *  For backward compatibility with mod_lsapi
 *   LSCAPI_SPECIAL_ENV_PHPVAL_SYSTEM should be 0
 *    LSCAPI_SPECIAL_ENV_PHPVAL_PERDIR should be 1
 *    */
enum lscapi_special_env_types
{
    LSCAPI_SPECIAL_ENV_PHPVAL_SYSTEM = 0,
    LSCAPI_SPECIAL_ENV_PHPVAL_PERDIR = 1,
    LSCAPI_SPECIAL_ENV_ALTER_PHPINI = 2
};

extern const char defaultHandler[]; // "application/x-httpd-lsphp";

int lscapi_init(char *errbuf, size_t errlen);

// Here caller must use memory pool associated with process
void lscapi_child_init(lscapi_alloc_fn user_alloc, void *user_data);

// for backward compatibility, use lscapi_get_backend_heuristic instead
const char *lscapi_get_backend(const char *handler);

// Here caller must use memory pool associated with HTTP request
const char *lscapi_get_backend_heuristic(const char *handler, lscapi_alloc_fn user_alloc, void *user_data);

uint32_t lscapi_get_uid(lscapi_rec *lscapi);

/**
 * create opaque structure to store connection to lsphp on logical level
 * args:
 * user_alloc = pointer to allocator function
 * user_data = arbitrary user data to pass to allocator function
 * uid = uid for suexec and lve
 * gid = gid for suexec and lve
 * flags =
 * errbuf = buffer to store error description on error
 * errlen = length of the error buffer
 * return codes:
 * allocated and initialized structure = on success, NULL on error
 */
lscapi_rec *lscapi_create(lscapi_alloc_fn user_alloc,
                          lscapi_log_fn user_log,
                            void *user_data,
                            uint32_t uid, uint32_t gid,
                            unsigned *flagsPtr,
                            char *errbuf, unsigned errlen);


/**
 * close connection to lsphp on logical level
 * args:
 * lscapi = opaque structure created with lscapi_create
 */
void lscapi_destroy(lscapi_rec *lscapi);

/**
 * return codes:
 * 0 = on success, -1 on error and sets appropriate flag on eventMaskPtr
 */
int lscapi_send_request(lsphp_conn_t *conn, unsigned *eventMaskPtr,
                        char *errbuf, unsigned errlen);

void lscapi_set_socket_path(lscapi_rec *lscapi, char *socket_path);
void lscapi_set_phprc(lscapi_rec *lscapi, const char *phprc);

void lscapi_set_user_body_info(lscapi_rec *lscapi, size_t body_len,
                               lscapi_user_get_body_fn user_get_body,
                               lscapi_should_get_block_fn user_should_get_block);

void lscapi_set_use_request_scope_buffer(lscapi_rec *lscapi, bool value);

size_t lscapi_get_body_len(lscapi_rec *lscapi);

void lscapi_set_header_info(lscapi_rec *lscapi,
                            lsapi_http_header_index_t *hdrIndexPtr,
                            lsapi_header_offset_t *hdrOffsets,
                            size_t hdrOffsetsNum,
                            char *httpHeader,
                            size_t httpHeaderLen);

void lscapi_set_envs(lscapi_rec *lscapi, lscapi_var_t *envs, int envNum);
void lscapi_set_special_envs(lscapi_rec *lscapi, lscapi_var_t *specialEnvs, int specialEnvNum);

void lscapi_set_backend_path(lscapi_rec *lscapi,
                             const char *handler,
                             const char *backend_path);

void lscapi_set_debug_enabled(lscapi_rec *lscapi, int debug_enabled);

void lscapi_set_error(lscapi_rec *lscapi);
void lscapi_set_recoverable_error(lscapi_rec *lscapi);
bool lscapi_get_error(const lscapi_rec *lscapi, bool *outIsRecoverableError);
void lscapi_reset_internal_error_state(lscapi_rec *lscapi);

void lscapi_set_random(lscapi_rec *lscapi, lscapi_random_fn get_random_bytes);

void lscapi_set_user_spawn_backend(lscapi_rec *lscapi, lscapi_spawn_backend_fn user_spawn_backend);

void lscapi_set_accept_notify(lscapi_rec *lscapi, int accept_notify);

void lscapi_set_domain(lscapi_rec *lscapi,
                        const char *domain);

void lscapi_set_protocol_log(lscapi_rec *lscapi,
                                const char *protocol_log);

void lscapi_set_tmpdir(lscapi_rec *lscapi, const char *tmpdir);

/* LSAPI_PRO_ONLY:BEGIN */
/*
DEPRECATED
*/
const char* lscapi_get_backend_log(lscapi_rec *lscapi);

/* LSAPI_PRO_ONLY:END */

void lscapi_init_backend_info(lscapi_backend_info_t *infoPtr);
void lscapi_merge_backend_info(lscapi_backend_info_t *base, lscapi_backend_info_t *cur, lscapi_backend_info_t *merged);

lsphp_conn_t* lscapi_acquire_lsphp_conn(lscapi_rec *lscapi, char *errbuf, unsigned errlen);

void lscapi_release_lsphp_conn(lsphp_conn_t *conn);

/* LSAPI_PRO_ONLY:BEGIN */
/*
   This function creates a safe environment for spawning new lsphp process.
   Memory for this is allocated with call to calloc and calls to strdup.
   So this function is intended to be called just after call to fork from within a child process and just before call to exec.
   DO NOT USE it otherwise to avoid memory leaks.
*/
/* DEPRECATED */
int lscapi_prepare_env_for_lsphp(spawn_info_t *spawn_info, const char *customEnv, int envLen, int envNum, const char *safePath, char *errbuf, unsigned errlen);
/* LSAPI_PRO_ONLY:END */

/*
   This function creates a safe environment for spawning new lsphp process.
   Memory for this is allocated with call to calloc and calls to strdup.
   So this function is intended to be called just after call to fork from within a child process and just before call to exec.
   DO NOT USE it otherwise to avoid memory leaks.
*/
char** lscapi_prepare_env(spawn_info_t *spawn_info, const char *customEnv, int envLen, int envNum, const char *safePath, char *errbuf, unsigned errlen);

int lscapi_lsphp_conn_get_socket(lsphp_conn_t *conn);

void lscapi_remove_stale_data_from_socket(lsphp_conn_t *conn);

int lscapi_is_conn_closed(lsphp_conn_t *conn);


/* LSAPI_PRO_ONLY:BEGIN */
/*
    DEPRECATED
    Do nothing. For compatibility with mod_lsapi ver. 0.2 only.
*/
void lscapi_set_userdir(lscapi_rec *lscapi, int userdir);

/*
    DEPRECATED
    Do nothing. For compatibility with mod_lsapi ver. 0.2 only.
*/
void lscapi_set_backend_coredump(lscapi_rec *lscapi, int coredump_enabled);

/*
    DEPRECATED
    Do nothing. For compatibility with mod_lsapi ver. 0.2 only.
*/
void lscapi_terminate_backends(void);

/* LSAPI_PRO_ONLY:END */

int lscapi_determine_conn_lsphp(lsphp_conn_t *conn,
                                lscapi_backend_info_t *backendInfoPtr,
                                char *errbuf, unsigned errlen);

int lscapi_determine_conn_lsphp_ex(lsphp_conn_t *conn,
                                    lscapi_backend_info_t *backendInfoPtr,
                                    const char *sockName,
                                    char *errbuf, unsigned errlen);

/* LSAPI_PRO_ONLY:BEGIN */
/* DEPRECATED */
int lscapi_connect_lsphp(lsphp_conn_t *conn, char *errbuf, unsigned errlen);

/* DEPRECATED */
int lscapi_connect_lsphp_ex(lsphp_conn_t *conn, char *errbuf, unsigned errlen, int chunked);

/* LSAPI_PRO_ONLY:END */
int lscapi_connect_backend(lsphp_conn_t *conn, unsigned *eventMaskPtr, char *errbuf, unsigned errlen);
int lscapi_connect_backend_ex(lsphp_conn_t *conn, unsigned *eventMaskPtr, char *errbuf, unsigned errlen, int chunked);

void lscapi_conn_set_failed_cb(lsphp_conn_t *conn, lsphp_conn_failed_fn cb, void *opaque);
lscapi_rec *lscapi_conn_get_lsapi_handle(lsphp_conn_t *conn);
void *lscapi_conn_get_opaque(lsphp_conn_t *conn);

const char *lscapi_conn_get_socket_name(lsphp_conn_t *conn);
pid_t lscapi_conn_get_worker_pid(lsphp_conn_t *conn);

/* DEPRECATED */
void lscapi_lsphp_use_sock(lsphp_conn_t *conn, int sock, char *errbuf, unsigned errlen);

void lscapi_lsphp_use_sock_ext(lsphp_conn_t *conn, int sock, pid_t backend_pid, char *errbuf, unsigned errlen);

/* LSAPI_PRO_ONLY:BEGIN */
/*
  DEPRECATED
  For backward compatibility only.
  Updated with lscapi_receive_response_hdr
*/
int lscapi_receive_response_header(lsphp_conn_t *conn,
                                   lscapi_resphdr_info_t *hdrInfoPtr,
                                   unsigned *eventMaskPtr,
                                   char *errbuf, unsigned errlen);

/* LSAPI_PRO_ONLY:END */

/*
  DEPRECATED
  For backward compatibility only.
  Use lscapi_receive_resp_hdr and lscapi_free_resp_hdr instead
*/
int lscapi_receive_response_hdr(lsphp_conn_t *conn,
                                lscapi_resphdr_t *hdrInfoPtr,
                                unsigned *eventMaskPtr,
                                char *errbuf, unsigned errlen);

/*
    Use it instead of deprecated lscapi_receive_response_hdr
    to receive header of http response from backend.

    lscapi_free_resp_hdr should called to free allocated resources.
*/
int lscapi_receive_resp_hdr(lsphp_conn_t *conn,
                            lscapi_resp_hdr_t *rspHdr,
                            unsigned *eventMaskPtr,
                            char *errbuf, unsigned errlen);

void lscapi_free_resp_hdr(lsphp_conn_t *conn,
                          lscapi_resp_hdr_t *rspHdr);


int lscapi_receive_response_chunk(lsphp_conn_t *conn,
                                  char *buf, size_t *lenPtr,
                                  unsigned *eventMaskPtr,
                                  char *errbuf, unsigned errlen);

/* LSAPI_PRO_ONLY:BEGIN */
// lve.c
#ifndef WITHOUT_LVE
/**
 * load LVE library by dlopen and initialize it
 * args:
 * lve_alloc = pointer to function to allocate memory
 * lve_register = pointer to function to register allocated block
 * lve_user_data = user data for lve_alloc and lve_register calls
 * errbuf = buffer to store error description on error
 * errlen = length of the error buffer
 * return codes:
 * 0 = on success, -1 on error
 */
int lscapi_load_lve(lscapi_lve_alloc_t lve_alloc,
                    lscapi_lve_register_t lve_register,
                    void *lve_user_data,
                    char *errbuf, int errlen);

/**
 * check whether lscapi_load_lve was successfully called previously
 * return codes:
 * 1 = in case of success, 0 otherwise
 */
int lscapi_is_lve_loaded(void);
#endif
/* LSAPI_PRO_ONLY:END */

/*
    socket_path - sockets with patterns lsapi_*.sock in this directory will be deleted after stop of backends
*/
void lscapi_terminate_backends_ex(const char *socket_path);


/* LSAPI_PRO_ONLY:BEGIN */
#ifdef WITH_CRIU
/*
    socket_path - sockets matched to pattern lsapi_*.sock in this directory will be deleted after stop of backends
    criu_imgs_dir_path - subdirectories matched to pattern lsapi_*_criu_imgs in this directory will be deleted after stop of backends
*/
void lscapi_terminate_backends_criu(const char *socket_path, const char *criu_imgs_dir_path);
void lscapi_check_imgs_cleanup(const char *criu_imgs_dir_path);
#endif
/* LSAPI_PRO_ONLY:END */

void lscapi_sign_uidgid_md5(lscapi_rec *lscapi, const uint32_t ids[2],
                            const uint8_t salt[LSCAPI_SALT_SIZE],
                            unsigned char sign[32]);

void lscapi_sign_uidgid_sha1(lscapi_rec *lscapi, const uint32_t ids[2],
                             const uint8_t salt[LSCAPI_SALT_SIZE],
                             uint8_t sign[LSCAPI_SHA1_SIGN_SIZE]);

void lscapi_sign_string_sha1(lscapi_rec *lscapi, const char *to_sign,
                             const uint8_t salt[LSCAPI_SALT_SIZE],
                             uint8_t sign[LSCAPI_SHA1_SIGN_SIZE]);

void lscapi_encode_bytes(const uint8_t *bytes, size_t len, char *buf);

void lscapi_encode_sha1_sign_without_salt(const uint8_t sign[LSCAPI_SHA1_SIGN_SIZE], char *buf);

pid_t lscapi_spawn_backend(spawn_info_t *spawn_info, const spawn_context_t *spawn_context);

/* LSAPI_PRO_ONLY:BEGIN */
#ifdef WITH_CRIU
void lscapi_set_criu_socket_path(lscapi_rec *lscapi, char *criu_socket_path);
void lscapi_set_criu_imgs_dir_path(lscapi_rec *lscapi, char *criu_imgs_dir_path);

pid_t lscapi_restore(spawn_info_t *spawn_info);
int lscapi_prepare_dump(spawn_info_t *spawn_info);
int lscapi_finish_prepare_dump(spawn_info_t *spawn_info, pid_t pid);
int lscapi_dump(spawn_info_t *spawn_info);
int lscapi_prepare_me(void);
int lscapi_dump_me(void);

void set_spawn_info_criu_opts(spawn_info_t *spawn_info,
                              char *criu_socket_name,
                              char *criu_images_dir,
                              unsigned criu_backend_initial_start,
                              unsigned use_criu,
                              unsigned use_criu_debug,
                              unsigned use_criu_signals);

#endif //WITH_CRIU
/* LSAPI_PRO_ONLY:END */

#define LSCAPI_PROC_CREATE_EXPORTED
pid_t lscapi_proc_create(const char * const *args,
                         const char * const *env );


/*
#define PROFILE_ENABLED
#ifndef PROFILE_LOG
#define PROFILE_LOG
#endif
*/

#ifdef PROFILE_ENABLED

#include <sys/time.h>
#include <sys/resource.h>

extern __thread int PROFILE_counter;
extern char *PROFILE_margins[];
#ifdef PROFILE_LOG

#define PROFILE_START(pr) \
    static __thread struct timeval pr##_U##__LINE__, pr##_S##__LINE__; \
    static __thread int32_t pr##_CUMU##__LINE__, pr##_CUMS##__LINE__; \
    static __thread int pr##_CNT##__LINE__; \
    static __thread int pr##_ENTERED##__LINE__; \
do { \
    struct rusage ruse; \
    getrusage(RUSAGE_THREAD, &ruse); \
    pr##_U##__LINE__ = ruse.ru_utime; \
    pr##_S##__LINE__ = ruse.ru_stime; \
    (pr##_CNT##__LINE__)++; \
    if(!((pr##_CNT##__LINE__) % 100))  {  \
        fprintf(stderr, "%s%s.%d: " #pr ": ENTER\n", \
                PROFILE_margins[PROFILE_counter], __FUNCTION__, __LINE__ ); \
        PROFILE_counter++; \
        pr##_ENTERED##__LINE__ = 1; \
    } \
} while(0)

#define PROFILE_STOP(pr) do { \
    struct rusage ruse; \
    struct timeval res_utime, res_stime; \
    getrusage(RUSAGE_THREAD, &ruse); \
    timersub(&ruse.ru_utime, &(pr##_U##__LINE__), &res_utime); \
    timersub(&ruse.ru_stime, &(pr##_S##__LINE__), &res_stime); \
    pr##_CUMU##__LINE__ += res_utime.tv_sec * 1000000 + res_utime.tv_usec; \
    pr##_CUMS##__LINE__ += res_stime.tv_sec * 1000000 + res_stime.tv_usec; \
    if(pr##_ENTERED##__LINE__) { \
        pr##_ENTERED##__LINE__ = 0; \
        PROFILE_counter--; \
        double u = pr##_CUMU##__LINE__; u /= pr##_CNT##__LINE__; \
        double s = pr##_CUMS##__LINE__; s /= pr##_CNT##__LINE__; \
        fprintf(stderr, "%s%s.%d: " #pr ": u:%g; s:%g; cnt %d\n", \
                PROFILE_margins[PROFILE_counter], __FUNCTION__, __LINE__, u, s, pr##_CNT##__LINE__ ); \
    } \
} while(0)

#else // PROFILE_LOG

#define PROFILE_START(pr)
#define PROFILE_STOP(pr)

#endif // PROFILE_LOG

#else // PROFILE_ENABLED

#define PROFILE_START(pr)
#define PROFILE_STOP(pr)

#ifdef __clang__
#define ENVIRONMENT __environ
#else
#define ENVIRONMENT environ
#endif

#endif // PROFILE_ENABLED

#endif // _LSCAPI_H_

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 Jan 2024 2.16 PM
root / root
0755
arpa
--
20 Aug 2025 9.09 AM
root / root
0755
asm
--
28 Feb 2025 12.40 AM
root / root
0755
asm-generic
--
28 Feb 2025 12.40 AM
root / root
0755
bits
--
20 Aug 2025 9.09 AM
root / root
0755
bsock
--
25 Jan 2024 5.03 PM
root / root
0755
c++
--
21 Oct 2025 6.56 AM
root / root
0755
criu
--
25 Jan 2024 5.23 PM
root / root
0755
curl
--
21 Oct 2025 6.55 AM
root / root
0755
drm
--
28 Feb 2025 12.40 AM
root / root
0755
et
--
21 Oct 2025 6.55 AM
root / root
0755
finclude
--
20 Aug 2025 9.09 AM
root / root
0755
gdb
--
20 Aug 2025 9.09 AM
root / root
0755
gnu
--
20 Aug 2025 9.09 AM
root / root
0755
gssapi
--
21 Oct 2025 6.55 AM
root / root
0755
gssrpc
--
21 Oct 2025 6.55 AM
root / root
0755
kadm5
--
21 Oct 2025 6.55 AM
root / root
0755
krb5
--
21 Oct 2025 6.55 AM
root / root
0755
libxml2
--
17 Feb 2025 2.33 AM
root / root
0755
linux
--
28 Feb 2025 12.40 AM
root / root
0755
lzma
--
25 Jan 2024 5.18 PM
root / root
0755
misc
--
28 Feb 2025 12.40 AM
root / root
0755
mtd
--
28 Feb 2025 12.40 AM
root / root
0755
mysql
--
4 Jul 2024 10.38 PM
root / root
0755
net
--
20 Aug 2025 9.09 AM
root / root
0755
netash
--
20 Aug 2025 9.09 AM
root / root
0755
netatalk
--
20 Aug 2025 9.09 AM
root / root
0755
netax25
--
20 Aug 2025 9.09 AM
root / root
0755
neteconet
--
20 Aug 2025 9.09 AM
root / root
0755
netinet
--
20 Aug 2025 9.09 AM
root / root
0755
netipx
--
20 Aug 2025 9.09 AM
root / root
0755
netiucv
--
20 Aug 2025 9.09 AM
root / root
0755
netpacket
--
20 Aug 2025 9.09 AM
root / root
0755
netrom
--
20 Aug 2025 9.09 AM
root / root
0755
netrose
--
20 Aug 2025 9.09 AM
root / root
0755
nfs
--
20 Aug 2025 9.09 AM
root / root
0755
openssl
--
21 Oct 2025 6.55 AM
root / root
0755
perf
--
28 Feb 2025 12.40 AM
root / root
0755
protocols
--
20 Aug 2025 9.09 AM
root / root
0755
python2.7
--
28 Feb 2025 12.49 AM
root / root
0755
python3.6m
--
2 Apr 2025 8.03 AM
root / root
0755
python3.8
--
21 Oct 2025 6.55 AM
root / root
0755
rdma
--
28 Feb 2025 12.40 AM
root / root
0755
rpc
--
20 Aug 2025 9.09 AM
root / root
0755
scsi
--
20 Aug 2025 9.09 AM
root / root
0755
selinux
--
21 Oct 2025 6.55 AM
root / root
0755
sepol
--
21 Oct 2025 6.55 AM
root / root
0755
sound
--
28 Feb 2025 12.40 AM
root / root
0755
sys
--
20 Aug 2025 9.09 AM
root / root
0755
video
--
28 Feb 2025 12.40 AM
root / root
0755
xen
--
28 Feb 2025 12.40 AM
root / root
0755
GeoIP.h
17.417 KB
17 Jan 2018 7.23 PM
root / root
0644
GeoIPCity.h
2.244 KB
17 Jan 2018 7.23 PM
root / root
0644
a.out.h
4.248 KB
5 Aug 2025 2.01 PM
root / root
0644
aio.h
7.281 KB
5 Aug 2025 2.01 PM
root / root
0644
aliases.h
1.983 KB
5 Aug 2025 2.01 PM
root / root
0644
alloca.h
1.175 KB
5 Aug 2025 2.01 PM
root / root
0644
ar.h
1.689 KB
5 Aug 2025 2.01 PM
root / root
0644
argp.h
24.818 KB
5 Aug 2025 2.01 PM
root / root
0644
argz.h
5.908 KB
5 Aug 2025 2.01 PM
root / root
0644
assert.h
4.454 KB
5 Aug 2025 2.01 PM
root / root
0644
byteswap.h
1.371 KB
5 Aug 2025 2.01 PM
root / root
0644
com_err.h
2.068 KB
21 Mar 2020 4.24 AM
root / root
0644
complex.h
6.995 KB
5 Aug 2025 2.01 PM
root / root
0644
cpio.h
2.214 KB
5 Aug 2025 2.01 PM
root / root
0644
cpuidle.h
0.824 KB
10 Feb 2025 11.10 PM
root / root
0644
crypt.h
8.904 KB
9 Oct 2021 4.04 AM
root / root
0644
ctype.h
10.706 KB
5 Aug 2025 2.01 PM
root / root
0644
dirent.h
12.191 KB
5 Aug 2025 2.01 PM
root / root
0644
dlfcn.h
7.068 KB
5 Aug 2025 2.01 PM
root / root
0644
elf.h
170.73 KB
5 Aug 2025 2.01 PM
root / root
0644
endian.h
3.114 KB
5 Aug 2025 2.01 PM
root / root
0644
envz.h
2.799 KB
5 Aug 2025 2.01 PM
root / root
0644
err.h
2.157 KB
5 Aug 2025 2.01 PM
root / root
0644
errno.h
1.639 KB
5 Aug 2025 2.01 PM
root / root
0644
error.h
1.991 KB
5 Aug 2025 2.01 PM
root / root
0644
execinfo.h
1.486 KB
5 Aug 2025 2.01 PM
root / root
0644
fcntl.h
10.701 KB
5 Aug 2025 2.01 PM
root / root
0644
features.h
15.686 KB
5 Aug 2025 2.00 PM
root / root
0644
fenv.h
5.72 KB
5 Aug 2025 2.01 PM
root / root
0644
fmtmsg.h
3.163 KB
5 Aug 2025 2.01 PM
root / root
0644
fnmatch.h
2.241 KB
5 Aug 2025 2.01 PM
root / root
0644
fpu_control.h
3.499 KB
5 Aug 2025 2.01 PM
root / root
0644
fstab.h
3.038 KB
5 Aug 2025 2.01 PM
root / root
0644
fts.h
8.176 KB
5 Aug 2025 2.01 PM
root / root
0644
ftw.h
5.128 KB
5 Aug 2025 2.01 PM
root / root
0644
gconv.h
4.307 KB
5 Aug 2025 2.00 PM
root / root
0644
getopt.h
1.434 KB
5 Aug 2025 2.01 PM
root / root
0644
glob.h
6.459 KB
5 Aug 2025 2.01 PM
root / root
0644
gnu-versions.h
2.287 KB
5 Aug 2025 2.00 PM
root / root
0644
gnumake.h
2.844 KB
18 Apr 2022 4.38 PM
root / root
0644
grp.h
6.529 KB
5 Aug 2025 2.01 PM
root / root
0644
gshadow.h
4.422 KB
5 Aug 2025 2.01 PM
root / root
0644
gssapi.h
0.177 KB
5 Nov 2024 2.15 AM
root / root
0644
iconv.h
1.813 KB
5 Aug 2025 2.00 PM
root / root
0644
ieee754.h
4.795 KB
5 Aug 2025 2.01 PM
root / root
0644
ifaddrs.h
2.773 KB
5 Aug 2025 2.01 PM
root / root
0644
inttypes.h
11.613 KB
5 Aug 2025 2.01 PM
root / root
0644
kdb.h
67.661 KB
5 Nov 2024 2.15 AM
root / root
0644
keyutils.h
7.518 KB
8 Oct 2021 1.50 PM
root / root
0644
krad.h
8.724 KB
5 Nov 2024 2.15 AM
root / root
0644
krb5.h
0.393 KB
5 Nov 2024 2.15 AM
root / root
0644
langinfo.h
17.43 KB
5 Aug 2025 2.00 PM
root / root
0644
lastlog.h
0.123 KB
5 Aug 2025 2.01 PM
root / root
0644
lauxlib.h
8.426 KB
9 Oct 2021 5.14 AM
root / root
0644
libgen.h
1.353 KB
5 Aug 2025 2.01 PM
root / root
0644
libintl.h
4.472 KB
5 Aug 2025 2.01 PM
root / root
0644
liblsapi-sha1.h
0.556 KB
2 Dec 2024 11.13 AM
root / root
0644
limits.h
5.285 KB
5 Aug 2025 2.00 PM
root / root
0644
link.h
7.049 KB
5 Aug 2025 2.01 PM
root / root
0644
locale.h
7.494 KB
5 Aug 2025 2.00 PM
root / root
0644
lsapidef.h
4.604 KB
2 Dec 2024 11.13 AM
root / root
0644
lscapi.h
24.154 KB
2 Dec 2024 11.13 AM
root / root
0644
lscapi_config.h
0.585 KB
2 Dec 2024 11.13 AM
root / root
0644
lua.h
14.485 KB
9 Oct 2021 5.14 AM
root / root
0644
lua.hpp
0.187 KB
9 Oct 2021 5.14 AM
root / root
0644
luaconf-x86_64.h
21.107 KB
9 Oct 2021 5.14 AM
root / root
0644
luaconf.h
1.616 KB
18 Aug 2021 1.25 PM
root / root
0644
lualib.h
1.271 KB
9 Oct 2021 5.14 AM
root / root
0644
lzma.h
9.587 KB
29 Apr 2018 3.10 PM
root / root
0644
malloc.h
5.959 KB
5 Aug 2025 2.01 PM
root / root
0644
math.h
52.068 KB
5 Aug 2025 2.01 PM
root / root
0644
mcheck.h
2.377 KB
5 Aug 2025 2.01 PM
root / root
0644
memory.h
0.933 KB
5 Aug 2025 2.01 PM
root / root
0644
mntent.h
3.279 KB
5 Aug 2025 2.01 PM
root / root
0644
monetary.h
1.761 KB
5 Aug 2025 2.01 PM
root / root
0644
mqueue.h
3.671 KB
5 Aug 2025 2.01 PM
root / root
0644
netdb.h
27.44 KB
5 Aug 2025 2.01 PM
root / root
0644
nl_types.h
1.711 KB
5 Aug 2025 2.01 PM
root / root
0644
nss.h
1.834 KB
5 Aug 2025 2.01 PM
root / root
0644
obstack.h
20.807 KB
5 Aug 2025 2.01 PM
root / root
0644
paths.h
2.907 KB
5 Aug 2025 2.01 PM
root / root
0644
pcre2.h
43.752 KB
2 Aug 2022 4.07 PM
root / root
0644
pcre2posix.h
5.668 KB
2 Aug 2022 4.07 PM
root / root
0644
poll.h
0.021 KB
5 Aug 2025 2.01 PM
root / root
0644
printf.h
6.641 KB
5 Aug 2025 2.01 PM
root / root
0644
proc_service.h
3.395 KB
5 Aug 2025 2.01 PM
root / root
0644
profile.h
11.869 KB
5 Nov 2024 2.15 AM
root / root
0644
pthread.h
40.302 KB
5 Aug 2025 2.01 PM
root / root
0644
pty.h
1.532 KB
5 Aug 2025 2.01 PM
root / root
0644
pwd.h
6.014 KB
5 Aug 2025 2.01 PM
root / root
0644
re_comp.h
0.939 KB
5 Aug 2025 2.01 PM
root / root
0644
regex.h
24.136 KB
5 Aug 2025 2.01 PM
root / root
0644
regexp.h
1.413 KB
5 Aug 2025 2.01 PM
root / root
0644
resolv.h
11.868 KB
5 Aug 2025 2.01 PM
root / root
0644
sched.h
4.621 KB
5 Aug 2025 2.01 PM
root / root
0644
search.h
5.101 KB
5 Aug 2025 2.01 PM
root / root
0644
semaphore.h
2.343 KB
5 Aug 2025 2.01 PM
root / root
0644
setjmp.h
3.583 KB
5 Aug 2025 2.01 PM
root / root
0644
sgtty.h
1.312 KB
5 Aug 2025 2.01 PM
root / root
0644
shadow.h
5.343 KB
5 Aug 2025 2.01 PM
root / root
0644
signal.h
11.956 KB
5 Aug 2025 2.01 PM
root / root
0644
spawn.h
6.533 KB
5 Aug 2025 2.01 PM
root / root
0644
stab.h
0.258 KB
5 Aug 2025 2.01 PM
root / root
0644
stdc-predef.h
2.235 KB
5 Aug 2025 2.00 PM
root / root
0644
stdint.h
8.271 KB
5 Aug 2025 2.01 PM
root / root
0644
stdio.h
29.461 KB
5 Aug 2025 2.01 PM
root / root
0644
stdio_ext.h
2.733 KB
5 Aug 2025 2.01 PM
root / root
0644
stdlib.h
34.817 KB
5 Aug 2025 2.01 PM
root / root
0644
string.h
17.175 KB
5 Aug 2025 2.01 PM
root / root
0644
strings.h
4.641 KB
5 Aug 2025 2.01 PM
root / root
0644
syscall.h
0.024 KB
5 Aug 2025 2.01 PM
root / root
0644
sysexits.h
5.109 KB
5 Aug 2025 2.01 PM
root / root
0644
syslog.h
0.023 KB
5 Aug 2025 2.01 PM
root / root
0644
tar.h
3.696 KB
5 Aug 2025 2.01 PM
root / root
0644
termio.h
0.209 KB
5 Aug 2025 2.01 PM
root / root
0644
termios.h
3.514 KB
5 Aug 2025 2.01 PM
root / root
0644
tgmath.h
30.751 KB
5 Aug 2025 2.01 PM
root / root
0644
thread_db.h
15.647 KB
5 Aug 2025 2.01 PM
root / root
0644
threads.h
6.499 KB
5 Aug 2025 2.01 PM
root / root
0644
time.h
10.117 KB
5 Aug 2025 2.01 PM
root / root
0644
ttyent.h
2.436 KB
5 Aug 2025 2.01 PM
root / root
0644
uchar.h
1.954 KB
5 Aug 2025 2.01 PM
root / root
0644
ucontext.h
1.988 KB
5 Aug 2025 2.01 PM
root / root
0644
ulimit.h
1.546 KB
5 Aug 2025 2.01 PM
root / root
0644
unistd.h
41.736 KB
5 Aug 2025 2.01 PM
root / root
0644
utime.h
1.466 KB
5 Aug 2025 2.01 PM
root / root
0644
utmp.h
3.146 KB
5 Aug 2025 2.01 PM
root / root
0644
utmpx.h
4.003 KB
5 Aug 2025 2.01 PM
root / root
0644
values.h
1.909 KB
5 Aug 2025 2.00 PM
root / root
0644
verto-module.h
6.484 KB
8 Oct 2022 7.49 AM
root / root
0644
verto.h
18.981 KB
8 Oct 2022 7.49 AM
root / root
0644
wait.h
0.021 KB
5 Aug 2025 2.01 PM
root / root
0644
wchar.h
30.382 KB
5 Aug 2025 2.01 PM
root / root
0644
wctype.h
5.418 KB
5 Aug 2025 2.01 PM
root / root
0644
wordexp.h
2.442 KB
5 Aug 2025 2.01 PM
root / root
0644
zconf.h
15.881 KB
11 Oct 2023 10.02 PM
root / root
0644
zlib.h
94.005 KB
11 Oct 2023 10.02 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF