summaryrefslogtreecommitdiff
path: root/machine-update
blob: 72365d77141d0a0fec0433ad6423a3262306fbd0 (plain)
  1. #!/usr/bin/perl
  2. $VERSION = "0.17";
  3. $CVS_VERSION = '$Revision: 1.1 $ $Date: 2005-03-11 16:57:22 $ $Author: jonas $';
  4. #
  5. # Get a machine's critical features, And mail them to the Linux Counter
  6. #
  7. # Copyright (c) Harald Tveit Alvestrand, the Linux Counter Project
  8. # License: GNU Copyleft - see bottom of file.
  9. #
  10. # As a matter of courtesy, if you change this file on your own,
  11. # make sure it does NOT mail to the counter!!!!!!!!!!!!
  12. #
  13. $HELP = <<EoF;
  14. machine-update version $VERSION
  15. Send machine information to the Linux Counter
  16. USE: machine-update [-i] [-(t|d|l|m|v|x|c|u|h)]
  17. SWITCHES:
  18. -i = interactive
  19. -t = test (do not send e-mail, just print it ot STDOUT - default)
  20. -d = debug (test, and print additional debug informations)
  21. -l = display license
  22. -m = mail results to linux-counter
  23. -v = print version and exit
  24. -x = send extra info to server (Debug)
  25. -c = install crontab entry
  26. -u = uninstall crontab entry
  27. -h = print usage information and exit
  28. If called interactively, will ask some questions and store the
  29. answers in $HOME/.linuxcounter/<uname -n>
  30. EoF
  31. #
  32. use POSIX;
  33. # Predecarations
  34. sub Debug;
  35. sub ErrorInfo;
  36. sub DebugInfo;
  37. # Some variables are for internal use, and never prompted for in
  38. # the loop of askquestions
  39. %dontask = (
  40. "uniqueid", 1, # Internal use
  41. "manual", 1,
  42. "method", 1,
  43. "owner", 1, # These 2 are always prompted for
  44. "key", 1,
  45. "uptime", 1, # We think we know how to get these
  46. );
  47. # Configuration: Where to fetch information from
  48. $cpufile = "/proc/cpuinfo";
  49. $kcorefile = "/proc/kcore";
  50. # Make sure nothing happens, so that the script's routines
  51. # can be debugged from another file
  52. if ($IsInTestHarness) {
  53. return 1;
  54. }
  55. preparation();
  56. options();
  57. if ($option{crontab}) {
  58. installcrontab();
  59. exit(0)
  60. } elsif ($option{uncrontab}) {
  61. uninstallcrontab();
  62. exit(0);
  63. }
  64. readfile();
  65. checkconfig();
  66. if ($option{ask}) {
  67. askquestions();
  68. } else {
  69. copymanuals();
  70. }
  71. writefile();
  72. sendfile();
  73. sub preparation {
  74. die "No HOME environment variable\n" if (!$ENV{HOME});
  75. die "No home diretory\n" if ! -d $ENV{HOME};
  76. $infodir = "$ENV{HOME}/.linuxcounter";
  77. if (! -d $infodir) {
  78. mkdir($infodir, 0766) || die "Unable to make $infodir\n";
  79. }
  80. # Keep track of where I am; need it to install crontab entry
  81. # progname is a global.
  82. $progname = $0;
  83. if ($progname !~ /^\//) {
  84. my $progdir = `pwd`;
  85. chop $progdir;
  86. $progname = "$progdir/$progname";
  87. $progname =~ s!/./!/!;
  88. }
  89. chdir($infodir) || die "Unable to change to $infodir\n";
  90. ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
  91. if (! -f $nodename) {
  92. print STDERR "Machine-update $VERSION. Use $0 -l to display license.\n";
  93. print STDERR "Creating the infofile for your computer.\n";
  94. # Create the infodir
  95. open(INFO, ">$nodename");
  96. print INFO "uniqueid: ", randomnumber(), "\n";
  97. close INFO;
  98. }
  99. }
  100. sub options {
  101. while ($ARGV[0] =~ /^-/) {
  102. $opt = shift @ARGV;
  103. $opt =~ /i/ && ($option{ask}=1) ;
  104. $opt =~ /d/ && ($option{DEBUG}+=1) && (print STDERR "Debug is $option{DEBUG}\n");
  105. $opt =~ /l/ && do {license(); exit(0)};
  106. $opt =~ /t/ && ($option{mail}=0);
  107. $opt =~ /m/ && ($option{mail}=1);
  108. $opt =~ /x/ && ($option{info}=1);
  109. $opt =~ /c/ && ($option{crontab}=1);
  110. $opt =~ /u/ && ($option{uncrontab}=1);
  111. $opt =~ /v/ && die "\n\t Linux Counter machine-update version $VERSION\n";
  112. $opt =~ /h/ && die $HELP;
  113. }
  114. }
  115. sub askquestions {
  116. return if ! -t STDIN || ! -t STDOUT;
  117. $| = 1;
  118. print "Here you can specify some info that the script can't know for itself\n";
  119. $values{owner} = askone("Your Linux Counter reg#, if any", $values{owner});
  120. $values{key} = askone("Your machine's counter reg#, if any", $values{key});
  121. print "Here is what the program has found:\n";
  122. for $key (keys(%values)) {
  123. if (!$dontask{$key}) {
  124. printf "%-10s%1s: %s\n", $key, $dontask{$key}?"*":" ", $values{$key};
  125. }
  126. }
  127. $domore = askone("Do you want to override some of the found values?", "no");
  128. if ($domore =~ /^Y/i) {
  129. my $manual;
  130. for $key (keys(%values)) {
  131. next if $dontask{$key};
  132. my $value = askone($key, $oldvalues{$key}, $values{$key});
  133. if ($values{$key} eq $value) {
  134. # go to automatic
  135. Debug "auto value: $key\n";
  136. } else {
  137. Debug "still manual value: $key\n";
  138. $manual .= " $key";
  139. }
  140. $values{$key} = $value;
  141. }
  142. $values{manual} = $manual;
  143. } else {
  144. delete $values{manual};
  145. }
  146. }
  147. sub askone {
  148. my $prompt = shift;
  149. my $default = shift;
  150. my $probed = shift;
  151. print $prompt;
  152. if (!defined($default) && defined($probed)) {
  153. $default = $probed;
  154. }
  155. if (defined($default)) {
  156. print " [$default]";
  157. }
  158. if (defined($probed) && $probed ne $default) {
  159. print "(program found $probed)";
  160. }
  161. print ":";
  162. $ans = <STDIN>;
  163. chop $ans;
  164. Debug "Answer was $ans\n";
  165. if (length($ans) == 0) {
  166. $ans = $default;
  167. }
  168. $ans;
  169. }
  170. sub copymanuals {
  171. my %keeps = map {$_ => 1} split(" ", $values{manual});
  172. Debug "Keeping ", join(" ", keys(%keeps)), "\n";
  173. for $key (keys(%keeps)) {
  174. $values{$key} = $oldvalues{$key};
  175. }
  176. }
  177. sub readfile {
  178. open(INFO, $nodename) || die "Did not find infofile $nodename\n";
  179. while (<INFO>) {
  180. chop;
  181. s/#.*//;
  182. if (/^(\S+): *(.+)/) {
  183. Debug "Read $1: $2\n";
  184. $values{$1} = $2;
  185. } else {
  186. print STDERR "Unparsed info line: $_ - discarded\n";
  187. }
  188. }
  189. close INFO;
  190. %oldvalues = %values;
  191. }
  192. sub writefile {
  193. open(INFO, ">$nodename.new");
  194. for $val (sort keys(%values)) {
  195. Debug "Saving $val: $values{$val}\n";
  196. print INFO "$val: $values{$val}\n";
  197. }
  198. close INFO;
  199. rename("$nodename.new", $nodename) || die "Rename failed\n";
  200. }
  201. sub sendfile {
  202. if ($option{mail}) {
  203. open(MAIL, "|/usr/lib/sendmail machine-registration\@counter.li.org")
  204. || die "Unable to open sendmail\n";
  205. } else {
  206. warn "--------------------------------------------------------\n";
  207. warn "This is what will be sent to the Linux Counter if you\n";
  208. warn "run the program with the -m switch. Now, NOTHING IS SENT\n";
  209. warn "--------------------------------------------------------\n";
  210. open(MAIL, ">&STDOUT");
  211. }
  212. # note that $ENV{USER} isn't (always) set in a cron job...
  213. $user = (getpwuid($<))[0];
  214. $user = "unknown-id-$<" if !$user;
  215. print MAIL <<EOF
  216. From: $user
  217. To: machine-registration\@counter.li.org
  218. Subject: machine-update for $values{name}
  219. //MACHINE
  220. EOF
  221. ;
  222. for $val (sort keys(%values)) {
  223. print MAIL "$val: $values{$val}\n";
  224. }
  225. print MAIL "//END\n";
  226. # Attach possible other info
  227. if ($errordata) {
  228. print MAIL "----- Problem info gathered during probing -----\n";
  229. print MAIL $errordata;
  230. }
  231. $option{info} && do {
  232. print MAIL "----- Debug data for the script maintainer's aid -----\n";
  233. print MAIL $debugdata;
  234. };
  235. close MAIL;
  236. }
  237. sub randomnumber {
  238. # Better randomness desired.
  239. return int(rand(1_000_000_000));
  240. }
  241. sub checkconfig {
  242. $values{method} = "machine-update version $VERSION";
  243. ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
  244. die "This is not Linux, but $sysname!\n" if $sysname ne "Linux";
  245. $values{kernel} = $release;
  246. $values{cpu_uname} = $machine;
  247. $values{name} = $nodename; # First order guess
  248. # Credit for some of the code below goes to
  249. # Denis Havlik: <havlik&#x40;ap.univie.ac.at>
  250. # Blame is, of course, all mine - HTA -
  251. open (TMP,"df -l |");
  252. $HD=0;
  253. while (<TMP>) {
  254. @line=split(/\s+/);
  255. ($line[1]=~ /blocks$/) || ($HD+=$line[1]);
  256. }
  257. Debug "$HD kbytes of disk found\n";
  258. $HD/=1024;
  259. $values{disk} = sprintf("%d", $HD);
  260. $values{accounts} = accounts();
  261. $values{users} = active_users();
  262. $uptime = `uptime`;
  263. if ($uptime =~ /up\s+(.*),\s+\d+ user/) {
  264. $values{uptime} = $1;
  265. } else {
  266. ErrorInfo "Can't parse uptime output: $uptime\n";
  267. }
  268. if ($option{info}) {
  269. DebugInfo "***** Uptime output *****\n$uptime";
  270. }
  271. # Not sure this is a Right Thing...so not saving it for the moment
  272. $s{mailaddr}=$s{hostname};
  273. if ( -f "/etc/sendmail.cf" ) {
  274. $values{mailer} = "sendmail";
  275. open (TMP,"</etc/sendmail.cf");
  276. while (<TMP>) {
  277. if (/^DM(.+)/) {
  278. $s{mailaddr}=$1;
  279. Debug "Found $s{mailaddr} in /etc/sendmail.cf\n";
  280. }
  281. }
  282. }
  283. if (-f $kcorefile) {
  284. $values{memory} = ((-s $kcorefile) - 4096) / (1024*1024);
  285. } else {
  286. ErrorInfo "No /proc/kcore file\n";
  287. }
  288. cpuinfo();
  289. }
  290. sub cpuinfo {
  291. # This procedure is likely to get tacky enough that I want to
  292. # isolate it from the rest....
  293. my %interesting = (
  294. # 2.0 and 2.2 kernels
  295. "bogomips" => "+bogomips",
  296. "processor" => "1+processors",
  297. "vendor_id" => "cpu_vendor",
  298. # 2.0 kernels
  299. "cpu" => "cpu_only",
  300. "model" => "cpu_model",
  301. "model name" => "cpu_model_name",
  302. # 2.2 kernels
  303. "cpu MHz" => "cpu_mhz",
  304. "cpu family" => "cpu_family",
  305. # from an Alpha processor
  306. "cycle frequency [Hz]" => "cpu_hz",
  307. "BogoMIPS" => "+bogomips",
  308. "cpu model" => "cpu_model",
  309. "system type" => "cpu_system_type",
  310. "cpus detected" => "processors",
  311. # from a PowerMAC
  312. "machine" => "cpu_machine",
  313. "clock" => "cpu_clock",
  314. "motherboard" => "cpu_motherboard",
  315. );
  316. # Zero out the accumulative values
  317. $values{bogomips} = 0;
  318. $values{processors} = 0;
  319. if (open (TMP,"<$cpufile")) {
  320. DebugInfo "**** Contents of $cpufile ****\n";
  321. while (<TMP>) {
  322. # Save /proc/cpuinfo to debugdata if -d
  323. DebugInfo $_;
  324. chop;
  325. # A bizarre selection of names are "interesting".
  326. # Make a data-driven pick routine
  327. if (/^(\S+[^:]+\S)\s+: /) {
  328. $name = $1;
  329. $value = $';
  330. if ($interesting{$name}) {
  331. if ($interesting{$name} =~ /^\+/) {
  332. $values{$'} += $value;
  333. } elsif ($interesting{$name} =~ /^1\+/) {
  334. $values{$'} += 1;
  335. } else {
  336. $values{$interesting{$name}} = $value;
  337. }
  338. }
  339. }
  340. }
  341. } else {
  342. ErrorInfo "Could not open $cpufile\n";
  343. }
  344. }
  345. sub accounts {
  346. my $s;
  347. my $niss;
  348. open (TMP,"</etc/passwd");
  349. $s += passwdscan();
  350. $option{DEBUG} && do {
  351. print STDERR "Found $s accounts total\n";
  352. };
  353. Debug "Switching to NIS passwords\n";
  354. open(TMP, "ypcat passwd 2> /dev/null|")
  355. || do {$errrordata .= "ypcat failed: $!\n"};
  356. $niss = passwdscan();
  357. $s += $niss;
  358. close TMP;
  359. Debug "Status of ypcat: $?\n";
  360. $option{DEBUG} && do {
  361. print STDERR "Found $niss accounts in ypcat passwd\n";
  362. };
  363. $option{DEBUG} && do {
  364. print STDERR "Sysaccounts: ", join(" ", keys(%is_sys_account)), "\n";
  365. print STDERR "Found $s accounts total\n";
  366. };
  367. return $s
  368. }
  369. sub passwdscan {
  370. # I suppose this is as good as it gets -
  371. # Usually user accounts have UID > 100 and
  372. # "system accounts" have UID < 100, but there is no guarantee that
  373. # this will hold for pseudo-users like "postgress" etc.
  374. # Also nobody is usually 99 on linux, but -1 on "standard" unices.
  375. my @line;
  376. my $s=0;
  377. while (<TMP>) {
  378. @line=split(":");
  379. if ($line[2] > 100) {
  380. $s++;
  381. $is_account{$line[0]} = 1;
  382. } else {
  383. $is_sys_account{$line[0]} = 1;
  384. }
  385. }
  386. $s;
  387. }
  388. sub active_users {
  389. # This is kind of alpha, but please test it.
  390. # It calculates the number of "active" users based on the "wtmp" entries
  391. # This guys shouldn't be counted. Who else?
  392. for $q (qw(reboot wtmp runlevel)) {
  393. $is_sys_account{$q} = 1;
  394. }
  395. open( TMP, "/usr/bin/last|");
  396. while (<TMP>){
  397. chop;
  398. @tmp=split;
  399. $name = $tmp[0];
  400. if ($is_sys_account{$name}) {
  401. # do nothing
  402. } elsif ($is_account{$name}) {
  403. $is_user{$name}=1;
  404. } elsif (/^\s*$/) {
  405. # blank line - do nothing
  406. } elsif ($#tmp == 9) {
  407. # OK line, but unknown user
  408. $option{DEBUG} && do {
  409. if (!$userslisted) {
  410. print STDERR "Know users are: ",
  411. join(" ", keys(%is_account)), "\n";
  412. $userslisted = 1;
  413. };
  414. print STDERR "Unknown user: $name\n";
  415. }
  416. } else {
  417. $option{DEBUG} && print STDERR "Strange line: $_\n";
  418. }
  419. }
  420. close TMP;
  421. $i=0;
  422. foreach $user (sort keys %is_user) {
  423. $i++;
  424. $option{DEBUG} && printf "Active user %3d: %s\n", $i, $user;
  425. }
  426. $option{DEBUG} && print "$i active users found.\n";
  427. return $i;
  428. }
  429. sub installcrontab {
  430. print STDERR "Installing start of script into your crontab\n";
  431. $hour = int(rand(24));
  432. $min = int(rand(60));
  433. $day = int(rand(7)); # Weekday. This version runs once a week.
  434. # Previous versions ran once a month.
  435. if (open(CRON, "crontab -l |")) {
  436. $option{DEBUG} && print "Checking crontab for machine-update\n";
  437. $option{DEBUG} && print "Want to install as $progname\n";
  438. while (<CRON>) {
  439. if (/^#/ && $. <= 3) { # initial comment
  440. Debug "Skipping comment: $_";
  441. next;
  442. }
  443. if (/machine-update/) {
  444. if (/ $progname -m/) {
  445. die "Crontab entry already installed: $_\n";
  446. } else {
  447. die "Another entry with machine-update: $_\n";
  448. }
  449. }
  450. $cron .= $_;
  451. }
  452. close CRON;
  453. Debug "Result from crontab -l: ", $? / 256, "\n";
  454. if ($? == 0) {
  455. Debug "Crontab successfully read\n";
  456. } elsif ($? == 256) {
  457. warn "You don't seem to have a crontab. I will create one.\n";
  458. } else {
  459. die "Failed to read your crontab. Please report this as a bug: $?\n";
  460. }
  461. } else {
  462. Debug "Result from crontab open(): $?\n";
  463. die "Unable to execute crontab command. Please check your system\n";
  464. }
  465. open(CRON, "|crontab -");
  466. print CRON $cron;
  467. print CRON "$min $hour * * $day $progname -m\n";
  468. close CRON;
  469. Debug "Result from crontab: $?\n";
  470. if ($?) {
  471. print <<EoF;
  472. Installing new crontab failed.
  473. YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
  474. Here's its former content (if any):
  475. $cron
  476. EoF
  477. die("\n");
  478. }
  479. print "Crontab entry successfully installed.\nWill run on day $day of every week, at $hour:$min\n";
  480. }
  481. sub uninstallcrontab {
  482. print STDERR "Removing $progname from your crontab\n";
  483. open(CRON, "crontab -l |");
  484. Debug "Checking crontab for machine-update\n";
  485. Debug "Want to uninstall as $progname\n";
  486. my $found = 0;
  487. while (<CRON>) {
  488. if (/^#/ && $. <= 3) { # initial comment
  489. Debug "Skipping comment: $_";
  490. next;
  491. }
  492. if (/machine-update/) {
  493. if (/ $progname -m/) {
  494. print STDERR "Crontab entry found and removed\n";
  495. $found = 1;
  496. next; # skip stuff at end....
  497. } else {
  498. die "Another entry with machine-update: $_\nUninstall manually?\n";
  499. }
  500. }
  501. $cron .= $_;
  502. }
  503. close CRON;
  504. Debug "Result from crontab -l: $?\n";
  505. if ($?) {
  506. die "Failed to read your crontab. You may not have one?\n";
  507. }
  508. if ($found) {
  509. open(CRON, "|crontab -");
  510. print CRON $cron;
  511. close CRON;
  512. Debug "Result from crontab: $?\n";
  513. if ($?) {
  514. print <<EoF;
  515. Installing new crontab failed.
  516. YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
  517. Here's its former content (if any):
  518. $cron
  519. EoF
  520. die("\n");
  521. }
  522. } else {
  523. print STDERR "No instance of $progname found in your crontab\n";
  524. }
  525. }
  526. sub Debug {
  527. $option{DEBUG} && print @_;
  528. }
  529. sub ErrorInfo {
  530. $errordata .= join("", @_);
  531. }
  532. sub DebugInfo {
  533. $option{info} && {$debugdata .= join("", @_)};
  534. }
  535. sub license {
  536. print <<EoF;
  537. Linux Counter Machine Update version $VERSION
  538. Copyright (C) 1999 Harald Tveit Alvestrand
  539. This program is free software; you can redistribute it and/or modify
  540. it under the terms of the GNU General Public License as published by
  541. the Free Software Foundation; either version 2 of the License, or
  542. (at your option) any later version.
  543. This program is distributed in the hope that it will be useful,
  544. but WITHOUT ANY WARRANTY; without even the implied warranty of
  545. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  546. GNU General Public License below for more details.
  547. GNU GENERAL PUBLIC LICENSE
  548. Version 2, June 1991
  549. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  550. 675 Mass Ave, Cambridge, MA 02139, USA
  551. Everyone is permitted to copy and distribute verbatim copies
  552. of this license document, but changing it is not allowed.
  553. Preamble
  554. The licenses for most software are designed to take away your
  555. freedom to share and change it. By contrast, the GNU General Public
  556. License is intended to guarantee your freedom to share and change free
  557. software--to make sure the software is free for all its users. This
  558. General Public License applies to most of the Free Software
  559. Foundation's software and to any other program whose authors commit to
  560. using it. (Some other Free Software Foundation software is covered by
  561. the GNU Library General Public License instead.) You can apply it to
  562. your programs, too.
  563. When we speak of free software, we are referring to freedom, not
  564. price. Our General Public Licenses are designed to make sure that you
  565. have the freedom to distribute copies of free software (and charge for
  566. this service if you wish), that you receive source code or can get it
  567. if you want it, that you can change the software or use pieces of it
  568. in new free programs; and that you know you can do these things.
  569. To protect your rights, we need to make restrictions that forbid
  570. anyone to deny you these rights or to ask you to surrender the rights.
  571. These restrictions translate to certain responsibilities for you if you
  572. distribute copies of the software, or if you modify it.
  573. For example, if you distribute copies of such a program, whether
  574. gratis or for a fee, you must give the recipients all the rights that
  575. you have. You must make sure that they, too, receive or can get the
  576. source code. And you must show them these terms so they know their
  577. rights.
  578. We protect your rights with two steps: (1) copyright the software, and
  579. (2) offer you this license which gives you legal permission to copy,
  580. distribute and/or modify the software.
  581. Also, for each author's protection and ours, we want to make certain
  582. that everyone understands that there is no warranty for this free
  583. software. If the software is modified by someone else and passed on, we
  584. want its recipients to know that what they have is not the original, so
  585. that any problems introduced by others will not reflect on the original
  586. authors' reputations.
  587. Finally, any free program is threatened constantly by software
  588. patents. We wish to avoid the danger that redistributors of a free
  589. program will individually obtain patent licenses, in effect making the
  590. program proprietary. To prevent this, we have made it clear that any
  591. patent must be licensed for everyone's free use or not licensed at all.
  592. The precise terms and conditions for copying, distribution and
  593. modification follow.
  594. GNU GENERAL PUBLIC LICENSE
  595. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  596. 0. This License applies to any program or other work which contains
  597. a notice placed by the copyright holder saying it may be distributed
  598. under the terms of this General Public License. The "Program", below,
  599. refers to any such program or work, and a "work based on the Program"
  600. means either the Program or any derivative work under copyright law:
  601. that is to say, a work containing the Program or a portion of it,
  602. either verbatim or with modifications and/or translated into another
  603. language. (Hereinafter, translation is included without limitation in
  604. the term "modification".) Each licensee is addressed as "you".
  605. Activities other than copying, distribution and modification are not
  606. covered by this License; they are outside its scope. The act of
  607. running the Program is not restricted, and the output from the Program
  608. is covered only if its contents constitute a work based on the
  609. Program (independent of having been made by running the Program).
  610. Whether that is true depends on what the Program does.
  611. 1. You may copy and distribute verbatim copies of the Program's
  612. source code as you receive it, in any medium, provided that you
  613. conspicuously and appropriately publish on each copy an appropriate
  614. copyright notice and disclaimer of warranty; keep intact all the
  615. notices that refer to this License and to the absence of any warranty;
  616. and give any other recipients of the Program a copy of this License
  617. along with the Program.
  618. You may charge a fee for the physical act of transferring a copy, and
  619. you may at your option offer warranty protection in exchange for a fee.
  620. 2. You may modify your copy or copies of the Program or any portion
  621. of it, thus forming a work based on the Program, and copy and
  622. distribute such modifications or work under the terms of Section 1
  623. above, provided that you also meet all of these conditions:
  624. a) You must cause the modified files to carry prominent notices
  625. stating that you changed the files and the date of any change.
  626. b) You must cause any work that you distribute or publish, that in
  627. whole or in part contains or is derived from the Program or any
  628. part thereof, to be licensed as a whole at no charge to all third
  629. parties under the terms of this License.
  630. c) If the modified program normally reads commands interactively
  631. when run, you must cause it, when started running for such
  632. interactive use in the most ordinary way, to print or display an
  633. announcement including an appropriate copyright notice and a
  634. notice that there is no warranty (or else, saying that you provide
  635. a warranty) and that users may redistribute the program under
  636. these conditions, and telling the user how to view a copy of this
  637. License. (Exception: if the Program itself is interactive but
  638. does not normally print such an announcement, your work based on
  639. the Program is not required to print an announcement.)
  640. These requirements apply to the modified work as a whole. If
  641. identifiable sections of that work are not derived from the Program,
  642. and can be reasonably considered independent and separate works in
  643. themselves, then this License, and its terms, do not apply to those
  644. sections when you distribute them as separate works. But when you
  645. distribute the same sections as part of a whole which is a work based
  646. on the Program, the distribution of the whole must be on the terms of
  647. this License, whose permissions for other licensees extend to the
  648. entire whole, and thus to each and every part regardless of who wrote it.
  649. Thus, it is not the intent of this section to claim rights or contest
  650. your rights to work written entirely by you; rather, the intent is to
  651. exercise the right to control the distribution of derivative or
  652. collective works based on the Program.
  653. In addition, mere aggregation of another work not based on the Program
  654. with the Program (or with a work based on the Program) on a volume of
  655. a storage or distribution medium does not bring the other work under
  656. the scope of this License.
  657. 3. You may copy and distribute the Program (or a work based on it,
  658. under Section 2) in object code or executable form under the terms of
  659. Sections 1 and 2 above provided that you also do one of the following:
  660. a) Accompany it with the complete corresponding machine-readable
  661. source code, which must be distributed under the terms of Sections
  662. 1 and 2 above on a medium customarily used for software interchange; or,
  663. b) Accompany it with a written offer, valid for at least three
  664. years, to give any third party, for a charge no more than your
  665. cost of physically performing source distribution, a complete
  666. machine-readable copy of the corresponding source code, to be
  667. distributed under the terms of Sections 1 and 2 above on a medium
  668. customarily used for software interchange; or,
  669. c) Accompany it with the information you received as to the offer
  670. to distribute corresponding source code. (This alternative is
  671. allowed only for noncommercial distribution and only if you
  672. received the program in object code or executable form with such
  673. an offer, in accord with Subsection b above.)
  674. The source code for a work means the preferred form of the work for
  675. making modifications to it. For an executable work, complete source
  676. code means all the source code for all modules it contains, plus any
  677. associated interface definition files, plus the scripts used to
  678. control compilation and installation of the executable. However, as a
  679. special exception, the source code distributed need not include
  680. anything that is normally distributed (in either source or binary
  681. form) with the major components (compiler, kernel, and so on) of the
  682. operating system on which the executable runs, unless that component
  683. itself accompanies the executable.
  684. If distribution of executable or object code is made by offering
  685. access to copy from a designated place, then offering equivalent
  686. access to copy the source code from the same place counts as
  687. distribution of the source code, even though third parties are not
  688. compelled to copy the source along with the object code.
  689. 4. You may not copy, modify, sublicense, or distribute the Program
  690. except as expressly provided under this License. Any attempt
  691. otherwise to copy, modify, sublicense or distribute the Program is
  692. void, and will automatically terminate your rights under this License.
  693. However, parties who have received copies, or rights, from you under
  694. this License will not have their licenses terminated so long as such
  695. parties remain in full compliance.
  696. 5. You are not required to accept this License, since you have not
  697. signed it. However, nothing else grants you permission to modify or
  698. distribute the Program or its derivative works. These actions are
  699. prohibited by law if you do not accept this License. Therefore, by
  700. modifying or distributing the Program (or any work based on the
  701. Program), you indicate your acceptance of this License to do so, and
  702. all its terms and conditions for copying, distributing or modifying
  703. the Program or works based on it.
  704. 6. Each time you redistribute the Program (or any work based on the
  705. Program), the recipient automatically receives a license from the
  706. original licensor to copy, distribute or modify the Program subject to
  707. these terms and conditions. You may not impose any further
  708. restrictions on the recipients' exercise of the rights granted herein.
  709. You are not responsible for enforcing compliance by third parties to
  710. this License.
  711. 7. If, as a consequence of a court judgment or allegation of patent
  712. infringement or for any other reason (not limited to patent issues),
  713. conditions are imposed on you (whether by court order, agreement or
  714. otherwise) that contradict the conditions of this License, they do not
  715. excuse you from the conditions of this License. If you cannot
  716. distribute so as to satisfy simultaneously your obligations under this
  717. License and any other pertinent obligations, then as a consequence you
  718. may not distribute the Program at all. For example, if a patent
  719. license would not permit royalty-free redistribution of the Program by
  720. all those who receive copies directly or indirectly through you, then
  721. the only way you could satisfy both it and this License would be to
  722. refrain entirely from distribution of the Program.
  723. If any portion of this section is held invalid or unenforceable under
  724. any particular circumstance, the balance of the section is intended to
  725. apply and the section as a whole is intended to apply in other
  726. circumstances.
  727. It is not the purpose of this section to induce you to infringe any
  728. patents or other property right claims or to contest validity of any
  729. such claims; this section has the sole purpose of protecting the
  730. integrity of the free software distribution system, which is
  731. implemented by public license practices. Many people have made
  732. generous contributions to the wide range of software distributed
  733. through that system in reliance on consistent application of that
  734. system; it is up to the author/donor to decide if he or she is willing
  735. to distribute software through any other system and a licensee cannot
  736. impose that choice.
  737. This section is intended to make thoroughly clear what is believed to
  738. be a consequence of the rest of this License.
  739. 8. If the distribution and/or use of the Program is restricted in
  740. certain countries either by patents or by copyrighted interfaces, the
  741. original copyright holder who places the Program under this License
  742. may add an explicit geographical distribution limitation excluding
  743. those countries, so that distribution is permitted only in or among
  744. countries not thus excluded. In such case, this License incorporates
  745. the limitation as if written in the body of this License.
  746. 9. The Free Software Foundation may publish revised and/or new versions
  747. of the General Public License from time to time. Such new versions will
  748. be similar in spirit to the present version, but may differ in detail to
  749. address new problems or concerns.
  750. Each version is given a distinguishing version number. If the Program
  751. specifies a version number of this License which applies to it and "any
  752. later version", you have the option of following the terms and conditions
  753. either of that version or of any later version published by the Free
  754. Software Foundation. If the Program does not specify a version number of
  755. this License, you may choose any version ever published by the Free Software
  756. Foundation.
  757. 10. If you wish to incorporate parts of the Program into other free
  758. programs whose distribution conditions are different, write to the author
  759. to ask for permission. For software which is copyrighted by the Free
  760. Software Foundation, write to the Free Software Foundation; we sometimes
  761. make exceptions for this. Our decision will be guided by the two goals
  762. of preserving the free status of all derivatives of our free software and
  763. of promoting the sharing and reuse of software generally.
  764. NO WARRANTY
  765. 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  766. FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
  767. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  768. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  769. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  770. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
  771. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
  772. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  773. REPAIR OR CORRECTION.
  774. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  775. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  776. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  777. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  778. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  779. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  780. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  781. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  782. POSSIBILITY OF SUCH DAMAGES.
  783. END OF TERMS AND CONDITIONS
  784. EoF
  785. }