void mh_read_profile () { char *p; const char *fallback; p = getenv ("MH"); if (p) p = mu_tilde_expansion (p, "/", NULL); else { char *home = mu_get_homedir (); if (!home) abort (); /* shouldn't happen */ asprintf (&p, "%s/%s", home, MH_USER_PROFILE); free (home); } if (mh_auto_install && access (p, R_OK)) mh_install (p, 1); profile = mh_context_create (p, 1); mh_context_read (profile); mu_set_folder_directory (mh_get_dir ()); mh_set_reply_regex (mh_global_profile_get ("Reply-Regex", NULL)); fallback = mh_global_profile_get ("Decode-Fallback", NULL); if (fallback && mu_set_default_fallback (fallback)) mu_error (_("Incorrect value for decode-fallback")); }
int imap4d_session_setup0 () { real_homedir = mu_normalize_path (mu_strdup (auth_data->dir)); if (imap4d_check_home_dir (real_homedir, auth_data->uid, auth_data->gid)) return 1; if (modify_homedir) { int rc; mu_vartab_t vtab; char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir); mu_vartab_create (&vtab); mu_vartab_define (vtab, "user", auth_data->name, 0); mu_vartab_define (vtab, "home", real_homedir, 0); rc = mu_vartab_expand (vtab, expr, &imap4d_homedir); mu_vartab_destroy (&vtab); free (expr); if (rc) { free (real_homedir); mu_diag_funcall (MU_DIAG_ERROR, "mu_vartab_expand", modify_homedir, rc); return 1; } } else imap4d_homedir = strdup (real_homedir); if (strcmp (imap4d_homedir, real_homedir) && imap4d_check_home_dir (imap4d_homedir, auth_data->uid, auth_data->gid)) { free (imap4d_homedir); free (real_homedir); return 1; } if (auth_data->change_uid) setuid (auth_data->uid); util_chdir (imap4d_homedir); namespace_init_session (imap4d_homedir); mu_diag_output (MU_DIAG_INFO, _("user `%s' logged in (source: %s)"), auth_data->name, auth_data->source); return 0; }
/* Check and update the vacation database. Return 0 if the mail should be answered, 0 if it should not, and throw exception if an error occurs. */ static int check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) { mu_property_t prop; char *file; mu_sieve_value_t *arg; unsigned int days; int rc; mu_stream_t str; mu_locker_t locker; if (mu_sieve_tag_lookup (tags, "days", &arg)) { days = arg->v.number; if (days > DAYS_MAX) days = DAYS_MAX; } else days = DAYS_DEFAULT; file = mu_tilde_expansion ("~/.vacation", MU_HIERARCHY_DELIMITER, NULL); if (!file) { mu_sieve_error (mach, _("%lu: cannot build db file name"), (unsigned long) mu_sieve_get_message_num (mach)); mu_sieve_abort (mach); } rc = mu_locker_create (&locker, file, 0); if (rc) { mu_sieve_error (mach, _("%lu: cannot lock %s: %s"), (unsigned long) mu_sieve_get_message_num (mach), file, mu_strerror (rc)); free (file); mu_sieve_abort (mach); } rc = mu_file_stream_create (&str, file, MU_STREAM_RDWR|MU_STREAM_CREAT); if (rc) { mu_sieve_error (mach, "%lu: mu_file_stream_create(%s): %s", (unsigned long) mu_sieve_get_message_num (mach), file, mu_strerror (rc)); mu_locker_destroy (&locker); free (file); mu_sieve_abort (mach); } free (file); rc = mu_property_create_init (&prop, mu_assoc_property_init, str); if (rc) { mu_sieve_error (mach, "%lu: mu_property_create_init: %s", (unsigned long) mu_sieve_get_message_num (mach), mu_strerror (rc)); mu_locker_destroy (&locker); mu_sieve_abort (mach); } rc = mu_locker_lock (locker); if (rc) { mu_sieve_error (mach, "%lu: cannot lock vacation database: %s", (unsigned long) mu_sieve_get_message_num (mach), mu_strerror (rc)); mu_property_destroy (&prop); mu_sieve_abort (mach); } rc = test_and_update_prop (prop, from, time (NULL), days, mach); mu_property_destroy (&prop); mu_locker_unlock (locker); mu_locker_destroy (&locker); if (rc == -1) mu_sieve_abort (mach); return rc; }