Re: etiquette of sharing executable files
On 7/6/2019 9:34 PM, mick crane wrote:
> As per recent post ( don't want to trash somebody's home directory ) I
> was wondering what is the etiquette of sharing executable files.
> I've never really thought about giving executable files to anybody but
> just recently while I'm getting my bits of code to work I was thinking
> "I have to be a bit careful what I put here because I might delete
> something I'd be unhappy about.
> And then hmmm, if I did give this to somebody else if they didn't know
> what did what they might trash they're home directory.
> I decided to follow the advice and not delete anything and I don't need
> to need to renumber now.
> And I decided to go through everything and put in error checking as much
> as able.
> So the question is about the etiquette.
> Install scripts could make directories willy nilly in user home
> directory but you might think that could be rude ?
Then test if the script is run as root and restrict where the script can
work in (/tmp/...)
> And what happens if by mischance there already exists a directory with
> the same name ?
Use as part of your directory name a random string:
- Define a variable that holds the directory name with that random string
- Die if that directory already exist or generate a new name
The name of the directory could have the form:
directory.random-string
https://metacpan.org/pod/String::Random
> I think the way would be to make a tar file with the wanted
> subdirectories and the executable that doesn't touch anything except the
> directories in the directory it is untarred within.
> seems with
> use File::Basename;
> use Cwd ;
> you can check if the basename is equal to the directory it's supposed to
> be in and die if not.
> Now I just need to make the executable not writeable and have the
> several variables in a text file that I get in some fashion.
> Do those things seem like sensible considerations for exchanging
> executables ?
Why not requiring the argument as script parameter instead of using a
var file.:
$ ./xxx.pl arg1 arg2 arg3 ...
You can never assume that your script will be used the way it should be
so you need to make it as secure as possible and document the script
usage with a README file for example (step 1, step 2 ...).
Be verbose as possible in your script by progress messages, error handler.
That is every questions that you ask here should be addressed in your
script! :)
--
John Doe
Reply to: