void* mem_alloc_executable( size_t size ) { void* p; size_t pagesize = sysconf( _SC_PAGESIZE ); size = (size + pagesize - 1) & ~(pagesize-1); if (posix_memalign(&p, pagesize, size) ) return NULL; make_executable(p,size); return p; }
STAGE_RC create_operation::deploy() { auto file_manager = config_.file_manager; const path_t destination(get_destination()); // Make sure the destination is free if (file_manager->is_readable(destination)) { error() << "Destination is occupied: " << destination; return STAGE_FILE_EXISTS; } // Can we write to the destination? if (!file_manager->is_writable(destination)) { error() << "Destination isn't writable: " << destination; return STAGE_UNAUTHORIZED; } // Can we write to the staging destination? if (!file_manager->is_writable(cache_path_)) { error() << "Temp isn't writable: " << cache_path_; return STAGE_UNAUTHORIZED; } // Move the staged file to the destination info() << "Creating " << destination; file_manager->move(cache_path_, destination); // validate integrity hasher::digest_rc rc = config_.hasher->hex_digest(destination); if (rc != src_checksum) { error() << "Created file integrity mismatch: " << rc.digest << " vs " << src_checksum; return STAGE_FILE_INTEGRITY_MISMATCH; } if (is_executable) { debug() << "MARKING EXECUTABLE!\n"; file_manager->make_executable(destination); } return STAGE_OK; }