Commit f70ebb8c f70ebb8c1d67d70222768b34ce7568b78fe191de by Sergey Poznyakoff

Simplify mu_file_safety_check call.

* include/mailutils/util.h (mu_file_safety_check): Change type
of the 3rd argument to uid_t.
* libmailutils/base/filesafety.c: Likewise.  All uses updated.
1 parent 1e9173df
......@@ -220,10 +220,8 @@ int mu_onexit (mu_onexit_t func, void *data);
MU_FILE_SAFETY_DIR_IWOTH )
struct mu_auth_data;
int mu_file_safety_check (const char *filename, int mode,
struct mu_auth_data *auth,
uid_t uid,
mu_list_t idlist);
int mu_file_safety_name_to_code (const char *name, int *pcode);
int mu_file_safety_name_to_error (const char *name, int *pcode);
......
......@@ -191,7 +191,7 @@ mu_file_safety_name_to_error (const char *name, int *pcode)
int
mu_file_safety_check (const char *filename, int mode,
struct mu_auth_data *auth,
uid_t uid,
mu_list_t idlist)
{
struct file_check_buffer buf;
......@@ -209,9 +209,7 @@ mu_file_safety_check (const char *filename, int mode,
return MU_ERR_EXISTS;
}
if ((mode & MU_FILE_SAFETY_OWNER_MISMATCH) &&
auth &&
auth->uid != buf.filst.st_uid)
if ((mode & MU_FILE_SAFETY_OWNER_MISMATCH) && uid != buf.filst.st_uid)
return MU_ERR_PERM_OWNER_MISMATCH;
for (pck = file_safety_check_tab; pck->flag; pck++)
......
......@@ -74,7 +74,7 @@ mu_check_tls_environment (void)
{
int rc = mu_file_safety_check (mu_tls_module_config.ssl_cert,
mu_tls_module_config.ssl_cert_safety_checks,
NULL, NULL);
-1, NULL);
if (rc)
{
mu_error ("%s: %s", mu_tls_module_config.ssl_cert,
......@@ -83,7 +83,7 @@ mu_check_tls_environment (void)
}
rc = mu_file_safety_check (mu_tls_module_config.ssl_key,
mu_tls_module_config.ssl_key_safety_checks,
NULL, NULL);
-1, NULL);
if (rc)
{
mu_error ("%s: %s", mu_tls_module_config.ssl_key,
......@@ -93,7 +93,7 @@ mu_check_tls_environment (void)
rc = mu_file_safety_check (mu_tls_module_config.ssl_cafile,
mu_tls_module_config.ssl_cafile_safety_checks,
NULL, NULL);
-1, NULL);
if (rc)
{
mu_error ("%s: %s", mu_tls_module_config.ssl_cafile,
......
......@@ -213,7 +213,7 @@ maidag_forward (mu_message_t msg, struct mu_auth_data *auth, char *fwfile)
mu_list_create (&idlist);
rc = mu_file_safety_check (filename, forward_file_checks,
auth, idlist);
auth->uid, idlist);
if (rc == 0)
result = process_forward (msg, filename, auth->name);
else if (rc == MU_ERR_EXISTS)
......