本文整理汇总了C++中pr_log_writefile函数的典型用法代码示例。如果您正苦于以下问题:C++ pr_log_writefile函数的具体用法?C++ pr_log_writefile怎么用?C++ pr_log_writefile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pr_log_writefile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snmp_stacktrace_log
void snmp_stacktrace_log(void) {
#if defined(HAVE_EXECINFO_H) && \
defined(HAVE_BACKTRACE) && \
defined(HAVE_BACKTRACE_SYMBOLS)
void *trace[PR_TUNABLE_CALLER_DEPTH];
char **strings;
size_t tracesz;
(void) pr_log_writefile(snmp_logfd, MOD_SNMP_VERSION,
"-----BEGIN STACK TRACE-----");
tracesz = backtrace(trace, PR_TUNABLE_CALLER_DEPTH);
strings = backtrace_symbols(trace, tracesz);
if (strings != NULL) {
register unsigned int i;
for (i = 1; i < tracesz; i++) {
(void) pr_log_writefile(snmp_logfd, MOD_SNMP_VERSION,
"[%u] %s", i-1, strings[i]);
}
/* Prevent memory leaks. */
free(strings);
} else {
(void) pr_log_writefile(snmp_logfd, MOD_SNMP_VERSION,
"error obtaining stacktrace symbols: %s", strerror(errno));
}
(void) pr_log_writefile(snmp_logfd, MOD_SNMP_VERSION,
"-----END STACK TRACE-----");
#endif
}
示例2: forward_handle_pass_passthru
static int forward_handle_pass_passthru(cmd_rec *cmd,
struct proxy_session *proxy_sess, int *successful) {
int res, xerrno;
pr_response_t *resp;
unsigned int resp_nlines = 0;
res = proxy_ftp_ctrl_send_cmd(cmd->tmp_pool, proxy_sess->backend_ctrl_conn,
cmd);
if (res < 0) {
xerrno = errno;
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"error sending %s to backend: %s", (char *) cmd->argv[0],
strerror(xerrno));
errno = xerrno;
return -1;
}
resp = proxy_ftp_ctrl_recv_resp(cmd->tmp_pool, proxy_sess->backend_ctrl_conn,
&resp_nlines);
if (resp == NULL) {
xerrno = errno;
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"error receiving %s response from backend: %s", (char *) cmd->argv[0],
strerror(xerrno));
/* If we receive an EPERM here, it is probably because the backend
* closed its control connection, yielding an EOF. To better indicate
* this situation, propagate the error using EPIPE.
*/
if (xerrno == EPERM) {
xerrno = EPIPE;
}
errno = xerrno;
return -1;
}
/* XXX What about other response codes for PASS? */
if (resp->num[0] == '2') {
*successful = TRUE;
proxy_sess_state |= PROXY_SESS_STATE_BACKEND_AUTHENTICATED;
}
res = proxy_ftp_ctrl_send_resp(cmd->tmp_pool, proxy_sess->frontend_ctrl_conn,
resp, resp_nlines);
if (res < 0) {
xerrno = errno;
pr_response_block(TRUE);
errno = xerrno;
return -1;
}
return 1;
}
示例3: filestore_verify_host_key
static int filestore_verify_host_key(sftp_keystore_t *store, pool *p,
const char *user, const char *host_fqdn, const char *host_user,
unsigned char *key_data, uint32_t key_len) {
struct filestore_key *key = NULL;
struct filestore_data *store_data = store->keystore_data;
int res = -1;
if (!store_data->path) {
errno = EPERM;
return -1;
}
/* XXX Note that this will scan the file from the beginning, each time.
* There's room for improvement; perhaps mmap() the file into memory?
*/
key = filestore_get_key(store, p);
while (key) {
int ok;
pr_signals_handle();
ok = sftp_keys_compare_keys(p, key_data, key_len, key->key_data,
key->key_datalen);
if (ok != TRUE) {
if (ok == -1) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error comparing keys from '%s': %s", store_data->path,
strerror(errno));
}
} else {
/* XXX Verify that the user and the host_user match?? */
res = 0;
break;
}
key = filestore_get_key(store, p);
}
if (res == 0) {
pr_trace_msg(trace_channel, 10, "found matching public key for host '%s' "
"in '%s'", host_fqdn, store_data->path);
}
if (pr_fsio_lseek(store_data->fh, 0, SEEK_SET) < 0) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error seeking to start of '%s': %s", store_data->path, strerror(errno));
return -1;
}
store_data->lineno = 0;
return res;
}
示例4: counter_get_sem
static int counter_get_sem(pr_fh_t *fh, const char *path) {
int semid;
key_t key;
/* Obtain a key for this path. */
key = counter_get_key(path);
if (key == (key_t) -1) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"unable to get key for '%s': %s", path, strerror(errno));
return -1;
}
/* Try first using IPC_CREAT|IPC_EXCL, to check if there is an existing
* semaphore set for this key. If there is, try again, using a flag of
* zero.
*/
semid = semget(key, COUNTER_NSEMS, IPC_CREAT|IPC_EXCL|0666);
if (semid < 0) {
if (errno == EEXIST) {
semid = semget(key, 0, 0);
} else {
return -1;
}
} else {
/* Set the values of the newly created semaphore to the configured
* CounterMaxReaders and CounterMaxWriters.
*/
if (counter_set_readers(semid) < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"error setting readers (semaphore ID %d): %s", semid, strerror(errno));
}
if (counter_set_writers(semid) < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"error setting writers (semaphore ID %d): %s", semid, strerror(errno));
}
if (counter_set_procs(semid) < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"error setting procs (semaphore ID %d): %s", semid, strerror(errno));
}
/* Record the ID of the created semaphore in the CounterFile. */
if (counter_file_add_id(fh, semid) < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"error recording semaphore (semaphore ID %d) in CounterFile '%s': %s",
semid, fh->fh_path, strerror(errno));
}
}
return semid;
}
示例5: sftp_cipher_write_data
int sftp_cipher_write_data(struct ssh2_packet *pkt, unsigned char *buf,
size_t *buflen) {
struct sftp_cipher *cipher;
EVP_CIPHER_CTX *cipher_ctx;
cipher = &(write_ciphers[write_cipher_idx]);
cipher_ctx = write_ctxs[write_cipher_idx];
if (cipher->key) {
int res;
unsigned char *data, *ptr;
uint32_t datalen, datasz = sizeof(uint32_t) + pkt->packet_len;
datalen = datasz;
ptr = data = palloc(pkt->pool, datasz);
sftp_msg_write_int(&data, &datalen, pkt->packet_len);
sftp_msg_write_byte(&data, &datalen, pkt->padding_len);
sftp_msg_write_data(&data, &datalen, pkt->payload, pkt->payload_len, FALSE);
sftp_msg_write_data(&data, &datalen, pkt->padding, pkt->padding_len, FALSE);
res = EVP_Cipher(cipher_ctx, buf, ptr, (datasz - datalen));
if (res != 1) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error encrypting %s data for client: %s", cipher->algo,
sftp_crypto_get_errors());
errno = EIO;
return -1;
}
*buflen = (datasz - datalen);
#ifdef SFTP_DEBUG_PACKET
{
unsigned int i;
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"encrypted packet data (len %lu):", (unsigned long) *buflen);
for (i = 0; i < *buflen;) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
" %02x%02x %02x%02x %02x%02x %02x%02x",
((unsigned char *) buf)[i], ((unsigned char *) buf)[i+1],
((unsigned char *) buf)[i+2], ((unsigned char *) buf)[i+3],
((unsigned char *) buf)[i+4], ((unsigned char *) buf)[i+5],
((unsigned char *) buf)[i+6], ((unsigned char *) buf)[i+7]);
i += 8;
}
}
#endif
return 0;
}
*buflen = 0;
return 0;
}
示例6: proxy_forward_sess_init
int proxy_forward_sess_init(pool *p, const char *tables_dir,
struct proxy_session *proxy_sess) {
config_rec *c;
int allowed = FALSE;
void *enabled = NULL;
/* By default, only allow connections from RFC1918 addresses to use
* forward proxying. Otherwise, it must be from an explicitly allowed
* connection class, via the class notes.
*/
if (session.conn_class != NULL) {
enabled = pr_table_get(session.conn_class->cls_notes,
PROXY_FORWARD_ENABLED_NOTE, NULL);
}
if (enabled != NULL) {
allowed = *((int *) enabled);
if (allowed == FALSE) {
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"forward proxying not allowed from client address %s in <Class %s> "
"(see ProxyForwardEnabled)",
pr_netaddr_get_ipstr(session.c->remote_addr),
session.conn_class->cls_name);
}
} else {
if (pr_netaddr_is_rfc1918(session.c->remote_addr) == TRUE) {
allowed = TRUE;
} else {
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"forward proxying not allowed from non-RFC1918 client address %s",
pr_netaddr_get_ipstr(session.c->remote_addr));
}
}
if (allowed == FALSE) {
errno = EPERM;
return -1;
}
c = find_config(main_server->conf, CONF_PARAM, "ProxyForwardMethod", FALSE);
if (c != NULL) {
proxy_method = *((int *) c->argv[0]);
}
c = find_config(main_server->conf, CONF_PARAM, "ProxyRetryCount", FALSE);
if (c != NULL) {
forward_retry_count = *((int *) c->argv[0]);
}
return 0;
}
示例7: sftp_cipher_read_data
int sftp_cipher_read_data(pool *p, unsigned char *data, uint32_t data_len,
unsigned char **buf, uint32_t *buflen) {
struct sftp_cipher *cipher;
EVP_CIPHER_CTX *cipher_ctx;
size_t cipher_blocksz;
cipher = &(read_ciphers[read_cipher_idx]);
cipher_ctx = read_ctxs[read_cipher_idx];
cipher_blocksz = cipher_blockszs[read_cipher_idx];
if (cipher->key) {
int res;
unsigned char *ptr = NULL;
size_t bufsz;
if (*buflen % cipher_blocksz != 0) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"bad input length for decryption (%u bytes, %u block size)", *buflen,
(unsigned int) cipher_blocksz);
return -1;
}
if (*buf == NULL) {
/* Allocate a buffer that's large enough. */
bufsz = (data_len + cipher_blocksz - 1);
ptr = palloc(p, bufsz);
} else {
ptr = *buf;
}
res = EVP_Cipher(cipher_ctx, ptr, data, data_len);
if (res != 1) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error decrypting %s data from client: %s", cipher->algo,
sftp_crypto_get_errors());
return -1;
}
*buflen = data_len;
*buf = ptr;
return 0;
}
*buf = data;
*buflen = data_len;
return 0;
}
示例8: counter_writer_done
MODRET counter_writer_done(cmd_rec *cmd) {
pr_fh_t *fh;
if (counter_engine == FALSE) {
return PR_DECLINED(cmd);
}
if (!(counter_pending & COUNTER_HAVE_WRITER)) {
return PR_DECLINED(cmd);
}
fh = counter_get_fh(cmd->tmp_pool, counter_curr_path);
if (fh == NULL) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"%s: no CounterFile found for path '%s'", (char *) cmd->argv[0],
counter_curr_path);
/* No CounterFile configured/available for this path. */
return PR_DECLINED(cmd);
}
if (counter_curr_semid == -1) {
counter_curr_semid = counter_get_sem(fh, counter_curr_path);
if (counter_curr_semid < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"unable to get semaphore for '%s': %s", counter_curr_path,
strerror(errno));
return PR_DECLINED(cmd);
}
}
if (counter_remove_writer(fh, counter_curr_semid) < 0) {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"error removing writer for '%s': %s", counter_curr_path,
strerror(errno));
} else {
(void) pr_log_writefile(counter_logfd, MOD_COUNTER_VERSION,
"removed writer counter for '%s' (semaphore ID %d)", counter_curr_path,
counter_curr_semid);
counter_curr_path = NULL;
counter_curr_semid = -1;
counter_pending &= ~COUNTER_HAVE_WRITER;
}
return PR_DECLINED(cmd);
}
示例9: proxy_session_check_password
int proxy_session_check_password(pool *p, const char *user,
const char *passwd) {
int res;
res = pr_auth_authenticate(p, user, passwd);
switch (res) {
case PR_AUTH_OK:
break;
case PR_AUTH_NOPWD:
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"password authentication for user '%s' failed: No such user", user);
pr_log_auth(PR_LOG_NOTICE, "USER %s (Login failed): No such user found",
user);
return -1;
case PR_AUTH_BADPWD:
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"password authentication for user '%s' failed: Incorrect password",
user);
pr_log_auth(PR_LOG_NOTICE, "USER %s (Login failed): Incorrect password",
user);
return -1;
case PR_AUTH_AGEPWD:
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"password authentication for user '%s' failed: Password expired",
user);
pr_log_auth(PR_LOG_NOTICE, "USER %s (Login failed): Password expired",
user);
return -1;
case PR_AUTH_DISABLEDPWD:
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"password authentication for user '%s' failed: Account disabled",
user);
pr_log_auth(PR_LOG_NOTICE, "USER %s (Login failed): Account disabled",
user);
return -1;
default:
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"unknown authentication value (%d), returning error", res);
return -1;
}
return 0;
}
示例10: sftp_compress_init_read
int sftp_compress_init_read(int flags) {
struct sftp_compress *comp;
z_stream *stream;
switch_read_compress(flags);
comp = &(read_compresses[read_comp_idx]);
stream = &(read_streams[read_comp_idx]);
if (comp->use_zlib == flags &&
!comp->stream_ready) {
int zres;
zres = inflateInit(stream);
if (zres != Z_OK) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error preparing decompression stream (%d)", zres);
}
pr_event_generate("mod_sftp.ssh.client-compression", NULL);
comp->stream_ready = TRUE;
}
return 0;
}
示例11: read_service_req
static int read_service_req(struct ssh2_packet *pkt, char **service) {
unsigned char *buf;
char *service_name;
uint32_t buflen;
cmd_rec *cmd;
buf = pkt->payload;
buflen = pkt->payload_len;
service_name = sftp_msg_read_string(pkt->pool, &buf, &buflen);
pr_trace_msg(trace_channel, 10, "'%s' service requested", service_name);
cmd = pr_cmd_alloc(pkt->pool, 1, pstrdup(pkt->pool, "SERVICE_REQUEST"));
cmd->arg = service_name;
cmd->cmd_class = CL_MISC|CL_SSH;
if (strncmp(service_name, "ssh-userauth", 13) == 0 ||
strncmp(service_name, "ssh-connection", 14) == 0) {
if (service)
*service = pstrdup(service_pool, service_name);
pr_cmd_dispatch_phase(cmd, LOG_CMD, 0);
return 0;
}
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"client requested unsupported '%s' service", service_name);
pr_cmd_dispatch_phase(cmd, LOG_CMD_ERR, 0);
return -1;
}
示例12: vroot_fsio_rmdir
int vroot_fsio_rmdir(pr_fs_t *fs, const char *path) {
char vpath[PR_TUNABLE_PATH_MAX + 1];
if (session.curr_phase == LOG_CMD ||
session.curr_phase == LOG_CMD_ERR ||
(session.sf_flags & SF_ABORT) ||
vroot_path_have_base() == FALSE) {
/* NOTE: once stackable FS modules are supported, have this fall through
* to the next module in the stack.
*/
return rmdir(path);
}
/* Do not allow deleting of aliased files/directories; the aliases may only
* exist for this user/group.
*/
if (vroot_path_lookup(NULL, vpath, sizeof(vpath)-1, path,
VROOT_LOOKUP_FL_NO_ALIAS, NULL) < 0) {
return -1;
}
if (vroot_alias_exists(vpath) == TRUE) {
(void) pr_log_writefile(vroot_logfd, MOD_VROOT_VERSION,
"denying delete of '%s' because it is a VRootAlias", vpath);
errno = EACCES;
return -1;
}
if (vroot_path_lookup(NULL, vpath, sizeof(vpath)-1, path, 0, NULL) < 0) {
return -1;
}
return rmdir(vpath);
}
示例13: send_pubkey_ok
static int send_pubkey_ok(const char *algo, const char *pubkey_data,
uint32_t pubkey_len) {
struct ssh2_packet *pkt;
char *buf, *ptr;
uint32_t buflen, bufsz;
int res;
/* Make sure to allocate a buffer large enough to hold the publickey
* data we're sending back.
*/
bufsz = buflen = pubkey_len + 1024;
pkt = sftp_ssh2_packet_create(sftp_pool);
buflen = bufsz;
ptr = buf = palloc(pkt->pool, bufsz);
sftp_msg_write_byte(&buf, &buflen, SFTP_SSH2_MSG_USER_AUTH_PK_OK);
sftp_msg_write_string(&buf, &buflen, algo);
sftp_msg_write_data(&buf, &buflen, pubkey_data, pubkey_len, TRUE);
pkt->payload = ptr;
pkt->payload_len = (bufsz - buflen);
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION, "sending publickey OK");
res = sftp_ssh2_packet_write(sftp_conn->wfd, pkt);
if (res < 0) {
destroy_pool(pkt->pool);
return -1;
}
destroy_pool(pkt->pool);
return 0;
}
示例14: log_failure_mkjson
static void log_failure_mkjson(void *json, const char *field_name,
size_t field_namelen, unsigned int field_type, const void *field_value) {
JsonNode *field = NULL;
switch (field_type) {
case LOG_FAILURE_FIELD_TYPE_STRING:
field = json_mkstring((const char *) field_value);
break;
case LOG_FAILURE_FIELD_TYPE_NUMBER:
field = json_mknumber(*((double *) field_value));
break;
case LOG_FAILURE_FIELD_TYPE_BOOLEAN:
field = json_mkbool(*((bool *) field_value));
break;
default:
(void) pr_log_writefile(log_failure_logfd, MOD_LOG_FAILURE_VERSION,
"unsupported field type: %u", field_type);
}
if (field != NULL) {
json_append_member(json, field_name, field);
}
}
示例15: proxy_db_init
int proxy_db_init(pool *p) {
const char *version;
if (p == NULL) {
errno = EINVAL;
return -1;
}
if (db_pool != NULL) {
return 0;
}
/* Check that the SQLite headers used match the version of the SQLite
* library used.
*
* For now, we only log if there is a difference.
*/
version = sqlite3_libversion();
if (strcmp(version, SQLITE_VERSION) != 0) {
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"compiled using SQLite version '%s' headers, but linked to "
"SQLite version '%s' library", SQLITE_VERSION, version);
}
pr_trace_msg(trace_channel, 9, "using SQLite %s", version);
db_pool = make_sub_pool(p);
pr_pool_tag(db_pool, "Proxy Database Pool");
return 0;
}