arup-group / elara

Command line utility for processing MATSim events output files.
MIT License
14 stars 4 forks source link

Box permissions #72

Closed fredshone closed 3 years ago

fredshone commented 3 years ago

Box elara install doesn't get permission without first creating the output directories and giving them permissions:

sudo mkdir elara_out
sudo chmod 777 elara_out
sudo mkdir elara_out/benchmarks
sudo chmod 777 elara_out/benchmarks

How can these shenanigans be avoided?

gac55 commented 3 years ago

This isn't Elara, but the disc permissions of the specific directory in question. Hht to @mfitz

To fix the above example, we'd recursively make the entire parent directory arup's, e.g:

sudo chown -R arup elara_out
mfitz commented 3 years ago

To be clear @fredshone @syhwawa @gac55, there are two things in play here:

1 - file system permissions 2 - the user running the Elara process

The two have to be in sync, such that if you are running Elara on a workbox as the arup user, that user needs read/write permissions on the directory in which Elara is going to try and create new output directories.

You can do this with either of the above approaches (give everybody all permissions via chmod 777, or make the arup (or whichever user will run Elara) the owner).

Note that like chown, chmod also supports the -R flag for recursively applying a set of permissions to a directory and all of it's contents, including subdirectories, plus mkdir can set permissions at creation time, so:

sudo mkdir -m 777 -p elara_out/benchmarks
sudo chmod -R 777 elara_out #optional, depending on how you will use the elara_out dir

This is a hybrid of the two different approaches above. You might still need the chmod because sudo mkdir -m 777 -p elara_out/benchmarks creates all the intermediate directories with default permission for root-created dirs (drwxr-xr-x or 755), and uses the specified permission only for the directory at the very end of the path (so benchmarks will be 777 in this case, but elara_out will be 755).

Bear in mind that if you run Elara (or anything else that creates new dirs) as root, any directories it creates will be owned by root, with 755 (i.e. read-only for non root users) permissions. If you run as arup, new dirs will be owned by arup and given 777 permissions, I think. So don't run anything as root unless there is a good reason; if you're doing it to access directories owned by root, fix the permissions rather than running your apps as root.

andkay commented 3 years ago

Closing stale issue.