I mean, if an executable is not there, the shell will still complain,
but I would like to make sure that users of my script have the "right"
executables, for example not aliases, custom functions, etc. Or should I
just leave the shell do its job?
A template would be like this:
for each of $PROGRAMS LIST
check if $PROGRAM it's installed in $PATH and it's not an alias
&& echo $PROGRAM has been found at $LOCATION
|| echo $PROGRAM has not been found; exit (which code?)
and so on.
(I'm using "for each" not literally here, it's not a csh script)
I am experimenting with "which" but I am having random results.
"command -v" is too tolerant and will accept aliases, which I don't want.
I mean, if an executable is not there, the shell will still complain,
but I would like to make sure that users of my script have the "right" executables,
for example not aliases, custom functions, etc. Or should I just
leave the shell do its job?
A template would be like this:
for each of $PROGRAMS LIST
check if $PROGRAM it's installed in $PATH and it's not an alias
&& echo $PROGRAM has been found at $LOCATION
|| echo $PROGRAM has not been found; exit (which code?)
and so on.
(I'm using "for each" not literally here, it's not a csh script)
I am experimenting with "which" but I am having random results.
"command -v" is too tolerant and will accept aliases, which I don't want.
I mean, if an executable is not there, the shell will still complain,
but I would like to make sure that users of my script have the "right" executables, for example not aliases, custom functions, etc.
Nobody ever does what you are proposing.
On 3/22/22 2:40 PM, Christian Weisgerber wrote:
Nobody ever does what you are proposing.
I question the veracity of that statement.
I've been known to create functions and / or scripts with the name of
other commands and arrange for them to be executed in place of the other commands.
E.g. I have ~/bin at the start of my path and a script named `ifconfig`
and another named `ip` that is a wrapper to run the command(s) through
sudo. As such, I can run `ifconfig` / `ip` at the command line, in a function, in a script and have it use sudo without changing what I do.
On Tue, 22 Mar 2022 21:25:48 -0400, Grant Taylor <[email protected]> wrote:
On 3/22/22 2:40 PM, Christian Weisgerber wrote:
Nobody ever does what you are proposing.
I question the veracity of that statement.
I've been known to create functions and / or scripts with the name of
other commands and arrange for them to be executed in place of the other
commands.
E.g. I have ~/bin at the start of my path and a script named `ifconfig`
and another named `ip` that is a wrapper to run the command(s) through
sudo. As such, I can run `ifconfig` / `ip` at the command line, in a
function, in a script and have it use sudo without changing what I do.
It's also common practice to use aliases with some options specified to reduce
typing.
Eg. alias diskdrake='diskdrake --expert &'
Nobody ever does what you are proposing.
I question the veracity of that statement.
I've been known to create functions and / or scripts with the name of
other commands and arrange for them to be executed in place of the other commands.
I meant that nobody checks in their scripts that standard commands
are in fact those standard commands.
On 3/23/22 8:59 AM, Christian Weisgerber wrote:
I meant that nobody checks in their scripts that standard commands are
in fact those standard commands.
I question the accuracy of that.
How would one check?
Simply checking / using the path to a /bin/ls vs ~/bin/ls in the PATH
doesn't suffice because the /bin/ls file can be replaced.
So what is standard vs non-standard?
I feel like using the full path alleviates any need to check which
instance of ls is being used.
I mean, if an executable is not there, the shell will still complain,
but I would like to make sure that users of my script have the "right" executables, for example not aliases, custom functions, etc. Or should I
just leave the shell do its job?
Replaced files in the standard bin directories would indicate to be
a compromised system, where it's not really relevant whether a well
meaning sysadmin replaced it or whether it's an effect of a malicious
system attack.
On 3/23/22 11:23 PM, Janis Papanagnou wrote:
Replaced files in the standard bin directories would indicate to be a
compromised system, where it's not really relevant whether a well
meaning sysadmin replaced it or whether it's an effect of a malicious
system attack.
Would you please elaborate on why you say "Replaced files in the
standard bin directories would indicate to be a compromised system..."?
I feel like there are legitimate replacements. The first thing that
comes to mind is Kerberized or S/Key version of things like passwd,
telnet, etc.
I'm particularly interested in why "not really relevant whether a well meaning sysadmin". E.g. a sysadmin installing a new version of telnet
that supports Kerberos based authentication that the site has chosen to
use across their network.
Does it matter if the new version of the binary comes from in-house (ostensibly compiled locally), the vendor, or a 3rd party?
Does it matter if the file from the vendor is an updated / patched
version of the binary in question?
I'll agree that replacing binaries will render a system no longer /pure/
to the original installed version. But I don't consider a system that
has had vendor provided files patched by vendor provided patches to be /compromised/.
Does a new installation of the new patched version differ from an old
install using the previous version and updated to the same version. Is
the old install any different than the fresh install when all the files
are exactly the same?
I think there is a difference between a system kept safe in case
of the detection of a security incident in a professionally managed environment and a "well meaning sysadmin" (as I called it).
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 158:25:38 |
| Calls: | 12,094 |
| Calls today: | 2 |
| Files: | 15,000 |
| Messages: | 6,517,756 |