Re: Script Test [OT]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06Sep2008 12:01, kwhiskerz <kwhiskerz@xxxxxxxxx> wrote:
| A suggestion I found on the net is to test for the value of md5sum 
| /etc/passwd.

That's horrible. Unreliable, etc.

| Now, does this stay the same, even if a password is added or 
| changed?

With shadow passwords, yes. But if someone: changes their name, changes
their shell, changes their homedir, a new user is added, a user is
deleted. All these will break the test.

| Is it unique to a computer?

And it is not unique.
It is a very bad suggestion.
Just check hostname (and maybe domainname, depending how widely
your test needs to wordk).

| And also, how do I isolate the number and 
| strip off the space and "/etc/passwd" from the result?

With cut or sed or awk or perl or ...
But since it is a "signature", who cares if the filename is there or
not? Just compare the full thing.

Seriously, don't do the md5sum thing.

Personally, I try to set up three environment variables: $HOSTNAME,
being the full hostname (foo.example.com), $HOST, being the shortname
(foo) and $SYSTEMID being what I call the "administrative zone" ("home"
at home, "cisra" at a former workplace of that name, etc).  These are
all arbitrary and of course need special setup everywhere, but once they
are there it is possible to make sensible comparison statements. Then
the problem moves from an ad hoc test in a script to maintaining these
variables, which at least is a better defined problem.

So my scripts which care tend to say:

  case "$HOST@$SYSTEMID" in
    fleet@home)
      # my laptop ...
      ...
      ;;
  esac

and so forth.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

I am returning this otherwise good typing paper to you because someone has
printed gibberish all over it and put your name at the top.
        - English Professor, Ohio University

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux