Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"BTW, does Jesus know you flame?" -- Diane Holt, dianeh@binky.UUCP, to Ed Carp


devel / comp.unix.shell / Re: ... indicate to be a compromised system ... -- Was: Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

SubjectAuthor
* Is it good/bad practice to check if a number of programs are on theOttavio Caruso
+- Re: Is it good/bad practice to check if a number of programs are onJanis Papanagnou
+- Re: Is it good/bad practice to check if a number of programs are onGrant Taylor
+* Re: Is it good/bad practice to check if a number of programs are onChristian Weisgerber
|`* Re: Is it good/bad practice to check if a number of programs are onGrant Taylor
| +* Re: Is it good/bad practice to check if a number of programs are onDavid W. Hodgins
| |`- Re: Is it good/bad practice to check if a number of programs are onBit Twister
| `* Re: Is it good/bad practice to check if a number of programs are onChristian Weisgerber
|  `* Re: Is it good/bad practice to check if a number of programs are onGrant Taylor
|   `* Re: Is it good/bad practice to check if a number of programs are onJanis Papanagnou
|    `* ... indicate to be a compromised system ... -- Was: Re: Is itGrant Taylor
|     `* Re: ... indicate to be a compromised system ... -- Was: Re: Is itJanis Papanagnou
|      `- Re: ... indicate to be a compromised system ... -- Was: Re: Is itGrant Taylor
`- Re: Is it good/bad practice to check if a number of programs are onJorgen Grahn

1
Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1ch4b$j79$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5150&group=comp.unix.shell#5150

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ottavio2...@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Is it good/bad practice to check if a number of programs are on the
system in a shell file?
Date: Tue, 22 Mar 2022 12:57:46 +0000
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <t1ch4b$j79$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Mar 2022 12:57:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d7b8bd02bd4c9d722affd9bac7c63be2";
logging-data="19689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192/BriYiBqFzvOY5gNqXEqBalTzauypiQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.0.3
Cancel-Lock: sha1:25xewnvddU5EsLi5b9GMZg8aUn0=
X-No-Archive: yes
Content-Language: en-GB
 by: Ottavio Caruso - Tue, 22 Mar 2022 12:57 UTC

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.

--
Ottavio Caruso

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1cp0f$gpm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5151&group=comp.unix.shell#5151

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Tue, 22 Mar 2022 16:12:14 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <t1cp0f$gpm$1@dont-email.me>
References: <t1ch4b$j79$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Mar 2022 15:12:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4e41ce7731c4c3142e20fe2d4d86428a";
logging-data="17206"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+M7Gn9xGBfUbdWCzWFtAEM"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:wEDEVxOp0E+JPzjPKvrORqSyNT8=
In-Reply-To: <t1ch4b$j79$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 22 Mar 2022 15:12 UTC

On 22.03.2022 13:57, Ottavio Caruso wrote:
> I mean, if an executable is not there, the shell will still complain,

Starting a post with "I mean" - what does that mean?

"not there" - where?

The shell complains about what?

> but I would like to make sure that users of my script have the "right"

Define "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)

Why not just using standard shell syntax to describe what you want?

>
> 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.

You didn't tell us what shell you are using, so I suggest to use ksh's
'whence' command that allows you to exclude functions, aliases, etc.;
'whence --man' will show you the details (or search in 'man ksh').

Janis

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1ddu6$85o$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5159&group=comp.unix.shell#5159

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Tue, 22 Mar 2022 15:09:53 -0600
Organization: TNet Consulting
Message-ID: <t1ddu6$85o$1@tncsrv09.home.tnetconsulting.net>
References: <t1ch4b$j79$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 22 Mar 2022 21:09:26 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="8376"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <t1ch4b$j79$1@dont-email.me>
Content-Language: en-US
 by: Grant Taylor - Tue, 22 Mar 2022 21:09 UTC

On 3/22/22 6:57 AM, Ottavio Caruso wrote:
> I mean, if an executable is not there, the shell will still complain,

I think it's important to define where "there" means /explicitly/. E.g.
what if the command you want is in /usr/bin instead of /bin. There is
also a possibility that /bin is a sym-link to /usr/bin, but earlier in
the PATH.

> but I would like to make sure that users of my script have the "right"
> executables,

What defines the "right" vs "wrong" executable?

What if it's the version that you are wanting but it's located in ~/bin
instead of the system's (/usr(/local))/bin directory? E.g. GNU tools on
a *BSD system existing in ~/bin.

> for example not aliases, custom functions, etc. Or should I just
> leave the shell do its job?

Why do you want to ignore user preferences?

I could be arrogant and ask "what gives you the audacity to specify
which `ls` is run on /my/ system?

Especially if you don't provide the version you want run.

Also, aliases tend to be interactive and don't function in
non-interactive execution of scripts. Functions are their own critter.

> 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?)

So you aren't differentiating between /bin/bla, /usr/bin/bla,
/usr/local/bin/bla. So which of those is the right version of bla?

That also fails to take into account ~/bin being the first directory in
$PATH.

> 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.

Try using a full path to the command that you want or prefixing commands
with a backslash to disable alias support.

Again, alias / function support in interactive shells is different than
in non-interactive scripts.

--
Grant. . . .
unix || die

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5161&group=comp.unix.shell#5161

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.niel.me!aioe.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Tue, 22 Mar 2022 20:40:27 -0000 (UTC)
Message-ID: <slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
References: <t1ch4b$j79$1@dont-email.me>
Injection-Date: Tue, 22 Mar 2022 20:40:27 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="18825"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Tue, 22 Mar 2022 20:40 UTC

On 2022-03-22, Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> wrote:

> 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.

I suspect your premises are wrong. How would the shell executing
your script pick up "aliases, custom functions, etc."?

Nobody ever does what you are proposing.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5162&group=comp.unix.shell#5162

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Tue, 22 Mar 2022 19:25:48 -0600
Organization: TNet Consulting
Message-ID: <t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Mar 2022 01:25:21 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="25673"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
Content-Language: en-US
 by: Grant Taylor - Wed, 23 Mar 2022 01:25 UTC

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.

--
Grant. . . .
unix || die

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<op.1jgp1gwga3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5163&group=comp.unix.shell#5163

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Tue, 22 Mar 2022 22:47:30 -0400
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <op.1jgp1gwga3w0dxdave@hodgins.homeip.net>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="fa2e12e037cdf4c0430c066099f76243";
logging-data="16187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+c5Dytw4O8GfJhG9cKjsPcmUVfX6tFJ7A="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:tUlnv43ruPBvPATC2qgkaA3r0Ww=
 by: David W. Hodgins - Wed, 23 Mar 2022 02:47 UTC

On Tue, 22 Mar 2022 21:25:48 -0400, Grant Taylor <gtaylor@tnetconsulting.net> 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 &'

Regards, Dave Hodgins

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<slrnt3lfcf.d9li.BitTwister@wb.home.test>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5164&group=comp.unix.shell#5164

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: BitTwis...@mouse-potato.com (Bit Twister)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Wed, 23 Mar 2022 01:26:12 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <slrnt3lfcf.d9li.BitTwister@wb.home.test>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<op.1jgp1gwga3w0dxdave@hodgins.homeip.net>
Injection-Info: reader02.eternal-september.org; posting-host="a8dcfb149a7557bc56d724b4058b4bb3";
logging-data="25048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UnpTEavF3QLUXrHZ+8FxiRqmfJDcOG60="
User-Agent: slrn/pre1.0.4-6 (Linux)
Cancel-Lock: sha1:m3TCGVYHhg+mBYRj3QUmlUOw1Uk=
 by: Bit Twister - Wed, 23 Mar 2022 06:26 UTC

On Tue, 22 Mar 2022 22:47:30 -0400, David W. Hodgins wrote:
> On Tue, 22 Mar 2022 21:25:48 -0400, Grant Taylor <gtaylor@tnetconsulting.net> 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 &'

Yep and quite possible for the user to alias bash key words and breaking
the script.

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5172&group=comp.unix.shell#5172

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Wed, 23 Mar 2022 14:59:13 -0000 (UTC)
Message-ID: <slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
Injection-Date: Wed, 23 Mar 2022 14:59:13 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="41194"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Wed, 23 Mar 2022 14:59 UTC

On 2022-03-23, Grant Taylor <gtaylor@tnetconsulting.net> 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.

I meant that nobody checks in their scripts that standard commands
are in fact those standard commands.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5179&group=comp.unix.shell#5179

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Wed, 23 Mar 2022 14:33:51 -0600
Organization: TNet Consulting
Message-ID: <t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Mar 2022 20:33:24 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="6501"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
Content-Language: en-US
 by: Grant Taylor - Wed, 23 Mar 2022 20:33 UTC

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.

--
Grant. . . .
unix || die

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1gv7n$ee9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5182&group=comp.unix.shell#5182

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: Thu, 24 Mar 2022 06:23:02 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <t1gv7n$ee9$1@dont-email.me>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
<t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 24 Mar 2022 05:23:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c5f1f217dd25e0d22fc29972fac8ea62";
logging-data="14793"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MnR+kaKZJDblRceVkWGJ5"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:1J/U/lc5T/hW2vWyfpMCY4OsAPo=
In-Reply-To: <t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 24 Mar 2022 05:23 UTC

On 23.03.2022 21:33, Grant Taylor wrote:
> 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.

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. I'd thus rely on these tools (not "check"
them during runtime, which I really consider to be a sick idea).

>
> 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.

Indeed, to have assurance with basic programs (rm, mv, cp, ...) you
can use the absolute paths, or, set the PATH explicitly in scripts
to call the intended tools. (That was something we had also defined
in our coding standard in the 1990's. Now there's also env(1).)

Janis

Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<slrnt3o71c.1rfm.grahn+nntp@frailea.sa.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5183&group=comp.unix.shell#5183

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: grahn+n...@snipabacken.se (Jorgen Grahn)
Newsgroups: comp.unix.shell
Subject: Re: Is it good/bad practice to check if a number of programs are on
the system in a shell file?
Date: 24 Mar 2022 07:22:20 GMT
Lines: 23
Message-ID: <slrnt3o71c.1rfm.grahn+nntp@frailea.sa.invalid>
References: <t1ch4b$j79$1@dont-email.me>
X-Trace: individual.net 9m9/+m+W/F7uYtfzDZMZWweV8cm+dSeg3ifVCuBzlM8yPDxqjA
Cancel-Lock: sha1:dyxXv39IUXD1LuEklq/Tltc3dz0=
User-Agent: slrn/1.0.3 (OpenBSD)
 by: Jorgen Grahn - Thu, 24 Mar 2022 07:22 UTC

On Tue, 2022-03-22, Ottavio Caruso wrote:
> 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?

What executables are we speaking of?

If I had users, I'd do it like this:
- For core Unix commands (however you define that) I'd just assume
they're there. (If I targeted both Linux and the BSDs, I'd worry
about whether the commands were really equivalent.)
- For exotic dependencies, if I was distributing my software as a package
(RPM, deb ...) I'd list them as dependencies.
- If I distributed my software as source code, I'd list the dependencies
in the documentation, and maybe have a "check for dependencies" build
step.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

... indicate to be a compromised system ... -- Was: Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1ihhe$msk$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5186&group=comp.unix.shell#5186

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: ... indicate to be a compromised system ... -- Was: Re: Is it
good/bad practice to check if a number of programs are on the system in a
shell file?
Date: Thu, 24 Mar 2022 13:42:02 -0600
Organization: TNet Consulting
Message-ID: <t1ihhe$msk$1@tncsrv09.home.tnetconsulting.net>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
<t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net> <t1gv7n$ee9$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 24 Mar 2022 19:41:34 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="23444"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <t1gv7n$ee9$1@dont-email.me>
Content-Language: en-US
 by: Grant Taylor - Thu, 24 Mar 2022 19:42 UTC

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?

--
Grant. . . .
unix || die

Re: ... indicate to be a compromised system ... -- Was: Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1jkg1$ti3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5188&group=comp.unix.shell#5188

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: ... indicate to be a compromised system ... -- Was: Re: Is it
good/bad practice to check if a number of programs are on the system in a
shell file?
Date: Fri, 25 Mar 2022 06:38:08 +0100
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <t1jkg1$ti3$1@dont-email.me>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
<t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net> <t1gv7n$ee9$1@dont-email.me>
<t1ihhe$msk$1@tncsrv09.home.tnetconsulting.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 25 Mar 2022 05:38:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c26dbf1f6288e5dac0c68f25afba465d";
logging-data="30275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JENacL+Bbve9SB0hxgtQ2"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:HsvOv8ejF4/xpZurcNXQoav9/mU=
In-Reply-To: <t1ihhe$msk$1@tncsrv09.home.tnetconsulting.net>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 25 Mar 2022 05:38 UTC

On 24.03.2022 20:42, Grant Taylor wrote:
> 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). In a managed environment
the established security processes should be the relevant measure, and
the individual opinion of a sysadmin - to formulate it defensively - of
lesser importance. (I'm sure that for smaller companies it's certainly
more a challenge than for larger, process-driven companies.)

A special case, BTW, is a certified system. In the past I had worked in
a company that developed and sold security solutions. Systems had been
security tested and evaluated and then certified. Any change of the
system and the software versions invalidated the certificate.

Other experiences from lesser managed company contexts with more casual
handling of issues were less rewarding (for the company and customers).

This is where I am coming from. YMMV.

Janis

Re: ... indicate to be a compromised system ... -- Was: Re: Is it good/bad practice to check if a number of programs are on the system in a shell file?

<t1l26n$o5p$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5191&group=comp.unix.shell#5191

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: ... indicate to be a compromised system ... -- Was: Re: Is it
good/bad practice to check if a number of programs are on the system in a
shell file?
Date: Fri, 25 Mar 2022 12:38:43 -0600
Organization: TNet Consulting
Message-ID: <t1l26n$o5p$1@tncsrv09.home.tnetconsulting.net>
References: <t1ch4b$j79$1@dont-email.me>
<slrnt3kd1r.ic8.naddy@lorvorc.mips.inka.de>
<t1dsu1$p29$1@tncsrv09.home.tnetconsulting.net>
<slrnt3mde1.1879.naddy@lorvorc.mips.inka.de>
<t1g06k$6b5$1@tncsrv09.home.tnetconsulting.net> <t1gv7n$ee9$1@dont-email.me>
<t1ihhe$msk$1@tncsrv09.home.tnetconsulting.net> <t1jkg1$ti3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 25 Mar 2022 18:38:15 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="24761"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <t1jkg1$ti3$1@dont-email.me>
Content-Language: en-US
 by: Grant Taylor - Fri, 25 Mar 2022 18:38 UTC

On 3/24/22 11:38 PM, Janis Papanagnou wrote:
> 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).

Okay.

I now think that what you originally meant by "well meaning sysadmin" is
what my coworkers refer to as a "cowboy" who's know for saying things
like "hold my beer" and "it works for me".

That is a distinctly different subset than a sys-admin knowingly
installing an alternate security package (e.g. Kerberized telnet) or
vendor updates pursuant to the organization's wishes and change control.

Yes, I acknowledge certified systems. I'm not quite sure how standard
software updates work in that arena. Mostly because I've not dealt with it.

--
Grant. . . .
unix || die

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor