Backport 4610 to stable5

Backport #4610 to stable5

@jancborchardt @karlitschek THX