2 # For Emacs: -*- mode:cperl; mode:folding; -*-
4 # Get a machine's critical features, And mail/http them to the Linux Counter
6 # (c) 1999 - Harald Tveit Alvestrand, the Linux Counter Project
7 # 2003 - PetaMem Group (www.petamem.com)
8 # License: GNU Copyleft - see bottom of file.
9 # Changelog: see even more bottom of the file
11 # As a matter of courtesy, if you change this file on your own,
12 # make sure it does NOT mail to the counter!
17 our $VERSION = '0.32';
18 our $CVS_VERSION = '$Revision: 1.8 $ $Date: 2007/01/21 17:22:50 $ $Author: patrick $';
20 use vars qw(%values %oldvalues $errordata $debugdata %files); # data that is sent
21 use vars qw($progname %option $mailprogram);
22 use vars qw(%is_sys_account %is_user %is_account);
24 # stuff that controls defaults for passwdscan & accounts subroutines
25 my ($UID_MIN, $UID_MAX, $got_defs) = (100, 65533, '');
27 # Make sure nothing happens, so that the script's routines
28 # can be debugged from another file
29 return 1 if($IsInTestHarness);
48 die "No HOME environment variable\n" if (!$ENV{HOME});
49 die "No home diretory\n" if ! -d $ENV{HOME};
50 # Kill some internationalization
52 delete $ENV{LC_CTYPE};
53 delete $ENV{LC_NUMERIC};
56 delete $ENV{LC_MESSAGES};
57 delete $ENV{LC_COLLATE};
58 delete $ENV{LC_MONETARY};
60 my $infodir = "$ENV{HOME}/.linuxcounter";
62 mkdir($infodir, 0766) || die "Unable to make $infodir\n";
64 # Keep track of where I am; need it to install crontab entry
65 # progname is a global.
67 if ($progname !~ /^\//) {
70 $progname = "$progdir/$progname";
71 $progname =~ s!/./!/!;
73 chdir($infodir) || die "Unable to change to $infodir\n";
74 my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
76 print STDERR "Machine-update $VERSION. Use $0 -l to display license.\n";
77 print STDERR "Creating the infofile for your computer.\n";
79 open(INFO, ">$nodename");
80 print INFO "uniqueid: ", randomnumber(), "\n";
84 srand time % $$; # do some seed "randomization"
86 # Find out what mail program to use !! Terrible kludge !!
87 $mailprogram = "/usr/bin/mail";
88 if (! -x "$mailprogram") {
90 $mailprogram = "/bin/mail";
92 if (-x "/usr/sbin/sendmail") {
93 $mailprogram = "/usr/sbin/sendmail";
95 if (-x "/usr/lib/sendmail") {
96 $mailprogram = "/usr/lib/sendmail";
98 if (-x "/usr/bin/mutt") {
99 $mailprogram = "/usr/bin/mutt";
101 if (-x "/usr/sbin/exim4") {
102 $mailprogram = "/usr/sbin/exim4";
104 if (-x "/usr/bin/elm") {
105 $mailprogram = "/usr/bin/elm";
107 print "--------------------------------------------------------\n";
108 print "!!! Cannot find a mail program to use !!!\n";
109 print "Please copy the output into a new email and send that\n";
110 print "email manually to machine-registration\@linuxcounter.net\n";
111 print "--------------------------------------------------------\n";
128 while (defined($ARGV[0]) && $ARGV[0] =~ /^-/) {
130 $opt =~ /c/ && &installcrontab;
131 $opt =~ /d/ && $option{DEBUG}++ && print STDERR "Debug is $option{DEBUG}\n";
132 $opt =~ /h/ && &help;
133 $opt =~ /i/ && ($option{ask} = 1);
134 $opt =~ /l/ && &license;
135 $opt =~ /m/ && ($option{mail} = 1);
136 $opt =~ /t/ && ($option{mail} = 0);
137 $opt =~ /u/ && &uninstallcrontab;
138 $opt =~ /v/ && die "\n\t Linux Counter machine-update version $VERSION\n"
139 . "\tCVS version $CVS_VERSION\n";
140 $opt =~ /x/ && ($option{info} = 1);
150 return if ! -t STDIN || ! -t STDOUT;
152 print "Here you can specify some info that the script can't know for itself\n";
153 $values{owner} = askone("Your Linux Counter reg#, if any", $values{owner});
154 $values{key} = askone("Your machine's counter reg#, if any", $values{key});
165 if (defined($default)) {
173 &Debug("Answer was $ans\n");
174 $ans = $default if (!length($ans));
184 my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
185 open(INFO, $nodename) || die "Did not find infofile $nodename\n";
189 if (/^(\S+): *(.+)/) {
192 if ($1 !~ /^(owner|key|uniqueid)$/) {
195 &Debug("Read $key: $value\n");
196 $values{$key} = $value;
198 print STDERR "Unparsed info line: $_ - discarded\n";
202 %oldvalues = %values;
210 my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
212 open(INFO, ">$nodename.new");
213 for my $val (sort keys(%values)) {
214 &Debug("Saving $val: $values{$val}\n");
215 print INFO "$val: $values{$val}\n";
218 rename("$nodename.new", $nodename) || die "Rename failed\n";
227 open(MAIL, "|$mailprogram machine-registration\@linuxcounter.net")
228 || die "Unable to open $mailprogram\n";
230 warn "--------------------------------------------------------\n";
231 warn "This is what will be sent to the Linux Counter if you\n";
232 warn "run the program with the -m switch. Now, NOTHING IS SENT\n";
233 warn "--------------------------------------------------------\n";
234 open(MAIL, ">&STDOUT");
236 # note that $ENV{USER} isn't (always) set in a cron job...
237 my $user = (getpwuid($<))[0];
238 $user = "unknown-id-$<" if !$user;
241 To: machine-registration\@linuxcounter.net
242 Subject: machine-update for $values{name}
244 Mail program that sent this email: $mailprogram
245 Perl version used to run machine-update: $]
250 for my $val (sort keys(%values)) {
251 print MAIL "$val: $values{$val}\n"
252 if length($values{$val}) > 0;
254 print MAIL "//END\n";
256 for my $file (keys(%files)) {
257 print MAIL "//FILE $file\n";
258 print MAIL $files{$file};
259 print MAIL "//EOF\n";
263 # Attach possible other info
265 print MAIL "----- Problem info gathered during probing -----\n";
266 print MAIL $errordata;
268 $option{info} && do {
269 print MAIL "----- Debug data for the script maintainer's aid -----\n";
270 print MAIL $debugdata;
280 return int(rand(1_000_000_000));
288 my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
290 warn "This is not Linux, but $sysname!\n" if($sysname ne 'Linux');
291 $values{method} = "machine-update version $VERSION";
292 $values{os} = $sysname;
293 $values{kernel} = $release;
294 $values{cpu_uname} = $machine;
295 $values{name} = $nodename; # First order guess
297 # Credit for some of the code below goes to
298 # Denis Havlik: <havlik@ap.univie.ac.at>
299 # Blame is, of course, all mine - HTA -
300 # Note - there are numerous problems with df, including:
301 # - early versions don't support the -l option
302 # - at least some include SAMBA filesystems in the -l option
304 my $dfbin = &xbin("df");
305 $files{"df -T"} = `$dfbin -T -x nfs`;
307 $values{accounts} = &accounts;
308 $values{users} = &active_users;
310 my $uptime = &xbin('uptime');
313 $values{uptime_1} = $uptime; # preserve raw version
314 $values{uptime_1} =~ s/\n.*//;
316 my $lastprog = xbin('last');
317 if ($lastprog && -r "/var/run/utmp") {
318 $values{uptime_2} = `$lastprog -xf /var/run/utmp runlevel`;
319 $values{uptime_2} =~ s/\n.*$//s;
321 DebugInfo("Can't do last to find uptime");
323 # Not sure this is a Right Thing...so not saving it for the moment
324 # This section based on a patch from Mark-Jason Dominus <mjd@plover.com>
325 # try to guess mailer based on content of /usr/lib/sendmail link
326 if (-l '/usr/lib/sendmail') {
327 my $realsendmail = readlink('/usr/lib/sendmail');
328 if ($realsendmail eq '../sbin/sendmail') {
329 $realsendmail = '/usr/sbin/sendmail';
330 if (-l $realsendmail) {
331 $realsendmail = readlink($realsendmail);
334 if ($realsendmail =~ m{^/var/qmail}) {
335 $values{mailer} = "qmail";
337 &DebugInfo("Found sendmail as a link to $realsendmail\n");
340 # Link method did not work. Try to guess based on presence of
341 # config files. (this is more susceptible to the old-junk problem)
342 if (!$values{mailer}) {
343 if ( -d '/var/qmail') {
344 $values{mailer} = 'qmail';
345 } elsif ( -f '/etc/sendmail.cf' || -f '/etc/mail/sendmail.cf') {
346 # TMDG claims recent Fedora Core has it in /etc/mail/sendmail.cf
347 $values{mailer} = 'sendmail';
348 } elsif ( -d '/etc/postfix') {
349 $values{mailer} = 'postfix';
353 $values{kcoresize} = -s "/proc/kcore" || 0;
354 addonefileforsending("/proc/meminfo");
355 addonefileforsending("/proc/cpuinfo");
356 addonefileforsending("/proc/version");
357 # info on what devices are in use on the system
358 addonefileforsending("/proc/pci");
359 addonefileforsending("/proc/bus/usb/devices");
360 # Both Mandrake and Red Hat use this file....
361 addonefileforsending("/etc/redhat-release");
372 my $ypcatbin; # will hold path to the ypcat binary (if any)
374 open (TMP,"</etc/passwd");
376 &DebugErr("Found $s accounts total\n");
377 &Debug("Switching to NIS passwords\n");
379 $ypcatbin = &xbin('ypcat'); # get path to ypcat binary (empty if none)
380 if($ypcatbin) { # test whether ypcat was found
381 open TMP, "$ypcatbin passwd 2> /dev/null|"
382 || ($errordata .= "ypcat failed: $!\n");
386 &Debug("Status of ypcat: $?\n");
387 &DebugErr("Found $niss accounts in ypcat passwd\n");
390 &DebugErr('Sysaccounts: ', join(' ', keys(%is_sys_account)), "\n");
391 &DebugErr("Found $s accounts total\n");
401 # Code for reading login.defs courtesy of Vassilii Khachaturov
402 # <vassilii@tarunz.org>
404 # Try importing UID_MIN and UID_MAX from /etc/login.defs, if possible
405 # else just assume the above defaults for min and max non-system UID
406 if (!$got_defs && open (DEFS, '/etc/login.defs')) {
408 if (/^\s*(UID_(?:MIN|MAX))\s+(\d+)/) {
409 # elegant, but not compatible with "strict refs":
411 if ($1 eq "UID_MIN") {
416 &Debug("DEFS match: $1 = $2\n");
422 &Debug("UID_MIN = $UID_MIN, UID_MAX = $UID_MAX\n");
423 # I suppose this is as good as it gets -
424 # Usually user accounts have UID > 100 and
425 # "system accounts" have UID < 100, but there is no guarantee
427 # this will hold for pseudo-users like "postgress" etc.
428 # Also nobody is usually 99 on linux, but -1 on "standard" unices.
429 # RedHat places the dividing line at 500. Others use 400...
435 if (!($line[2] eq "")) {
436 if ($line[2] >= $UID_MIN && $line[2] <= $UID_MAX
437 && !($line[0] eq 'nobody')) {
439 $is_account{$line[0]} = 1;
441 $is_sys_account{$line[0]} = 1;
453 # This is kind of alpha, but please test it.
454 # It calculates the number of "active" users based on the "wtmp" entries
455 # unfortunately at least Mandrake 8 and 9 ship with non-world-read wtmp
456 # and non-set-uid last, so this does not work any more...
458 # RJ: Actually I think the best thing to do is to bury this code and be silent about it.
463 for (qw(reboot wtmp runlevel)) { # This sysaccounts shouldn't be counted. Who else?
464 $is_sys_account{$_} = 1;
466 open( TMP, "/usr/bin/last 2>&1|");
469 if (m!/var/log/wtmp: Permission denied!) { # RJ: ***Boom*** on every non-EN system
470 &ErrorInfo("/usr/bin/last failed because /var/log/wtmp isn't readable\n");
473 last if(!$_); # RJ: quick hack to safe bad code from harm
476 if ($is_sys_account{$name}) {
478 } elsif (defined $is_account{$name}) {
480 } elsif (/^\s*$/) { # blank line - do nothing
481 } elsif ($#tmp == 9) { # OK line, but unknown user
482 $option{DEBUG} && do {
484 print STDERR 'Know users are: ',
485 join(' ', keys(%is_account)), "\n";
488 print STDERR "Unknown user: $name\n";
491 &DebugErr("Strange line: $_\n");
496 for (sort keys %is_user) {
497 $option{DEBUG} && printf "Active user %3d: %s\n", ++$i, $_;
499 &Debug("$i active users found.\n");
510 my $hour = int(rand(24));
511 my $min = int(rand(60));
512 my $day = int(rand(7)); # Weekday. This version runs once a week.
515 warn "Installing start of script into your crontab\n";
516 if (open(CRON, "crontab -l |")) {
517 &Debug("Checking crontab for machine-update\n");
518 &Debug("Want to install as $progname\n");
520 if (/machine-update/) {
521 if (/ $progname -m/) {
522 die "Crontab entry already installed: $_\n";
524 die "Another entry with machine-update: $_\n";
530 &Debug("Result from crontab -l: ", $? / 256, "\n");
532 &Debug("Crontab successfully read\n");
533 } elsif ($? == 256) {
534 warn "You don't seem to have a crontab. I will create one.\n";
536 die "Failed to read your crontab. Please report this as a bug: $?\n";
539 &Debug("Result from crontab open(): $?\n");
540 die "Unable to execute crontab command. Please check your system\n";
542 open(CRON, "|crontab -");
544 print CRON "$min $hour * * $day $progname -m\n";
546 &Debug("Result from crontab: $?\n");
549 Installing new crontab failed.
550 YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
551 Here's its former content (if any):
557 print "Crontab entry successfully installed.\nWill run on day $day of every week, at $hour:$min\n";
563 # {{{ uninstallcrontab
566 sub uninstallcrontab {
570 print STDERR "Removing $progname from your crontab\n";
571 open(CRON, "crontab -l |");
572 &Debug("Checking crontab for machine-update\n");
573 &Debug("Want to uninstall as $progname\n");
575 if (/^#/ && $. <= 3) { # initial comment
576 &Debug("Skipping comment: $_");
579 if (/machine-update/) {
580 if (/ $progname -m/) {
581 print STDERR "Crontab entry found and removed\n";
583 next; # skip stuff at end....
585 die "Another entry with machine-update: $_\nUninstall manually?\n";
591 &Debug("Result from crontab -l: $?\n");
593 die "Failed to read your crontab. You may not have one?\n";
596 open(CRON, "|crontab -");
599 &Debug("Result from crontab: $?\n");
602 Installing new crontab failed.
603 YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
604 Here's its former content (if any):
611 print STDERR "No instance of $progname found in your crontab\n";
619 # {{{ xbin execute a linux binary
622 # This sub is to execute a linux binary robustly. i.e. testing
623 # whether it is present, where it is present, whether it is executable
626 my $bin = shift; # get name of binary to execute
628 $bin = `which $bin 2>/dev/null`; # determine binarys full path
630 return $bin if(-x $bin); # if there and executable: all is well - return it
632 if(!$bin) { # if not there
633 &Debug("No $bin found\n"); # state so
634 } else { # there but not executable
635 &Debug("$bin found, but not executable\n");
638 return ''; # so return an empty string (binary will not exec)
642 # {{{ getval_from_file get value from system file @ row,col
645 sub getval_from_file {
653 &DebugErr("File $file not readable\n");
656 sysopen(FH,$file, O_RDONLY);
657 @file = <FH>; # read whole file to array
660 @cols = split /\s+/, $file[$row]; # get the right row
662 return $cols[$col]; # return the right column
667 sub addonefileforsending {
672 &DebugErr("File $file not readable\n");
675 sysopen(FH,$file, O_RDONLY);
676 @file = <FH>; # read whole file to array
678 $files{$file} = join('', @file);
682 # {{{ Debug print debug information if flag is set
686 $option{DEBUG} && print @_;
690 # {{{ DebugErr print debug on STDERR if flag is set
694 $option{DEBUG} && print STDERR @_;
700 $errordata .= join('', @_);
706 $option{info} && ($debugdata .= join('', @_));
711 # {{{ help print help & exit
715 my $host = `uname -n`;
718 machine-update version $VERSION
719 Send machine information to the Linux Counter
721 USE: machine-update [-i] [-(t|d|l|m|v|x|c|u|h)]
725 -t = test (do not send e-mail, just print it ot STDOUT - default)
726 -d = debug (test, and print additional debug informations)
728 -m = mail results to linux-counter
729 -v = print version and exit
730 -x = send extra info to server (Debug)
731 -c = install crontab entry
732 -u = uninstall crontab entry
733 -h = print usage information and exit
734 If called with the "-i" option, will ask some questions and store the
735 answers in $ENV{HOME}/.linuxcounter/$host
743 # {{{ license print license & exit
749 Linux Counter Machine Update version $VERSION
751 Copyright (C) 1999-2005 Harald Tveit Alvestrand
752 2003 PetaMem Group (www.petamem.com)
754 This program is free software; you can redistribute it and/or modify
755 it under the terms of the GNU General Public License as published by
756 the Free Software Foundation; either version 2 of the License, or
757 (at your option) any later version.
759 This program is distributed in the hope that it will be useful,
760 but WITHOUT ANY WARRANTY; without even the implied warranty of
761 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
762 GNU General Public License below for more details.
765 GNU GENERAL PUBLIC LICENSE
768 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
769 675 Mass Ave, Cambridge, MA 02139, USA
770 Everyone is permitted to copy and distribute verbatim copies
771 of this license document, but changing it is not allowed.
775 The licenses for most software are designed to take away your
776 freedom to share and change it. By contrast, the GNU General Public
777 License is intended to guarantee your freedom to share and change free
778 software--to make sure the software is free for all its users. This
779 General Public License applies to most of the Free Software
780 Foundation's software and to any other program whose authors commit to
781 using it. (Some other Free Software Foundation software is covered by
782 the GNU Library General Public License instead.) You can apply it to
785 When we speak of free software, we are referring to freedom, not
786 price. Our General Public Licenses are designed to make sure that you
787 have the freedom to distribute copies of free software (and charge for
788 this service if you wish), that you receive source code or can get it
789 if you want it, that you can change the software or use pieces of it
790 in new free programs; and that you know you can do these things.
792 To protect your rights, we need to make restrictions that forbid
793 anyone to deny you these rights or to ask you to surrender the rights.
794 These restrictions translate to certain responsibilities for you if you
795 distribute copies of the software, or if you modify it.
797 For example, if you distribute copies of such a program, whether
798 gratis or for a fee, you must give the recipients all the rights that
799 you have. You must make sure that they, too, receive or can get the
800 source code. And you must show them these terms so they know their
803 We protect your rights with two steps: (1) copyright the software, and
804 (2) offer you this license which gives you legal permission to copy,
805 distribute and/or modify the software.
807 Also, for each author's protection and ours, we want to make certain
808 that everyone understands that there is no warranty for this free
809 software. If the software is modified by someone else and passed on, we
810 want its recipients to know that what they have is not the original, so
811 that any problems introduced by others will not reflect on the original
812 authors' reputations.
814 Finally, any free program is threatened constantly by software
815 patents. We wish to avoid the danger that redistributors of a free
816 program will individually obtain patent licenses, in effect making the
817 program proprietary. To prevent this, we have made it clear that any
818 patent must be licensed for everyone's free use or not licensed at all.
820 The precise terms and conditions for copying, distribution and
823 GNU GENERAL PUBLIC LICENSE
824 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
826 0. This License applies to any program or other work which contains
827 a notice placed by the copyright holder saying it may be distributed
828 under the terms of this General Public License. The "Program", below,
829 refers to any such program or work, and a "work based on the Program"
830 means either the Program or any derivative work under copyright law:
831 that is to say, a work containing the Program or a portion of it,
832 either verbatim or with modifications and/or translated into another
833 language. (Hereinafter, translation is included without limitation in
834 the term "modification".) Each licensee is addressed as "you".
836 Activities other than copying, distribution and modification are not
837 covered by this License; they are outside its scope. The act of
838 running the Program is not restricted, and the output from the Program
839 is covered only if its contents constitute a work based on the
840 Program (independent of having been made by running the Program).
841 Whether that is true depends on what the Program does.
843 1. You may copy and distribute verbatim copies of the Program's
844 source code as you receive it, in any medium, provided that you
845 conspicuously and appropriately publish on each copy an appropriate
846 copyright notice and disclaimer of warranty; keep intact all the
847 notices that refer to this License and to the absence of any warranty;
848 and give any other recipients of the Program a copy of this License
849 along with the Program.
851 You may charge a fee for the physical act of transferring a copy, and
852 you may at your option offer warranty protection in exchange for a fee.
854 2. You may modify your copy or copies of the Program or any portion
855 of it, thus forming a work based on the Program, and copy and
856 distribute such modifications or work under the terms of Section 1
857 above, provided that you also meet all of these conditions:
859 a) You must cause the modified files to carry prominent notices
860 stating that you changed the files and the date of any change.
862 b) You must cause any work that you distribute or publish, that in
863 whole or in part contains or is derived from the Program or any
864 part thereof, to be licensed as a whole at no charge to all third
865 parties under the terms of this License.
867 c) If the modified program normally reads commands interactively
868 when run, you must cause it, when started running for such
869 interactive use in the most ordinary way, to print or display an
870 announcement including an appropriate copyright notice and a
871 notice that there is no warranty (or else, saying that you provide
872 a warranty) and that users may redistribute the program under
873 these conditions, and telling the user how to view a copy of this
874 License. (Exception: if the Program itself is interactive but
875 does not normally print such an announcement, your work based on
876 the Program is not required to print an announcement.)
878 These requirements apply to the modified work as a whole. If
879 identifiable sections of that work are not derived from the Program,
880 and can be reasonably considered independent and separate works in
881 themselves, then this License, and its terms, do not apply to those
882 sections when you distribute them as separate works. But when you
883 distribute the same sections as part of a whole which is a work based
884 on the Program, the distribution of the whole must be on the terms of
885 this License, whose permissions for other licensees extend to the
886 entire whole, and thus to each and every part regardless of who wrote it.
888 Thus, it is not the intent of this section to claim rights or contest
889 your rights to work written entirely by you; rather, the intent is to
890 exercise the right to control the distribution of derivative or
891 collective works based on the Program.
893 In addition, mere aggregation of another work not based on the Program
894 with the Program (or with a work based on the Program) on a volume of
895 a storage or distribution medium does not bring the other work under
896 the scope of this License.
898 3. You may copy and distribute the Program (or a work based on it,
899 under Section 2) in object code or executable form under the terms of
900 Sections 1 and 2 above provided that you also do one of the following:
902 a) Accompany it with the complete corresponding machine-readable
903 source code, which must be distributed under the terms of Sections
904 1 and 2 above on a medium customarily used for software interchange; or,
906 b) Accompany it with a written offer, valid for at least three
907 years, to give any third party, for a charge no more than your
908 cost of physically performing source distribution, a complete
909 machine-readable copy of the corresponding source code, to be
910 distributed under the terms of Sections 1 and 2 above on a medium
911 customarily used for software interchange; or,
913 c) Accompany it with the information you received as to the offer
914 to distribute corresponding source code. (This alternative is
915 allowed only for noncommercial distribution and only if you
916 received the program in object code or executable form with such
917 an offer, in accord with Subsection b above.)
919 The source code for a work means the preferred form of the work for
920 making modifications to it. For an executable work, complete source
921 code means all the source code for all modules it contains, plus any
922 associated interface definition files, plus the scripts used to
923 control compilation and installation of the executable. However, as a
924 special exception, the source code distributed need not include
925 anything that is normally distributed (in either source or binary
926 form) with the major components (compiler, kernel, and so on) of the
927 operating system on which the executable runs, unless that component
928 itself accompanies the executable.
930 If distribution of executable or object code is made by offering
931 access to copy from a designated place, then offering equivalent
932 access to copy the source code from the same place counts as
933 distribution of the source code, even though third parties are not
934 compelled to copy the source along with the object code.
936 4. You may not copy, modify, sublicense, or distribute the Program
937 except as expressly provided under this License. Any attempt
938 otherwise to copy, modify, sublicense or distribute the Program is
939 void, and will automatically terminate your rights under this License.
940 However, parties who have received copies, or rights, from you under
941 this License will not have their licenses terminated so long as such
942 parties remain in full compliance.
944 5. You are not required to accept this License, since you have not
945 signed it. However, nothing else grants you permission to modify or
946 distribute the Program or its derivative works. These actions are
947 prohibited by law if you do not accept this License. Therefore, by
948 modifying or distributing the Program (or any work based on the
949 Program), you indicate your acceptance of this License to do so, and
950 all its terms and conditions for copying, distributing or modifying
951 the Program or works based on it.
953 6. Each time you redistribute the Program (or any work based on the
954 Program), the recipient automatically receives a license from the
955 original licensor to copy, distribute or modify the Program subject to
956 these terms and conditions. You may not impose any further
957 restrictions on the recipients' exercise of the rights granted herein.
958 You are not responsible for enforcing compliance by third parties to
961 7. If, as a consequence of a court judgment or allegation of patent
962 infringement or for any other reason (not limited to patent issues),
963 conditions are imposed on you (whether by court order, agreement or
964 otherwise) that contradict the conditions of this License, they do not
965 excuse you from the conditions of this License. If you cannot
966 distribute so as to satisfy simultaneously your obligations under this
967 License and any other pertinent obligations, then as a consequence you
968 may not distribute the Program at all. For example, if a patent
969 license would not permit royalty-free redistribution of the Program by
970 all those who receive copies directly or indirectly through you, then
971 the only way you could satisfy both it and this License would be to
972 refrain entirely from distribution of the Program.
974 If any portion of this section is held invalid or unenforceable under
975 any particular circumstance, the balance of the section is intended to
976 apply and the section as a whole is intended to apply in other
979 It is not the purpose of this section to induce you to infringe any
980 patents or other property right claims or to contest validity of any
981 such claims; this section has the sole purpose of protecting the
982 integrity of the free software distribution system, which is
983 implemented by public license practices. Many people have made
984 generous contributions to the wide range of software distributed
985 through that system in reliance on consistent application of that
986 system; it is up to the author/donor to decide if he or she is willing
987 to distribute software through any other system and a licensee cannot
990 This section is intended to make thoroughly clear what is believed to
991 be a consequence of the rest of this License.
993 8. If the distribution and/or use of the Program is restricted in
994 certain countries either by patents or by copyrighted interfaces, the
995 original copyright holder who places the Program under this License
996 may add an explicit geographical distribution limitation excluding
997 those countries, so that distribution is permitted only in or among
998 countries not thus excluded. In such case, this License incorporates
999 the limitation as if written in the body of this License.
1001 9. The Free Software Foundation may publish revised and/or new versions
1002 of the General Public License from time to time. Such new versions will
1003 be similar in spirit to the present version, but may differ in detail to
1004 address new problems or concerns.
1006 Each version is given a distinguishing version number. If the Program
1007 specifies a version number of this License which applies to it and "any
1008 later version", you have the option of following the terms and conditions
1009 either of that version or of any later version published by the Free
1010 Software Foundation. If the Program does not specify a version number of
1011 this License, you may choose any version ever published by the Free Software
1014 10. If you wish to incorporate parts of the Program into other free
1015 programs whose distribution conditions are different, write to the author
1016 to ask for permission. For software which is copyrighted by the Free
1017 Software Foundation, write to the Free Software Foundation; we sometimes
1018 make exceptions for this. Our decision will be guided by the two goals
1019 of preserving the free status of all derivatives of our free software and
1020 of promoting the sharing and reuse of software generally.
1024 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
1025 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
1026 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
1027 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
1028 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1029 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
1030 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
1031 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
1032 REPAIR OR CORRECTION.
1034 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
1035 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
1036 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
1037 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
1038 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
1039 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
1040 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
1041 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
1042 POSSIBILITY OF SUCH DAMAGES.
1044 END OF TERMS AND CONDITIONS
1054 # - indentation and folding marks
1055 # - made script work with -w and use strict
1056 # - removed some localization traps
1057 # - marked some BUGS - but they`re still there (mostly localization)
1058 # - more robust binary calls
1059 # - getval_from_file data acquisition method
1060 # - fixed df (shmfs) - but only temporarily (quick hack)
1061 # - various code optimizations & cleanup (removed unneded vars)
1062 # - Memory size detection now robst and >960MB capable
1063 # - slightly better randomness
1067 # - added attaching of files
1068 # - added fetching of uptime_1 and uptime_2
1071 # - removed "manual" copying of entries
1072 # - added suppressing error messages from "xbin" calling "which"
1073 # - suppressed NFS from "df -T" listing
1076 # - added sending /proc/pci
1077 # - removed client-side parsing of DF output and uptime
1080 # - added sending /proc/version (inspired by klive)
1081 # - changed fetching of old data from "all" to "needed"
1082 # - removed CPU-parsing code
1083 # - fixed warning (harmless) from crontab creation
1084 # - added sending /proc/bus/usb/devices
1087 # - added sending size of /proc/kcore
1088 # - removed computation of memory client-side
1091 # - adding cron entry no longer removes comments from crontab.
1092 # Crontab is not ours, so hands off.
1095 # - When /proc/kcore does not exist on a system, its size is now zero
1098 # - Added a terrible way to find out what email program can be used to send out the mail
1101 # - Extended the hardcoded list of programs that can be used to send the
1102 # machine-update email
1105 # - The script now sends us the version of perl used to run the script
1106 # We need this to solve some problems due to changes in between perl
1110 # - The script now sends the email to machine-registration@linuxcounter.net
1111 # instead of the old counter machine machine-registration@counter.li.org
1114 # - If no mail program was found, the script will not stop anymore. It prints
1115 # the output anyways and you can send this manually to machine-registration@counter.li.org
1117 #vim:ts=8:sw=4:sts=4