How to deal in tcl with user rights issues for working subdirectory in Linux containing core files?

50 Views Asked by At

I have developed a cross-platform tcl script that includes a subdirectory that must be written with temporary files and that includes certain files by default. (The temporary files are used in order to add new resources files or for update the existing files).

The script works ok on Windows. However, it seems that in Linux this is not so simple (user rights issues) and another working directory must be configured outside the script directory. In that case it seems to involve some kind of "installation" since if you change the default working directory, the included files should be moved to this new location. Sorry if this sound silly but isn't possible in Linux just install the script (full) in a less restricted location ?.

How is this usually resolved using tcl tools?.

Thanks,

2

There are 2 best solutions below

1
Donal Fellows On

Configuring a path by what platform you are on is mostly just a matter of checking $tcl_platform(platform). I would warn that your Windows code is probably just working by accident; it's a platform that can be quite thoroughly locked down too.

If all you need is a temporary file, use file tempfile and it will default to being made somewhere the current user can write. (The current beta of 9.0 also has file tempdir.)

0
thomas On

There is more to it:

  1. path/location: That is not what is blocking you. It's the users and group permissions. You can install your application to e.g. /usr/share and give it world permissions: chmod a+rwX though i'd not recommend, it would simplify your life.

  2. temporary folders: The "correct" way of handling this, from my perspective, would be to use mktemp -d and put your temporary folders there. They would be lost after reboot.

  3. user: If you script is run from a user login/shell, then the temporary files could also be stored in the /home/<user>/<whatever> path.