def delete_dir(self): base_dir = os.path.dirname(self.dir) if not os.path.isdir(base_dir): raise RuntimeError("Missing base %s directory %s!" % (self.dir_name, base_dir)) if self.user == MY_USERNAME: # keep it simple, if possible shutil.rmtree(self.dir) elif self.privsep_mkdir: try: # use privsep rmtree, as requested condorPrivsep.rmtree(base_dir, os.path.basename(self.dir)) except condorPrivsep.ExeError as e: raise RuntimeError("Failed to remove %s dir (user %s): %s" % (self.dir_name, self.user, e)) except: raise RuntimeError( "Failed to remove %s dir (user %s): Unknown privsep error" % (self.dir_name, self.user)) else: try: # use the execute command # do not use the rmtree one, as we do not need root privileges condorPrivsep.execute(self.user, base_dir, '/bin/rm', ['rm', '-fr', self.dir], stdout_fname=None) except condorPrivsep.ExeError as e: raise RuntimeError("Failed to remove %s dir (user %s): %s" % (self.dir_name, self.user, e)) except: raise RuntimeError( "Failed to remove %s dir (user %s): Unknown privsep error" % (self.dir_name, self.user))
def delete_ps_directories(self,dirs): """ Delete the contents of directories with privilege separation in effect.""" for type in dirs.keys(): if type not in ["client logs", "client proxies",]: common.remove_dir_path(dirs[type]) continue #-- Factory create requires client logs/proxies directories be empty #-- when privspep is in effect condor_sbin = "%s/sbin" % self.wms.condor_location() condor_bin = "%s/bin" % self.wms.condor_location() condorExe.set_path(condor_bin,condor_sbin) parent_dir = dirs[type] subdirs = os.listdir(parent_dir) for base_dir in subdirs: if os.path.isdir("%s/%s" % (parent_dir,base_dir)): try: condorPrivsep.rmtree(parent_dir,base_dir) except Exception,e: common.logerr("""Encountered a problem in executing condor_root_switchboard to remove this client's sub-directories: %(dir)s %(error)s Check your /etc/condor/privsep.conf file to verify. You may need to configure/install your WMS Collector to resolve or correct the ini file for the %(type)s attribute. Be careful now. """ % { "dir" : parent_dir, "type" : type, "error" : e, } ) common.logit("Files in %s deleted" % parent_dir)
def delete_dir(self): base_dir=os.path.dirname(self.dir) if not os.path.isdir(base_dir): raise RuntimeError,"Missing base %s directory %s!"%(self.dir_name,base_dir) if self.user==MY_USERNAME: # keep it simple, if possible shutil.rmtree(self.dir) elif self.privsep_mkdir: try: # use privsep rmtree, as requested condorPrivsep.rmtree(base_dir,os.path.basename(self.dir)) except condorPrivsep.ExeError, e: raise RuntimeError,"Failed to remove %s dir (user %s): %s"%(self.dir_name,self.user,e) except: