static bool auth_worker_handle_line(struct auth_worker_client *client, const char *line) { const char *const *args; unsigned int id; bool ret = FALSE; args = t_strsplit(line, "\t"); if (args[0] == NULL || args[1] == NULL || args[2] == NULL || str_to_uint(args[0], &id) < 0) { i_error("BUG: Invalid input: %s", line); return FALSE; } if (strcmp(args[1], "PASSV") == 0) ret = auth_worker_handle_passv(client, id, args + 2); else if (strcmp(args[1], "PASSL") == 0) ret = auth_worker_handle_passl(client, id, args + 2); else if (strcmp(args[1], "SETCRED") == 0) ret = auth_worker_handle_setcred(client, id, args + 2); else if (strcmp(args[1], "USER") == 0) ret = auth_worker_handle_user(client, id, args + 2); else if (strcmp(args[1], "LIST") == 0) ret = auth_worker_handle_list(client, id, args + 2); else { i_error("BUG: Auth-worker received unknown command: %s", args[1]); } return ret; }
static int auth_server_connection_input_line(struct auth_server_connection *conn, const char *line) { const char *const *args; if (conn->client->debug) i_debug("auth input: %s", line); args = t_strsplit(line, "\t"); if (args[0] == NULL) { i_error("Auth server sent empty line"); return -1; } if (strcmp(args[0], "OK") == 0) return auth_server_input_ok(conn, args + 1); else if (strcmp(args[0], "CONT") == 0) return auth_server_input_cont(conn, args + 1); else if (strcmp(args[0], "FAIL") == 0) return auth_server_input_fail(conn, args + 1); else if (strcmp(args[0], "MECH") == 0) return auth_server_input_mech(conn, args + 1); else if (strcmp(args[0], "SPID") == 0) return auth_server_input_spid(conn, args + 1); else if (strcmp(args[0], "CUID") == 0) return auth_server_input_cuid(conn, args + 1); else if (strcmp(args[0], "COOKIE") == 0) return auth_server_input_cookie(conn, args + 1); else if (strcmp(args[0], "DONE") == 0) return auth_server_input_done(conn); else { i_error("Auth server sent unknown command: %s", args[0]); return -1; } }
int cmd_mail(struct client *client, const char *args) { const char *addr, *const *argv; if (client->state.mail_from != NULL) { client_send_line(client, "503 5.5.1 MAIL already given"); return 0; } if (strncasecmp(args, "FROM:", 5) != 0 || parse_address(args + 5, &addr, &args) < 0) { client_send_line(client, "501 5.5.4 Invalid parameters"); return 0; } argv = t_strsplit(args, " "); for (; *argv != NULL; argv++) { if (strcasecmp(*argv, "BODY=7BIT") == 0) client->state.mail_body_7bit = TRUE; else if (strcasecmp(*argv, "BODY=8BITMIME") == 0) client->state.mail_body_8bitmime = TRUE; else { client_send_line(client, "501 5.5.4 Unsupported options"); return 0; } } client->state.mail_from = p_strdup(client->state_pool, addr); p_array_init(&client->state.rcpt_to, client->state_pool, 64); client_send_line(client, "250 2.1.0 OK"); client_state_set(client, "MAIL FROM"); return 0; }
void dsync_brain_send_mailbox_tree(struct dsync_brain *brain) { struct dsync_mailbox_node *node; enum dsync_ibc_send_ret ret; const char *full_name; char sep[2]; sep[0] = brain->hierarchy_sep; sep[1] = '\0'; while (dsync_mailbox_tree_iter_next(brain->local_tree_iter, &full_name, &node)) { T_BEGIN { const char *const *parts; if (brain->debug) { i_debug("brain %c: Local mailbox tree: %s %s", brain->master_brain ? 'M' : 'S', full_name, dsync_mailbox_node_to_string(node)); } parts = t_strsplit(full_name, sep); ret = dsync_ibc_send_mailbox_tree_node(brain->ibc, parts, node); } T_END; if (ret == DSYNC_IBC_SEND_RET_FULL) return; } dsync_mailbox_tree_iter_deinit(&brain->local_tree_iter); dsync_ibc_send_end_of_list(brain->ibc, DSYNC_IBC_EOL_MAILBOX_TREE); brain->state = DSYNC_STATE_SEND_MAILBOX_TREE_DELETES; }
static struct userdb_module * userdb_nss_preinit(pool_t pool, const char *args) { struct nss_userdb_module *module; const char *const *tmp; module = p_new(pool, struct nss_userdb_module, 1); module->bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); module->buf = p_malloc(pool, module->bufsize); module->module.blocking = TRUE; for (tmp = t_strsplit(args, " "); *tmp != NULL; tmp++) { if (strcmp(*tmp, "blocking=no") == 0) module->module.blocking = FALSE; else if (strncmp(*tmp, "service=", 8) == 0) module->nss_module.name = p_strdup(pool, *tmp + 8); else i_fatal("userdb nss: Unknown setting: %s", *tmp); } if (module->nss_module.name == NULL) i_fatal("userdb nss: Missing service"); userdb_nss_load_module(module, pool); module->module.cache_key = USER_CACHE_KEY; return &module->module; }
static void checkpassword_request_finish(struct chkpw_auth_request *request, enum userdb_result result) { struct userdb_module *_module = request->request->userdb->userdb; struct checkpassword_userdb_module *module = (struct checkpassword_userdb_module *)_module; userdb_callback_t *callback = (userdb_callback_t *)request->callback; hash_table_remove(module->clients, POINTER_CAST(request->pid)); if (result == USERDB_RESULT_OK) { if (strchr(str_c(request->input_buf), '\n') != NULL) { auth_request_log_error(request->request, "userdb-checkpassword", "LF characters in checkpassword reply"); result = USERDB_RESULT_INTERNAL_FAILURE; } else { auth_request_init_userdb_reply(request->request); auth_request_set_fields(request->request, t_strsplit(str_c(request->input_buf), "\t"), NULL); } } callback(result, request->request); auth_request_unref(&request->request); checkpassword_request_free(request); }
static void ATTR_NORETURN checkpassword_lookup_child(struct auth_request *request, struct checkpassword_userdb_module *module, int fd_in, int fd_out) { const char *cmd, *const *args; if (dup2(fd_out, 3) < 0 || dup2(fd_in, 4) < 0) { auth_request_log_error(request, "userdb-checkpassword", "dup2() failed: %m"); } else { /* We want to retrieve user data and don't do authorization, so we need to signalize the checkpassword program that the password shall be ignored by setting AUTHORIZED. This needs a special checkpassword program which knows how to handle this. */ env_put("AUTHORIZED=1"); checkpassword_setup_env(request); cmd = checkpassword_get_cmd(request, module->checkpassword_path, module->checkpassword_reply_path); auth_request_log_debug(request, "userdb-checkpassword", "execute: %s", cmd); /* very simple argument splitting. */ args = t_strsplit(cmd, " "); execv_const(args[0], args); } exit(2); }
static bool dsync_mailbox_info_is_excluded(const struct mailbox_info *info, const char *const *exclude_mailboxes) { const char *const *info_specialuses; unsigned int i; if (exclude_mailboxes == NULL) return FALSE; info_specialuses = info->special_use == NULL ? NULL : t_strsplit(info->special_use, " "); for (i = 0; exclude_mailboxes[i] != NULL; i++) { const char *exclude = exclude_mailboxes[i]; if (exclude[0] == '\\') { /* special-use */ if (info_specialuses != NULL && str_array_icase_find(info_specialuses, exclude)) return TRUE; } else { /* mailbox with wildcards */ if (wildcard_match(info->vname, exclude)) return TRUE; } } return FALSE; }
static bool module_check_wrong_binary_dependency(const struct module_dir_load_settings *set, struct module *module, const char **error_r) { const char *symbol_name, *binary_dep, *const *names; string_t *errstr; if (set->binary_name == NULL) return TRUE; symbol_name = t_strconcat(module->name, "_binary_dependency", NULL); binary_dep = dlsym(module->handle, symbol_name); if (binary_dep == NULL) return TRUE; names = t_strsplit(binary_dep, " "); if (str_array_find(names, set->binary_name)) return TRUE; errstr = t_str_new(128); str_printfa(errstr, "Can't load plugin %s: " "Plugin is intended to be used only by ", module->name); if (names[1] == NULL) str_printfa(errstr, "%s binary", binary_dep); else str_printfa(errstr, "binaries: %s", binary_dep); str_printfa(errstr, " (we're %s)", set->binary_name); *error_r = str_c(errstr); return FALSE; }
static void mbox_read_lock_methods(const char *str, const char *env, enum mbox_lock_type *locks) { enum mbox_lock_type type; const char *const *lock; int i, dest; for (lock = t_strsplit(str, " "), dest = 0; *lock != NULL; lock++) { for (type = 0; lock_data[type].name != NULL; type++) { if (strcasecmp(*lock, lock_data[type].name) == 0) { type = lock_data[type].type; break; } } if (lock_data[type].name == NULL) i_fatal("%s: Invalid value %s", env, *lock); if (lock_data[type].func == NULL) { i_fatal("%s: Support for lock type %s " "not compiled into binary", env, *lock); } for (i = 0; i < dest; i++) { if (locks[i] == type) i_fatal("%s: Duplicated value %s", env, *lock); } /* @UNSAFE */ locks[dest++] = type; } locks[dest] = (enum mbox_lock_type)-1; }
static int acl_attribute_update_acl(struct mailbox_transaction_context *t, const char *key, const struct mail_attribute_value *value) { const char *value_str, *id, *const *rights, *error; struct acl_rights_update update; /* for now allow only dsync to update ACLs this way. if this check is removed, it should be replaced by a setting, since some admins may still have configured Dovecot using dovecot-acl files directly that they don't want users to update. and in any case ACL_STORAGE_RIGHT_ADMIN must be checked then. */ if (!t->box->storage->user->dsyncing) { mail_storage_set_error(t->box->storage, MAIL_ERROR_PERM, MAIL_ERRSTR_NO_PERMISSION); return -1; } if (mailbox_attribute_value_to_string(t->box->storage, value, &value_str) < 0) return -1; memset(&update, 0, sizeof(update)); update.modify_mode = ACL_MODIFY_MODE_REPLACE; update.neg_modify_mode = ACL_MODIFY_MODE_REPLACE; update.last_change = value->last_change; id = key + strlen(MAILBOX_ATTRIBUTE_PREFIX_ACL); rights = value_str == NULL ? NULL : t_strsplit(value_str, " "); if (acl_rights_update_import(&update, id, rights, &error) < 0) { mail_storage_set_error(t->box->storage, MAIL_ERROR_PARAMS, error); return -1; } /* FIXME: this should actually be done only at commit().. */ return acl_mailbox_update_acl(t, &update); }
static void test_t_strsplit(void) { const char *const *args; test_begin("t_strsplit"); /* empty string -> empty array. was this perhaps a mistake for the API to do this originally?.. can't really change now anyway. */ args = t_strsplit("", "\n"); test_assert(args[0] == NULL); /* two empty strings */ args = t_strsplit("\n", "\n"); test_assert(args[0][0] == '\0'); test_assert(args[1][0] == '\0'); test_assert(args[2] == NULL); test_end(); }
bool t_binary_abspath(const char **binpath) { const char *path_env, *const *paths; string_t *path; if (**binpath == '/') { /* already have absolute path */ return TRUE; } else if (strchr(*binpath, '/') != NULL) { /* relative to current directory */ *binpath = t_abspath(*binpath); return TRUE; } else if ((path_env = getenv("PATH")) != NULL) { /* we have to find our executable from path */ path = t_str_new(256); paths = t_strsplit(path_env, ":"); for (; *paths != NULL; paths++) { str_append(path, *paths); str_append_c(path, '/'); str_append(path, *binpath); if (access(str_c(path), X_OK) == 0) { *binpath = str_c(path); return TRUE; } str_truncate(path, 0); } } return FALSE; }
static int fs_quota_init(struct quota_root *_root, const char *args, const char **error_r) { struct fs_quota_root *root = (struct fs_quota_root *)_root; const char *const *tmp; if (args == NULL) return 0; for (tmp = t_strsplit(args, ":"); *tmp != NULL; tmp++) { if (strcmp(*tmp, "user") == 0) root->group_disabled = TRUE; else if (strcmp(*tmp, "group") == 0) root->user_disabled = TRUE; else if (strcmp(*tmp, "inode_per_mail") == 0) root->inode_per_mail = TRUE; else if (strcmp(*tmp, "noenforcing") == 0) _root->no_enforcing = TRUE; else if (strcmp(*tmp, "hidden") == 0) _root->hidden = TRUE; else if (strncmp(*tmp, "mount=", 6) == 0) { i_free(root->storage_mount_path); root->storage_mount_path = i_strdup(*tmp + 6); } else { *error_r = t_strdup_printf("Invalid parameter: %s", *tmp); return -1; } } _root->auto_updating = TRUE; return 0; }
static int acl_backend_vfile_init(struct acl_backend *_backend, const char *data) { struct acl_backend_vfile *backend = (struct acl_backend_vfile *)_backend; struct stat st; const char *const *tmp; tmp = t_strsplit(data, ":"); backend->global_path = p_strdup_empty(_backend->pool, *tmp); backend->cache_secs = ACL_VFILE_DEFAULT_CACHE_SECS; if (*tmp != NULL) tmp++; for (; *tmp != NULL; tmp++) { if (strncmp(*tmp, "cache_secs=", 11) == 0) { if (str_to_uint(*tmp + 11, &backend->cache_secs) < 0) { i_error("acl vfile: Invalid cache_secs value: %s", *tmp + 11); return -1; } } else { i_error("acl vfile: Unknown parameter: %s", *tmp); return -1; } } if (backend->global_path != NULL) { if (stat(backend->global_path, &st) < 0) { if (errno != ENOENT) { i_error("acl vfile: stat(%s) failed: %m", backend->global_path); return -1; } } else if (!S_ISDIR(st.st_mode)) { _backend->global_file = acl_global_file_init(backend->global_path, backend->cache_secs); } } if (_backend->debug) { if (backend->global_path == NULL) i_debug("acl vfile: Global ACLs disabled"); else if (_backend->global_file != NULL) { i_debug("acl vfile: Global ACL file: %s", backend->global_path); } else { i_debug("acl vfile: Global ACL legacy directory: %s", backend->global_path); } } _backend->cache = acl_cache_init(_backend, sizeof(struct acl_backend_vfile_validity)); return 0; }
static struct mail_search_args * test_build_search_args(const char *args) { struct mail_search_parser *parser; struct mail_search_args *sargs; const char *error, *charset = "UTF-8"; parser = mail_search_parser_init_cmdline(t_strsplit(args, " ")); if (mail_search_build(mail_search_register_get_imap(), parser, &charset, &sargs, &error) < 0) i_panic("%s", error); mail_search_parser_deinit(&parser); return sargs; }
static void env_put_extra_fields(const char *extra_fields) { const char *const *tmp; const char *key, *p; for (tmp = t_strsplit(extra_fields, "\t"); *tmp != NULL; tmp++) { key = t_str_ucase(t_strcut(*tmp, '=')); p = strchr(*tmp, '='); if (p == NULL) env_put(t_strconcat(key, "=1", NULL)); else env_put(t_strconcat(key, p, NULL)); } }
static void lmtp_client_parse_capabilities(struct lmtp_client *client, const char *lines) { const char *const *linep; for (linep = t_strsplit(lines, "\n"); *linep != NULL; linep++) { const char *line = *linep; line += 4; /* already checked this is valid */ if (strncasecmp(line, "XCLIENT ", 8) == 0) { client->xclient_args = (void *)p_strsplit(client->pool, line + 8, " "); } } }
static int proxy_write_starttls(struct imap_client *client, string_t *str) { enum login_proxy_ssl_flags ssl_flags = login_proxy_get_ssl_flags(client->common.login_proxy); if ((ssl_flags & PROXY_SSL_FLAG_STARTTLS) != 0) { if (client->proxy_backend_capability != NULL && !str_array_icase_find(t_strsplit(client->proxy_backend_capability, " "), "STARTTLS")) { client_log_err(&client->common, "proxy: Remote doesn't support STARTTLS"); return -1; } str_append(str, "S STARTTLS\r\n"); return 1; } return 0; }
static int dbox_file_parse_header(struct dbox_file *file, const char *line) { const char *const *tmp, *value; unsigned int pos; enum dbox_header_key key; file->file_version = *line - '0'; if (!i_isdigit(line[0]) || line[1] != ' ' || (file->file_version != 1 && file->file_version != DBOX_VERSION)) { dbox_file_set_corrupted(file, "Invalid dbox version"); return -1; } line += 2; pos = 2; file->msg_header_size = 0; for (tmp = t_strsplit(line, " "); *tmp != NULL; tmp++) { uintmax_t time; key = **tmp; value = *tmp + 1; switch (key) { case DBOX_HEADER_OLDV1_APPEND_OFFSET: break; case DBOX_HEADER_MSG_HEADER_SIZE: if (str_to_uint_hex(value, &file->msg_header_size) < 0) { dbox_file_set_corrupted(file, "Invalid message header size"); return -1; } break; case DBOX_HEADER_CREATE_STAMP: if (str_to_uintmax_hex(value, &time) < 0) { dbox_file_set_corrupted(file, "Invalid create time stamp"); return -1; } file->create_time = (time_t)time; break; } pos += strlen(value) + 2; } if (file->msg_header_size == 0) { dbox_file_set_corrupted(file, "Missing message header size"); return -1; } return 0; }
static int proxy_input_banner(struct imap_client *client, struct ostream *output, const char *line) { const char *const *capabilities = NULL; string_t *str; int ret; if (!str_begins(line, "* OK ")) { client_log_err(&client->common, t_strdup_printf( "proxy: Remote returned invalid banner: %s", str_sanitize(line, 160))); return -1; } str = t_str_new(128); if (str_begins(line + 5, "[CAPABILITY ")) { capabilities = t_strsplit(t_strcut(line + 5 + 12, ']'), " "); if (str_array_icase_find(capabilities, "SASL-IR")) client->proxy_sasl_ir = TRUE; if (str_array_icase_find(capabilities, "LOGINDISABLED")) client->proxy_logindisabled = TRUE; i_free(client->proxy_backend_capability); client->proxy_backend_capability = i_strdup(t_strcut(line + 5 + 12, ']')); if (str_array_icase_find(capabilities, "ID") && !client->common.proxy_not_trusted) { client->proxy_sent_state |= IMAP_PROXY_SENT_STATE_ID; proxy_write_id(client, str); if (client->common.proxy_nopipelining) { /* write login or starttls after I OK */ o_stream_nsend(output, str_data(str), str_len(str)); return 0; } } } if ((ret = proxy_write_starttls(client, str)) < 0) { return -1; } else if (ret == 0) { if (proxy_write_login(client, str) < 0) return -1; } o_stream_nsend(output, str_data(str), str_len(str)); return 0; }
static int proxy_input_banner(struct imap_client *client, struct ostream *output, const char *line) { enum login_proxy_ssl_flags ssl_flags; const char *const *capabilities = NULL; string_t *str; if (strncmp(line, "* OK ", 5) != 0) { client_log_err(&client->common, t_strdup_printf( "proxy: Remote returned invalid banner: %s", str_sanitize(line, 160))); return -1; } str = t_str_new(128); if (strncmp(line + 5, "[CAPABILITY ", 12) == 0) { capabilities = t_strsplit(t_strcut(line + 5 + 12, ']'), " "); if (str_array_icase_find(capabilities, "ID")) proxy_write_id(client, str); if (str_array_icase_find(capabilities, "SASL-IR")) client->proxy_sasl_ir = TRUE; if (str_array_icase_find(capabilities, "LOGINDISABLED")) client->proxy_logindisabled = TRUE; i_free(client->proxy_backend_capability); client->proxy_backend_capability = i_strdup(t_strcut(line + 5 + 12, ']')); } ssl_flags = login_proxy_get_ssl_flags(client->common.login_proxy); if ((ssl_flags & PROXY_SSL_FLAG_STARTTLS) != 0) { if (capabilities != NULL && !str_array_icase_find(capabilities, "STARTTLS")) { client_log_err(&client->common, "proxy: Remote doesn't support STARTTLS"); return -1; } str_append(str, "S STARTTLS\r\n"); } else { if (proxy_write_login(client, str) < 0) return -1; } o_stream_nsend(output, str_data(str), str_len(str)); return 0; }
static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx, const char *user, const char *const **cmd_args_r) { const char *p, *host, *const *argv = ctx->ctx.args; if (argv[1] != NULL) { /* more than one parameter, so it contains a full command (e.g. ssh host dsync) */ mirror_get_remote_cmd_line(argv, cmd_args_r); return TRUE; } /* if it begins with /[a-z0-9]+:/, it's a mail location (e.g. mdbox:~/mail) */ for (p = argv[0]; *p != '\0'; p++) { if (!i_isalnum(*p)) { if (*p == ':') return FALSE; break; } } if (strchr(argv[0], ' ') != NULL || strchr(argv[0], '/') != NULL) { /* a) the whole command is in one string. this is mainly for backwards compatibility. b) script/path */ mirror_get_remote_cmd_line(t_strsplit(argv[0], " "), cmd_args_r); return TRUE; } /* [user@]host */ host = strchr(argv[0], '@'); if (host != NULL) user = t_strdup_until(argv[0], host++); else host = argv[0]; /* we'll assume virtual users, so in user@host it really means not to give ssh a username, but to give dsync -u user parameter. */ *cmd_args_r = get_ssh_cmd_args(host, "", user); return TRUE; }
static bool client_is_allowed_command(const struct doveadm_settings *set, const char *cmd_name) { bool ret = FALSE; if (*set->doveadm_allowed_commands == '\0') return TRUE; T_BEGIN { const char *const *cmds = t_strsplit(set->doveadm_allowed_commands, ","); for (; *cmds != NULL; cmds++) { if (strcmp(*cmds, cmd_name) == 0) { ret = TRUE; break; } } } T_END; return ret; }
static bool validate_chroot(const struct mail_user_settings *user_set, const char *dir) { const char *const *chroot_dirs; if (*dir == '\0') return FALSE; if (*user_set->valid_chroot_dirs == '\0') return FALSE; chroot_dirs = t_strsplit(user_set->valid_chroot_dirs, ":"); while (*chroot_dirs != NULL) { if (**chroot_dirs != '\0' && strncmp(dir, *chroot_dirs, strlen(*chroot_dirs)) == 0) return TRUE; chroot_dirs++; } return FALSE; }
static void cmd_flags_init(struct doveadm_mail_cmd_context *_ctx, const char *const args[]) { struct flags_cmd_context *ctx = (struct flags_cmd_context *)_ctx; const char *const *tmp; enum mail_flags flag; ARRAY_TYPE(const_string) keywords; if (args[0] == NULL || args[1] == NULL) { switch (ctx->modify_type) { case MODIFY_ADD: doveadm_mail_help_name("flags add"); case MODIFY_REMOVE: doveadm_mail_help_name("flags remove"); case MODIFY_REPLACE: doveadm_mail_help_name("flags replace"); } i_unreached(); } p_array_init(&keywords, _ctx->pool, 8); for (tmp = t_strsplit(args[0], " "); *tmp != NULL; tmp++) { const char *str = *tmp; if (str[0] == '\\') { flag = imap_parse_system_flag(str); if (flag == 0) i_fatal("Invalid system flag: %s", str); ctx->flags |= flag; } else { str = p_strdup(_ctx->pool, str); array_append(&keywords, &str, 1); } } if (array_count(&keywords) > 0 || ctx->modify_type == MODIFY_REPLACE) { array_append_zero(&keywords); ctx->keywords = array_idx(&keywords, 0); } _ctx->search_args = doveadm_mail_build_search_args(args+1); }
static unsigned int dump_file_hdr(struct istream *input) { const char *line, *const *arg, *version; unsigned int msg_hdr_size = 0; if ((line = i_stream_read_next_line(input)) == NULL) i_fatal("Empty file"); arg = t_strsplit(line, " "); /* check version */ version = *arg; if (version == NULL || !str_is_numeric(version, ' ')) i_fatal("%s is not a dbox file", i_stream_get_name(input)); if (strcmp(version, "2") != 0) i_fatal("Unsupported dbox file version %s", version); arg++; for (; *arg != NULL; arg++) { switch (**arg) { case DBOX_HEADER_MSG_HEADER_SIZE: msg_hdr_size = hex2dec((const void *)(*arg + 1), strlen(*arg + 1)); if (msg_hdr_size == 0) { i_fatal("Invalid msg_header_size header: %s", *arg + 1); } printf("file.msg_header_size = %u\n", msg_hdr_size); break; case DBOX_HEADER_CREATE_STAMP: dump_timestamp(input, "file.create_stamp", *arg + 1); break; default: printf("file.unknown-%c = %s\n", **arg, *arg + 1); break; } } if (msg_hdr_size == 0) i_fatal("Missing msg_header_size in file header"); return msg_hdr_size; }
static struct mailbox_list_index_node * mailbox_list_index_lookup_real(struct mailbox_list *list, const char *name) { struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); struct mailbox_list_index_node *node = ilist->mailbox_tree; const char *const *path; unsigned int i; char sep[2]; if (*name == '\0') return mailbox_list_index_node_find_sibling(node, ""); sep[0] = mailbox_list_get_hierarchy_sep(list); sep[1] = '\0'; path = t_strsplit(name, sep); for (i = 0;; i++) { node = mailbox_list_index_node_find_sibling(node, path[i]); if (node == NULL || path[i+1] == NULL) break; node = node->children; } return node; }
static int filter_connect(struct mail_filter_istream *mstream, const char *socket_path, const char *args) { const char **argv; string_t *str; int fd; argv = t_strsplit(args, " "); if ((fd = net_connect_unix_with_retries(socket_path, 1000)) < 0) { if (errno == EACCES) { i_error("ext-filter: %s", eacces_error_get("net_connect_unix", socket_path)); } else { i_error("ext-filter: net_connect_unix(%s) failed: %m", socket_path); } return -1; } if (mstream->istream.istream.blocking) net_set_nonblock(fd, FALSE); mstream->fd = fd; mstream->ext_in = i_stream_create_fd(fd, mstream->istream.max_buffer_size, FALSE); mstream->ext_out = o_stream_create_fd(fd, 0, FALSE); str = t_str_new(256); str_append(str, "VERSION\tscript\t3\t0\nnoreply\n"); for (; *argv != NULL; argv++) { str_append(str, *argv); str_append_c(str, '\n'); } str_append_c(str, '\n'); o_stream_send(mstream->ext_out, str_data(str), str_len(str)); return 0; }
static int process_io_buffer_parse(const char *buf, struct mail_stats *stats) { const char *const *tmp; tmp = t_strsplit(buf, "\n"); for (; *tmp != NULL; tmp++) { if (strncmp(*tmp, "rchar: ", 7) == 0) { if (str_to_uint64(*tmp + 7, &stats->read_bytes) < 0) return -1; } else if (strncmp(*tmp, "wchar: ", 7) == 0) { if (str_to_uint64(*tmp + 7, &stats->write_bytes) < 0) return -1; } else if (strncmp(*tmp, "syscr: ", 7) == 0) { if (str_to_uint32(*tmp + 7, &stats->read_count) < 0) return -1; } else if (strncmp(*tmp, "syscw: ", 7) == 0) { if (str_to_uint32(*tmp + 7, &stats->write_count) < 0) return -1; } } return 0; }