Bose-glass phases of ultracold atoms due to cavity backaction