potiuk commented on pull request #21145:
URL: https://github.com/apache/airflow/pull/21145#issuecomment-1039033267


   I think the easiest aand most pythonic way is described as accepted answer 
here (bit manipulation_:
   
   
https://stackoverflow.com/questions/25988471/remove-particular-permission-using-os-chmod
   
   For files:
   ```
   current  = stat.S_IMODE(os.stat(file).st_mode)
   new = current & ~stat.S_IWGRP  & ~stat.SIWOTH # Removes group/other write 
permission
   os.chmod(file, new) 
   ```
   
   For directories:
   ```
   current  = stat.S_IMODE(os.stat(dir).st_mode)
   new = current & ~stat.S_IWGRP  & ~stat.S_IWOTH # Removes group/other write 
permission
   new = new | stat.S_IXGRP | stat.S_IXOTH # Add group/other execute permission 
(to be able to list directories)
   os.chmod(dir, new) 
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to