@@ -3104,7 +3104,12 @@ static ec_error_t op_delegate(const rulexec_in &rp, seen_list &seen,
31043104 auto mid_string = fmt::format (" {}.x{}.{}" , time (nullptr ),
31053105 common_util_sequence_ID (), get_host_ID ());
31063106 auto eml_path = maildir + " /eml/" s + mid_string;
3107- auto ret = HX_copy_file (tmp_path1, eml_path.c_str (), 0 );
3107+ auto ret = gx_mkbasedir (eml_path.c_str (), FMODE_PRIVATE | S_IXUSR | S_IXGRP);
3108+ if (ret < 0 ) {
3109+ mlog (LV_ERR, " E-1492: mkbasedir for %s: %s" , eml_path.c_str (), strerror (-ret));
3110+ continue ;
3111+ }
3112+ ret = HX_copy_file (tmp_path1, eml_path.c_str (), 0 );
31083113 if (ret < 0 ) {
31093114 mlog (LV_ERR, " E-1606: HX_copy_file %s -> %s: %s" ,
31103115 tmp_path1, eml_path.c_str (), strerror (-ret));
@@ -3410,7 +3415,12 @@ static ec_error_t opx_delegate(const rulexec_in &rp, const rule_node &rule,
34103415 auto mid_string = fmt::format (" {}.x{}.{}" , time (nullptr ),
34113416 common_util_sequence_ID (), get_host_ID ());
34123417 auto eml_path = maildir + " /eml/" s + mid_string;
3413- auto ret = HX_copy_file (tmp_path1, eml_path.c_str (), 0 );
3418+ auto ret = gx_mkbasedir (eml_path.c_str (), FMODE_PRIVATE | S_IXUSR | S_IXGRP);
3419+ if (ret < 0 ) {
3420+ mlog (LV_ERR, " E-1493: mkbasedir for %s: %s" , eml_path.c_str (), strerror (-ret));
3421+ continue ;
3422+ }
3423+ ret = HX_copy_file (tmp_path1, eml_path.c_str (), 0 );
34143424 if (ret < 0 ) {
34153425 mlog (LV_ERR, " E-1607: HX_copy_file %s -> %s: %s" ,
34163426 tmp_path1, eml_path.c_str (), strerror (-ret));
@@ -3766,6 +3776,11 @@ BOOL exmdb_server::deliver_message(const char *dir, const char *from_address,
37663776 snprintf (tmp_path, std::size (tmp_path), " %s/ext/%s" ,
37673777 exmdb_server::get_dir (), mid_string);
37683778 auto djson = json_to_str (std::move (newdigest));
3779+ auto ret = gx_mkbasedir (tmp_path, FMODE_PRIVATE | S_IXUSR | S_IXGRP);
3780+ if (ret < 0 ) {
3781+ mlog (LV_ERR, " E-1942: mkbasedir for %s: %s" , tmp_path, strerror (-ret));
3782+ return false ;
3783+ }
37693784 wrapfd fd = open (tmp_path, O_CREAT | O_TRUNC | O_WRONLY, FMODE_PRIVATE);
37703785 if (fd.get () >= 0 ) {
37713786 if (HXio_fullwrite (fd.get (), djson.c_str (), djson.size ()) < 0 ||
@@ -3900,6 +3915,11 @@ BOOL exmdb_server::write_message(const char *dir, cpid_t cpid,
39003915 if (json_from_str (digest_stream, digest) &&
39013916 digest[" file" ].asString ().size () > 0 ) {
39023917 std::string ext_file = exmdb_server::get_dir () + " /ext/" s + digest[" file" ].asString ();
3918+ auto ret = gx_mkbasedir (ext_file.c_str (), FMODE_PRIVATE);
3919+ if (ret < 0 ) {
3920+ mlog (LV_ERR, " E-1944: mkbasedir for %s: %s" , ext_file.c_str (), strerror (-ret));
3921+ return false ;
3922+ }
39033923 wrapfd fd = open (ext_file.c_str (), O_CREAT | O_TRUNC | O_WRONLY, FMODE_PRIVATE);
39043924 if (fd.get () >= 0 ) {
39053925 if (HXio_fullwrite (fd.get (), digest_stream.c_str (), digest_stream.size ()) < 0 ||
0 commit comments