From c3a08f5910a028cdace032ed79beb406c750d530 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 24 Oct 2003 23:30:25 +0000 Subject: [PATCH] system_cmds-279.tar.gz --- APPLE_LICENSE | 695 +++--- Makefile | 14 +- PB.project | 7 +- ac.tproj/ac.c | 21 +- accton.tproj/accton.c | 21 +- arch.tproj/arch.c | 21 +- at.tproj/at.c | 21 +- at.tproj/at.h | 21 +- at.tproj/panic.c | 21 +- at.tproj/panic.h | 21 +- at.tproj/parsetime.c | 21 +- at.tproj/parsetime.h | 21 +- at.tproj/pathnames.h | 21 +- at.tproj/perm.c | 21 +- at.tproj/perm.h | 21 +- at.tproj/privs.h | 21 +- atrun.tproj/atrun.c | 21 +- atrun.tproj/atrun.h | 21 +- chkpasswd.tproj/ds_passwd.c | 21 +- chkpasswd.tproj/file_passwd.c | 21 +- chkpasswd.tproj/netinfo_passwd.c | 21 +- chkpasswd.tproj/nis_passwd.c | 21 +- chkpasswd.tproj/passwd.c | 21 +- chkpasswd.tproj/stringops.c | 21 +- chkpasswd.tproj/stringops.h | 21 +- chpass.tproj/Makefile | 6 +- chpass.tproj/Makefile.preamble | 3 +- chpass.tproj/chpass.1 | 288 +-- chpass.tproj/chpass.c | 111 +- chpass.tproj/chpass.h | 68 +- chpass.tproj/directory_service.c | 694 ++++++ chpass.tproj/directory_service.h | 74 + chpass.tproj/ds_pw_util.c | 260 +++ chpass.tproj/edit.c | 97 +- chpass.tproj/field.c | 102 +- chpass.tproj/pathnames.h | 21 +- chpass.tproj/pw_copy.c | 21 +- chpass.tproj/pw_copy.h | 21 +- chpass.tproj/table.c | 40 +- chpass.tproj/util.c | 21 +- dmesg.tproj/dmesg.c | 21 +- dynamic_pager.tproj/Makefile | 2 +- dynamic_pager.tproj/Makefile.postamble | 4 + dynamic_pager.tproj/Makefile.preamble | 1 + dynamic_pager.tproj/PB.project | 3 +- dynamic_pager.tproj/dynamic_pager.8 | 73 + dynamic_pager.tproj/dynamic_pager.c | 275 ++- fs_usage.tproj/Makefile.postamble | 3 + fs_usage.tproj/fs_usage.1 | 2 + fs_usage.tproj/fs_usage.c | 89 +- getty.tproj/extern.h | 21 +- getty.tproj/gettytab.h | 21 +- getty.tproj/init.c | 21 +- getty.tproj/main.c | 21 +- getty.tproj/pathnames.h | 21 +- getty.tproj/subr.c | 21 +- hostinfo.tproj/hostinfo.c | 21 +- init.tproj/Makefile.preamble | 1 + init.tproj/init.c | 21 +- init.tproj/pathnames.h | 21 +- iostat.tproj/iostat.c | 21 +- kdump.tproj/kdump.c | 21 +- kdump.tproj/syscalls.c | 23 +- kgmon.tproj/kgmon.c | 21 +- ktrace.tproj/ktrace.c | 21 +- ktrace.tproj/subr.c | 21 +- latency.tproj/latency.c | 21 +- login.tproj/klogin.c | 21 +- login.tproj/login.c | 31 +- login.tproj/pathnames.h | 21 +- mach_init.tproj/bootstrap.c | 195 +- mach_init.tproj/bootstrap.defs | 21 +- mach_init.tproj/bootstrap_internal.h | 21 +- mach_init.tproj/error_log.c | 25 +- mach_init.tproj/error_log.h | 23 +- mach_init.tproj/lists.c | 24 +- mach_init.tproj/lists.h | 24 +- mach_init.tproj/rpc_services.c | 35 +- makekey.tproj/makekey.c | 21 +- mkfile.tproj/mkfile.c | 21 +- nvram.tproj/Makefile.postamble | 16 +- nvram.tproj/nvram.8 | 27 +- nvram.tproj/nvram.c | 29 +- nvram.tproj/nvram/Alchemy | 64 - nvram.tproj/nvram/Gossamer | 93 - nvram.tproj/nvram/Hooper | 60 - nvram.tproj/nvram/Kanga | 57 - nvram.tproj/nvram/Mainstreet | 103 - nvram.tproj/nvram/PowerExpress | 61 - nvram.tproj/nvram/PowerSurge | 103 - nvram.tproj/nvram/Silk | 63 - nvram.tproj/nvram/Wallstreet | 102 - passwd.tproj/Makefile.postamble | 4 + passwd.tproj/Makefile.preamble | 2 +- passwd.tproj/ds_passwd.c | 38 +- passwd.tproj/file_passwd.c | 21 +- passwd.tproj/netinfo_passwd.c | 21 +- passwd.tproj/nis_passwd.c | 21 +- passwd.tproj/passwd.1 | 56 +- passwd.tproj/passwd.c | 21 +- passwd.tproj/stringops.c | 21 +- passwd.tproj/stringops.h | 21 +- pwd_mkdb.tproj/Makefile.postamble | 4 + pwd_mkdb.tproj/Makefile.preamble | 4 +- pwd_mkdb.tproj/pw_scan.c | 137 +- pwd_mkdb.tproj/pw_scan.h | 23 +- pwd_mkdb.tproj/pwd_mkdb.8 | 139 +- pwd_mkdb.tproj/pwd_mkdb.c | 594 +++-- sa.tproj/PB.project | 26 - sa.tproj/extern.h | 97 - sa.tproj/main.c | 556 ----- sa.tproj/pathnames.h | 35 - sa.tproj/pdb.c | 424 ---- sa.tproj/sa.8 | 237 -- sa.tproj/usrdb.c | 288 --- sadc.tproj/Makefile | 54 + sadc.tproj/Makefile.postamble | 131 ++ sadc.tproj/Makefile.preamble | 143 ++ sadc.tproj/PB.project | 38 + sadc.tproj/sa1.8 | 83 + sadc.tproj/sa1.sh | 35 + sadc.tproj/sa2.8 | 98 + sadc.tproj/sa2.sh | 33 + sadc.tproj/sadc.8 | 110 + sadc.tproj/sadc.c | 1001 +++++++++ sadc.tproj/sadc.h | 124 ++ {sa.tproj => sar.tproj}/Makefile | 18 +- {sa.tproj => sar.tproj}/Makefile.postamble | 14 +- {sa.tproj => sar.tproj}/Makefile.preamble | 6 +- sar.tproj/PB.project | 27 + sar.tproj/sar.1 | 208 ++ sar.tproj/sar.c | 2325 ++++++++++++++++++++ sar.tproj/sar.h | 142 ++ sc_usage.tproj/sc_usage.c | 21 +- sc_usage.tproj/trace.codes | 2 + shutdown.tproj/Makefile.postamble | 2 +- shutdown.tproj/pathnames.h | 21 +- sync.tproj/sync.c | 21 +- sysctl.tproj/sysctl.8 | 69 +- sysctl.tproj/sysctl.c | 67 +- update.tproj/update.c | 21 +- vipw.tproj/pw_util.c | 23 +- vipw.tproj/pw_util.h | 21 +- vipw.tproj/vipw.c | 21 +- vm_stat.tproj/vm_stat.c | 21 +- zdump.tproj/zdump.c | 21 +- zic.tproj/datfiles/africa | 26 +- zic.tproj/datfiles/antarctica | 28 +- zic.tproj/datfiles/asia | 508 +++-- zic.tproj/datfiles/australasia | 183 +- zic.tproj/datfiles/backward | 12 +- zic.tproj/datfiles/europe | 499 ++++- zic.tproj/datfiles/leapseconds | 34 +- zic.tproj/datfiles/northamerica | 169 +- zic.tproj/datfiles/southamerica | 247 ++- zic.tproj/datfiles/yearistype.sh | 54 +- zic.tproj/ialloc.c | 21 +- zic.tproj/private.h | 21 +- zic.tproj/scheck.c | 21 +- zic.tproj/tzfile.h | 21 +- zic.tproj/zic.c | 21 +- zprint.tproj/Makefile | 2 +- zprint.tproj/Makefile.postamble | 4 + zprint.tproj/Makefile.preamble | 2 + zprint.tproj/zprint.1 | 40 + 165 files changed, 9831 insertions(+), 4871 deletions(-) create mode 100644 chpass.tproj/directory_service.c create mode 100644 chpass.tproj/directory_service.h create mode 100644 chpass.tproj/ds_pw_util.c create mode 100644 dynamic_pager.tproj/dynamic_pager.8 delete mode 100644 nvram.tproj/nvram/Alchemy delete mode 100644 nvram.tproj/nvram/Gossamer delete mode 100644 nvram.tproj/nvram/Hooper delete mode 100644 nvram.tproj/nvram/Kanga delete mode 100644 nvram.tproj/nvram/Mainstreet delete mode 100644 nvram.tproj/nvram/PowerExpress delete mode 100644 nvram.tproj/nvram/PowerSurge delete mode 100644 nvram.tproj/nvram/Silk delete mode 100644 nvram.tproj/nvram/Wallstreet delete mode 100644 sa.tproj/PB.project delete mode 100644 sa.tproj/extern.h delete mode 100644 sa.tproj/main.c delete mode 100644 sa.tproj/pathnames.h delete mode 100644 sa.tproj/pdb.c delete mode 100644 sa.tproj/sa.8 delete mode 100644 sa.tproj/usrdb.c create mode 100644 sadc.tproj/Makefile create mode 100644 sadc.tproj/Makefile.postamble create mode 100644 sadc.tproj/Makefile.preamble create mode 100644 sadc.tproj/PB.project create mode 100644 sadc.tproj/sa1.8 create mode 100644 sadc.tproj/sa1.sh create mode 100644 sadc.tproj/sa2.8 create mode 100644 sadc.tproj/sa2.sh create mode 100644 sadc.tproj/sadc.8 create mode 100644 sadc.tproj/sadc.c create mode 100644 sadc.tproj/sadc.h rename {sa.tproj => sar.tproj}/Makefile (66%) rename {sa.tproj => sar.tproj}/Makefile.postamble (95%) rename {sa.tproj => sar.tproj}/Makefile.preamble (99%) create mode 100644 sar.tproj/PB.project create mode 100644 sar.tproj/sar.1 create mode 100644 sar.tproj/sar.c create mode 100644 sar.tproj/sar.h create mode 100644 zprint.tproj/zprint.1 diff --git a/APPLE_LICENSE b/APPLE_LICENSE index e7aa7d0..fe81a60 100644 --- a/APPLE_LICENSE +++ b/APPLE_LICENSE @@ -1,349 +1,344 @@ - APPLE PUBLIC SOURCE LICENSE - Version 1.0 - March 16, 1999 +APPLE PUBLIC SOURCE LICENSE +Version 2.0 - August 6, 2003 Please read this License carefully before downloading this software. -By downloading and using this software, you are agreeing to be bound -by the terms of this License. If you do not or cannot agree to the -terms of this License, please do not download or use the software. - -1. General; Definitions. This License applies to any program or other - work which Apple Computer, Inc. ("Apple") publicly announces as - subject to this Apple Public Source License and which contains a - notice placed by Apple identifying such program or work as "Original - Code" and stating that it is subject to the terms of this Apple - Public Source License version 1.0 (or subsequent version thereof), - as it may be revised from time to time by Apple ("License"). As - used in this License: - -1.1 "Applicable Patents" mean: (a) in the case where Apple is the - grantor of rights, (i) patents or patent applications that are now - or hereafter acquired, owned by or assigned to Apple and (ii) whose - claims cover subject matter contained in the Original Code, but only - to the extent necessary to use, reproduce and/or distribute the - Original Code without infringement; and (b) in the case where You - are the grantor of rights, (i) patents and patent applications that - are now or hereafter acquired, owned by or assigned to You and (ii) - whose claims cover subject matter in Your Modifications, taken alone - or in combination with Original Code. - -1.2 "Covered Code" means the Original Code, Modifications, the - combination of Original Code and any Modifications, and/or any - respective portions thereof. - -1.3 "Deploy" means to use, sublicense or distribute Covered Code other - than for Your internal research and development (R&D), and includes - without limitation, any and all internal use or distribution of - Covered Code within Your business or organization except for R&D - use, as well as direct or indirect sublicensing or distribution of - Covered Code by You to any third party in any form or manner. - -1.4 "Larger Work" means a work which combines Covered Code or portions - thereof with code not governed by the terms of this License. - -1.5 "Modifications" mean any addition to, deletion from, and/or change - to, the substance and/or structure of Covered Code. When code is - released as a series of files, a Modification is: (a) any addition - to or deletion from the contents of a file containing Covered Code; - and/or (b) any new file or other representation of computer program - statements that contains any part of Covered Code. - -1.6 "Original Code" means the Source Code of a program or other work - as originally made available by Apple under this License, including - the Source Code of any updates or upgrades to such programs or works - made available by Apple under this License, and that has been - expressly identified by Apple as such in the header file(s) of such - work. - -1.7 "Source Code" means the human readable form of a program or other - work that is suitable for making modifications to it, including all - modules it contains, plus any associated interface definition files, - scripts used to control compilation and installation of an - executable (object code). - -1.8 "You" or "Your" means an individual or a legal entity exercising - rights under this License. For legal entities, "You" or "Your" - includes any entity which controls, is controlled by, or is under - common control with, You, where "control" means (a) the power, - direct or indirect, to cause the direction or management of such - entity, whether by contract or otherwise, or (b) ownership of fifty - percent (50%) or more of the outstanding shares or beneficial - ownership of such entity. - -2. Permitted Uses; Conditions & Restrictions. Subject to the terms - and conditions of this License, Apple hereby grants You, effective - on the date You accept this License and download the Original Code, - a world-wide, royalty-free, non-exclusive license, to the extent of - Apple's Applicable Patents and copyrights covering the Original - Code, to do the following: - -2.1 You may use, copy, modify and distribute Original Code, with or - without Modifications, solely for Your internal research and - development, provided that You must in each instance: - -(a) retain and reproduce in all copies of Original Code the copyright -and other proprietary notices and disclaimers of Apple as they appear -in the Original Code, and keep intact all notices in the Original Code -that refer to this License; - -(b) include a copy of this License with every copy of Source Code of -Covered Code and documentation You distribute, and You may not offer -or impose any terms on such Source Code that alter or restrict this -License or the recipients' rights hereunder, except as permitted under -Section 6; and - -(c) completely and accurately document all Modifications that you have -made and the date of each such Modification, designate the version of -the Original Code you used, prominently include a file carrying such -information with the Modifications, and duplicate the notice in -Exhibit A in each file of the Source Code of all such Modifications. - -2.2 You may Deploy Covered Code, provided that You must in each - instance: - -(a) satisfy all the conditions of Section 2.1 with respect to the -Source Code of the Covered Code; - -(b) make all Your Deployed Modifications publicly available in Source -Code form via electronic distribution (e.g. download from a web site) -under the terms of this License and subject to the license grants set -forth in Section 3 below, and any additional terms You may choose to -offer under Section 6. You must continue to make the Source Code of -Your Deployed Modifications available for as long as you Deploy the -Covered Code or twelve (12) months from the date of initial -Deployment, whichever is longer; - -(c) must notify Apple and other third parties of how to obtain Your -Deployed Modifications by filling out and submitting the required -information found at -http://www.apple.com/publicsource/modifications.html; and - -(d) if you Deploy Covered Code in object code, executable form only, -include a prominent notice, in the code itself as well as in related -documentation, stating that Source Code of the Covered Code is -available under the terms of this License with information on how and -where to obtain such Source Code. - -3. Your Grants. In consideration of, and as a condition to, the - licenses granted to You under this License: - -(a) You hereby grant to Apple and all third parties a non-exclusive, -royalty-free license, under Your Applicable Patents and other -intellectual property rights owned or controlled by You, to use, -reproduce, modify, distribute and Deploy Your Modifications of the -same scope and extent as Apple's licenses under Sections 2.1 and 2.2; -and - -(b) You hereby grant to Apple and its subsidiaries a non-exclusive, -worldwide, royalty-free, perpetual and irrevocable license, under Your -Applicable Patents and other intellectual property rights owned or -controlled by You, to use, reproduce, execute, compile, display, -perform, modify or have modified (for Apple and/or its subsidiaries), -sublicense and distribute Your Modifications, in any form, through -multiple tiers of distribution. - -4. Larger Works. You may create a Larger Work by combining Covered - Code with other code not governed by the terms of this License and - distribute the Larger Work as a single product. In each such - instance, You must make sure the requirements of this License are - fulfilled for the Covered Code or any portion thereof. - -5. Limitations on Patent License. Except as expressly stated in - Section 2, no other patent rights, express or implied, are granted - by Apple herein. Modifications and/or Larger Works may require - additional patent licenses from Apple which Apple may grant in its - sole discretion. - -6. Additional Terms. You may choose to offer, and to charge a fee - for, warranty, support, indemnity or liability obligations and/or - other rights consistent with the scope of the license granted herein - ("Additional Terms") to one or more recipients of Covered - Code. However, You may do so only on Your own behalf and as Your - sole responsibility, and not on behalf of Apple. You must obtain the - recipient's agreement that any such Additional Terms are offered by - You alone, and You hereby agree to indemnify, defend and hold Apple - harmless for any liability incurred by or claims asserted against - Apple by reason of any such Additional Terms. - -7. Versions of the License. Apple may publish revised and/or new - versions of this License from time to time. Each version will be - given a distinguishing version number. Once Original Code has been - published under a particular version of this License, You may - continue to use it under the terms of that version. You may also - choose to use such Original Code under the terms of any subsequent - version of this License published by Apple. No one other than Apple - has the right to modify the terms applicable to Covered Code created - under this License. - -8. NO WARRANTY OR SUPPORT. The Original Code may contain in whole or - in part pre-release, untested, or not fully tested works. The - Original Code may contain errors that could cause failures or loss - of data, and may be incomplete or contain inaccuracies. You - expressly acknowledge and agree that use of the Original Code, or - any portion thereof, is at Your sole and entire risk. THE ORIGINAL - CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT - OF ANY KIND AND APPLE AND APPLE'S LICENSOR(S) (FOR THE PURPOSES OF - SECTIONS 8 AND 9, APPLE AND APPLE'S LICENSOR(S) ARE COLLECTIVELY - REFERRED TO AS "APPLE") EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR - CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY OR - SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT OF THIRD PARTY RIGHTS. APPLE DOES NOT WARRANT THAT - THE FUNCTIONS CONTAINED IN THE ORIGINAL CODE WILL MEET YOUR - REQUIREMENTS, OR THAT THE OPERATION OF THE ORIGINAL CODE WILL BE - UNINTERRUPTED OR ERROR-FREE, OR THAT DEFECTS IN THE ORIGINAL CODE - WILL BE CORRECTED. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN - BY APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE SHALL CREATE A - WARRANTY OR IN ANY WAY INCREASE THE SCOPE OF THIS WARRANTY. You - acknowledge that the Original Code is not intended for use in the - operation of nuclear facilities, aircraft navigation, communication - systems, or air traffic control machines in which case the failure - of the Original Code could lead to death, personal injury, or severe - physical or environmental damage. - -9. Liability. - -9.1 Infringement. If any of the Original Code becomes the subject of - a claim of infringement ("Affected Original Code"), Apple may, at - its sole discretion and option: (a) attempt to procure the rights - necessary for You to continue using the Affected Original Code; (b) - modify the Affected Original Code so that it is no longer - infringing; or (c) terminate Your rights to use the Affected - Original Code, effective immediately upon Apple's posting of a - notice to such effect on the Apple web site that is used for - implementation of this License. - -9.2 LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES SHALL APPLE BE - LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL - DAMAGES ARISING OUT OF OR RELATING TO THIS LICENSE OR YOUR USE OR - INABILITY TO USE THE ORIGINAL CODE, OR ANY PORTION THEREOF, WHETHER - UNDER A THEORY OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), - PRODUCTS LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF - THE POSSIBILITY OF SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF - ESSENTIAL PURPOSE OF ANY REMEDY. In no event shall Apple's total - liability to You for all damages under this License exceed the - amount of fifty dollars ($50.00). - -10. Trademarks. This License does not grant any rights to use the - trademarks or trade names "Apple", "Apple Computer", "Mac OS X", - "Mac OS X Server" or any other trademarks or trade names belonging - to Apple (collectively "Apple Marks") and no Apple Marks may be - used to endorse or promote products derived from the Original Code - other than as permitted by and in strict compliance at all times - with Apple's third party trademark usage guidelines which are - posted at http://www.apple.com/legal/guidelinesfor3rdparties.html. - -11. Ownership. Apple retains all rights, title and interest in and to - the Original Code and any Modifications made by or on behalf of - Apple ("Apple Modifications"), and such Apple Modifications will - not be automatically subject to this License. Apple may, at its - sole discretion, choose to license such Apple Modifications under - this License, or on different terms from those contained in this - License or may choose not to license them at all. Apple's - development, use, reproduction, modification, sublicensing and - distribution of Covered Code will not be subject to this License. +By downloading or using this software, you are agreeing to be bound by +the terms of this License. If you do not or cannot agree to the terms +of this License, please do not download or use the software. + +1. General; Definitions. This License applies to any program or other +work which Apple Computer, Inc. ("Apple") makes publicly available and +which contains a notice placed by Apple identifying such program or +work as "Original Code" and stating that it is subject to the terms of +this Apple Public Source License version 2.0 ("License"). As used in +this License: + +1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is +the grantor of rights, (i) claims of patents that are now or hereafter +acquired, owned by or assigned to Apple and (ii) that cover subject +matter contained in the Original Code, but only to the extent +necessary to use, reproduce and/or distribute the Original Code +without infringement; and (b) in the case where You are the grantor of +rights, (i) claims of patents that are now or hereafter acquired, +owned by or assigned to You and (ii) that cover subject matter in Your +Modifications, taken alone or in combination with Original Code. + +1.2 "Contributor" means any person or entity that creates or +contributes to the creation of Modifications. + +1.3 "Covered Code" means the Original Code, Modifications, the +combination of Original Code and any Modifications, and/or any +respective portions thereof. + +1.4 "Externally Deploy" means: (a) to sublicense, distribute or +otherwise make Covered Code available, directly or indirectly, to +anyone other than You; and/or (b) to use Covered Code, alone or as +part of a Larger Work, in any way to provide a service, including but +not limited to delivery of content, through electronic communication +with a client other than You. + +1.5 "Larger Work" means a work which combines Covered Code or portions +thereof with code not governed by the terms of this License. + +1.6 "Modifications" mean any addition to, deletion from, and/or change +to, the substance and/or structure of the Original Code, any previous +Modifications, the combination of Original Code and any previous +Modifications, and/or any respective portions thereof. When code is +released as a series of files, a Modification is: (a) any addition to +or deletion from the contents of a file containing Covered Code; +and/or (b) any new file or other representation of computer program +statements that contains any part of Covered Code. + +1.7 "Original Code" means (a) the Source Code of a program or other +work as originally made available by Apple under this License, +including the Source Code of any updates or upgrades to such programs +or works made available by Apple under this License, and that has been +expressly identified by Apple as such in the header file(s) of such +work; and (b) the object code compiled from such Source Code and +originally made available by Apple under this License. + +1.8 "Source Code" means the human readable form of a program or other +work that is suitable for making modifications to it, including all +modules it contains, plus any associated interface definition files, +scripts used to control compilation and installation of an executable +(object code). + +1.9 "You" or "Your" means an individual or a legal entity exercising +rights under this License. For legal entities, "You" or "Your" +includes any entity which controls, is controlled by, or is under +common control with, You, where "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of fifty percent +(50%) or more of the outstanding shares or beneficial ownership of +such entity. + +2. Permitted Uses; Conditions & Restrictions. Subject to the terms +and conditions of this License, Apple hereby grants You, effective on +the date You accept this License and download the Original Code, a +world-wide, royalty-free, non-exclusive license, to the extent of +Apple's Applicable Patent Rights and copyrights covering the Original +Code, to do the following: + +2.1 Unmodified Code. You may use, reproduce, display, perform, +internally distribute within Your organization, and Externally Deploy +verbatim, unmodified copies of the Original Code, for commercial or +non-commercial purposes, provided that in each instance: + +(a) You must retain and reproduce in all copies of Original Code the +copyright and other proprietary notices and disclaimers of Apple as +they appear in the Original Code, and keep intact all notices in the +Original Code that refer to this License; and + +(b) You must include a copy of this License with every copy of Source +Code of Covered Code and documentation You distribute or Externally +Deploy, and You may not offer or impose any terms on such Source Code +that alter or restrict this License or the recipients' rights +hereunder, except as permitted under Section 6. + +2.2 Modified Code. You may modify Covered Code and use, reproduce, +display, perform, internally distribute within Your organization, and +Externally Deploy Your Modifications and Covered Code, for commercial +or non-commercial purposes, provided that in each instance You also +meet all of these conditions: + +(a) You must satisfy all the conditions of Section 2.1 with respect to +the Source Code of the Covered Code; + +(b) You must duplicate, to the extent it does not already exist, the +notice in Exhibit A in each file of the Source Code of all Your +Modifications, and cause the modified files to carry prominent notices +stating that You changed the files and the date of any change; and + +(c) If You Externally Deploy Your Modifications, You must make +Source Code of all Your Externally Deployed Modifications either +available to those to whom You have Externally Deployed Your +Modifications, or publicly available. Source Code of Your Externally +Deployed Modifications must be released under the terms set forth in +this License, including the license grants set forth in Section 3 +below, for as long as you Externally Deploy the Covered Code or twelve +(12) months from the date of initial External Deployment, whichever is +longer. You should preferably distribute the Source Code of Your +Externally Deployed Modifications electronically (e.g. download from a +web site). + +2.3 Distribution of Executable Versions. In addition, if You +Externally Deploy Covered Code (Original Code and/or Modifications) in +object code, executable form only, You must include a prominent +notice, in the code itself as well as in related documentation, +stating that Source Code of the Covered Code is available under the +terms of this License with information on how and where to obtain such +Source Code. + +2.4 Third Party Rights. You expressly acknowledge and agree that +although Apple and each Contributor grants the licenses to their +respective portions of the Covered Code set forth herein, no +assurances are provided by Apple or any Contributor that the Covered +Code does not infringe the patent or other intellectual property +rights of any other entity. Apple and each Contributor disclaim any +liability to You for claims brought by any other entity based on +infringement of intellectual property rights or otherwise. As a +condition to exercising the rights and licenses granted hereunder, You +hereby assume sole responsibility to secure any other intellectual +property rights needed, if any. For example, if a third party patent +license is required to allow You to distribute the Covered Code, it is +Your responsibility to acquire that license before distributing the +Covered Code. + +3. Your Grants. In consideration of, and as a condition to, the +licenses granted to You under this License, You hereby grant to any +person or entity receiving or distributing Covered Code under this +License a non-exclusive, royalty-free, perpetual, irrevocable license, +under Your Applicable Patent Rights and other intellectual property +rights (other than patent) owned or controlled by You, to use, +reproduce, display, perform, modify, sublicense, distribute and +Externally Deploy Your Modifications of the same scope and extent as +Apple's licenses under Sections 2.1 and 2.2 above. + +4. Larger Works. You may create a Larger Work by combining Covered +Code with other code not governed by the terms of this License and +distribute the Larger Work as a single product. In each such instance, +You must make sure the requirements of this License are fulfilled for +the Covered Code or any portion thereof. + +5. Limitations on Patent License. Except as expressly stated in +Section 2, no other patent rights, express or implied, are granted by +Apple herein. Modifications and/or Larger Works may require additional +patent licenses from Apple which Apple may grant in its sole +discretion. + +6. Additional Terms. You may choose to offer, and to charge a fee for, +warranty, support, indemnity or liability obligations and/or other +rights consistent with the scope of the license granted herein +("Additional Terms") to one or more recipients of Covered Code. +However, You may do so only on Your own behalf and as Your sole +responsibility, and not on behalf of Apple or any Contributor. You +must obtain the recipient's agreement that any such Additional Terms +are offered by You alone, and You hereby agree to indemnify, defend +and hold Apple and every Contributor harmless for any liability +incurred by or claims asserted against Apple or such Contributor by +reason of any such Additional Terms. + +7. Versions of the License. Apple may publish revised and/or new +versions of this License from time to time. Each version will be given +a distinguishing version number. Once Original Code has been published +under a particular version of this License, You may continue to use it +under the terms of that version. You may also choose to use such +Original Code under the terms of any subsequent version of this +License published by Apple. No one other than Apple has the right to +modify the terms applicable to Covered Code created under this +License. + +8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in +part pre-release, untested, or not fully tested works. The Covered +Code may contain errors that could cause failures or loss of data, and +may be incomplete or contain inaccuracies. You expressly acknowledge +and agree that use of the Covered Code, or any portion thereof, is at +Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND +WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND +APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE +PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM +ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF +MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR +PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD +PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST +INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE +FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS, +THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR +ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO +ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE +AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. +You acknowledge that the Covered Code is not intended for use in the +operation of nuclear facilities, aircraft navigation, communication +systems, or air traffic control machines in which case the failure of +the Covered Code could lead to death, personal injury, or severe +physical or environmental damage. + +9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO +EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL, +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING +TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR +ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY, +TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF +APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY +REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF +INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY +TO YOU. In no event shall Apple's total liability to You for all +damages (other than as may be required by applicable law) under this +License exceed the amount of fifty dollars ($50.00). + +10. Trademarks. This License does not grant any rights to use the +trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS", +"QuickTime", "QuickTime Streaming Server" or any other trademarks, +service marks, logos or trade names belonging to Apple (collectively +"Apple Marks") or to any trademark, service mark, logo or trade name +belonging to any Contributor. You agree not to use any Apple Marks in +or as part of the name of products derived from the Original Code or +to endorse or promote products derived from the Original Code other +than as expressly permitted by and in strict compliance at all times +with Apple's third party trademark usage guidelines which are posted +at http://www.apple.com/legal/guidelinesfor3rdparties.html. + +11. Ownership. Subject to the licenses granted under this License, +each Contributor retains all rights, title and interest in and to any +Modifications made by such Contributor. Apple retains all rights, +title and interest in and to the Original Code and any Modifications +made by or on behalf of Apple ("Apple Modifications"), and such Apple +Modifications will not be automatically subject to this License. Apple +may, at its sole discretion, choose to license such Apple +Modifications under this License, or on different terms from those +contained in this License or may choose not to license them at all. 12. Termination. -12.1 Termination. This License and the rights granted hereunder will - terminate: +12.1 Termination. This License and the rights granted hereunder will +terminate: (a) automatically without notice from Apple if You fail to comply with any term(s) of this License and fail to cure such breach within 30 -days of becoming aware of such breach; (b) immediately in the event of -the circumstances described in Sections 9.1 and/or 13.6(b); or (c) -automatically without notice from Apple if You, at any time during the -term of this License, commence an action for patent infringement -against Apple. - -12.2 Effect of Termination. Upon termination, You agree to - immediately stop any further use, reproduction, modification and - distribution of the Covered Code, or Affected Original Code in the - case of termination under Section 9.1, and to destroy all copies of - the Covered Code or Affected Original Code (in the case of - termination under Section 9.1) that are in your possession or - control. All sublicenses to the Covered Code which have been - properly granted prior to termination shall survive any termination - of this License. Provisions which, by their nature, should remain - in effect beyond the termination of this License shall survive, - including but not limited to Sections 3, 5, 8, 9, 10, 11, 12.2 and - 13. Neither party will be liable to the other for compensation, - indemnity or damages of any sort solely as a result of terminating - this License in accordance with its terms, and termination of this - License will be without prejudice to any other right or remedy of - either party. - -13. Miscellaneous. - -13.1 Export Law Assurances. You may not use or otherwise export or - re-export the Original Code except as authorized by United States - law and the laws of the jurisdiction in which the Original Code was - obtained. In particular, but without limitation, the Original Code - may not be exported or re-exported (a) into (or to a national or - resident of) any U.S. embargoed country or (b) to anyone on the - U.S. Treasury Department's list of Specially Designated Nationals - or the U.S. Department of Commerce's Table of Denial Orders. By - using the Original Code, You represent and warrant that You are not - located in, under control of, or a national or resident of any such - country or on any such list. - -13.2 Government End Users. The Covered Code is a "commercial item" as - defined in FAR 2.101. Government software and technical data - rights in the Covered Code include only those rights customarily - provided to the public as defined in this License. This customary - commercial license in technical data and software is provided in - accordance with FAR 12.211 (Technical Data) and 12.212 (Computer - Software) and, for Department of Defense purchases, DFAR - 252.227-7015 (Technical Data -- Commercial Items) and 227.7202-3 - (Rights in Commercial Computer Software or Computer Software - Documentation). Accordingly, all U.S. Government End Users acquire - Covered Code with only those rights set forth herein. - -13.3 Relationship of Parties. This License will not be construed as - creating an agency, partnership, joint venture or any other form of - legal association between You and Apple, and You will not represent - to the contrary, whether expressly, by implication, appearance or - otherwise. - -13.4 Independent Development. Nothing in this License will impair - Apple's right to acquire, license, develop, have others develop for - it, market and/or distribute technology or products that perform - the same or similar functions as, or otherwise compete with, - Modifications, Larger Works, technology or products that You may - develop, produce, market or distribute. - -13.5 Waiver; Construction. Failure by Apple to enforce any provision - of this License will not be deemed a waiver of future enforcement - of that or any other provision. Any law or regulation which - provides that the language of a contract shall be construed against - the drafter will not apply to this License. - -13.6 Severability. (a) If for any reason a court of competent - jurisdiction finds any provision of this License, or portion - thereof, to be unenforceable, that provision of the License will be - enforced to the maximum extent permissible so as to effect the - economic benefits and intent of the parties, and the remainder of - this License will continue in full force and effect. (b) - Notwithstanding the foregoing, if applicable law prohibits or - restricts You from fully and/or specifically complying with - Sections 2 and/or 3 or prevents the enforceability of either of - those Sections, this License will immediately terminate and You - must immediately discontinue any use of the Covered Code and - destroy all copies of it that are in your possession or control. - -13.7 Dispute Resolution. Any litigation or other dispute resolution - between You and Apple relating to this License shall take place in - the Northern District of California, and You and Apple hereby - consent to the personal jurisdiction of, and venue in, the state - and federal courts within that District with respect to this - License. The application of the United Nations Convention on - Contracts for the International Sale of Goods is expressly - excluded. - -13.8 Entire Agreement; Governing Law. This License constitutes the - entire agreement between the parties with respect to the subject - matter hereof. This License shall be governed by the laws of the - United States and the State of California, except that body of - California law concerning conflicts of law. +days of becoming aware of such breach; + +(b) immediately in the event of the circumstances described in Section +13.5(b); or + +(c) automatically without notice from Apple if You, at any time during +the term of this License, commence an action for patent infringement +against Apple; provided that Apple did not first commence +an action for patent infringement against You in that instance. + +12.2 Effect of Termination. Upon termination, You agree to immediately +stop any further use, reproduction, modification, sublicensing and +distribution of the Covered Code. All sublicenses to the Covered Code +which have been properly granted prior to termination shall survive +any termination of this License. Provisions which, by their nature, +should remain in effect beyond the termination of this License shall +survive, including but not limited to Sections 3, 5, 8, 9, 10, 11, +12.2 and 13. No party will be liable to any other for compensation, +indemnity or damages of any sort solely as a result of terminating +this License in accordance with its terms, and termination of this +License will be without prejudice to any other right or remedy of +any party. + +13. Miscellaneous. + +13.1 Government End Users. The Covered Code is a "commercial item" as +defined in FAR 2.101. Government software and technical data rights in +the Covered Code include only those rights customarily provided to the +public as defined in this License. This customary commercial license +in technical data and software is provided in accordance with FAR +12.211 (Technical Data) and 12.212 (Computer Software) and, for +Department of Defense purchases, DFAR 252.227-7015 (Technical Data -- +Commercial Items) and 227.7202-3 (Rights in Commercial Computer +Software or Computer Software Documentation). Accordingly, all U.S. +Government End Users acquire Covered Code with only those rights set +forth herein. + +13.2 Relationship of Parties. This License will not be construed as +creating an agency, partnership, joint venture or any other form of +legal association between or among You, Apple or any Contributor, and +You will not represent to the contrary, whether expressly, by +implication, appearance or otherwise. + +13.3 Independent Development. Nothing in this License will impair +Apple's right to acquire, license, develop, have others develop for +it, market and/or distribute technology or products that perform the +same or similar functions as, or otherwise compete with, +Modifications, Larger Works, technology or products that You may +develop, produce, market or distribute. + +13.4 Waiver; Construction. Failure by Apple or any Contributor to +enforce any provision of this License will not be deemed a waiver of +future enforcement of that or any other provision. Any law or +regulation which provides that the language of a contract shall be +construed against the drafter will not apply to this License. + +13.5 Severability. (a) If for any reason a court of competent +jurisdiction finds any provision of this License, or portion thereof, +to be unenforceable, that provision of the License will be enforced to +the maximum extent permissible so as to effect the economic benefits +and intent of the parties, and the remainder of this License will +continue in full force and effect. (b) Notwithstanding the foregoing, +if applicable law prohibits or restricts You from fully and/or +specifically complying with Sections 2 and/or 3 or prevents the +enforceability of either of those Sections, this License will +immediately terminate and You must immediately discontinue any use of +the Covered Code and destroy all copies of it that are in your +possession or control. + +13.6 Dispute Resolution. Any litigation or other dispute resolution +between You and Apple relating to this License shall take place in the +Northern District of California, and You and Apple hereby consent to +the personal jurisdiction of, and venue in, the state and federal +courts within that District with respect to this License. The +application of the United Nations Convention on Contracts for the +International Sale of Goods is expressly excluded. + +13.7 Entire Agreement; Governing Law. This License constitutes the +entire agreement between the parties with respect to the subject +matter hereof. This License shall be governed by the laws of the +United States and the State of California, except that body of +California law concerning conflicts of law. Where You are located in the province of Quebec, Canada, the following clause applies: The parties hereby confirm that they have requested @@ -351,20 +346,22 @@ that this License and all related documents be drafted in English. Les parties ont exige que le present contrat et tous les documents connexes soient rediges en anglais. -EXHIBIT A. +EXHIBIT A. -"Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -Reserved. This file contains Original Code and/or Modifications of -Original Code as defined in and that are subject to the Apple Public -Source License Version 1.0 (the 'License'). You may not use this file -except in compliance with the License. Please obtain a copy of the -License at http://www.apple.com/publicsource and read it before using -this file. +"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights +Reserved. + +This file contains Original Code and/or Modifications of Original Code +as defined in and that are subject to the Apple Public Source License +Version 2.0 (the 'License'). You may not use this file except in +compliance with the License. Please obtain a copy of the License at +http://www.opensource.apple.com/apsl/ and read it before using this +file. The Original Code and all software distributed under the License are distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -License for the specific language governing rights and limitations -under the License." +FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +Please see the License for the specific language governing rights and +limitations under the License." diff --git a/Makefile b/Makefile index a635afc..9d65a8d 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,13 @@ PROJECT_TYPE = Aggregate TOOLS = dynamic_pager.tproj ac.tproj accton.tproj arch.tproj at.tproj\ atrun.tproj chkpasswd.tproj chpass.tproj dmesg.tproj\ - getty.tproj hostinfo.tproj init.tproj iostat.tproj\ - kgmon.tproj ktrace.tproj login.tproj mach_init.tproj\ - makekey.tproj mkfile.tproj nvram.tproj passwd.tproj\ - pwd_mkdb.tproj reboot.tproj sa.tproj shutdown.tproj sync.tproj\ - sysctl.tproj update.tproj vipw.tproj zic.tproj zdump.tproj\ - vm_stat.tproj zprint.tproj latency.tproj\ - sc_usage.tproj fs_usage.tproj kdump.tproj + getty.tproj hostinfo.tproj init.tproj iostat.tproj kgmon.tproj\ + ktrace.tproj login.tproj mach_init.tproj makekey.tproj\ + mkfile.tproj nvram.tproj passwd.tproj pwd_mkdb.tproj\ + reboot.tproj shutdown.tproj sync.tproj sysctl.tproj\ + update.tproj vipw.tproj zic.tproj zdump.tproj vm_stat.tproj\ + zprint.tproj latency.tproj sc_usage.tproj fs_usage.tproj\ + kdump.tproj sadc.tproj sar.tproj LIBRARIES = dp_notify_lib diff --git a/PB.project b/PB.project index 8f42f58..5d1d356 100644 --- a/PB.project +++ b/PB.project @@ -23,9 +23,7 @@ "chkpasswd.tproj", "chpass.tproj", "dmesg.tproj", - "fastboot.tproj", "getty.tproj", - "halt.tproj", "hostinfo.tproj", "init.tproj", "iostat.tproj", @@ -50,11 +48,12 @@ "zdump.tproj", "vm_stat.tproj", "zprint.tproj", - "top.tproj", "latency.tproj", "sc_usage.tproj", "fs_usage.tproj", - "kdump.tproj" + "kdump.tproj", + "sadc.tproj", + "sar.tproj" ); }; LANGUAGE = English; diff --git a/ac.tproj/ac.c b/ac.tproj/ac.c index f23915c..249b80a 100644 --- a/ac.tproj/ac.c +++ b/ac.tproj/ac.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/accton.tproj/accton.c b/accton.tproj/accton.c index 723c336..40ec198 100644 --- a/accton.tproj/accton.c +++ b/accton.tproj/accton.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/arch.tproj/arch.c b/arch.tproj/arch.c index 0e140fe..7b5d5dc 100644 --- a/arch.tproj/arch.c +++ b/arch.tproj/arch.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/at.c b/at.tproj/at.c index 0caf2d1..e5ce512 100644 --- a/at.tproj/at.c +++ b/at.tproj/at.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/at.h b/at.tproj/at.h index 117a547..a107751 100644 --- a/at.tproj/at.h +++ b/at.tproj/at.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/panic.c b/at.tproj/panic.c index 839a54c..b4d8b76 100644 --- a/at.tproj/panic.c +++ b/at.tproj/panic.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/panic.h b/at.tproj/panic.h index dda9212..5f40a37 100644 --- a/at.tproj/panic.h +++ b/at.tproj/panic.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/parsetime.c b/at.tproj/parsetime.c index 46811fa..582dce5 100644 --- a/at.tproj/parsetime.c +++ b/at.tproj/parsetime.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/parsetime.h b/at.tproj/parsetime.h index c2e792b..ef334a1 100644 --- a/at.tproj/parsetime.h +++ b/at.tproj/parsetime.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/pathnames.h b/at.tproj/pathnames.h index daf1edc..209135f 100644 --- a/at.tproj/pathnames.h +++ b/at.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/perm.c b/at.tproj/perm.c index 0a5ba30..a2df820 100644 --- a/at.tproj/perm.c +++ b/at.tproj/perm.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/perm.h b/at.tproj/perm.h index 8d14b37..30fb0ca 100644 --- a/at.tproj/perm.h +++ b/at.tproj/perm.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/privs.h b/at.tproj/privs.h index ae37877..5e6b226 100644 --- a/at.tproj/privs.h +++ b/at.tproj/privs.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/atrun.tproj/atrun.c b/atrun.tproj/atrun.c index f9e31bd..0634fb2 100644 --- a/atrun.tproj/atrun.c +++ b/atrun.tproj/atrun.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/atrun.tproj/atrun.h b/atrun.tproj/atrun.h index af24723..ef281f2 100644 --- a/atrun.tproj/atrun.h +++ b/atrun.tproj/atrun.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/ds_passwd.c b/chkpasswd.tproj/ds_passwd.c index 29c18d9..c01cc0b 100644 --- a/chkpasswd.tproj/ds_passwd.c +++ b/chkpasswd.tproj/ds_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/file_passwd.c b/chkpasswd.tproj/file_passwd.c index 51fc8c1..083c111 100644 --- a/chkpasswd.tproj/file_passwd.c +++ b/chkpasswd.tproj/file_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/netinfo_passwd.c b/chkpasswd.tproj/netinfo_passwd.c index 762f00d..e04f723 100644 --- a/chkpasswd.tproj/netinfo_passwd.c +++ b/chkpasswd.tproj/netinfo_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/nis_passwd.c b/chkpasswd.tproj/nis_passwd.c index 89b0411..a1227eb 100644 --- a/chkpasswd.tproj/nis_passwd.c +++ b/chkpasswd.tproj/nis_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/passwd.c b/chkpasswd.tproj/passwd.c index 2115573..6c201cb 100644 --- a/chkpasswd.tproj/passwd.c +++ b/chkpasswd.tproj/passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/stringops.c b/chkpasswd.tproj/stringops.c index fcf861d..e6cd093 100644 --- a/chkpasswd.tproj/stringops.c +++ b/chkpasswd.tproj/stringops.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/stringops.h b/chkpasswd.tproj/stringops.h index 417a167..34f9b4f 100644 --- a/chkpasswd.tproj/stringops.h +++ b/chkpasswd.tproj/stringops.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/Makefile b/chpass.tproj/Makefile index 4fa59cb..d0c8e02 100644 --- a/chpass.tproj/Makefile +++ b/chpass.tproj/Makefile @@ -12,9 +12,10 @@ NAME = chpass PROJECTVERSION = 2.8 PROJECT_TYPE = Tool -HFILES = chpass.h pathnames.h pw_copy.h pw_scan.h pw_util.h +HFILES = chpass.h pathnames.h pw_copy.h pw_scan.h pw_util.h directory_service.h -CFILES = chpass.c edit.c field.c pw_copy.c table.c util.c +CFILES = chpass.c edit.c field.c pw_copy.c table.c util.c \ + directory_service.c ds_pw_util.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble chpass.1 \ Makefile.dist @@ -32,6 +33,7 @@ PROF_LIBS = $(LIBS) HEADER_PATHS = -I../pwd_mkdb.tproj -I../vipw.tproj +FRAMEWORKS = -framework DirectoryService PROJECT_HEADERS = pw_copy.h diff --git a/chpass.tproj/Makefile.preamble b/chpass.tproj/Makefile.preamble index cb6b681..24ac6bf 100644 --- a/chpass.tproj/Makefile.preamble +++ b/chpass.tproj/Makefile.preamble @@ -1,4 +1,5 @@ CLEAN_ALL_SUBPROJECTS = YES -OTHER_OFILES = pw_scan.o pw_util.o +OTHER_CFLAGS = -DDIRECTORY_SERVICE +OTHER_OFILES = pw_scan.o OTHER_GENERATED_OFILES = $(VERS_OFILE) diff --git a/chpass.tproj/chpass.1 b/chpass.tproj/chpass.1 index 69840c2..d515a76 100644 --- a/chpass.tproj/chpass.1 +++ b/chpass.tproj/chpass.1 @@ -47,16 +47,6 @@ .Op Fl e Ar expiretime .Op Fl s Ar newshell .Op user -.Pp -.Nm -.Op Fl oly -.Op Fl a Ar list -.Op Fl p Ar encpass -.Op Fl e Ar expiretime -.Op Fl s Ar newshell -.Op Fl d Ar domain -.Op Fl h Ar host -.Op user .Sh DESCRIPTION The .Nm @@ -89,11 +79,16 @@ This argument must be a colon .Pq Dq \&: separated list of all the user database fields, although they may be empty. +[Note that this only changes the user database, +.Li master.passwd Ns .] .It Fl p The super-user is allowed to directly supply an encrypted password field, in the format used by .Xr crypt 3 , as an argument. +[See the discussion in +.Xr getpwent 3 +about types of passwords; this option may not be appropriate.] .It Fl e Ar expiretime Change the account expire time. This option is used to set the expire time @@ -110,6 +105,11 @@ Possible display items are as follows: user's login name .It Password: user's encrypted password +[do +.Em not +use this to change a password; use +.Xr passwd 1 +instead] .It Uid: user's login .It Gid: @@ -121,23 +121,28 @@ password change time .It Expire: account expiration time .It Full Name: -user's real name -.It Office Location: -user's office location (1) -.It Office Phone: -user's office phone (1) -.It Home Phone: -user's home phone (1) -.It Other Information: -any locally defined parameters for user (1) +user's real name (*) +.\"user's real name +.\".It Office Location: +.\"user's office location (1) +.\".It Office Phone: +.\"user's office phone (1) +.\".It Home Phone: +.\"user's home phone (1) +.\".It Other Information: +.\"any locally defined parameters for user (1) .It Home Directory: user's home directory .It Shell: user's login shell .Pp -.It NOTE(1) - -In the actual master.passwd file, these fields are comma-delimited -fields embedded in the FullName field. +.It NOTE(*) - +.\"In the actual master.passwd file, these fields are comma-delimited +.\"fields embedded in the FullName field. +Historically, the so-call +.Qq GECOS +field in the user database entry contain the full name plus other information. +Only the full name is currently supported. .El .Pp The @@ -147,6 +152,11 @@ field is the user name used to access the computer account. The .Ar password field contains the encrypted form of the user's password. +Do +.Em not +use this to change a password; use +.Xr passwd 1 +instead. .Pp The .Ar uid @@ -201,20 +211,23 @@ is the day of the month, and .Ar year is the year. .Pp -Five fields are available for storing the user's -.Ar full name , office location , -.Ar work -and -.Ar home telephone -numbers and finally -.Ar other information -which is a single comma delimited string to represent any additional -gcos fields (typically used for site specific user information). -Note that -.Xr finger 1 -will display the office location and office phone together under the -heading -.Ar Office: . +.\"Five fields are available for storing the user's +.\".Ar full name , office location , +.\".Ar work +.\"and +.\".Ar home telephone +.\"numbers and finally +.\".Ar other information +.\"which is a single comma delimited string to represent any additional +.\"gcos fields (typically used for site specific user information). +.\"Note that +.\".Xr finger 1 +.\"will display the office location and office phone together under the +.\"heading +.\".Ar Office: . +The +.Ar full name +field contains the full name of the user. .Pp The user's .Ar home directory @@ -242,6 +255,19 @@ Once the information has been verified, uses .Xr pwd_mkdb 8 to update the user database. +.Sh LOOKUPD AND DIRECTORY SERVICE AWARENESS +User database entries (among other things) are under the control of +.Xr lookupd 8 +and may be physically located in many different places, including local +and remote +.Xr netinfo 5 +databases, directory service agents such as LDAP servers and flat file databases +such as +.Li master.passwd . +This version of +.Nm +is currently limited to changing user database entries in the flat file +and local netinfo databases. .Sh ENVIRONMENT The .Xr vi 1 @@ -259,196 +285,6 @@ See for an explanation of the impact of setting the .Ev PW_SCAN_BIG_IDS environment variable. -.Sh NIS INTERACTION -The -.Nm -utility can also be used in conjunction with NIS, however some restrictions -apply. -Currently, -.Nm -can only make changes to the NIS passwd maps through -.Xr rpc.yppasswdd 8 , -which normally only permits changes to a user's password, shell and GECOS -fields. -Except when invoked by the super-user on the NIS master server, -.Nm -(and, similarly, -.Xr passwd 1 ) -cannot use the -.Xr rpc.yppasswdd 8 -server to change other user information or -add new records to the NIS passwd maps. -Furthermore, -.Xr rpc.yppasswdd 8 -requires password authentication before it will make any -changes. -The only user allowed to submit changes without supplying -a password is the super-user on the NIS master server; all other users, -including those with root privileges on NIS clients (and NIS slave -servers) must enter a password. -(The super-user on the NIS master is allowed to bypass these restrictions -largely for convenience: a user with root access -to the NIS master server already has the privileges required to make -updates to the NIS maps, but editing the map source files by hand can -be cumbersome. -.Pp -Note: these exceptions only apply when the NIS master server is a -.Fx -system). -.Pp -Consequently, except where noted, the following restrictions apply when -.Nm -is used with NIS: -.Bl -enum -offset indent -.It -.Em "Only the shell and GECOS information may be changed" . -All other -fields are restricted, even when -.Nm -is invoked by the super-user. -While support for -changing other fields could be added, this would lead to -compatibility problems with other NIS-capable systems. -Even though the super-user may supply data for other fields -while editing an entry, the extra information (other than the -password -- see below) will be silently discarded. -.Pp -Exception: the super-user on the NIS master server is permitted to -change any field. -.Pp -.It -.Em "Password authentication is required" . -The -.Nm -utility will prompt for the user's NIS password before effecting -any changes. -If the password is invalid, all changes will be -discarded. -.Pp -Exception: the super-user on the NIS master server is allowed to -submit changes without supplying a password. -(The super-user may -choose to turn off this feature using the -.Fl o -flag, described below.) -.It -.Em "Adding new records to the local password database is discouraged" . -The -.Nm -utility will allow the administrator to add new records to the -local password database while NIS is enabled, but this can lead to -some confusion since the new records are appended to the end of -the master password file, usually after the special NIS '+' entries. -The administrator should use -.Xr vipw 8 -to modify the local password -file when NIS is running. -.Pp -The super-user on the NIS master server is permitted to add new records -to the NIS password maps, provided the -.Xr rpc.yppasswdd 8 -server has been started with the -.Fl a -flag to permitted additions (it refuses them by default). -The -.Nm -utility tries to update the local password database by default; to update the -NIS maps instead, invoke chpass with the -.Fl y -flag. -.It -.Em "Password changes are not permitted". -Users should use -.Xr passwd 1 -or -.Xr yppasswd 1 -to change their NIS passwords. -The super-user is allowed to specify -a new password (even though the -.Dq Password: -field does not show -up in the editor template, the super-user may add it back by hand), -but even the super-user must supply the user's original password -otherwise -.Xr rpc.yppasswdd 8 -will refuse to update the NIS maps. -.Pp -Exception: the super-user on the NIS master server is permitted to -change a user's NIS password with -.Nm . -.El -.Pp -There are also a few extra option flags that are available when -.Nm -is compiled with NIS support: -.Bl -tag -width indent -.It Fl l -Force -.Nm -to modify the local copy of a user's password -information in the even that a user exists in both -the local and NIS databases. -.It Fl y -Opposite effect of -.Fl l . -This flag is largely redundant since -.Nm -operates on NIS entries by default if NIS is enabled. -.It Fl d Ar domain -Specify a particular NIS domain. -The -.Nm -utility uses the system domain name by default, as set by the -.Xr domainname 1 -utility. -The -.Fl d -option can be used to override a default, or to specify a domain -when the system domain name is not set. -.It Fl h Ar host -Specify the name or address of an NIS server to query. -Normally, -.Nm -will communicate with the NIS master host specified in the -.Pa master.passwd -or -.Pa passwd -maps. -On hosts that have not been configured as NIS clients, there is -no way for the program to determine this information unless the user -provides the hostname of a server. -Note that the specified hostname need -not be that of the NIS master server; the name of any server, master or -slave, in a given NIS domain will do. -.Pp -When using the -.Fl d -option, the hostname defaults to -.Dq localhost . -The -.Fl h -option can be used in conjunction with the -.Fl d -option, in which case the user-specified hostname will override -the default. -.Pp -.It Fl o -Force the use of RPC-based updates when communicating with -.Xr rpc.yppasswdd 8 -.Pq Dq old-mode . -When invoked by the super-user on the NIS master server, -.Nm -allows unrestricted changes to the NIS passwd maps using dedicated, -non-RPC-based mechanism (in this case, a -.Ux -domain socket). The -.Fl o -flag can be used to force -.Nm -to use the standard update mechanism instead. -This option is provided -mainly for testing purposes. -.El .Sh FILES .Bl -tag -width /etc/master.passwd -compact .It Pa /etc/master.passwd diff --git a/chpass.tproj/chpass.c b/chpass.tproj/chpass.c index 8068511..4deeaa9 100644 --- a/chpass.tproj/chpass.c +++ b/chpass.tproj/chpass.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -82,10 +83,18 @@ static char copyright[] = #include "chpass.h" #include "pathnames.h" +#ifdef DIRECTORY_SERVICE +#include "directory_service.h" + +#define PWSETFIELD(field, in, out) if(in->field) out.field = strdup(in->field) +#endif /* DIRECTORY_SERVICE */ char *progname = "chpass"; char *tempname; uid_t uid; +#ifdef DIRECTORY_SERVICE +int dswhere; +#endif /* DIRECTORY_SERVICE */ void baduser __P((void)); void usage __P((void)); @@ -99,6 +108,9 @@ main(argc, argv) struct passwd *pw, lpw; int ch, pfd, tfd; char *arg; +#ifdef DIRECTORY_SERVICE + struct passwd pworig; +#endif /* DIRECTORY_SERVICE */ op = EDITENTRY; while ((ch = getopt(argc, argv, "a:s:")) != EOF) @@ -121,6 +133,9 @@ main(argc, argv) uid = getuid(); if (op == EDITENTRY || op == NEWSH) +#ifdef DIRECTORY_SERVICE + { +#endif /* DIRECTORY_SERVICE */ switch(argc) { case 0: if (!(pw = getpwuid(uid))) @@ -129,13 +144,53 @@ main(argc, argv) case 1: if (!(pw = getpwnam(*argv))) errx(1, "unknown user: %s", *argv); +#ifndef DIRECTORY_SERVICE if (uid && uid != pw->pw_uid) baduser(); +#endif /* DIRECTORY_SERVICE */ break; default: usage(); } +#ifdef DIRECTORY_SERVICE + if ((dswhere = wherepwent(pw->pw_name)) < 0) { + if(dswhere > E_NOTFOUND) + errc(1, dswhere, "wherepwent"); + else + errx(1, "wherepwent returned %d", dswhere); + } + switch(dswhere) { + case WHERE_REMOTENI: + errx(1, +"Can't change info for user \"%s\", which resides in the\n" +"netinfo domain \"%s\"", + pw->pw_name, DSPath); + case WHERE_DS: + errx(1, +"Can't change info for user \"%s\", which resides in the\n" +"Directory Service path \"%s\"", + pw->pw_name, DSPath); + case WHERE_NIS: + errx(1, +"Can't change info for user \"%s\", which resides in NIS", + pw->pw_name); + case WHERE_LOCALNI: + pworig = *pw; + PWSETFIELD(pw_name, pw, pworig); + PWSETFIELD(pw_passwd, pw, pworig); + PWSETFIELD(pw_class, pw, pworig); + PWSETFIELD(pw_gecos, pw, pworig); + PWSETFIELD(pw_dir, pw, pworig); + PWSETFIELD(pw_shell, pw, pworig); + /* drop through */ + default: + if (uid && uid != pw->pw_uid) + baduser(); + } + } +#endif /* DIRECTORY_SERVICE */ + if (op == NEWSH) { /* protect p_shell -- it thinks NULL is /bin/sh */ if (!arg[0]) @@ -145,10 +200,14 @@ main(argc, argv) } if (op == LOADENTRY) { +#ifdef DIRECTORY_SERVICE + warnx("-a is only supported for %s", MasterPasswd); + dswhere = WHERE_FILES; +#endif /* DIRECTORY_SERVICE */ if (uid) baduser(); pw = &lpw; - if (!pw_scan(arg, pw)) + if (!pw_scan(arg, pw, NULL)) exit(1); } @@ -178,20 +237,40 @@ main(argc, argv) * The exit closes the master passwd fp/fd. */ pw_init(); - pfd = pw_lock(); +#ifdef DIRECTORY_SERVICE + if (dswhere == WHERE_FILES) +#endif /* DIRECTORY_SERVICE */ + pfd = pw_lock(); tfd = pw_tmp(); if (op == EDITENTRY) { +#ifdef DIRECTORY_SERVICE + setrestricted(dswhere, pw); +#endif /* DIRECTORY_SERVICE */ display(tfd, pw); edit(pw); (void)unlink(tempname); - tfd = pw_tmp(); +#ifdef DIRECTORY_SERVICE + if (dswhere == WHERE_FILES) +#endif /* DIRECTORY_SERVICE */ + tfd = pw_tmp(); } - pw_copy(pfd, tfd, pw); +#ifdef DIRECTORY_SERVICE + switch (dswhere) { + case WHERE_LOCALNI: + update_local_ni(&pworig, pw); + break; + case WHERE_FILES: +#endif /* DIRECTORY_SERVICE */ + pw_copy(pfd, tfd, pw); - if (!pw_mkdb()) - pw_error((char *)NULL, 0, 1); + if (pw_mkdb() != 0) + pw_error((char *)NULL, 0, 1); +#ifdef DIRECTORY_SERVICE + } + system("/usr/sbin/lookupd -flushcache"); +#endif /* DIRECTORY_SERVICE */ exit(0); } diff --git a/chpass.tproj/chpass.h b/chpass.tproj/chpass.h index 99209d2..1a59e75 100644 --- a/chpass.tproj/chpass.h +++ b/chpass.tproj/chpass.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,25 +57,72 @@ * @(#)chpass.h 8.4 (Berkeley) 4/2/94 */ +#ifdef DIRECTORY_SERVICE +#include +#include + +struct display { + struct passwd *pw; + char *fullname; + char *location; + char *officephone; + char *homephone; +}; +#endif /* DIRECTORY_SERVICE */ + struct passwd; typedef struct _entry { char *prompt; +#ifdef DIRECTORY_SERVICE + void (*display)(); +#endif /* DIRECTORY_SERVICE */ int (*func)(), restricted, len; char *except, *save; } ENTRY; /* Field numbers. */ +#ifdef DIRECTORY_SERVICE +#define E_LOGIN 0 +#define E_PASSWD 1 +#define E_UID 2 +#define E_GID 3 +#define E_CHANGE 4 +#define E_EXPIRE 5 +#define E_CLASS 6 +#define E_HOME 7 +#define E_SHELL 8 +#define E_NAME 9 +#define E_LOCATE 10 +#define E_BPHONE 11 +#define E_HPHONE 12 +#else /* DIRECTORY_SERVICE */ #define E_BPHONE 8 #define E_HPHONE 9 #define E_LOCATE 10 #define E_NAME 7 #define E_SHELL 12 +#endif /* DIRECTORY_SERVICE */ extern ENTRY list[]; extern uid_t uid; int atot __P((char *, time_t *)); +#ifdef DIRECTORY_SERVICE +void d_change __P((struct display *, FILE *)); +void d_class __P((struct display *, FILE *)); +void d_expire __P((struct display *, FILE *)); +void d_fullname __P((struct display *, FILE *)); +void d_gid __P((struct display *, FILE *)); +void d_hdir __P((struct display *, FILE *)); +void d_homephone __P((struct display *, FILE *)); +void d_login __P((struct display *, FILE *)); +void d_location __P((struct display *, FILE *)); +void d_officephone __P((struct display *, FILE *)); +void d_passwd __P((struct display *, FILE *)); +void d_shell __P((struct display *, FILE *)); +void d_uid __P((struct display *, FILE *)); +#endif /* DIRECTORY_SERVICE */ void display __P((int, struct passwd *)); void edit __P((struct passwd *)); char *ok_shell __P((char *)); diff --git a/chpass.tproj/directory_service.c b/chpass.tproj/directory_service.c new file mode 100644 index 0000000..0bffe30 --- /dev/null +++ b/chpass.tproj/directory_service.c @@ -0,0 +1,694 @@ +#ifdef DIRECTORY_SERVICE + +#include "directory_service.h" +#include "chpass.h" +#include + +#define CONFIGNAMELEN 14 +#define GLOBALCONFIGLEN 20 +#define LOOKUPORDERLEN 13 +#define LINESIZE 128 +#define NETINFOROOTLEN 13 +#define NLIST 13 +#define REMOTEINFOLEN 9 +#define USERCONFIGLEN 18 + +/*--------------------------------------------------------------------------- + * Global variables + *---------------------------------------------------------------------------*/ +const char *DSPath = NULL; +const char MasterPasswd[] = "/etc/master.passwd"; + +/*--------------------------------------------------------------------------- + * Local variables + *---------------------------------------------------------------------------*/ +static char Agent[] = "Agent"; +static char ConfigName[] = "_config_name: "; +static char DSFiles[] = "/BSD/local"; +static char FFPatFmt[] = "^%s:"; +static char GlobalConfig[] = "Global Configuration"; +static char LocalNI[] = "/NetInfo/DefaultLocalNode"; +static char LookupOrder[] = "LookupOrder: "; +static char LookupOrderSep[] = " "; +static char NetinfoRoot[] = "/NetInfo/root"; +static char NiclPathFmt[] = "/users/%s"; +static char NISPatFmt[] = "/usr/bin/ypcat passwd.byname | /usr/bin/grep -q '^%s:'"; +static char RemoteNI[] = "/NetInfo/"; +static char PathSep[] = "/"; +static char UserConfig[] = "User Configuration"; +static unsigned char RestrictedFFRoot[] = { + 0, /*E_LOGIN */ + 0, /*E_PASSWD */ + 0, /*E_UID */ + 0, /*E_GID */ + 0, /*E_CHANGE */ + 0, /*E_EXPIRE */ + 0, /*E_CLASS */ + 0, /*E_HOME */ + 0, /*E_SHELL */ + 0, /*E_NAME */ + 1, /*E_LOCATE */ + 1, /*E_BPHONE */ + 1, /*E_HPHONE */ +}; +static unsigned char RestrictedFFUser[] = { + 1, /*E_LOGIN */ + 1, /*E_PASSWD */ + 1, /*E_UID */ + 1, /*E_GID */ + 1, /*E_CHANGE */ + 1, /*E_EXPIRE */ + 1, /*E_CLASS */ + 1, /*E_HOME */ + 0, /*E_SHELL */ + 0, /*E_NAME */ + 1, /*E_LOCATE */ + 1, /*E_BPHONE */ + 1, /*E_HPHONE */ +}; +static unsigned char RestrictedLocalNIRoot[] = { + 0, /*E_LOGIN */ + 1, /*E_PASSWD */ + 0, /*E_UID */ + 0, /*E_GID */ + 0, /*E_CHANGE */ + 0, /*E_EXPIRE */ + 0, /*E_CLASS */ + 0, /*E_HOME */ + 0, /*E_SHELL */ + 0, /*E_NAME */ + 1, /*E_LOCATE */ + 1, /*E_BPHONE */ + 1, /*E_HPHONE */ +}; +static unsigned char RestrictedLocalNIUser[] = { + 1, /*E_LOGIN */ + 1, /*E_PASSWD */ + 1, /*E_UID */ + 1, /*E_GID */ + 1, /*E_CHANGE */ + 1, /*E_EXPIRE */ + 1, /*E_CLASS */ + 1, /*E_HOME */ + 0, /*E_SHELL */ + 0, /*E_NAME */ + 1, /*E_LOCATE */ + 1, /*E_BPHONE */ + 1, /*E_HPHONE */ +}; + +#define NWHERE 4 + +typedef int (*wherefunc)(const char *); + +static int compar(const void *, const void *); +static int runnicl(char *name, char *key, char *val); +static int whereCache(const char *); +static int whereDS(const char *); +static int whereFF(const char *); +static int whereNI(const char *); +static int whereNIL(const char *); +static int whereNIS(const char *); + +/*--------------------------------------------------------------------------- + * WhereList determines what functions to call when the LookupOrder is followed + *---------------------------------------------------------------------------*/ +struct where { + char *agent; + int len; + wherefunc func; +} WhereList[] = { + {"Cache", 5, whereCache}, + {"DS", 2, whereDS}, + {"FF", 2, whereFF}, + {"NI", 2, whereNI}, + {"NIL", 3, whereNIL}, + {"NIS", 3, whereNIS}, +}; + +#define PATINDEX 2 +static char *Grep[] = { + "/usr/bin/grep", + "-q", + NULL, /* pattern goes here */ + (char *)MasterPasswd, + NULL +}; + +#define NICLPATHINDEX 3 +#define NICLKEYINDEX 4 +#define NICLVALUEINDEX 5 +static char *Nicl[] = { + "/usr/bin/nicl", + ".", + "-create", + NULL, /* path goes here */ + NULL, /* key goes here */ + NULL, /* value goes here */ + NULL +}; + +#define YPCATINDEX 2 +static char *Ypcat[] = { + "/bin/sh", + "-c", + NULL, /* ypcat cmd goes here */ + NULL +}; + +/*--------------------------------------------------------------------------- + * compar - called by bsearch() to search WhereList for an agent + *---------------------------------------------------------------------------*/ +#define A ((const struct where *)a) +#define KEY ((const char *)key) +static int +compar(const void *key, const void *a) +{ + int result = strncmp(KEY, A->agent, A->len); + if(result) + return result; + if(KEY[A->len] == 0) + return 0; + return strcmp(KEY + A->len, Agent); +} +#undef KEY +#undef A + +/*--------------------------------------------------------------------------- + * runnicl - run the nicl command to update local netinfo fields + *---------------------------------------------------------------------------*/ +static int +runnicl(char *name, char *key, char *val) +{ + char path[128]; + pid_t pid; + int estat; + int status; + + IF((pid = fork()) >= 0) { + if(pid == 0) { + sprintf(path, NiclPathFmt, name); + Nicl[NICLPATHINDEX] = path; + Nicl[NICLKEYINDEX] = key; + Nicl[NICLVALUEINDEX] = val; + /*--------------------------------------------------------------- + * Become fully root to call nicl + *---------------------------------------------------------------*/ + setuid(geteuid()); + execv(Nicl[0], Nicl); + _exit(1); + } + if(waitpid(pid, &estat, 0) < 0) { + status = errno; + break; + } + if(!WIFEXITED(estat)) { + status = E_NICLFAILED; + break; + } + status = (WEXITSTATUS(estat) == 0 ? 0 : E_NICLFAILED); + } CLEANUP { + } ELSE { + status = errno; + } ENDIF + return status; +} +/*--------------------------------------------------------------------------- + * PUBLIC setrestricted - sets the restricted flag + *---------------------------------------------------------------------------*/ +void +setrestricted(int where, struct passwd *pw) +{ + unsigned char *restricted; + int i; + ENTRY *ep; + + switch(where) { + case WHERE_FILES: + restricted = uid ? RestrictedFFUser : RestrictedFFRoot; + break; + case WHERE_LOCALNI: + restricted = uid ? RestrictedLocalNIUser : RestrictedLocalNIRoot; + break; + } + + for (ep = list, i = NLIST; i > 0; i--) + (ep++)->restricted = *restricted++; + + if (uid && !ok_shell(pw->pw_shell)) + list[E_SHELL].restricted = 1; +} + +/*--------------------------------------------------------------------------- + * PUBLIC update_local_ni - update local netinfo + *---------------------------------------------------------------------------*/ +void +update_local_ni(struct passwd *pworig, struct passwd *pw) +{ + char buf[64]; + char *np, *op, *bp; + + if(pworig->pw_uid != pw->pw_uid) { + sprintf(buf, "%d", pw->pw_uid); + runnicl(pworig->pw_name, "uid", buf); + } + if(pworig->pw_gid != pw->pw_gid) { + sprintf(buf, "%d", pw->pw_gid); + runnicl(pworig->pw_name, "gid", buf); + } + if(pworig->pw_change != pw->pw_change) { + sprintf(buf, "%lu", pw->pw_change); + runnicl(pworig->pw_name, "change", buf); + } + if(pworig->pw_expire != pw->pw_expire) { + sprintf(buf, "%lu", pw->pw_expire); + runnicl(pworig->pw_name, "expire", buf); + } + if(strcmp(pworig->pw_dir, pw->pw_dir) != 0) + runnicl(pworig->pw_name, "home", pw->pw_dir); + if(strcmp(pworig->pw_shell, pw->pw_shell) != 0) + runnicl(pworig->pw_name, "shell", pw->pw_shell); + if(strcmp(pworig->pw_class, pw->pw_class) != 0) + runnicl(pworig->pw_name, "class", pw->pw_class); + + bp = pworig->pw_gecos; + op = strsep(&bp, ","); + if(!op) + op = ""; + bp = pw->pw_gecos; + np = strsep(&bp, ","); + if(!np) + np = ""; + if(strcmp(op, np) != 0) + runnicl(pworig->pw_name, "realname", np); + + if(strcmp(pworig->pw_name, pw->pw_name) != 0) + runnicl(pworig->pw_name, "name", pw->pw_name); + + warnx("netinfo domain \"%s\" updated", DSPath); +} + +/*--------------------------------------------------------------------------- + * whereCache - we skip the cache + *---------------------------------------------------------------------------*/ +static int +whereCache(const char *name) +{ + return E_NOTFOUND; +} + +/*--------------------------------------------------------------------------- + * whereDS - call DirectoryService. This does both netinfo and other directory + * services, so we cache the value so we only process once. + *---------------------------------------------------------------------------*/ +static int +whereDS(const char *name) +{ + tDirReference dsRef; + static tDirStatus status; + static int dsCached = 0; + + if(dsCached) + return status; + dsCached = 1; + IF((status = dsOpenDirService(&dsRef)) == eDSNoErr) { + tDataBuffer *dataBuff; + + IF((dataBuff = dsDataBufferAllocate(dsRef, 4096)) != NULL) { + tContextData context = NULL; + unsigned long nodeCount; + + /*--------------------------------------------------------------- + * Find and open the search node. + *---------------------------------------------------------------*/ + IF((status = dsFindDirNodes(dsRef, dataBuff, NULL, + eDSAuthenticationSearchNodeName, &nodeCount, &context)) + == eDSNoErr) { + tDataListPtr nodeName; + if(nodeCount < 1) { + status = eDSNodeNotFound; + break; + } + nodeName = NULL; + IF((status = dsGetDirNodeName(dsRef, dataBuff, 1, + &nodeName)) == eDSNoErr) { + tDirNodeReference nodeRef; + + IF((status = dsOpenDirNode(dsRef, nodeName, &nodeRef)) + == eDSNoErr) { + tDataListPtr pRecType; + tDataListPtr pAttrType; + tDataListPtr pPattern; + unsigned long recCount; + tContextData context2 = NULL; + + /*--------------------------------------------------- + * Now search the search node for the given user name. + *---------------------------------------------------*/ + pRecType = dsBuildListFromStrings(dsRef, + kDSStdRecordTypeUsers, NULL); + pAttrType = dsBuildListFromStrings(dsRef, + kStandardSourceAlias, NULL); + pPattern = dsBuildListFromStrings(dsRef, name, NULL); + IF((status = dsGetRecordList(nodeRef, dataBuff, + pPattern, eDSExact, pRecType, pAttrType, 0, &recCount, + &context2)) == eDSNoErr) { + tAttributeListRef attrListRef; + tRecordEntry *pRecEntry; + + if(recCount < 1) { + status = E_NOTFOUND; + break; + } + /*----------------------------------------------- + * Get the attributes for the first entry we find + *-----------------------------------------------*/ + IF((status = dsGetRecordEntry(nodeRef, + dataBuff, 1, &attrListRef, &pRecEntry)) == + eDSNoErr) { + tAttributeValueListRef valueRef; + tAttributeEntry *pAttrEntry; + + /*------------------------------------------- + * Get the first (only) attribute + *-------------------------------------------*/ + IF((status = dsGetAttributeEntry( nodeRef, + dataBuff, attrListRef, 1, &valueRef, + &pAttrEntry)) == eDSNoErr) { + tDataListPtr pPathList; + + /*--------------------------------------- + * Put the attribute values into a data + * list. + *---------------------------------------*/ + IF((pPathList = dsDataListAllocate(dsRef)) + != NULL) { + int k; + tAttributeValueEntry *pValueEntry; + + for(k = 1; k <= + pAttrEntry->fAttributeValueCount; + k++) { + IF((status = + dsGetAttributeValue(nodeRef, + dataBuff, k, valueRef, + &pValueEntry)) == eDSNoErr) { + if((status = + dsAppendStringToListAlloc( + dsRef, pPathList, + pValueEntry->fAttributeValueData.fBufferData)) + != eDSNoErr) { + k = pAttrEntry->fAttributeValueCount; + break; + } + } CLEANUP { + dsDeallocAttributeValueEntry( + dsRef, pValueEntry); + } ELSE { + break; + } ENDIF + } + if(status != eDSNoErr) + break; + /*----------------------------------- + * Finally, build a path from the data + * list, and compare it to known paths. + *-----------------------------------*/ + if(DSPath) + free((void *)DSPath); + if((DSPath = dsGetPathFromList(dsRef, + pPathList, PathSep)) != NULL) { + if(strcmp(DSPath, LocalNI) == 0) { + status = WHERE_LOCALNI; + /*--------------------------- + * Translate to netinfo path + *---------------------------*/ + free((void *)DSPath); + DSPath = strdup("."); + } else if(strcmp(DSPath, DSFiles) + == 0) { + status = WHERE_FILES; + /*--------------------------- + * Translate to master.passwd + * path + *---------------------------*/ + free((void *)DSPath); + DSPath = strdup(MasterPasswd); + } else if(strncmp(DSPath, RemoteNI, + REMOTEINFOLEN) == 0) { + status = WHERE_REMOTENI; + /*--------------------------- + * Translate to netinfo path + *---------------------------*/ + if(strncmp(DSPath, NetinfoRoot, + NETINFOROOTLEN) == 0) { + if(DSPath[NETINFOROOTLEN] + == 0) { + free((void *)DSPath); + DSPath = strdup("/"); + } else { + char *tmp = + strdup(DSPath + + NETINFOROOTLEN); + free((void *)DSPath); + DSPath = tmp; + } + } + } else + status = WHERE_DS; + } else + status = E_PATHOUTOFMEM; + } CLEANUP { + dsDataListDeallocate(dsRef, pPathList); + free(pPathList); + } ELSE { + status = E_DATALISTOUTOFMEM; + } ENDIF + } CLEANUP { + dsCloseAttributeValueList(valueRef); + dsDeallocAttributeEntry(dsRef, pAttrEntry); + } ELSE { + } ENDIF + } CLEANUP { + dsCloseAttributeList(attrListRef); + dsDeallocRecordEntry(dsRef, pRecEntry); + } ENDIF + } CLEANUP { + if(context2) + dsReleaseContinueData(dsRef, context2); + } ENDIF + dsDataListDeallocate(dsRef, pRecType); + free(pRecType); + dsDataListDeallocate(dsRef, pAttrType); + free(pAttrType); + dsDataListDeallocate(dsRef, pPattern); + free(pPattern); + } CLEANUP { + dsCloseDirNode(nodeRef); + } ENDIF + } CLEANUP { + dsDataListDeallocate(dsRef, nodeName); + } ENDIF + } CLEANUP { + if(context) + dsReleaseContinueData(dsRef, context); + } ENDIF + } CLEANUP { + dsDataBufferDeAllocate(dsRef, dataBuff); + } ELSE { + status = eMemoryAllocError; + } ENDIF + } CLEANUP { + dsCloseDirService(dsRef); + } ENDIF + return status; +} + +/*--------------------------------------------------------------------------- + * whereFF - check the flat file (/etc/master.passwd) + *---------------------------------------------------------------------------*/ +static int +whereFF(const char *name) +{ + pid_t pid; + int estat; + int status; + + IF((pid = fork()) >= 0) { + if(pid == 0) { + char pat[64]; + + sprintf(pat, FFPatFmt, name); + Grep[PATINDEX] = pat; + /*--------------------------------------------------------------- + * Become fully root to read /etc/master.passwd + *---------------------------------------------------------------*/ + setuid(geteuid()); + execv(Grep[0], Grep); + _exit(1); + } + if(waitpid(pid, &estat, 0) < 0) { + status = errno; + break; + } + if(!WIFEXITED(estat)) { + status = E_CHILDFAILED; + break; + } + status = (WEXITSTATUS(estat) == 0 ? WHERE_FILES : E_NOTFOUND); + } CLEANUP { + } ELSE { + status = errno; + } ENDIF + return status; +} + +/*--------------------------------------------------------------------------- + * whereNI - call whereDS to do the work, then the entry is found in directory + * service (and not netinfo), mark as not found. + *---------------------------------------------------------------------------*/ +static int +whereNI(const char *name) +{ + int status = whereDS(name); + + if(status == WHERE_DS) + status = E_NOTFOUND; + return status; +} + +/*--------------------------------------------------------------------------- + * whereNIL - we skip the NILAgent + *---------------------------------------------------------------------------*/ +static int +whereNIL(const char *name) +{ + return E_NOTFOUND; +} + +/*--------------------------------------------------------------------------- + * whereNIS - check NIS passwd.byname + *---------------------------------------------------------------------------*/ +static int +whereNIS(const char *name) +{ + pid_t pid; + int estat; + int status; + + IF((pid = fork()) >= 0) { + if(pid == 0) { + char cmd[256]; + + sprintf(cmd, NISPatFmt, name); + Ypcat[YPCATINDEX] = cmd; + execv(Ypcat[0], Ypcat); + _exit(1); + } + if(waitpid(pid, &estat, 0) < 0) { + status = errno; + break; + } + if(!WIFEXITED(estat)) { + status = E_CHILDFAILED; + break; + } + status = (WEXITSTATUS(estat) == 0 ? WHERE_NIS : E_NOTFOUND); + } CLEANUP { + } ELSE { + status = errno; + } ENDIF + return status; +} + +/*--------------------------------------------------------------------------- + * PUBLIC wherepwent - Given a const char *, determine lookupd's LookupOrder + * and then search for the corresponding record for each agent. + *---------------------------------------------------------------------------*/ +int +wherepwent(const char *name) +{ + char user[LINESIZE]; + char *cp, *str; + struct where *w; + FILE *fp = popen("/usr/sbin/lookupd -configuration", "r"); + int status = 0; + + IF(fp != NULL) { + char order[LINESIZE], line[LINESIZE]; + + /*------------------------------------------------------------------- + * Save the first LookupOrder as the global setting. We make sure + * that the first _config_name is Global Configuration. + *-------------------------------------------------------------------*/ + *user = 0; + while(fgets(line, LINESIZE, fp)) { + if(strncasecmp(line, LookupOrder, LOOKUPORDERLEN) == 0) { + if((cp = strchr(line, '\n')) != NULL) + *cp = 0; + strcpy(user, line + LOOKUPORDERLEN); + continue; + } + if(strncasecmp(line, ConfigName, CONFIGNAMELEN) == 0) { + if(strncasecmp(line + CONFIGNAMELEN, GlobalConfig, + GLOBALCONFIGLEN) != 0) { + status = E_NOGLOBALCONFIG; + } + break; + } + } + if(status < 0) + break; + /*------------------------------------------------------------------- + * Save the each LookupOrder and look for _config_name of User + * Configuration. If found, replace the global order with this one. + *-------------------------------------------------------------------*/ + *order = 0; + while(fgets(line, LINESIZE, fp)) { + if(strncasecmp(line, LookupOrder, LOOKUPORDERLEN) == 0) { + if((cp = strchr(line, '\n')) != NULL) + *cp = 0; + strcpy(order, line + LOOKUPORDERLEN); + continue; + } + if(strncasecmp(line, ConfigName, CONFIGNAMELEN) == 0) { + if(strncasecmp(line + CONFIGNAMELEN, UserConfig, + USERCONFIGLEN) == 0) { + if(*order) + strcpy(user, order); + break; + } + *order = 0; + } + } + if(*user == 0) { + status = E_NOLOOKUPORDER; + break; + } + } CLEANUP { + pclose(fp); + } ELSE { + status = E_POPENFAILED; + } ENDIF + + if(status < 0) + return status; + + /*----------------------------------------------------------------------- + * Now for each agent, call the corresponding where function. If the + * return value is no E_NOTFOUND, then we either have found it or have + * detected an error. + *-----------------------------------------------------------------------*/ + str = user; + while((cp = strtok(str, LookupOrderSep)) != NULL) { + if((w = bsearch(cp, WhereList, NWHERE, sizeof(struct where), + compar)) != NULL) { + if((status = w->func(name)) != E_NOTFOUND) + return status; + } else + printf("%s not supported\n", cp); + str = NULL; + } + return E_NOTFOUND; +} +#endif /* DIRECTORY_SERVICE */ diff --git a/chpass.tproj/directory_service.h b/chpass.tproj/directory_service.h new file mode 100644 index 0000000..7a3d6bc --- /dev/null +++ b/chpass.tproj/directory_service.h @@ -0,0 +1,74 @@ +#ifndef _DIRECTORY_SERVICE_H_ +#define _DIRECTORY_SERVICE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*--------------------------------------------------------------------------- + * Convenience macros: to be used to provide a cleanup section (eg, to + * deallocate memory, etc). IF, CLEANUP and ENDIF must always be used, and + * must be used with braces; ELSE is optional, but must also be used with + * braces. + * + * IF(expression) { + * ... + * } CLEANUP { + * ... + * } ELSE { + * ... + * } ENDIF + * + * "break" may be used in the IF section to exit the block prematurely; the + * CLEANUP section will still be performed. "break" in the CLEANUP and ELSE + * sections apply to higher level blocks. + *---------------------------------------------------------------------------*/ +#define IF(x) if(x) { do +#define CLEANUP while(0); +#define ELSE } else { +#define ENDIF } + +/*--------------------------------------------------------------------------- + * Error codes (not including DirectoryService error codes and standard error + * codes) + *---------------------------------------------------------------------------*/ +#define E_NOTFOUND -1000 +#define E_NOGLOBALCONFIG -1001 +#define E_NOLOOKUPORDER -1002 +#define E_POPENFAILED -1003 +#define E_CHILDFAILED -1004 +#define E_DATALISTOUTOFMEM -1005 +#define E_PATHOUTOFMEM -1006 +#define E_NICLFAILED -1007 + +/*--------------------------------------------------------------------------- + * Success return values from wherepwent() + *---------------------------------------------------------------------------*/ +enum { + WHERE_FILES = 0, + WHERE_LOCALNI, + WHERE_REMOTENI, + WHERE_DS, + WHERE_NIS, +}; + +/*--------------------------------------------------------------------------- + * Global variables + *---------------------------------------------------------------------------*/ +extern const char *DSPath; +extern const char MasterPasswd[]; + +/*--------------------------------------------------------------------------- + * Function prototypes + *---------------------------------------------------------------------------*/ +extern void setrestricted(int where, struct passwd *pw); +extern void update_local_ni(struct passwd *pworig, struct passwd *pw); +extern int wherepwent(const char *name); + +#endif /* _DIRECTORY_SERVICE_H_ */ diff --git a/chpass.tproj/ds_pw_util.c b/chpass.tproj/ds_pw_util.c new file mode 100644 index 0000000..b0f86cd --- /dev/null +++ b/chpass.tproj/ds_pw_util.c @@ -0,0 +1,260 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)pw_util.c 8.4 (Berkeley) 4/28/95"; +#endif /* not lint */ + +/* + * This file is used by all the "password" programs; vipw(8), chpass(1), + * and passwd(1). + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pw_util.h" +#ifdef DIRECTORY_SERVICE +#include "directory_service.h" +#endif /* DIRECTORY_SERVICE */ + +extern char *tempname; +static pid_t editpid = -1; +static int lockfd; + +void +pw_cont(sig) + int sig; +{ + + if (editpid != -1) + kill(editpid, sig); +} + +void +pw_init() +{ + struct rlimit rlim; + + /* Unlimited resource limits. */ + rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; + (void)setrlimit(RLIMIT_CPU, &rlim); + (void)setrlimit(RLIMIT_FSIZE, &rlim); + (void)setrlimit(RLIMIT_STACK, &rlim); + (void)setrlimit(RLIMIT_DATA, &rlim); + (void)setrlimit(RLIMIT_RSS, &rlim); + + /* Don't drop core (not really necessary, but GP's). */ + rlim.rlim_cur = rlim.rlim_max = 0; + (void)setrlimit(RLIMIT_CORE, &rlim); + + /* Turn off signals. */ + (void)signal(SIGALRM, SIG_IGN); + (void)signal(SIGHUP, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); + (void)signal(SIGPIPE, SIG_IGN); + (void)signal(SIGQUIT, SIG_IGN); + (void)signal(SIGTERM, SIG_IGN); + (void)signal(SIGCONT, pw_cont); + + /* Create with exact permissions. */ + (void)umask(0); +} + +int +pw_lock() +{ + /* + * If the master password file doesn't exist, the system is hosed. + * Might as well try to build one. Set the close-on-exec bit so + * that users can't get at the encrypted passwords while editing. + * Open should allow flock'ing the file; see 4.4BSD. XXX + */ + lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); + if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) + err(1, "%s", _PATH_MASTERPASSWD); + if (flock(lockfd, LOCK_EX|LOCK_NB)) + errx(1, "the password db file is busy"); + return (lockfd); +} + +int +pw_tmp() +{ + static char path[MAXPATHLEN] = _PATH_MASTERPASSWD; + int fd; + char *p; + + if (p = strrchr(path, '/')) + ++p; + else + p = path; + strcpy(p, "pw.XXXXXX"); + if ((fd = mkstemp(path)) == -1) + err(1, "%s", path); + tempname = path; + return (fd); +} + +int +pw_mkdb() +{ + int pstat; + pid_t pid; + + warnx("rebuilding the database..."); + (void)fflush(stderr); + if (!(pid = vfork())) { + execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); + pw_error(_PATH_PWD_MKDB, 1, 1); + } + pid = waitpid(pid, &pstat, 0); + if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) + return (1); + warnx("done"); + return (0); +} + +void +pw_edit(notsetuid) + int notsetuid; +{ + int pstat; + char *p, *editor; + + if (!(editor = getenv("EDITOR"))) + editor = _PATH_VI; + if (p = strrchr(editor, '/')) + ++p; + else + p = editor; + + if (!(editpid = vfork())) { + if (notsetuid) { + (void)setgid(getgid()); + (void)setuid(getuid()); + } + execlp(editor, p, tempname, NULL); + _exit(1); + } + for (;;) { + editpid = waitpid(editpid, (int *)&pstat, WUNTRACED); + if (editpid == -1) + pw_error(editor, 1, 1); + else if (WIFSTOPPED(pstat)) + raise(WSTOPSIG(pstat)); + else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0) + break; + else + pw_error(editor, 1, 1); + } + editpid = -1; +} + +void +pw_prompt() +{ + int c; + + (void)printf("re-edit the password file? [y]: "); + (void)fflush(stdout); + c = getchar(); + if (c != EOF && c != '\n') + while (getchar() != '\n'); + if (c == 'n') + pw_error(NULL, 0, 0); +} + +void +pw_error(name, err, eval) + char *name; + int err, eval; +{ +#ifdef DIRECTORY_SERVICE + extern int dswhere; +#endif /* DIRECTORY_SERVICE */ + if (err) + warn("%s", name); + +#ifdef DIRECTORY_SERVICE + switch(dswhere) { + case WHERE_LOCALNI: + warnx("netinfo domain \"%s\": unchanged", DSPath); + break; + case WHERE_FILES: +#endif /* DIRECTORY_SERVICE */ + warnx("%s: unchanged", _PATH_MASTERPASSWD); +#ifdef DIRECTORY_SERVICE + } +#endif /* DIRECTORY_SERVICE */ + (void)unlink(tempname); + exit(eval); +} diff --git a/chpass.tproj/edit.c b/chpass.tproj/edit.c index 0b9e3d2..ecdbe70 100644 --- a/chpass.tproj/edit.c +++ b/chpass.tproj/edit.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -71,6 +72,11 @@ #include #include "chpass.h" +#ifdef DIRECTORY_SERVICE +#include "directory_service.h" + +extern int dswhere; +#endif /* DIRECTORY_SERVICE */ extern char *tempname; @@ -108,12 +114,68 @@ display(fd, pw) { FILE *fp; char *bp, *p, *ttoa(); +#ifdef DIRECTORY_SERVICE + ENTRY *ep; + struct display d; + int ndisplayed = 0; +#endif /* DIRECTORY_SERVICE */ if (!(fp = fdopen(fd, "w"))) pw_error(tempname, 1, 1); (void)fprintf(fp, - "#Changing user database information for %s.\n", pw->pw_name); + "# Changing user database information for %s.\n" + "#\n" + "# (use \"passwd\" to change the password)\n" + "##\n", + pw->pw_name); + +#ifdef DIRECTORY_SERVICE + switch (dswhere) { + case WHERE_FILES: + (void)fprintf(fp, + "# Flat file: /etc/master.passwd\n" + "##\n"); + break; + case WHERE_LOCALNI: + (void)fprintf(fp, + "# Local NetInfo Database\n" + "##\n"); + break; + } + d.pw = pw; + bp = pw->pw_gecos; + p = strsep(&bp, ","); + d.fullname = (p ? p : ""); + p = strsep(&bp, ","); + d.location = (p ? p : ""); + p = strsep(&bp, ","); + d.officephone = (p ? p : ""); + p = strsep(&bp, ","); + d.homephone = ( p ? p : ""); + + for (ep = list; ep->prompt; ep++) + if (!ep->restricted) { + ep->display(&d, fp); + ndisplayed++; + } + if(!ndisplayed) { + (void)fprintf(fp, "###################################\n"); + (void)fprintf(fp, "# No fields are available to change\n"); + (void)fprintf(fp, "###################################\n"); + } +#else /* DIRECTORY_SERVICE */ + (void)fprintf(fp, + "##\n" + "# User Database\n" + "# \n" + "# Note: This program edits the /etc/master.passwd file which is only \n" + "# consulted when the system is running in single-user mode. At other times \n" + "# this information is handled by lookupd. By default, lookupd gets \n" + "# information from NetInfo, so this file will not be consulted unless you \n" + "# have changed lookupd's configuration.\n" + "##\n"); + if (!uid) { (void)fprintf(fp, "Login: %s\n", pw->pw_name); (void)fprintf(fp, "Password: %s\n", pw->pw_passwd); @@ -147,6 +209,7 @@ display(fd, pw) (void)fprintf(fp, "Office Phone: %s\n", p ? p : ""); p = strsep(&bp, ","); (void)fprintf(fp, "Home Phone: %s\n", p ? p : ""); +#endif /* DIRECTORY_SERVICE */ (void)fchown(fd, getuid(), getgid()); (void)fclose(fp); @@ -213,12 +276,22 @@ bad: (void)fclose(fp); (void)fclose(fp); /* Build the gecos field. */ +#ifdef DIRECTORY_SERVICE + if (list[E_NAME].save) { + if (list[E_LOCATE].save) { +#endif /* DIRECTORY_SERVICE */ len = strlen(list[E_NAME].save) + strlen(list[E_BPHONE].save) + strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) + 4; if (!(p = malloc(len))) err(1, NULL); (void)sprintf(pw->pw_gecos = p, "%s,%s,%s,%s", list[E_NAME].save, list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save); +#ifdef DIRECTORY_SERVICE + } else + pw->pw_gecos = list[E_NAME].save; + } else + pw->pw_gecos = ""; +#endif /* DIRECTORY_SERVICE */ if (snprintf(buf, sizeof(buf), "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s", @@ -228,5 +301,5 @@ bad: (void)fclose(fp); warnx("entries too long"); return (0); } - return (pw_scan(buf, pw)); + return (pw_scan(buf, pw, NULL)); } diff --git a/chpass.tproj/field.c b/chpass.tproj/field.c index 2fc07ba..c997892 100644 --- a/chpass.tproj/field.c +++ b/chpass.tproj/field.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -285,3 +286,84 @@ p_shell(p, pw, ep) } return (0); } + +#ifdef DIRECTORY_SERVICE +void +d_change(struct display *d, FILE *fp) +{ + fprintf(fp, "Change [month day year]: %s\n", ttoa(d->pw->pw_change)); +} + +void +d_class(struct display *d, FILE *fp) +{ + fprintf(fp, "Class: %s\n", d->pw->pw_class); +} + +void +d_expire(struct display *d, FILE *fp) +{ + fprintf(fp, "Expire [month day year]: %s\n", ttoa(d->pw->pw_expire)); +} + +void +d_fullname(struct display *d, FILE *fp) +{ + fprintf(fp, "Full Name: %s\n", d->fullname); +} + +void +d_gid(struct display *d, FILE *fp) +{ + fprintf(fp, "Gid [# or name]: %d\n", d->pw->pw_gid); +} + +void +d_hdir(struct display *d, FILE *fp) +{ + fprintf(fp, "Home directory: %s\n", d->pw->pw_dir); +} + +void +d_homephone(struct display *d, FILE *fp) +{ + fprintf(fp, "Home Phone: %s\n", d->homephone); +} + +void +d_login(struct display *d, FILE *fp) +{ + fprintf(fp, "Login: %s\n", d->pw->pw_name); +} + +void +d_location(struct display *d, FILE *fp) +{ + fprintf(fp, "Location: %s\n", d->location); +} + +void +d_officephone(struct display *d, FILE *fp) +{ + fprintf(fp, "Office Phone: %s\n", d->officephone); +} + +void +d_passwd(struct display *d, FILE *fp) +{ + fprintf(fp, "Password: %s\n", d->pw->pw_passwd); +} + +void +d_shell(struct display *d, FILE *fp) +{ + fprintf(fp, "Shell: %s\n", *d->pw->pw_shell ? d->pw->pw_shell + : _PATH_BSHELL); +} + +void +d_uid(struct display *d, FILE *fp) +{ + fprintf(fp, "Uid [#]: %d\n", d->pw->pw_uid); +} +#endif /* DIRECTORY_SERVICE */ diff --git a/chpass.tproj/pathnames.h b/chpass.tproj/pathnames.h index 03c43a3..6f0a0bc 100644 --- a/chpass.tproj/pathnames.h +++ b/chpass.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/pw_copy.c b/chpass.tproj/pw_copy.c index 64ddc9f..d30b56f 100644 --- a/chpass.tproj/pw_copy.c +++ b/chpass.tproj/pw_copy.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/pw_copy.h b/chpass.tproj/pw_copy.h index 4a742ac..c71c067 100644 --- a/chpass.tproj/pw_copy.h +++ b/chpass.tproj/pw_copy.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/table.c b/chpass.tproj/table.c index dbae702..b260e80 100644 --- a/chpass.tproj/table.c +++ b/chpass.tproj/table.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -61,6 +62,24 @@ char e1[] = ": "; char e2[] = ":,"; +#ifdef DIRECTORY_SERVICE +ENTRY list[] = { + { "login", d_login, p_login, 0, 5, e1, }, + { "password", d_passwd, p_passwd, 0, 8, e1, }, + { "uid", d_uid, p_uid, 0, 3, e1, }, + { "gid", d_gid, p_gid, 0, 3, e1, }, + { "change", d_change, p_change, 0, 6, NULL, }, + { "expire", d_expire, p_expire, 0, 6, NULL, }, + { "class", d_class, p_class, 0, 5, e1, }, + { "home directory", d_hdir, p_hdir, 0, 14, e1, }, + { "shell", d_shell, p_shell, 0, 5, e1, }, + { "full name", d_fullname, p_gecos, 0, 9, e2, }, + { "location", d_location, p_gecos, 0, 8, e2, }, + { "office phone", d_officephone, p_gecos, 0, 12, e2, }, + { "home phone", d_homephone, p_gecos, 0, 10, e2, }, + { NULL }, +}; +#else /* DIRECTORY_SERVICE */ ENTRY list[] = { { "login", p_login, 1, 5, e1, }, { "password", p_passwd, 1, 8, e1, }, @@ -77,3 +96,4 @@ ENTRY list[] = { { "shell", p_shell, 0, 5, e1, }, { NULL, 0, }, }; +#endif /* DIRECTORY_SERVICE */ diff --git a/chpass.tproj/util.c b/chpass.tproj/util.c index c4dd4d3..74fd386 100644 --- a/chpass.tproj/util.c +++ b/chpass.tproj/util.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dmesg.tproj/dmesg.c b/dmesg.tproj/dmesg.c index 10d5cae..321c40a 100644 --- a/dmesg.tproj/dmesg.c +++ b/dmesg.tproj/dmesg.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dynamic_pager.tproj/Makefile b/dynamic_pager.tproj/Makefile index 6bc4214..40d68a4 100644 --- a/dynamic_pager.tproj/Makefile +++ b/dynamic_pager.tproj/Makefile @@ -16,7 +16,7 @@ CFILES = dynamic_pager.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ default_pager_alerts.defs backing_store_alerts.defs\ - backing_store_triggers.defs + backing_store_triggers.defs dynamic_pager.8 MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles diff --git a/dynamic_pager.tproj/Makefile.postamble b/dynamic_pager.tproj/Makefile.postamble index aedcab1..b00ad8b 100644 --- a/dynamic_pager.tproj/Makefile.postamble +++ b/dynamic_pager.tproj/Makefile.postamble @@ -124,3 +124,7 @@ backing_store_triggers_server.c: \ cp $(SRCROOT)/dynamic_pager.tproj/backing_store_triggers.defs $(SYM_DIR); cd $(SYM_DIR) && \ $(MIG) $(MIGFLAGS) -user /dev/null -server backing_store_triggers_server.c -sheader backing_store_triggers_server.h backing_store_triggers.defs + +install-man-page: + install -d $(DSTROOT)/usr/share/man/man8 + install -c -m 444 dynamic_pager.8 $(DSTROOT)/usr/share/man/man8/dynamic_pager.8 diff --git a/dynamic_pager.tproj/Makefile.preamble b/dynamic_pager.tproj/Makefile.preamble index 088fb3c..2b74ce3 100644 --- a/dynamic_pager.tproj/Makefile.preamble +++ b/dynamic_pager.tproj/Makefile.preamble @@ -127,3 +127,4 @@ OTHER_OFILES = default_pager_alerts_server.o backing_store_alerts.o backing_stor -include ../Makefile.include OTHER_CFLAGS = BEFORE_BUILD = default_pager_alerts_server.o +AFTER_INSTALL += install-man-page diff --git a/dynamic_pager.tproj/PB.project b/dynamic_pager.tproj/PB.project index 74203e7..05aa432 100644 --- a/dynamic_pager.tproj/PB.project +++ b/dynamic_pager.tproj/PB.project @@ -9,7 +9,8 @@ Makefile.postamble, default_pager_alerts.defs, backing_store_alerts.defs, - backing_store_triggers.defs + backing_store_triggers.defs, + dynamic_pager.8 ); }; LANGUAGE = English; diff --git a/dynamic_pager.tproj/dynamic_pager.8 b/dynamic_pager.tproj/dynamic_pager.8 new file mode 100644 index 0000000..ae06d92 --- /dev/null +++ b/dynamic_pager.tproj/dynamic_pager.8 @@ -0,0 +1,73 @@ +.\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +.\" +.Dd July 8, 2003 +.Dt dynamic_pager 8 +.Os "Mac OS X" +.Sh NAME +.Nm dynamic_pager +.Nd dynamic pager external storage manager +.Sh SYNOPSIS +.Nm dynamic_pager +.Op Fl F Ar filename +.Op Fl S Ar filesize +.Op Fl H Ar high-water-trigger +.Op Fl L Ar low-water-trigger +.Op Fl P Ar priority +.Sh DESCRIPTION +The +.Nm dynamic_pager +daemon manages a pool of external swap files which the kernel uses to +support demand paging. This pool is expanded with new swap files as load on +the system increases, and contracted when the swapping resources are no +longer needed. The +.Nm dynamic_pager +daemon also provides a notification service for those applications which +wish to receive notices when the external paging pool expands or contracts. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl F +The base name of the +.Ar filename +to use for the external paging files. By default this is +.Pa /private/var/vm/swapfile . +.It Fl S +The fixed +.Ar filesize +[in bytes] to use for the paging files. By default +.Nm dynamic_pager +uses variable sized paging files, using larger sized files as paging demands +increase. The +.Fl S , +.Fl H +and +.Fl L +options disable that default and cause +.Nm dynamic_pager +to use a series of fixed sized external paging files. +.It Fl H +If there are less than +.Ar high-water-trigger +bytes free in the external paging files, the kernel will signal +.Nm dynamic_pager +to add a new external paging file. +.It Fl L +If there are more than +.Ar low-water-trigger +bytes free in the external paging files, the kernel will coalese in-use pages +and signal +.Nm dynamic_pager +to discard an external paging file. +.Ar Low-water-trigger +must be greater than +.Ar high-water-trigger ++ +.Ar filesize . +.It Fl P +This option is currently unimplemented. +.Sh FILES +.Bl -tag -width /private/var/vp/swapfile* --compact +.It Pa /private/var/vm/swapfile* +Default external paging files. +.Sh SEE ALSO +.Xr macx_swapon 2 , +.Xr macx_swapoff 2 . diff --git a/dynamic_pager.tproj/dynamic_pager.c b/dynamic_pager.tproj/dynamic_pager.c index e4d1cda..c168eab 100644 --- a/dynamic_pager.tproj/dynamic_pager.c +++ b/dynamic_pager.tproj/dynamic_pager.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -35,22 +36,41 @@ #include #include + +/* + * HI_WATER_DEFAULT set to this funny value to + * match the size that the low space application + * is asking for... need to keep MINIMUM_SIZE + * above this value. + */ +#define HI_WATER_DEFAULT 40000000 +#define MINIMUM_SIZE (1024 * 1024 * 64) +#define MAXIMUM_SIZE (1024 * 1024 * 1024) + +#define MAX_LIMITS 8 + + +struct limit { + unsigned int size; + unsigned int low_water; +} limits[MAX_LIMITS]; + + int debug = 0; +int max_valid = 0; int file_count = 0; -int low_water = 0; -int hi_water = 0; -int local_hi_water = 0; -int size = 20000000; +unsigned int hi_water; +unsigned int local_hi_water; int priority = 0; -int options = 0; +int options = 0; char fileroot[512]; /* global parameters for application notification option */ mach_port_t trigger_port = MACH_PORT_NULL; mach_port_t notify_port = MACH_PORT_NULL; -int notify_high = 0; -int bs_recovery; +unsigned int notify_high = 0; +unsigned int bs_recovery; /* void setprof __P((struct kvmvars *kvp, int state)); @@ -152,7 +172,14 @@ backing_store_triggers(dynamic_pager, hi_wat, flags, port) int flags; mach_port_t port; { - if((hi_wat + size) > low_water) + int cur_limits; + + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; + + if((hi_wat + limits[cur_limits].size) > limits[cur_limits].low_water) return KERN_FAILURE; /* let ipc system clean up port */ /* If there was a previous registration, throw it away */ @@ -182,24 +209,60 @@ default_pager_space_alert(alert_port, flags) { char subfile[512]; FILE *file_ptr; - off_t filesize = size; + off_t filesize; int error; kern_return_t ret; + int cur_limits; + unsigned int cur_size; + unsigned int notifications; + if(flags & HI_WAT_ALERT) { -/* printf("HI WAT ALERT!!\n"); */ + file_count++; + + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; + + cur_size = limits[cur_limits].size; + filesize = cur_size; + + /* + * because the LO_WAT threshold changes relative to + * the size of the swap file we're creating + * we need to reset the LO_WAT_ALERT threshold each + * time we create a new swap file + */ + if (limits[cur_limits].low_water) + notifications = HI_WAT_ALERT | LO_WAT_ALERT; + else + notifications = HI_WAT_ALERT; + sprintf(subfile, "%s%d", fileroot, file_count); file_ptr = fopen(subfile, "w+"); fchmod(fileno(file_ptr), (mode_t)01600); error = fcntl(fileno(file_ptr), F_SETSIZE, &filesize); if(error) { - error = ftruncate(fileno(file_ptr), (off_t)size); + error = ftruncate(fileno(file_ptr), filesize); } fclose(file_ptr); + if(error == -1) { unlink(subfile); file_count--; + + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; + + if (limits[cur_limits].low_water) + notifications = HI_WAT_ALERT | LO_WAT_ALERT; + else + notifications = HI_WAT_ALERT; + local_hi_water = local_hi_water>>2; if(notify_high >= (local_hi_water)) { if(notify_port != MACH_PORT_NULL) { @@ -213,8 +276,7 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; } } - macx_triggers(local_hi_water, - low_water, HI_WAT_ALERT, alert_port); + macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); } else { if(hi_water < notify_high) { if(local_hi_water < notify_high) { @@ -227,10 +289,22 @@ default_pager_space_alert(alert_port, flags) } local_hi_water = hi_water; } - ret = macx_swapon(subfile, flags, size, priority); + ret = macx_swapon(subfile, flags, cur_size, priority); + if(ret) { unlink(subfile); file_count--; + + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; + + if (limits[cur_limits].low_water) + notifications = HI_WAT_ALERT | LO_WAT_ALERT; + else + notifications = HI_WAT_ALERT; + local_hi_water = local_hi_water>>2; if(notify_high >= (local_hi_water)) { if(notify_port != MACH_PORT_NULL) { @@ -246,9 +320,8 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; } } - macx_triggers(local_hi_water, - low_water, HI_WAT_ALERT, alert_port); - } else if(bs_recovery <= size) { + macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); + } else if(bs_recovery <= cur_size) { if((bs_recovery != 0) && (notify_port)) { backing_store_alert(notify_port, LO_WAT_ALERT); @@ -259,14 +332,11 @@ default_pager_space_alert(alert_port, flags) bs_recovery = 0; } } else - bs_recovery = bs_recovery-size; + bs_recovery = bs_recovery-cur_size; } - - macx_triggers(local_hi_water, - low_water, HI_WAT_ALERT, alert_port); + macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); } if(flags & LO_WAT_ALERT) { -/* Turn into a logged message printf("LO WAT ALERT!!\n"); */ sprintf(subfile, "%s%d", fileroot, file_count); if(hi_water < notify_high) { local_hi_water = notify_high; @@ -280,11 +350,26 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; bs_recovery = 0; } - if(macx_swapoff(subfile, flags) == 0) { + if((error = macx_swapoff(subfile, flags)) == 0) { + unlink(subfile); file_count--; + + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; + } else { + if (file_count > max_valid) + cur_limits = max_valid; + else + cur_limits = file_count; } - macx_triggers(local_hi_water, low_water, LO_WAT_ALERT, alert_port); + /* + * only need to reset the LO_WAT_ALERT... the HI_WAT size is fixed, + * it doesn't change even if the swap file size shrinks or grows + */ + macx_triggers(local_hi_water, limits[cur_limits].low_water, LO_WAT_ALERT, alert_port); } return KERN_SUCCESS; } @@ -321,11 +406,12 @@ paging_setup(flags, size, priority, low, high) fchmod(fileno(file_ptr), (mode_t)01600); error = fcntl(fileno(file_ptr), F_SETSIZE, &filesize); if(error) { - error = ftruncate(fileno(file_ptr), (off_t)size); + error = ftruncate(fileno(file_ptr), filesize); } fclose(file_ptr); macx_swapon(subfile, flags, size, priority); + if(hi_water) { mach_msg_type_name_t poly; @@ -341,9 +427,9 @@ paging_setup(flags, size, priority, low, high) mach_port_extract_right(mach_task_self(), trigger_port, MACH_MSG_TYPE_MAKE_SEND, &trigger_port, &poly); macx_triggers(high, low, HI_WAT_ALERT, trigger_port); + if(low) { - macx_triggers(high, - low, LO_WAT_ALERT, trigger_port); + macx_triggers(high, low, LO_WAT_ALERT, trigger_port); } /* register control port for applications wishing to */ /* get backing store notifications or change dynamic */ @@ -351,7 +437,7 @@ paging_setup(flags, size, priority, low, high) set_dp_control_port(mach_host_self(), trigger_port); wait_on_paging_trigger(trigger_port); } - exit(0); + exit(0); } int main(int argc, char **argv) @@ -360,10 +446,18 @@ main(int argc, char **argv) extern int optind; char default_filename[] = "/private/var/vm/swapfile"; int ch; + int variable_sized = 1; seteuid(getuid()); strcpy(fileroot, default_filename); + limits[0].size = 20000000; + limits[0].low_water = 0; + + hi_water = 0; + local_hi_water = 0; + + while ((ch = getopt(argc, argv, "F:L:H:S:P:O:")) != EOF) { switch((char)ch) { @@ -372,13 +466,16 @@ main(int argc, char **argv) break; case 'L': - low_water = atoi(optarg); + variable_sized = 0; + limits[0].low_water = atoi(optarg); break; case 'H': + variable_sized = 0; hi_water = atoi(optarg); break; case 'S': - size = atoi(optarg); + variable_sized = 0; + limits[0].size = atoi(optarg); break; case 'P': priority = atoi(optarg); @@ -390,13 +487,127 @@ main(int argc, char **argv) exit(1); } } + + if (variable_sized) { + static char tmp[1024]; + struct statfs sfs; + char *q; + int i; + int mib[4]; + size_t len; + unsigned int size; + u_int64_t memsize; + u_int64_t fs_limit; + + /* + * if we get here, then none of the following options were specified... -L, H, or -S + * drop into a new mode that scales the size of the swap file based on how much free + * space is left on the volume being used for swap and the amount of physical ram + * installed on the system... + * basically, we'll pick a maximum size that doesn't exceed the following limits... + * 1/4 the remaining free space of the swap volume + * the size of phsyical ram + * MAXIMUM_SIZE - currently set to 1 Gbyte... + * once we have the maximum, we'll create a list of sizes and low_water limits + * we'll start with 2 files of MINIMUM_SIZE - currently 64 Mbytes... + * subsequent entries will double in size up to the calculated maximum... the low_water + * limit will be the sum of the current file size and the previous file size for each entry... + * as we add or delete files, we'll use the current file_count as an index into this + * table... if it's beyond the table size, we'll use the last entry + * the table entry will determine the size of the file to be created and the new low_water mark... + * the high_water mark is set to HI_WATER_DEFAULT which must be smaller than MINIMUM_SIZE... + * currently it is set to 40,000,000 to match the size being requested by the application + * monitoring low space conditions... having it set to the same size keeps us from creating + * an additional swap file when it really isn't necessary + */ + + /* + * get rid of the filename at the end of the swap file specification + * we only want the portion of the pathname that should already exist + */ + strcpy(tmp, fileroot); + if (q = strrchr(tmp, '/')) + *q = 0; + + if (statfs(tmp, &sfs) != -1) { + /* + * limit the maximum size of a swap file to 1/4 the free + * space available on the filesystem where the swap files + * are to reside + */ + fs_limit = ((u_int64_t)sfs.f_bfree * (u_int64_t)sfs.f_bsize) / 4; + + } else { + (void)fprintf(stderr, "usage: swap directory must exist\n"); + exit(1); + } + mib[0] = CTL_HW; + mib[1] = HW_MEMSIZE; + len = sizeof(u_int64_t); + + if (sysctl(mib, 2, &memsize, &len, NULL, 0) < 0) { + /* + * if the sysctl fails for some reason + * use the starting size as the default + */ + memsize = MINIMUM_SIZE; + } + if (memsize > fs_limit) + /* + * clip based on filesystem space available + */ + memsize = fs_limit; + + /* + * further limit the maximum size of a swap file + */ + if (memsize > MAXIMUM_SIZE) + memsize = MAXIMUM_SIZE; + + size = MINIMUM_SIZE; + + /* + * start small and work our way up to the maximum + * sized allowed... this way, we don't tie up too + * much disk space if we never do any real paging + */ + for (max_valid = 0, i = 0; i < MAX_LIMITS; i++) { + limits[i].size = size; + + if (i == 0) + limits[i].low_water = size * 2; + else { + if ((limits[i - 1].size / 2) > HI_WATER_DEFAULT) + limits[i].low_water = size + (limits[i - 1].size / 2); + else + limits[i].low_water = size + limits[i - 1].size; + } + if (size >= memsize) + break; + + if (i) { + /* + * make the first 2 files the same size + */ + size = size * 2; + } + max_valid++; + } + if (max_valid >= MAX_LIMITS) + max_valid = MAX_LIMITS - 1; + + hi_water = HI_WATER_DEFAULT; + } local_hi_water = hi_water; - if((low_water != 0) && (low_water <= (size + hi_water))) { + + if((limits[0].low_water != 0) && (limits[0].low_water <= (limits[0].size + hi_water))) { (void)fprintf(stderr, "usage: low water trigger must be larger than size + hi_water\n"); exit(1); } argc -= optind; argv += optind; - paging_setup(0, size, priority, low_water, hi_water); + + paging_setup(0, limits[0].size, priority, limits[0].low_water, hi_water); + return (0); } diff --git a/fs_usage.tproj/Makefile.postamble b/fs_usage.tproj/Makefile.postamble index c7388e8..fb9cd4c 100644 --- a/fs_usage.tproj/Makefile.postamble +++ b/fs_usage.tproj/Makefile.postamble @@ -53,6 +53,9 @@ # Some compiler flags can be overridden here for certain build situations. # # WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) + +WARNING_CFLAGS = -Wall + # DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults # to -g) # DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) diff --git a/fs_usage.tproj/fs_usage.1 b/fs_usage.tproj/fs_usage.1 index cbe57b9..7c1dd7b 100644 --- a/fs_usage.tproj/fs_usage.1 +++ b/fs_usage.tproj/fs_usage.1 @@ -105,6 +105,8 @@ Of the form A=0xnnnnnnnn, where 0xnnnnnnnn is the address being faulted. .It DISK BLOCK NUMBER Of the form D=0xnnnnnnnn, where 0xnnnnnnnn is the block number of the physical disk block being read or written. +.It OFFSET +Of the form O=0xnnnnnnnn, where 0xnnnnnnnn is a file offset. .It SELECT RETURN Of the form S=x, x is the number of ready descriptors returned by the select() system call. diff --git a/fs_usage.tproj/fs_usage.c b/fs_usage.tproj/fs_usage.c index 62ffde9..8ce4f55 100644 --- a/fs_usage.tproj/fs_usage.c +++ b/fs_usage.tproj/fs_usage.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -266,6 +267,10 @@ void create_map_entry(int, int, char *); #define BSC_rmdir 0x040C0224 #define BSC_utimes 0x040C0228 #define BSC_futimes 0x040C022C +#define BSC_pread 0x040C0264 +#define BSC_pread_extended 0x040E0264 +#define BSC_pwrite 0x040C0268 +#define BSC_pwrite_extended 0x040E0268 #define BSC_statfs 0x040C0274 #define BSC_fstatfs 0x040C0278 #define BSC_stat 0x040C02F0 @@ -914,6 +919,7 @@ sample_sc() struct diskio *dio; void enter_syscall(); void exit_syscall(); + void extend_syscall(); void kill_thread_map(); thread = kd[i].arg5 & KDBG_THREAD_MASK; @@ -1297,7 +1303,12 @@ sample_sc() enter_syscall(thread, type, &kd[i], p, (double)now); continue; } + switch (type) { + + case BSC_pread_extended: + case BSC_pwrite_extended: + extend_syscall(thread, type, &kd[i], (double)now); case MACH_pageout: if (kd[i].arg2) @@ -1504,6 +1515,14 @@ sample_sc() exit_syscall("writev", thread, type, kd[i].arg1, kd[i].arg2, 1, 1, (double)now); break; + case BSC_pread: + exit_syscall("pread", thread, type, kd[i].arg1, kd[i].arg2, 1, 9, (double)now); + break; + + case BSC_pwrite: + exit_syscall("pwrite", thread, type, kd[i].arg1, kd[i].arg2, 1, 9, (double)now); + break; + case BSC_fchown: exit_syscall("fchown", thread, type, kd[i].arg1, kd[i].arg2, 1, 0, (double)now); break; @@ -1879,6 +1898,8 @@ enter_syscall(int thread, int type, kd_buf *kd, char *name, double now) case BSC_fsync: case BSC_readv: case BSC_writev: + case BSC_pread: + case BSC_pwrite: case BSC_fchown: case BSC_fchmod: case BSC_rename: @@ -2062,6 +2083,40 @@ enter_syscall(int thread, int type, kd_buf *kd, char *name, double now) fflush (0); } +/* + * Handle system call extended trace data. + * pread and pwrite: + * Wipe out the kd args that were collected upon syscall_entry + * because it is the extended info that we really want, and it + * is all we really need. +*/ + +void +extend_syscall(int thread, int type, kd_buf *kd, char *name, double now) +{ + struct th_info *ti; + + switch (type) { + case BSC_pread_extended: + if ((ti = find_thread(thread, BSC_pread)) == (struct th_info *)0) + return; + ti->arg1 = kd->arg1; /* the fd */ + ti->arg2 = kd->arg2; /* nbytes */ + ti->arg3 = kd->arg3; /* top half offset */ + ti->arg4 = kd->arg4; /* bottom half offset */ + break; + case BSC_pwrite_extended: + if ((ti = find_thread(thread, BSC_pwrite)) == (struct th_info *)0) + return; + ti->arg1 = kd->arg1; /* the fd */ + ti->arg2 = kd->arg2; /* nbytes */ + ti->arg3 = kd->arg3; /* top half offset */ + ti->arg4 = kd->arg4; /* bottom half offset */ + break; + default: + return; + } +} void exit_syscall(char *sc_name, int thread, int type, int error, int retval, @@ -2150,7 +2205,9 @@ format_print(struct th_info *ti, char *sc_name, int thread, int type, int error, else sprintf(&buf[clen], " B=0x%-6x /dev/%s", dio->iosize, find_disk_name(dio->dev)); } else { - + + off_t offset_reassembled = 0LL; + if (has_fd == 2 && error == 0) sprintf(&buf[clen], " F=%-3d", retval); else if (has_fd == 1) @@ -2179,6 +2236,16 @@ format_print(struct th_info *ti, char *sc_name, int thread, int type, int error, sprintf(&buf[clen], "B=0x%-8x", retval); else if (has_ret == 8) /* BSC_select */ sprintf(&buf[clen], " S=%-3d ", retval); + else if (has_ret == 9) /* BSC_pread, BSC_pwrite */ + { + sprintf(&buf[clen], "B=0x%-8x", retval); + clen = strlen(buf); + offset_reassembled = (((off_t)(unsigned int)(ti->arg3)) << 32) | (unsigned int)(ti->arg4); + if ((offset_reassembled >> 32) != 0) + sprintf(&buf[clen], "O=0x%16.16qx", (off_t)offset_reassembled); + else + sprintf(&buf[clen], "O=0x%8.8qx", (off_t)offset_reassembled); + } else sprintf(&buf[clen], " "); } diff --git a/getty.tproj/extern.h b/getty.tproj/extern.h index f8e759a..37241b8 100644 --- a/getty.tproj/extern.h +++ b/getty.tproj/extern.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/gettytab.h b/getty.tproj/gettytab.h index 2fcd79c..0d869e2 100644 --- a/getty.tproj/gettytab.h +++ b/getty.tproj/gettytab.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/init.c b/getty.tproj/init.c index 99c980a..b5b6581 100644 --- a/getty.tproj/init.c +++ b/getty.tproj/init.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/main.c b/getty.tproj/main.c index ee934ae..5b38228 100644 --- a/getty.tproj/main.c +++ b/getty.tproj/main.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/pathnames.h b/getty.tproj/pathnames.h index 909042a..1cf18ea 100644 --- a/getty.tproj/pathnames.h +++ b/getty.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/subr.c b/getty.tproj/subr.c index d3322b6..cd9aca9 100644 --- a/getty.tproj/subr.c +++ b/getty.tproj/subr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/hostinfo.tproj/hostinfo.c b/hostinfo.tproj/hostinfo.c index ee9b6dc..b228499 100644 --- a/hostinfo.tproj/hostinfo.c +++ b/hostinfo.tproj/hostinfo.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/init.tproj/Makefile.preamble b/init.tproj/Makefile.preamble index 04b6fe7..da08479 100644 --- a/init.tproj/Makefile.preamble +++ b/init.tproj/Makefile.preamble @@ -1,4 +1,5 @@ # can be added to Compiler Flags to provide Secure login # -DSECURE LIBS = -lutil +OTHER_CFLAGS = -DSECURE OTHER_GENERATED_OFILES = $(VERS_OFILE) AFTER_INSTALL = after_install diff --git a/init.tproj/init.c b/init.tproj/init.c index b5b0979..6027707 100644 --- a/init.tproj/init.c +++ b/init.tproj/init.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/init.tproj/pathnames.h b/init.tproj/pathnames.h index 777fe14..ac36be9 100644 --- a/init.tproj/pathnames.h +++ b/init.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/iostat.tproj/iostat.c b/iostat.tproj/iostat.c index da5fe41..3ea24b1 100644 --- a/iostat.tproj/iostat.c +++ b/iostat.tproj/iostat.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kdump.tproj/kdump.c b/kdump.tproj/kdump.c index 7f1238e..822b118 100644 --- a/kdump.tproj/kdump.c +++ b/kdump.tproj/kdump.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kdump.tproj/syscalls.c b/kdump.tproj/syscalls.c index 71a9215..456f002 100644 --- a/kdump.tproj/syscalls.c +++ b/kdump.tproj/syscalls.c @@ -3,19 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kgmon.tproj/kgmon.c b/kgmon.tproj/kgmon.c index 47161c0..3039a89 100644 --- a/kgmon.tproj/kgmon.c +++ b/kgmon.tproj/kgmon.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/ktrace.tproj/ktrace.c b/ktrace.tproj/ktrace.c index dc09649..74484ce 100644 --- a/ktrace.tproj/ktrace.c +++ b/ktrace.tproj/ktrace.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/ktrace.tproj/subr.c b/ktrace.tproj/subr.c index 90144d3..e5186dd 100644 --- a/ktrace.tproj/subr.c +++ b/ktrace.tproj/subr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/latency.tproj/latency.c b/latency.tproj/latency.c index 42a9155..10cbc14 100644 --- a/latency.tproj/latency.c +++ b/latency.tproj/latency.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/login.tproj/klogin.c b/login.tproj/klogin.c index 3426d9c..ed9444d 100644 --- a/login.tproj/klogin.c +++ b/login.tproj/klogin.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/login.tproj/login.c b/login.tproj/login.c index cdaed0e..9f28ec0 100644 --- a/login.tproj/login.c +++ b/login.tproj/login.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -653,6 +654,16 @@ dolastlog(quiet) struct lastlog ll; int fd; + /* HACK HACK HACK: This is because HFS doesn't support sparse files + * and seeking into the file too far is too slow. The "solution" + * is to just bail if the seek time for a large uid would be too + * slow. + */ + if(pwd->pw_uid > 100000) { + syslog(LOG_NOTICE, "User login %s (%d) not logged in lastlog. UID too large.", pwd->pw_name, pwd->pw_uid); + return; + } + if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) { (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET); if (!quiet) { diff --git a/login.tproj/pathnames.h b/login.tproj/pathnames.h index b83bb9b..ffdde6d 100644 --- a/login.tproj/pathnames.h +++ b/login.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/bootstrap.c b/mach_init.tproj/bootstrap.c index 970bc93..15d09a1 100644 --- a/mach_init.tproj/bootstrap.c +++ b/mach_init.tproj/bootstrap.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -186,7 +187,6 @@ main(int argc, char * argv[]) { const char *argp; char c; - server_t *serverp; kern_return_t result; mach_port_t init_notify_port; pthread_attr_t attr; @@ -246,7 +246,6 @@ main(int argc, char * argv[]) * Wait for mach_init ot give us a real bootstrap port */ wait_for_go(init_notify_port); - info("Execing init"); close(0); close(1); @@ -265,20 +264,17 @@ main(int argc, char * argv[]) } /* - * Child - will continue along as mach_init. Construct - * a very basic environment - as much as if we were - * actually forked from init (instead of the other way - * around): - * - * Set up the PATH to be approriate for the root user. - * Create an initial session. - * Establish an initial user. - * Disbale core dumps. + * Child - will continue along as mach_init. Save off + * the init_notify_port and put back a NULL bootstrap + * port for ourselves. */ - setenv("PATH", _PATH_STDPATH, 1); - setsid(); - setlogin("root"); - enablecoredumps(FALSE); + init_notify_port = bootstrap_port; + bootstrap_port = MACH_PORT_NULL; + (void)task_set_bootstrap_port( + mach_task_self(), + bootstrap_port); + if (result != KERN_SUCCESS) + kern_fatal(result, "task_get_bootstrap_port"); } else init_notify_port = MACH_PORT_NULL; @@ -297,14 +293,13 @@ main(int argc, char * argv[]) switch (c = *argp++) { case 'd': debugging = TRUE; - enablecoredumps(TRUE); break; case 'D': debugging = FALSE; - enablecoredumps(FALSE); break; case 'F': - force_fork = TRUE; + if (init_notify_port != MACH_PORT_NULL) + force_fork = TRUE; break; case 'r': register_self = forward_ok = TRUE; @@ -331,53 +326,18 @@ main(int argc, char * argv[]) exit(0); } - /* block all but SIGHUP and SIGTERM and mark us as an init process */ - setsid(); - sigfillset(&mask); - sigdelset(&mask, SIGHUP); - signal(SIGHUP, toggle_debug); - sigdelset(&mask, SIGTERM); - signal(SIGTERM, start_shutdown); - (void) sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); - - init_errlog(pid == 0); /* are we a daemon? */ - init_lists(); - /* - * This task will become the bootstrap task, so go ahead and - * initialize the ports now. + * This task will become the bootstrap task, initialize the ports. */ bootstrap_self = mach_task_self(); inherited_uid = getuid(); + init_lists(); init_ports(); - - log("Started with uid=%d%s%s%s", - inherited_uid, - (register_self) ? " registered-as=" : "", - (register_self) ? register_name : "", - (debugging) ? " in debug-mode" : ""); - - /* - * If we are supposed to coordinate with init, we have to - * get that port again, because we only have a (probably wrong) - * name in memory, not a proper right. - */ if (init_notify_port != MACH_PORT_NULL) { - result = task_get_bootstrap_port( - bootstrap_self, - &init_notify_port); - if (result != KERN_SUCCESS) - kern_fatal(result, "task_get_bootstrap_port"); - + /* send init a real bootstrap port to use */ unblock_init(init_notify_port, bootstraps.bootstrap_port); - result = task_set_bootstrap_port( - bootstrap_self, - MACH_PORT_NULL); - if (result != KERN_SUCCESS) - kern_fatal(result, "task_set_bootstrap_port"); - result = mach_port_deallocate( bootstrap_self, init_notify_port); @@ -388,7 +348,6 @@ main(int argc, char * argv[]) inherited_bootstrap_port = MACH_PORT_NULL; } else { - /* get inherited bootstrap port */ result = task_get_bootstrap_port( bootstrap_self, @@ -412,14 +371,6 @@ main(int argc, char * argv[]) } } - - /* Kick off all continuously running server processes */ - for ( serverp = FIRST(servers) - ; !IS_END(serverp, servers) - ; serverp = NEXT(serverp)) - if (serverp->servertype != DEMAND) - start_server(serverp); - pthread_attr_init (&attr); pthread_attr_setdetachstate ( &attr, PTHREAD_CREATE_DETACHED ); result = pthread_create( @@ -432,6 +383,36 @@ main(int argc, char * argv[]) exit(1); } + /* block all but SIGHUP and SIGTERM */ + sigfillset(&mask); + sigdelset(&mask, SIGHUP); + signal(SIGHUP, toggle_debug); + sigdelset(&mask, SIGTERM); + signal(SIGTERM, start_shutdown); + (void) sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); + + /* + * Construct a very basic environment - as much as if we + * were actually forked from init (instead of the other + * way around): + * + * Set up the PATH to be approriate for the root user. + * Create an initial session. + * Establish an initial user. + * Disbale core dumps. + */ + setsid(); + setlogin("root"); + enablecoredumps(debugging); + setenv("PATH", _PATH_STDPATH, 1); + + init_errlog(pid == 0); /* are we a daemon? */ + notice("Started with uid=%d%s%s%s", + inherited_uid, + (register_self) ? " registered-as=" : "", + (register_self) ? register_name : "", + (debugging) ? " in debug-mode" : ""); + /* Process bootstrap service requests */ server_loop(); /* Should never return */ exit(1); @@ -459,9 +440,10 @@ wait_for_go(mach_port_t init_notify_port) if (result != KERN_SUCCESS) { kern_error(result, "mach_msg(receive) failed in wait_for_go"); } + bootstrap_port = init_go_msg.hdr.msgh_remote_port; result = task_set_bootstrap_port( mach_task_self(), - init_go_msg.hdr.msgh_remote_port); + bootstrap_port); if (result != KERN_SUCCESS) { kern_error(result, "task_get_bootstrap_port()"); } @@ -496,7 +478,6 @@ static void init_ports(void) { kern_return_t result; - service_t *servicep; /* * This task will become the bootstrap task. @@ -571,60 +552,6 @@ init_ports(void) bootstrap_port_set); if (result != KERN_SUCCESS) kern_fatal(result, "mach_port_move_member"); - - /* - * Allocate service ports for declared services. - */ - for ( servicep = FIRST(services) - ; ! IS_END(servicep, services) - ; servicep = NEXT(servicep)) - { - switch (servicep->servicetype) { - case DECLARED: - result = mach_port_allocate( - bootstrap_self, - MACH_PORT_RIGHT_RECEIVE, - &(servicep->port)); - if (result != KERN_SUCCESS) - kern_fatal(result, "mach_port_allocate"); - - result = mach_port_insert_right( - bootstrap_self, - servicep->port, - servicep->port, - MACH_MSG_TYPE_MAKE_SEND); - if (result != KERN_SUCCESS) - kern_fatal(result, "mach_port_insert_right"); - info("Declared port %x for service %s", - servicep->port, - servicep->name); - - if (servicep->server != NULL_SERVER && - servicep->server->servertype == DEMAND) { - result = mach_port_move_member( - bootstrap_self, - servicep->port, - demand_port_set); - if (result != KERN_SUCCESS) - kern_fatal(result, "mach_port_move_member"); - } - break; - - case SELF: - servicep->port = bootstraps.bootstrap_port; - servicep->server = new_server(&bootstraps, - program_name, - inherited_uid, - MACHINIT); - info("Set port %x for self port", - bootstraps.bootstrap_port); - break; - - case REGISTERED: - fatal("Can't allocate REGISTERED port!?!"); - break; - } - } } boolean_t @@ -662,7 +589,7 @@ reap_server(server_t *serverp) if (presult != serverp->pid) { unix_error("waitpid: cmd = %s", serverp->cmd); } else if (wstatus) { - log("Server %x in bootstrap %x uid %d: \"%s\": %s %d [pid %d]", + notice("Server %x in bootstrap %x uid %d: \"%s\": %s %d [pid %d]", serverp->port, serverp->bootstrap->bootstrap_port, serverp->uid, serverp->cmd, ((WIFEXITED(wstatus)) ? @@ -1048,10 +975,10 @@ server_demux( * Do minimal cleanup and then exit. */ if (shutdown_in_progress == TRUE) { - log("Shutting down. Deactivating root bootstrap (%x) ...", + notice("Shutting down. Deactivating root bootstrap (%x) ...", bootstraps.bootstrap_port); deactivate_bootstrap(&bootstraps); - log("Done."); + notice("Done."); exit(0); } diff --git a/mach_init.tproj/bootstrap.defs b/mach_init.tproj/bootstrap.defs index 55c0b32..f18f103 100644 --- a/mach_init.tproj/bootstrap.defs +++ b/mach_init.tproj/bootstrap.defs @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/bootstrap_internal.h b/mach_init.tproj/bootstrap_internal.h index 38c4234..d50b622 100644 --- a/mach_init.tproj/bootstrap_internal.h +++ b/mach_init.tproj/bootstrap_internal.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/error_log.c b/mach_init.tproj/error_log.c index 183abfc..441840b 100644 --- a/mach_init.tproj/error_log.c +++ b/mach_init.tproj/error_log.c @@ -1,23 +1,24 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -112,7 +113,7 @@ void info(const char *format, ...) va_end(ap); } -__private_extern__ void log(const char *format, ...) +void notice(const char *format, ...) { va_list ap; diff --git a/mach_init.tproj/error_log.h b/mach_init.tproj/error_log.h index f6dc4df..9b5da33 100644 --- a/mach_init.tproj/error_log.h +++ b/mach_init.tproj/error_log.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -36,7 +37,7 @@ extern void stop_errlog(void); extern void close_errlog(void); extern void debug(const char *format, ...); extern void info(const char *format, ...); -extern void log(const char *format, ...); +extern void notice(const char *format, ...); extern void error(const char *format, ...); extern void kern_error(kern_return_t result, const char *format, ...); extern void parse_error(const char *token_string, const char *format, ...); diff --git a/mach_init.tproj/lists.c b/mach_init.tproj/lists.c index 92bb29c..35b66b6 100644 --- a/mach_init.tproj/lists.c +++ b/mach_init.tproj/lists.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -250,9 +251,6 @@ delete_service(service_t *servicep) mach_port_mod_refs(mach_task_self(), servicep->port, MACH_PORT_RIGHT_RECEIVE, -1); break; - case SELF: - error("Self service %s now unavailable", servicep->name); - break; default: error("unknown service type %d\n", servicep->servicetype); break; diff --git a/mach_init.tproj/lists.h b/mach_init.tproj/lists.h index 4ad1515..cf49805 100644 --- a/mach_init.tproj/lists.h +++ b/mach_init.tproj/lists.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,8 +57,7 @@ struct bootstrap { /* Service types */ typedef enum { DECLARED, /* Declared in config file */ - REGISTERED, /* Registered dynamically */ - SELF /* Name bound bootstrap service itself */ + REGISTERED /* Registered dynamically */ } servicetype_t; struct service { diff --git a/mach_init.tproj/rpc_services.c b/mach_init.tproj/rpc_services.c index 9f0a546..d500310 100644 --- a/mach_init.tproj/rpc_services.c +++ b/mach_init.tproj/rpc_services.c @@ -1,23 +1,24 @@ /* - * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -93,7 +94,7 @@ x_bootstrap_create_server( /* only same uid (or root client) */ if (sectoken.val[0] && sectoken.val[0] != server_uid) { - log("Server create: \"%s\": invalid security token (%d != %d)", + notice("Server create: \"%s\": invalid security token (%d != %d)", server_cmd, sectoken.val[0], server_uid); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -135,7 +136,7 @@ x_bootstrap_unprivileged( debug("Get unprivileged attempt for bootstrap %x", bootstrap_port); bootstrap = lookup_bootstrap_by_port(bootstrap_port); - if (!bootstrap || !active_bootstrap(bootstrap)) { + if (!bootstrap) { debug("Get unprivileged: invalid bootstrap %x", bootstrap_port); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -196,7 +197,7 @@ x_bootstrap_check_in( service_name); return BOOTSTRAP_NOT_PRIVILEGED; } - if (servicep->servicetype == SELF || !canReceive(servicep->port)) { + if (!canReceive(servicep->port)) { ASSERT(servicep->isActive); debug("bootstrap_check_in service %s already active", service_name); @@ -499,14 +500,14 @@ x_bootstrap_parent( debug("Parent attempt for bootstrap %x", bootstrap_port); bootstrap = lookup_bootstrap_by_port(bootstrap_port); - if (!bootstrap || !active_bootstrap(bootstrap)) { + if (!bootstrap) { debug("Parent attempt for bootstrap %x: invalid bootstrap", bootstrap_port); return BOOTSTRAP_NOT_PRIVILEGED; } if (sectoken.val[0]) { - log("Bootstrap parent for bootstrap %x: invalid security token (%d)", - bootstrap_port, sectoken.val[0]); + notice("Bootstrap parent for bootstrap %x: invalid security token (%d)", + bootstrap_port, sectoken.val[0]); return BOOTSTRAP_NOT_PRIVILEGED; } debug("Returning bootstrap parent %x for bootstrap %x", diff --git a/makekey.tproj/makekey.c b/makekey.tproj/makekey.c index 487cfaa..557bcfc 100644 --- a/makekey.tproj/makekey.c +++ b/makekey.tproj/makekey.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mkfile.tproj/mkfile.c b/mkfile.tproj/mkfile.c index 4aff548..5f70877 100644 --- a/mkfile.tproj/mkfile.c +++ b/mkfile.tproj/mkfile.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nvram.tproj/Makefile.postamble b/nvram.tproj/Makefile.postamble index 0c1d774..a1cb866 100644 --- a/nvram.tproj/Makefile.postamble +++ b/nvram.tproj/Makefile.postamble @@ -121,26 +121,16 @@ # Note: on MS Windows, executables, have an extension, so rules and dependencies # for generated tools should use $(EXECUTABLE_EXT) on the end. -IMPLICIT_SOURCE_FILES += nvram +# Don't use IMPLICIT_SOURCE_FILES since that will get the CVS directory +# too. Instead, list the files in that directory in the OTHERSRCS line +#IMPLICIT_SOURCE_FILES += nvram PAX = /bin/pax SHAREDIR = /usr/share MANDIR = $(SHAREDIR)/man/man8 MANPAGE = nvram.8 -NVRAMDIR = $(SHAREDIR)/nvram after_install:: $(MKDIRS) $(DSTROOT)$(MANDIR) $(CP) -f $(MANPAGE) $(DSTROOT)$(MANDIR)/$(MANPAGE) $(CHMOD) og-w $(DSTROOT)$(MANDIR)/$(MANPAGE) - $(PAX) -rw nvram $(DSTROOT)$(SHAREDIR) - $(CHOWN) -R root.wheel $(DSTROOT)$(NVRAMDIR) - $(LN) -fs PowerSurge $(DSTROOT)$(NVRAMDIR)/7300 - $(LN) -fs PowerSurge $(DSTROOT)$(NVRAMDIR)/7500 - $(LN) -fs PowerSurge $(DSTROOT)$(NVRAMDIR)/8500 - $(LN) -fs PowerSurge $(DSTROOT)$(NVRAMDIR)/9500 - $(LN) -fs PowerExpress $(DSTROOT)$(NVRAMDIR)/9700 - $(LN) -fs Hooper $(DSTROOT)$(NVRAMDIR)/3400-2400 - $(LN) -fs Kanga $(DSTROOT)$(NVRAMDIR)/3500 - $(LN) -fs Silk $(DSTROOT)$(NVRAMDIR)/PowerMac-G3 - $(LN) -fs Wallstreet $(DSTROOT)$(NVRAMDIR)/PowerBook1998 diff --git a/nvram.tproj/nvram.8 b/nvram.tproj/nvram.8 index 57d22d5..d563ef6 100644 --- a/nvram.tproj/nvram.8 +++ b/nvram.tproj/nvram.8 @@ -22,11 +22,11 @@ The command allows manipulation of Open Firmware NVRAM variables. It can be used to get or set a variable. It can also be used to print all of the variables or set a list of variables from a file. +Changes to NVRAM variables are only saved by clean restart or shutdown. .LP In principle, .IR name can be any string. In practice, not all strings will be accepted. -Old world machines have a fixed set of Open Firmware variables. New World machines can create new variables as desired. Some variables require administrator privilege to get or set. .LP @@ -37,26 +37,6 @@ must match the data type required for Binary data can be set using the %xx notation, where xx is the hex value of the byte. The type for new variables is always binary data. -.LP -Two Open Firmware variables have special treatment on old world -machines: -.IR boot-command -and -.IR boot-args . -As long as -.IR boot-command -starts with "# bootr," the -.IR boot-args -variable will be present. Getting or setting -.IR boot-args -will get or set the -.IR boot-command -while preserving the "# bootr". In most cases when setting boot arguments -for the kernel, there is no need to test for old world and set -.IR boot-command . -Instead set -.IR boot-args -with the desired arguments. .SH OPTIONS .TP .B \-p @@ -81,9 +61,4 @@ example% nvram my-variable="String One%00String Two%00%00" .LP Create a new variable, my-variable, containing a list of two C-strings that is terminated by a NUL. -.SH FILES -.PD 0 -.TP 30 -.B /usr/share/nvram -Files containing patches for old world machines. .PD diff --git a/nvram.tproj/nvram.c b/nvram.tproj/nvram.c index a681211..eabcdb9 100644 --- a/nvram.tproj/nvram.c +++ b/nvram.tproj/nvram.c @@ -2,21 +2,24 @@ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ /* diff --git a/nvram.tproj/nvram/Alchemy b/nvram.tproj/nvram/Alchemy deleted file mode 100644 index 2024734..0000000 --- a/nvram.tproj/nvram/Alchemy +++ /dev/null @@ -1,64 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.0 Date: 8-17-2000 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev /packages/mac-parts\ -: $M -7E9408 $X 8000 alloc-mem 7F00 + 4 -7E9408 $X ;\ -' load 268 - ' $M $L\ -' load 168 + ' 0 $L\ -$E\ -dev ata\ -d encode-int 2 encode-int encode+ " AAPL,interrupts" $p\ -$E\ -dev scsi\ -: $M ['] open 888 - + ;\ -: $M1 -E48 $M $X ;\ -: $M2 begin 1 ms $M1 1 and -1068 $M $X or until $M1 case 0 of -1 endof 1 of 1 -E08 $M $X false endof dup endcase ;\ -: $M3 -F68 $M f over $X $X ;\ -: $M4 1 ms ;\ -2C $M ' 2 $L\ --A18 $M ' $M2 $R\ --788 $M ' $M3 $L\ --768 $M ' $M4 $L\ --764 $M ' 1 $L\ -$E\ -unselect-dev diff --git a/nvram.tproj/nvram/Gossamer b/nvram.tproj/nvram/Gossamer deleted file mode 100644 index 78fb571..0000000 --- a/nvram.tproj/nvram/Gossamer +++ /dev/null @@ -1,93 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.0 Date: 8-17-2000 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: &c " ata-enable" $call-parent ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev enet\ -' open constant $M\ -: $M2 $M 710 - $X ;\ -: rl@ -7D9D40 $X ;\ -: chstat begin $M2 $M 14f8 - $X -7D6C20 $X rl@ 400 and 0= until ;\ -: bmstat begin $M2 $M 13F0 - $X rl@ 100 and until ;\ -: xmt1 get-msecs $M 720 - ! chstat $M A00 - $X bmstat chstat ;\ -' xmt1 ' WRITE 10 + l!\ -62 ' READ 7 - c!\ -: READ { _p _n ; _a } begin _p _n bead -> _a _a 2+\ -if _p c@ 80 and 0= else 1 then until _a ;\ -$E\ -dev /packages/obp-tftp\ -: $M over + ['] noop $L ;\ -: $O ['] open + ;\ -: $M1 dup 24 - -1720 $O $X 6 move 14 + ;\ --5BC $O ' $M1 $L\ -0 $O E8 $M EC $M F0 $M F4 $M F8 + ' true $L\ -$E\ -dev /packages/mac-parts\ -: $M -7E89E0 $X 8000 alloc-mem 7F00 + 4 -7E89E0 $X ;\ -' load 268 - ' $M $L\ -' load 160 + ' 0 $L\ -$E\ -dev ide0\ -: open use-ata-interface 0 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -' reset-ata-bus 2c + ' 2 $L\ -$E\ -dev ide1\ -: open use-ata-interface 0 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -' reset-ata-bus 2c + ' 2 $L\ -$E\ -dev scsi\ -: $M ['] do-cmd + ;\ -: $M2 5 us -5f0 $M $X ;\ -: $M3 -710 $M f over $X $X ;\ -: $M4 1 ms ;\ --1AC $M ' $M2 $L\ -100 $M ' $M3 $L\ -120 $M ' $M4 $L\ -124 $M ' 1 $L\ -$E\ -ff000000 dup dup 400 28 do-map 4+ w@ 10 and 0=\ -if 90b7 f3000032 w! then\ -unselect-dev diff --git a/nvram.tproj/nvram/Hooper b/nvram.tproj/nvram/Hooper deleted file mode 100644 index c5e5aca..0000000 --- a/nvram.tproj/nvram/Hooper +++ /dev/null @@ -1,60 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.1 Date: 1-30-2001 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: helpb " backlight-on" _pmu-ihandle $call-method ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else helpb 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev /packages/mac-parts\ -: $M -7E8DD8 $X 8000 alloc-mem 7F00 + 4 -7E8DD8 $X ;\ -' load 268 - ' $M $L\ -' load 160 + ' 0 $L\ -$E\ -dev scsi\ -: $M ['] do-cmd + ;\ -: $M2 1 ms -5F0 $M $X ;\ -: $M3 -710 $M f over $X $X ;\ -: $M4 1 ms ;\ --1AC $M ' $M2 $L\ -100 $M ' $M3 $L\ -120 $M ' $M4 $L\ -124 $M ' 1 $L\ -$E\ -unselect-dev diff --git a/nvram.tproj/nvram/Kanga b/nvram.tproj/nvram/Kanga deleted file mode 100644 index 72d9bd8..0000000 --- a/nvram.tproj/nvram/Kanga +++ /dev/null @@ -1,57 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.1 Date: 1-30-2001 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: helpb " backlight-on" _pmu-ihandle $call-method ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else helpb 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev /packages/mac-parts\ -: $M -7E8D88 $X 8000 alloc-mem 7F00 + 4 -7E8D88 $X ;\ -' load 268 - ' $M $L\ -' load 160 + ' 0 $L\ -$E\ -dev scsi\ -: $M ['] do-cmd + ;\ -: $M2 1 ms -608 $M $X ;\ -: $M3 -728 $M f over $X $X ;\ --1B4 $M ' $M2 $L\ -100 $M ' $M3 $L\ -$E\ -unselect-dev diff --git a/nvram.tproj/nvram/Mainstreet b/nvram.tproj/nvram/Mainstreet deleted file mode 100644 index 2f8fbd9..0000000 --- a/nvram.tproj/nvram/Mainstreet +++ /dev/null @@ -1,103 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.1 Date: 1-30-2001 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $P 0 to my-self property ;\ -: &a " /chosen" $D $P $E ;\ -: &c " ata-enable" $call-parent ;\ -: helpb " backlight-on" _pmu-ihandle $call-method\ -0 0 " "(70)" 40 " pmu-op" _pmu-ihandle $call-method drop ;\ -10 buffer: km\ -devalias ide0 /pci/@10/ata0\ -devalias ide1 /pci/@10/@34/ata1\ -devalias ide4 /pci/@d/@34/ata4\ -dev /aliases\ -: $M delete-property ;\ -" ata-int" $M\ -" ata0" $M\ -" ata1" $M\ -" ata4" $M\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" &a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else helpb 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev enet\ -62 ' READ 7 - c!\ -: READ { _p _n ; _a } begin _p _n bead -> _a _a 2+\ -if _p c@ 80 and 0= else 1 then until _a ;\ -$E\ -dev /packages/obp-tftp\ -: $M over + ['] noop $L ;\ -: $O ['] open + ;\ -: $M1 dup 24 - -1720 $O $X 6 move 14 + ;\ --5BC $O ' $M1 $L\ -0 $O E8 $M EC $M F0 $M F4 $M F8 + ' true $L\ -$E\ -dev /packages/mac-parts\ -: $M -7E86F0 $X 8000 alloc-mem 7F00 + 4 -7E86F0 $X ;\ -' load 268 - ' $M $L\ -' load 160 + ' 0 $L\ -dev ide0\ -: open use-ata-interface 0 &c -1 ;\ -: set-device-ID set-drive-select ;\ -$E\ -dev mac-io/@34\ -1 value &f\ -: ata-enable &f if 1000 ms &c 1000 ms 0 to &f else drop then ;\ -$E\ -dev ide1\ -: open use-ata-interface 1 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -$E\ -dev pci1/@d/@34\ -: ata-enable &c ;\ -$E\ -dev ide4\ -: open use-ata-interface 1 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -$E\ -dev scsi\ -: $M ['] do-cmd + ;\ -: $M2 5 us -5f0 $M $X ;\ -: $M3 -710 $M f over $X $X ;\ -: $M4 1 ms ;\ --1AC $M ' $M2 $L\ -100 $M ' $M3 $L\ -120 $M ' $M4 $L\ -124 $M ' 1 $L\ -$E\ -unselect-dev diff --git a/nvram.tproj/nvram/PowerExpress b/nvram.tproj/nvram/PowerExpress deleted file mode 100644 index 3038a25..0000000 --- a/nvram.tproj/nvram/PowerExpress +++ /dev/null @@ -1,61 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.0 Date: 8-17-2000 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: helpb " scsi" find-device 0 to my-self\ -d# 5300 encode-int " AAPL,load-priority" property\ -unselect-dev ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev /packages/mac-parts\ -: $M 7F00 - 4 ;\ -' my-init-program 34 + ' $M $L\ -' load-partition dup\ -80 + ' 2drop $L\ -104 + ' 0 $L\ -' load 15C + ' 0 $L\ -$E\ -dev /packages/obp-tftp\ -: $M dup 24 - HIS-ENET-HA 6 move 14 + ;\ -' open 66C - ' $M $L\ -$E\ -" /chaos" ['] find-device catch if 2drop else\ -0 to my-self 0 0 " AAPL,ignore" property then\ -unselect-dev diff --git a/nvram.tproj/nvram/PowerSurge b/nvram.tproj/nvram/PowerSurge deleted file mode 100644 index 10696c5..0000000 --- a/nvram.tproj/nvram/PowerSurge +++ /dev/null @@ -1,103 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.0 Date: 8-17-2000 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $C $call-method ;\ -: $D find-device ;\ -: $E device-end ;\ -: $x execute ;\ -: $F $D " open" $find drop ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: R BRpatch ; : L BLpatch ;\ -: q over + ;\ -: g code! ;\ -: & get-token drop ;\ -6ED & $x\ -0 value mi\ -: mmr " map-range" mi if my-self $C else $call-parent then ;\ -89B & ' mmr R\ -: mcm -1 to mi $C 0 to mi ;\ -8CB & 1E na+ ' mcm L\ -: maa -1 to mi 1D swap ;\ -8C9 & 5 na+ ' maa L\ -8C9 & 134 + ' 1 L\ -8CD & 184 + 14 q dup @ 6 << 6 >>a -4 and + R\ -8C6 & 7C + ' u< L\ -0 value yn\ -: y yn 0= if dup @ to yn then ;\ -8CB & ' y R\ -' y 28 + 8CB & 8 + R\ -: z yn ?dup if over ! 0 to yn then ;\ -8CC & ' z R\ -' z 2C + 8CC & 8 + R\ -@startvec BC + @ 40820014 over 88 + g 41820010 swap E0 + g\ -0 @startvec 5C + @ 1D8 + g\ -dev /packages/mac-parts\ -400000 ' load 14 + g\ -: m1 400000 do-unmap ;\ -' load 8 + ' m1 L\ -' load 160 + ' 0 L\ -: &r1 4+ dup 8000 alloc-mem 7F00 + swap ! 4+ F8 ;\ -' load 2AC - ' &r1 L\ -$E\ -4180FFF0 ' msr! 44 + g\ -dev /packages/xcoff-loader\ -: p&+ ['] open 600 - + ;\ -: p1 { _a _s } _a -1000 and _a _s + over - FFF ;\ -60000000 dup 8 p&+ g C p&+ g\ -18 p&+ ' p1 L\ -$E\ -" enet" $F dup\ -1D8 - 24 q ['] or L $x\ -248 - @ 6 encode-bytes 2dup\ -" local-mac-address" $p\ -$E\ -" mac-address" $a\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: &SI\ -" scsi-int" open-dev\ -" open" 2 pick 4+ @ find-method drop\ -2c q ['] 2 L 848 -\ -8 q 1C q R\ -88 q 4 q R\ -$x " close" rot $C ;\ -&SI\ -dev /packages/obp-tftp\ -: O ['] open + ;\ -: M dup 24 - -18E0 O $X 6 move 14 + ;\ -684 O ['] drop L\ --63C O ' M L\ -$E\ -unselect-dev diff --git a/nvram.tproj/nvram/Silk b/nvram.tproj/nvram/Silk deleted file mode 100644 index e1bdc32..0000000 --- a/nvram.tproj/nvram/Silk +++ /dev/null @@ -1,63 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.1 Date: 1-30-2001 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $p 0 to my-self property ;\ -: $a " /chosen" $D $p $E ;\ -: helpb ['] install-interrupt-vectors ['] noop $R\ -0 4000 release-mem 8000 2000 release-mem ;\ -10 buffer: km\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" $a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else helpb 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev /packages/mac-parts\ -: $M 7F00 - 4 ;\ -' my-init-program 34 + ' $M $L\ -' load-partition dup\ -80 + ' 2drop $L\ -104 + ' 0 $L\ -' load 15C + ' 0 $L\ -$E\ -dev /packages/obp-tftp\ -: $M dup 24 - HIS-ENET-HA 6 move 14 + ;\ -' open 66C - ' $M $L\ -$E\ -dev mac-io\ -: decode-unit parse-1hex ;\ -$E\ -ff000000 dup dup 400 28 do-map 4+ w@ 10 and 0=\ -if 90b7 f3000032 w! then\ -unselect-dev diff --git a/nvram.tproj/nvram/Wallstreet b/nvram.tproj/nvram/Wallstreet deleted file mode 100644 index a3c8fdf..0000000 --- a/nvram.tproj/nvram/Wallstreet +++ /dev/null @@ -1,102 +0,0 @@ -## -# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights -# Reserved. This file contains Original Code and/or Modifications of -# Original Code as defined in and that are subject to the Apple Public -# Source License Version 1.0 (the 'License'). You may not use this file -# except in compliance with the License. Please obtain a copy of the -# License at http://www.apple.com/publicsource and read it before using -# this file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the -# License for the specific language governing rights and limitations -# under the License." -# -# @APPLE_LICENSE_HEADER_END@ -## -# Version: 1.2.1 Date: 1-30-2001 -use-nvramrc? true -load-base 600000 -diag-device -nvramrc hex\ -: $D find-device ;\ -: $E device-end ;\ -: $L BLpatch ; : $R BRpatch ;\ -: $X execute ;\ -: $P 0 to my-self property ;\ -: &a " /chosen" $D $P $E ;\ -: &c " ata-enable" $call-parent ;\ -: helpb " backlight-on" _pmu-ihandle $call-method ;\ -10 buffer: km\ -devalias ide0 /pci/@10/ata0\ -devalias ide1 /pci/@10/@34/ata1\ -devalias ide4 /pci/@d/@34/ata4\ -dev /aliases\ -: $M delete-property ;\ -" ata-int" $M\ -" ata0" $M\ -" ata1" $M\ -" ata4" $M\ -dev kbd\ -get-key-map km swap move\ -$E\ -: ck 0 do swap dup 3 >> km + c@ 1 rot 7 and << and or loop ;\ -: bootr 0d word count encode-string " machargs" &a\ -0 0 1 ck if 0 and else dup 1 = if 3d 0 1 else f 3d 0 2 then ck if 40 or then then\ -40 and if bye else helpb 1e 0 do ['] boot catch drop 1f4 ms loop then bye ;\ -: myboot boot-command eval ;\ -dev enet\ -62 ' READ 7 - c!\ -: READ { _p _n ; _a } begin _p _n bead -> _a _a 2+\ -if _p c@ 80 and 0= else 1 then until _a ;\ -$E\ -dev /packages/obp-tftp\ -: $M over + ['] noop $L ;\ -: $O ['] open + ;\ -: $M1 dup 24 - -1720 $O $X 6 move 14 + ;\ --5BC $O ' $M1 $L\ -0 $O E8 $M EC $M F0 $M F4 $M F8 + ' true $L\ -$E\ -dev /packages/mac-parts\ -: $M -7E86F0 $X 8000 alloc-mem 7F00 + 4 -7E86F0 $X ;\ -' load 268 - ' $M $L\ -' load 160 + ' 0 $L\ -dev ide0\ -: open use-ata-interface 0 &c -1 ;\ -: set-device-ID set-drive-select ;\ -$E\ -dev mac-io/@34\ -1 value &f\ -: ata-enable &f if 1000 ms &c 1000 ms 0 to &f else drop then ;\ -$E\ -dev ide1\ -: open use-ata-interface 1 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -$E\ -dev pci1/@d/@34\ -: ata-enable &c ;\ -$E\ -dev ide4\ -: open use-ata-interface 1 &c -1 ;\ -: set-device-ID set-drive-select ;\ -: reset-atapi-bus reset-ata-bus ;\ -$E\ -dev scsi\ -: $M ['] do-cmd + ;\ -: $M2 5 us -5f0 $M $X ;\ -: $M3 -710 $M f over $X $X ;\ -: $M4 1 ms ;\ --1AC $M ' $M2 $L\ -100 $M ' $M3 $L\ -120 $M ' $M4 $L\ -124 $M ' 1 $L\ -$E\ -unselect-dev diff --git a/passwd.tproj/Makefile.postamble b/passwd.tproj/Makefile.postamble index 4d8d2c7..de934cc 100644 --- a/passwd.tproj/Makefile.postamble +++ b/passwd.tproj/Makefile.postamble @@ -6,3 +6,7 @@ INSTALL_PERMISSIONS = 4555 #after_install:: # $(CHFLAGS) schg $(DSTROOT)$(INSTALLDIR)/$(NAME) + +install-man-page: + install -d $(DSTROOT)/usr/share/man/man1 + install -c -m 444 passwd.1 $(DSTROOT)/usr/share/man/man1/passwd.1 diff --git a/passwd.tproj/Makefile.preamble b/passwd.tproj/Makefile.preamble index f4bc80f..a28c6e6 100644 --- a/passwd.tproj/Makefile.preamble +++ b/passwd.tproj/Makefile.preamble @@ -1,3 +1,3 @@ OTHER_GENERATED_OFILES = $(VERS_OFILE) CLEAN_ALL_SUBPROJECTS = YES - +AFTER_INSTALL += install-man-page diff --git a/passwd.tproj/ds_passwd.c b/passwd.tproj/ds_passwd.c index 169edfb..e8da6ae 100644 --- a/passwd.tproj/ds_passwd.c +++ b/passwd.tproj/ds_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -35,6 +36,7 @@ #include #include #include +#include #include #include @@ -49,12 +51,13 @@ //------------------------------------------------------------------------------------- void -ds_getpasswd(char *name, int isroot, int wasroot, int changePassOnSelf, char **old_clear, char **new_clear) +ds_getpasswd(const char *loginUser, char *name, int isroot, int wasroot, int changePassOnSelf, char **old_clear, char **new_clear) { int tries, len; char *p; static char obuf[kMaxPassword]; static char nbuf[kMaxPassword]; + char prompt[MAXNAMLEN + 16]; printf("Changing password for %s.\n", name); @@ -62,7 +65,16 @@ ds_getpasswd(char *name, int isroot, int wasroot, int changePassOnSelf, char **o if (isroot == 0) { - p = getpass( changePassOnSelf ? "Old password:" : "Administrator password:" ); + if ( changePassOnSelf ) + { + strcpy( prompt, "Old password:" ); + } + else + { + snprintf( prompt, sizeof(prompt), "password for %s:", loginUser ); + } + + p = getpass( prompt ); snprintf( obuf, sizeof(obuf), "%s", p ); } @@ -183,7 +195,7 @@ ds_passwd(char *uname, char *locn) if ( getuid() == 0 ) isroot = 1; - ds_getpasswd( uname, isroot, wasroot, changePassOnSelf, &old_clear, &new_clear ); + ds_getpasswd( loginUser, uname, isroot, wasroot, changePassOnSelf, &old_clear, &new_clear ); status = dsGetDirNodeName( dsRef, tDataBuff, 1, &nodeName ); if (status != eDSNoErr) continue; diff --git a/passwd.tproj/file_passwd.c b/passwd.tproj/file_passwd.c index d439d97..67278c5 100644 --- a/passwd.tproj/file_passwd.c +++ b/passwd.tproj/file_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/netinfo_passwd.c b/passwd.tproj/netinfo_passwd.c index 6abdd39..e86a25b 100644 --- a/passwd.tproj/netinfo_passwd.c +++ b/passwd.tproj/netinfo_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/nis_passwd.c b/passwd.tproj/nis_passwd.c index 9043e92..8be2044 100644 --- a/passwd.tproj/nis_passwd.c +++ b/passwd.tproj/nis_passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/passwd.1 b/passwd.tproj/passwd.1 index 4b07f93..950c5b5 100644 --- a/passwd.tproj/passwd.1 +++ b/passwd.tproj/passwd.1 @@ -39,11 +39,12 @@ .Nd modify a user's password .Sh SYNOPSIS .Nm passwd -.Op Fl l -.Op Ar user +.Op Fl i Ar infosystem +.Op Fl l Ar location +.Op Ar name .Sh DESCRIPTION .Nm Passwd -changes the user's Kerberos password. First, the user is prompted for their +changes the user's password. First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. @@ -51,31 +52,50 @@ The new password must be entered twice to avoid typing errors. .Pp The new password should be at least six characters long and not purely alphabetic. -Its total length must be less than +Its total length should be less than .Dv _PASSWORD_LEN -(currently 128 characters). +(currently 128 characters) although some infosystems allow longer passwords. Numbers, upper case letters and meta characters are encouraged. .Pp Once the password has been verified, .Nm passwd communicates the new password information to -the Kerberos authenticating host. +the authenticating host. .Bl -tag -width flag -.It Fl l -This option causes the password to be updated only in the local -password file, and not with the Kerberos database. +.It Fl i Ar infosystem +This option specifies where the password update should be applied. +Under Mac OS X 10.3, supported infosystems are: +.Bl -tag -width flag +.It Ar netinfo +(default) +The netinfo database containing the user's password. +If no -l option is specified, the local netinfo database is assumed. +.It Ar file +The local flat-files (included for legacy configurations). +.It Ar nis +A remote NIS server containing the user's password. +.It Ar opendirectory +A system conforming to opendirectory APIs and supporting updates (including LDAP, netinfo, etc). +.El +.It Fl l Ar location +This option causes the password to be updated in the given location of the choosen infosystem. When changing only the local password, .Xr pwd_mkdb 8 is used to update the password databases. +.Bl -tag -width flag +.It for netinfo, +location may be a domain name or server/tag +.It for file, +location may be a file name (/etc/master.passwd is the default) +.It for nis, +location may be a NIS domainname +.It for opendirectory, +location may be a directory node name +.Bl .El .Pp -To change another user's Kerberos password, one must first -run -.Xr kinit 1 -followed by -.Xr passwd 1 . -The super-user is not required to provide a user's current password +The super-user privilages are not required change a user's current password if only the local password is modified. .Sh FILES .Bl -tag -width /etc/master.passwd -compact @@ -88,13 +108,11 @@ Temporary copy of the password file .El .Sh SEE ALSO .Xr chpass 1 , -.Xr kerberos 1 , -.Xr kinit 1 , .Xr login 1 , .Xr passwd 5 , -.Xr kpasswdd 8 , .Xr pwd_mkdb 8 , -.Xr vipw 8 +.Xr vipw 8, +.Xr nicl 1 .Rs .%A Robert Morris .%A Ken Thompson diff --git a/passwd.tproj/passwd.c b/passwd.tproj/passwd.c index 894d797..3d2b19d 100644 --- a/passwd.tproj/passwd.c +++ b/passwd.tproj/passwd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/stringops.c b/passwd.tproj/stringops.c index fcf861d..e6cd093 100644 --- a/passwd.tproj/stringops.c +++ b/passwd.tproj/stringops.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/stringops.h b/passwd.tproj/stringops.h index 417a167..34f9b4f 100644 --- a/passwd.tproj/stringops.h +++ b/passwd.tproj/stringops.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/pwd_mkdb.tproj/Makefile.postamble b/pwd_mkdb.tproj/Makefile.postamble index 70b747f..2d18955 100644 --- a/pwd_mkdb.tproj/Makefile.postamble +++ b/pwd_mkdb.tproj/Makefile.postamble @@ -107,3 +107,7 @@ # Makefile API), which are rules that get invoked before and after the install # target runs. Such rules should be specified with the '::' syntax rather than # a single colon. + +install-man-page: + install -d $(DSTROOT)/usr/share/man/man8 + install -c -m 444 pwd_mkdb.8 $(DSTROOT)/usr/share/man/man8/pwd_mkdb.8 diff --git a/pwd_mkdb.tproj/Makefile.preamble b/pwd_mkdb.tproj/Makefile.preamble index e371f9d..12b2108 100644 --- a/pwd_mkdb.tproj/Makefile.preamble +++ b/pwd_mkdb.tproj/Makefile.preamble @@ -16,7 +16,7 @@ ## (e.g. change -O to -O2), see Makefile.postamble. # Flags passed to compiler (in addition to -g, -O, etc) -OTHER_CFLAGS = +OTHER_CFLAGS = -D_PW_NAME_LEN=MAXLOGNAME -D_PW_YPTOKEN=\"__YP!\" # Flags passed to ld (in addition to -ObjC, etc.) OTHER_LDFLAGS = @@ -111,3 +111,5 @@ OTHER_HELP_DIRS = # $(NAME).%d[.%d][.%d] and the following line must be uncommented. OTHER_GENERATED_OFILES = $(VERS_OFILE) +AFTER_INSTALL += install-man-page + diff --git a/pwd_mkdb.tproj/pw_scan.c b/pwd_mkdb.tproj/pw_scan.c index 8e49984..c3e0de3 100644 --- a/pwd_mkdb.tproj/pw_scan.c +++ b/pwd_mkdb.tproj/pw_scan.c @@ -1,28 +1,7 @@ +/* $OpenBSD: passwd.c,v 1.42 2003/06/26 16:34:42 deraadt Exp $ */ + /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." - * - * @APPLE_LICENSE_HEADER_END@ - */ -/*- - * Copyright (c) 1990, 1993, 1994 + * Copyright (c) 1987, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,11 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -54,39 +29,44 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94"; -#endif /* not lint */ - -/* - * This module is used to "verify" password entries by chpass(1) and - * pwd_mkdb(8). - */ +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = "$OpenBSD: passwd.c,v 1.42 2003/06/26 16:34:42 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ -#include +#include +#include +#include +#include +#include -#include #include -#include -#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include "pw_scan.h" +#include "util.h" int -pw_scan(bp, pw) - char *bp; - struct passwd *pw; +pw_scan(char *bp, struct passwd *pw, int *flags) { - uid_t id; + u_long id; int root; - char *p, *sh; + char *p, *sh, *p2; + + if (flags != (int *)NULL) + *flags = 0; - if (!(pw->pw_name = strsep(&bp, ":"))) /* login */ + if (!(p = strsep(&bp, ":")) || *p == '\0') /* login */ goto fmt; + pw->pw_name = p; root = !strcmp(pw->pw_name, "root"); if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */ @@ -94,62 +74,79 @@ pw_scan(bp, pw) if (!(p = strsep(&bp, ":"))) /* uid */ goto fmt; - errno = 0; - id = strtoul(p, NULL, 10); - if( (id == 0) && (errno == EINVAL) ) { - warnx("%s did not convert to uid", p); - return(0); - } + id = strtoul(p, &p2, 10); if (root && id) { warnx("root uid should be 0"); return (0); } - if ( (id == ULONG_MAX) && (errno == ERANGE) ) { - warnx("%s > max uid value (%d)", p, ULONG_MAX); + if (*p2 != '\0') { + warnx("illegal uid field"); return (0); } - pw->pw_uid = id; +#ifndef __APPLE__ + /* Apple's UID_MAX is too small (sizeof signed) 3091256 */ + if (id > UID_MAX) { + /* errno is set to ERANGE by strtoul(3) */ + warnx("uid greater than %u", UID_MAX-1); + return (0); + } +#endif + pw->pw_uid = (uid_t)id; + if ((*p == '\0') && (flags != (int *)NULL)) + *flags |= _PASSWORD_NOUID; if (!(p = strsep(&bp, ":"))) /* gid */ goto fmt; - errno = 0; - id = strtoul(p, NULL, 10); - if( (id == 0) && (errno == EINVAL) ) { - warnx("%s did not convert to gid", p); - return(0); + id = strtoul(p, &p2, 10); + if (*p2 != '\0') { + warnx("illegal gid field"); + return (0); } - if ( (id == ULONG_MAX) && (errno == ERANGE) ) { - warnx("%s > max gid value (%d)", p, ULONG_MAX); +#ifndef __APPLE__ + /* Apple's UID_MAX is too small (sizeof signed) 3091256 */ + if (id > UID_MAX) { + /* errno is set to ERANGE by strtoul(3) */ + warnx("gid greater than %u", UID_MAX-1); return (0); } - pw->pw_gid = id; +#endif + pw->pw_gid = (gid_t)id; + if ((*p == '\0') && (flags != (int *)NULL)) + *flags |= _PASSWORD_NOGID; pw->pw_class = strsep(&bp, ":"); /* class */ if (!(p = strsep(&bp, ":"))) /* change */ goto fmt; pw->pw_change = atol(p); + if ((*p == '\0') && (flags != (int *)NULL)) + *flags |= _PASSWORD_NOCHG; if (!(p = strsep(&bp, ":"))) /* expire */ goto fmt; pw->pw_expire = atol(p); + if ((*p == '\0') && (flags != (int *)NULL)) + *flags |= _PASSWORD_NOEXP; pw->pw_gecos = strsep(&bp, ":"); /* gecos */ pw->pw_dir = strsep(&bp, ":"); /* directory */ if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */ goto fmt; p = pw->pw_shell; - if (root && *p) /* empty == /bin/sh */ + if (root && *p) { /* empty == /bin/sh */ for (setusershell();;) { if (!(sh = getusershell())) { warnx("warning, unknown root shell"); break; } if (!strcmp(p, sh)) - break; + break; } + endusershell(); + } - if (p = strsep(&bp, ":")) { /* too many */ + if ((p = strsep(&bp, ":"))) { /* too many */ fmt: warnx("corrupted entry"); return (0); } + return (1); } diff --git a/pwd_mkdb.tproj/pw_scan.h b/pwd_mkdb.tproj/pw_scan.h index 55754b6..f7ec9c4 100644 --- a/pwd_mkdb.tproj/pw_scan.h +++ b/pwd_mkdb.tproj/pw_scan.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,4 +57,4 @@ * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94 */ -extern int pw_scan __P((char *, struct passwd *)); +extern int pw_scan __P((char *, struct passwd *, int *)); diff --git a/pwd_mkdb.tproj/pwd_mkdb.8 b/pwd_mkdb.tproj/pwd_mkdb.8 index 3d012e3..ec4bd88 100644 --- a/pwd_mkdb.tproj/pwd_mkdb.8 +++ b/pwd_mkdb.tproj/pwd_mkdb.8 @@ -1,3 +1,5 @@ +.\" $OpenBSD: pwd_mkdb.8,v 1.17 2003/06/12 12:59:52 jmc Exp $ +.\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -9,11 +11,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" @@ -29,100 +27,145 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)pwd_mkdb.8 8.2 (Berkeley) 4/27/95 +.\" from: @(#)pwd_mkdb.8 8.1 (Berkeley) 6/6/93 .\" -.Dd April 27, 1995 +.Dd June 6, 1993 .Dt PWD_MKDB 8 .Os .Sh NAME .Nm pwd_mkdb -.Nd "generate the password databases" +.Nd generate the password databases .Sh SYNOPSIS .Nm pwd_mkdb -.Op Fl p +.Op Fl c +.Op Fl p | Fl s +.Op Fl d Ar directory +.Op Fl u Ar username .Ar file .Sh DESCRIPTION -.Nm Pwd_mkdb +.Nm creates .Xr db 3 style secure and insecure databases for the specified file. These databases are then installed into -.Dq Pa /etc/spwd.db +.Pa /etc/spwd.db and -.Dq Pa /etc/pwd.db +.Pa /etc/pwd.db , respectively. The file is installed into -.Dq Pa /etc/master.passwd . +.Pa /etc/master.passwd . The file must be in the correct format (see .Xr passwd 5 ) . It is important to note that the format used in this system is different from the historic Version 7 style format. .Pp The options are as follows: -.Bl -tag -width flag +.Bl -tag -width Ds +.It Fl c +Check if the password file is in the correct format. +Do not change, add, or remove any files. .It Fl p Create a Version 7 style password file and install it into -.Dq Pa /etc/passwd . +.Pa /etc/passwd . +.It Fl s +Only update the secure version of the database. +This is most commonly used in conjunction with the +.Fl u +flag during a password change. +Because the insecure database doesn't contain the password there +is no reason to update it if the only change is in the password field. +Cannot be used in conjunction with the +.Fl p +flag. +.It Fl d Ar directory +Operate in a base directory other than the default of +.Pa /etc . +All absolute paths (including +.Ar file ) +will be made relative to +.Ar directory . +Any directories specified as a part of +.Ar file +will be stripped off. +This option is used to create password databases in directories +other than +.Pa etc ; +for instance in a +.Xr chroot 8 +jail. +.It Fl u Ar username +Only update the record for the specified user. +Utilities that operate on a single user can use this option to avoid the +overhead of rebuilding the entire database. +This option must never be used if the line number of the user's record in +.Pa /etc/master.passwd +has changed. +.It Ar file +The absolute path to a file in +.Ar master.passwd +format, as described in +.Xr passwd 5 . .El .Pp -The two databases differ in that the secure version contains the user's -encrypted password and the insecure version has an asterisk (``*'') +The two databases differ in that the secure version contains the user's +encrypted password and the insecure version has an asterisk +.Pq Sq \&* . .Pp The databases are used by the C library password routines (see .Xr getpwent 3 ) . .Pp -.Nm Pwd_mkdb +.Nm exits zero on success, non-zero on failure. .Sh FILES -.Bl -tag -width Pa -compact +.Bl -tag -width /etc/master.passwd -compact .It Pa /etc/master.passwd -The current password file. +current password file .It Pa /etc/passwd -A Version 7 format password file. +a Version 7 format password file .It Pa /etc/pwd.db -The insecure password database file. +insecure password database file .It Pa /etc/pwd.db.tmp -A temporary file. +temporary file .It Pa /etc/spwd.db -The secure password database file. +secure password database file .It Pa /etc/spwd.db.tmp -A temporary file. +temporary file .El +.Sh SEE ALSO +.Xr chpass 1 , +.Xr passwd 1 , +.Xr db 3 , +.Xr getpwent 3 , +.Xr passwd 5 , +.Xr vipw 8 +.Sh STANDARDS +Previous versions of the system had a program similar to +.Nm pwd_mkdb , +.Xr mkpasswd , +which built +.Xr dbm 3 +style databases for the password file but depended on the calling programs +to install them. +The program was renamed in order that previous users of the program +not be surprised by the changes in functionality. .Sh BUGS Because of the necessity for atomic update of the password files, -.Nm pwd_mkdb +.Nm uses .Xr rename 2 to install them. This, however, requires that the file specified on the command line live on the same file system as the -.Dq Pa /etc +.Pa /etc directory. .Pp There are the obvious races with multiple people running -.Nm pwd_mkdb +.Nm on different password files at the same time. -The front-ends to +The front-ends to .Nm pwd_mkdb , .Xr chpass 1 , -.Xr passwd 1 -and -.Xr vipw 8 , -handle the locking necessary to avoid this problem. -.Sh COMPATIBILITY -Previous versions of the system had a program similar to -.Nm pwd_mkdb , -.Xr mkpasswd 8 , -which built -.Xr dbm 3 -style databases for the password file but depended on the calling programs -to install them. -The program was renamed in order that previous users of the program -not be surprised by the changes in functionality. -.Sh SEE ALSO -.Xr chpass 1 , .Xr passwd 1 , -.Xr db 3 , -.Xr getpwent 3 , -.Xr passwd 5 , +and .Xr vipw 8 +handle the locking necessary to avoid this problem. diff --git a/pwd_mkdb.tproj/pwd_mkdb.c b/pwd_mkdb.tproj/pwd_mkdb.c index b9acefa..b2daac5 100644 --- a/pwd_mkdb.tproj/pwd_mkdb.c +++ b/pwd_mkdb.tproj/pwd_mkdb.c @@ -1,29 +1,10 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." - * - * @APPLE_LICENSE_HEADER_END@ - */ +/* $OpenBSD: pwd_mkdb.c,v 1.36 2003/06/08 21:14:55 millert Exp $ */ + /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. + * Portions Copyright (c) 1994, Jason Downs. All rights reserved. + * Portions Copyright (c) 1998, Todd C. Miller. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,11 +14,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -55,13 +32,17 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1991, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"; +#if 0 +static const char sccsid[] = "from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"; +#else +static const char rcsid[] = "$OpenBSD: pwd_mkdb.c,v 1.36 2003/06/08 21:14:55 millert Exp $"; +#endif #endif /* not lint */ #include @@ -71,6 +52,7 @@ static char sccsid[] = "@(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"; #include #include #include +#include #include #include #include @@ -78,14 +60,20 @@ static char sccsid[] = "@(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"; #include #include #include - -#include "pw_scan.h" +#include +#include #define INSECURE 1 #define SECURE 2 #define PERM_INSECURE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #define PERM_SECURE (S_IRUSR|S_IWUSR) +#define FILE_SECURE 0x01 +#define FILE_INSECURE 0x02 +#define FILE_ORIG 0x04 + +#define SHADOW_GROUP "wheel" + HASHINFO openinfo = { 4096, /* bsize */ 32, /* ffactor */ @@ -95,35 +83,59 @@ HASHINFO openinfo = { 0 /* lorder */ }; -static enum state { FILE_INSECURE, FILE_SECURE, FILE_ORIG } clean; -static struct passwd pwd; /* password structure */ static char *pname; /* password file name */ - -void cleanup __P((void)); -void error __P((char *)); -void mv __P((char *, char *)); -int scan __P((FILE *, struct passwd *)); -void usage __P((void)); +static char *basedir; /* dir holding master.passwd */ +static int clean; /* what to remove on cleanup */ +static int hasyp; /* are we running YP? */ + +void cleanup(void); +void error(char *); +void errorx(char *); +void cp(char *, char *, mode_t); +void mv(char *, char *); +int scan(FILE *, struct passwd *, int *); +void usage(void); +char *changedir(char *path, char *dir); +void db_store(FILE *, FILE *, DB *, DB *,struct passwd *, int, char *, uid_t); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { DB *dp, *edp; DBT data, key; - FILE *fp, *oldfp; + FILE *fp, *oldfp = NULL; + struct stat st; + struct passwd pwd; + struct group *grp; sigset_t set; - int ch, cnt, len, makeold, tfd; - char *p, *t; - char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024]; - - makeold = 0; - while ((ch = getopt(argc, argv, "pv")) != EOF) - switch(ch) { + uid_t olduid; + gid_t shadow; + int ch, tfd, makeold, secureonly, flags, checkonly; + char *username, buf[MAX(MAXPATHLEN, LINE_MAX * 2)]; + + flags = checkonly = makeold = secureonly = 0; + username = NULL; + while ((ch = getopt(argc, argv, "cd:psu:v")) != -1) + switch (ch) { + case 'c': /* verify only */ + checkonly = 1; + break; + case 'd': + basedir = optarg; + if (strlen(basedir) > MAXPATHLEN - 40) + errx(1, "basedir too long"); + break; case 'p': /* create V7 "file.orig" */ makeold = 1; break; + case 's': /* only update spwd.db */ + secureonly = 1; + break; + case 'u': /* only update this record */ + username = optarg; + if (strlen(username) > _PW_NAME_LEN) + errx(1, "username too long"); + break; case 'v': /* backward compatible */ break; case '?': @@ -133,8 +145,14 @@ main(argc, argv) argc -= optind; argv += optind; - if (argc != 1) + if (argc != 1 || (makeold && secureonly) || + (username && (*username == '+' || *username == '-'))) usage(); + + if ((grp = getgrnam(SHADOW_GROUP)) == NULL) + errx(1, "cannot find `%s' in the group database, aborting", + SHADOW_GROUP); + shadow = grp->gr_gid; /* * This could be changed to allow the user to interrupt. @@ -151,18 +169,92 @@ main(argc, argv) /* We don't care what the user wants. */ (void)umask(0); - pname = *argv; + if (**argv != '/' && basedir == NULL) + errx(1, "%s must be specified as an absolute path", *argv); + + if ((pname = strdup(changedir(*argv, basedir))) == NULL) + err(1, NULL); /* Open the original password file */ if (!(fp = fopen(pname, "r"))) error(pname); - /* Open the temporary insecure password database. */ - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_MP_DB); - dp = dbopen(buf, - O_RDWR|O_CREAT|O_EXCL, PERM_INSECURE, DB_HASH, &openinfo); - if (dp == NULL) + /* Check only if password database is valid */ + if (checkonly) { + u_int cnt; + + for (cnt = 1; scan(fp, &pwd, &flags); ++cnt) + ; + exit(0); + } + + if (fstat(fileno(fp), &st) == -1) + error(pname); + + /* Tweak openinfo values for large passwd files. */ + if (st.st_size > (off_t)100*1024) + openinfo.cachesize = MIN(st.st_size * 20, (off_t)12*1024*1024); + if (st.st_size / 128 > openinfo.nelem) + openinfo.nelem = st.st_size / 128; + + /* If only updating a single record, stash the old uid */ + if (username) { + dp = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL); + if (dp == NULL) + error(_PATH_MP_DB); + buf[0] = _PW_KEYBYNAME; + strlcpy(buf + 1, username, sizeof(buf) - 1); + key.data = (u_char *)buf; + key.size = strlen(buf + 1) + 1; + if ((dp->get)(dp, &key, &data, 0) == 0) { + char *p = (char *)data.data; + /* Skip to uid field */ + while (*p++ != '\0') + ; + while (*p++ != '\0') + ; + memcpy(&olduid, p, sizeof(olduid)); + } else + olduid = UID_MAX; + (dp->close)(dp); + } + + /* Open the temporary encrypted password database. */ + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_SMP_DB, basedir)); + if (username) { + cp(changedir(_PATH_SMP_DB, basedir), buf, PERM_SECURE); + edp = dbopen(buf, + O_RDWR, PERM_SECURE, DB_HASH, &openinfo); + } else { + edp = dbopen(buf, + O_RDWR|O_CREAT|O_EXCL, PERM_SECURE, DB_HASH, &openinfo); + } + if (!edp) error(buf); - clean = FILE_INSECURE; + if (fchown(edp->fd(edp), (uid_t)-1, shadow) != 0) + warn("%s: unable to set group to %s", _PATH_SMP_DB, + SHADOW_GROUP); + else if (fchmod(edp->fd(edp), PERM_SECURE|S_IRGRP) != 0) + warn("%s: unable to make group readable", _PATH_SMP_DB); + clean |= FILE_SECURE; + + /* Open the temporary insecure password database. */ + if (!secureonly) { + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_MP_DB, basedir)); + if (username) { + cp(changedir(_PATH_MP_DB, basedir), buf, PERM_INSECURE); + dp = dbopen(buf, O_RDWR, PERM_INSECURE, DB_HASH, + &openinfo); + } else { + dp = dbopen(buf, O_RDWR|O_CREAT|O_EXCL, PERM_INSECURE, + DB_HASH, &openinfo); + } + if (dp == NULL) + error(buf); + clean |= FILE_INSECURE; + } else + dp = NULL; /* * Open file for old password file. Minor trickiness -- don't want to @@ -178,7 +270,7 @@ main(argc, argv) error(buf); if ((oldfp = fdopen(tfd, "w")) == NULL) error(buf); - clean = FILE_ORIG; + clean |= FILE_ORIG; } /* @@ -191,171 +283,97 @@ main(argc, argv) * _PW_KEYBYUID character. The third key is the line number in the * original file prepended by the _PW_KEYBYNUM character. (The special * characters are prepended to ensure that the keys do not collide.) + * + * If we see something go by that looks like YP, we save a special + * pointer record, which if YP is enabled in the C lib, will speed + * things up. */ - data.data = (u_char *)buf; - key.data = (u_char *)tbuf; - for (cnt = 1; scan(fp, &pwd); ++cnt) { -#define COMPACT(e) t = e; while (*p++ = *t++); - /* Create insecure data. */ - p = buf; - COMPACT(pwd.pw_name); - COMPACT("*"); - memmove(p, &pwd.pw_uid, sizeof(int)); - p += sizeof(int); - memmove(p, &pwd.pw_gid, sizeof(int)); - p += sizeof(int); - memmove(p, &pwd.pw_change, sizeof(time_t)); - p += sizeof(time_t); - COMPACT(pwd.pw_class); - COMPACT(pwd.pw_gecos); - COMPACT(pwd.pw_dir); - COMPACT(pwd.pw_shell); - memmove(p, &pwd.pw_expire, sizeof(time_t)); - p += sizeof(time_t); - data.size = p - buf; - - /* Store insecure by name. */ - tbuf[0] = _PW_KEYBYNAME; - len = strlen(pwd.pw_name); - memmove(tbuf + 1, pwd.pw_name, len); - key.size = len + 1; - if ((dp->put)(dp, &key, &data, R_NOOVERWRITE) == -1) - error("put"); - - /* Store insecure by number. */ - tbuf[0] = _PW_KEYBYNUM; - memmove(tbuf + 1, &cnt, sizeof(cnt)); - key.size = sizeof(cnt) + 1; - if ((dp->put)(dp, &key, &data, R_NOOVERWRITE) == -1) - error("put"); - - /* Store insecure by uid. */ - tbuf[0] = _PW_KEYBYUID; - memmove(tbuf + 1, &pwd.pw_uid, sizeof(pwd.pw_uid)); - key.size = sizeof(pwd.pw_uid) + 1; - if ((dp->put)(dp, &key, &data, R_NOOVERWRITE) == -1) - error("put"); - - /* Create original format password file entry */ - if (makeold) - (void)fprintf(oldfp, "%s:*:%d:%d:%s:%s:%s\n", - pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos, - pwd.pw_dir, pwd.pw_shell); - } - (void)(dp->close)(dp); - if (makeold) { - (void)fflush(oldfp); - (void)fclose(oldfp); - } - - /* Open the temporary encrypted password database. */ - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_SMP_DB); - edp = dbopen(buf, - O_RDWR|O_CREAT|O_EXCL, PERM_SECURE, DB_HASH, &openinfo); - if (!edp) - error(buf); - clean = FILE_SECURE; - rewind(fp); - for (cnt = 1; scan(fp, &pwd); ++cnt) { - - /* Create secure data. */ - p = buf; - COMPACT(pwd.pw_name); - COMPACT(pwd.pw_passwd); - memmove(p, &pwd.pw_uid, sizeof(int)); - p += sizeof(int); - memmove(p, &pwd.pw_gid, sizeof(int)); - p += sizeof(int); - memmove(p, &pwd.pw_change, sizeof(time_t)); - p += sizeof(time_t); - COMPACT(pwd.pw_class); - COMPACT(pwd.pw_gecos); - COMPACT(pwd.pw_dir); - COMPACT(pwd.pw_shell); - memmove(p, &pwd.pw_expire, sizeof(time_t)); - p += sizeof(time_t); - data.size = p - buf; + /* + * Write the .db files. + * We do this three times, one per key type (for getpw{nam,uid,ent}). + * The first time through we also check for YP, issue warnings + * and save the V7 format passwd file if necessary. + */ + db_store(fp, oldfp, edp, dp, &pwd, _PW_KEYBYNAME, username, olduid); + db_store(fp, oldfp, edp, dp, &pwd, _PW_KEYBYUID, username, olduid); + db_store(fp, oldfp, edp, dp, &pwd, _PW_KEYBYNUM, username, olduid); - /* Store secure by name. */ - tbuf[0] = _PW_KEYBYNAME; - len = strlen(pwd.pw_name); - memmove(tbuf + 1, pwd.pw_name, len); - key.size = len + 1; - if ((edp->put)(edp, &key, &data, R_NOOVERWRITE) == -1) - error("put"); + /* Store YP token, if needed. */ + if (hasyp && !username) { + key.data = (u_char *)_PW_YPTOKEN; + key.size = strlen(_PW_YPTOKEN); + data.data = (u_char *)NULL; + data.size = 0; - /* Store secure by number. */ - tbuf[0] = _PW_KEYBYNUM; - memmove(tbuf + 1, &cnt, sizeof(cnt)); - key.size = sizeof(cnt) + 1; if ((edp->put)(edp, &key, &data, R_NOOVERWRITE) == -1) error("put"); - /* Store secure by uid. */ - tbuf[0] = _PW_KEYBYUID; - memmove(tbuf + 1, &pwd.pw_uid, sizeof(pwd.pw_uid)); - key.size = sizeof(pwd.pw_uid) + 1; - if ((edp->put)(edp, &key, &data, R_NOOVERWRITE) == -1) + if (dp && (dp->put)(dp, &key, &data, R_NOOVERWRITE) == -1) error("put"); } - (void)(edp->close)(edp); + if ((edp->close)(edp)) + error("close edp"); + if (dp && (dp->close)(dp)) + error("close dp"); + if (makeold) { + if (fclose(oldfp) == EOF) + error("close old"); + } /* Set master.passwd permissions, in case caller forgot. */ (void)fchmod(fileno(fp), S_IRUSR|S_IWUSR); - (void)fclose(fp); + if (fclose(fp) != 0) + error("fclose"); /* Install as the real password files. */ - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_MP_DB); - mv(buf, _PATH_MP_DB); - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_SMP_DB); - mv(buf, _PATH_SMP_DB); + if (!secureonly) { + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_MP_DB, basedir)); + mv(buf, changedir(_PATH_MP_DB, basedir)); + } + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_SMP_DB, basedir)); + mv(buf, changedir(_PATH_SMP_DB, basedir)); if (makeold) { (void)snprintf(buf, sizeof(buf), "%s.orig", pname); - mv(buf, _PATH_PASSWD); + mv(buf, changedir(_PATH_PASSWD, basedir)); } + /* * Move the master password LAST -- chpass(1), passwd(1) and vipw(8) * all use flock(2) on it to block other incarnations of themselves. * The rename means that everything is unlocked, as the original file * can no longer be accessed. */ - mv(pname, _PATH_MASTERPASSWD); + mv(pname, changedir(_PATH_MASTERPASSWD, basedir)); exit(0); } int -scan(fp, pw) - FILE *fp; - struct passwd *pw; +scan(FILE *fp, struct passwd *pw, int *flags) { static int lcnt; static char line[LINE_MAX]; char *p; -#if defined(__APPLE__) - do { - if (!fgets(line, sizeof(line), fp)) - return (0); - } while (line[0] == '#'); -#else - if (!fgets(line, sizeof(line), fp)) + if (fgets(line, sizeof(line), fp) == NULL) return (0); -#endif ++lcnt; /* * ``... if I swallow anything evil, put your fingers down my * throat...'' * -- The Who */ - if (!(p = strchr(line, '\n'))) { + p = line; + if (*p != '\0' && *(p += strlen(line) - 1) != '\n') { warnx("line too long"); goto fmt; - } *p = '\0'; - if (!pw_scan(line, pw)) { + *flags = 0; + if (!pw_scan(line, pw, flags)) { warnx("at line #%d", lcnt); fmt: errno = EFTYPE; /* XXX */ error(pname); @@ -364,14 +382,46 @@ fmt: errno = EFTYPE; /* XXX */ return (1); } +void +cp(from, to, mode) + char *from, *to; + mode_t mode; +{ + static char buf[MAXBSIZE]; + int from_fd, rcount, to_fd, wcount; + + if ((from_fd = open(from, O_RDONLY, 0)) < 0) + error(from); + if ((to_fd = open(to, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) + error(to); + while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) { + wcount = write(to_fd, buf, rcount); + if (rcount != wcount || wcount == -1) { + int sverrno = errno; + + (void)snprintf(buf, sizeof(buf), "%s to %s", from, to); + errno = sverrno; + error(buf); + } + } + if (rcount < 0) { + int sverrno = errno; + + (void)snprintf(buf, sizeof(buf), "%s to %s", from, to); + errno = sverrno; + error(buf); + } +} + void mv(from, to) char *from, *to; { - char buf[MAXPATHLEN]; + char buf[MAXPATHLEN * 2]; if (rename(from, to)) { int sverrno = errno; + (void)snprintf(buf, sizeof(buf), "%s to %s", from, to); errno = sverrno; error(buf); @@ -383,7 +433,17 @@ error(name) char *name; { - warn(name); + warn("%s", name); + cleanup(); + exit(1); +} + +void +errorx(name) + char *name; +{ + + warnx("%s", name); cleanup(); exit(1); } @@ -393,25 +453,173 @@ cleanup() { char buf[MAXPATHLEN]; - switch(clean) { - case FILE_ORIG: + if (clean & FILE_ORIG) { (void)snprintf(buf, sizeof(buf), "%s.orig", pname); (void)unlink(buf); - /* FALLTHROUGH */ - case FILE_SECURE: - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_SMP_DB); + } + if (clean & FILE_SECURE) { + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_SMP_DB, basedir)); (void)unlink(buf); - /* FALLTHROUGH */ - case FILE_INSECURE: - (void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_MP_DB); + } + if (clean & FILE_INSECURE) { + (void)snprintf(buf, sizeof(buf), "%s.tmp", + changedir(_PATH_MP_DB, basedir)); (void)unlink(buf); } } void -usage() +usage(void) { - (void)fprintf(stderr, "usage: pwd_mkdb [-p] file\n"); + (void)fprintf(stderr, + "usage: pwd_mkdb [-c] [-p | -s] [-d basedir] [-u username] file\n"); exit(1); } + +char * +changedir(char *path, char *dir) +{ + static char fixed[MAXPATHLEN]; + char *p; + + if (!dir) + return (path); + + if ((p = strrchr(path, '/')) != NULL) + path = p + 1; + snprintf(fixed, sizeof(fixed), "%s/%s", dir, path); + return (fixed); +} + +void +db_store(FILE *fp, FILE *oldfp, DB *edp, DB *dp, struct passwd *pw, + int keytype, char *username, uid_t olduid) +{ + int flags = 0; + int dbmode, found = 0; + u_int cnt; + char *p, *t, buf[LINE_MAX * 2], tbuf[1024]; + DBT data, key; + size_t len; + static int firsttime = 1; + + /* If given a username just add that record to the existing db. */ + dbmode = username ? 0 : R_NOOVERWRITE; + + rewind(fp); + data.data = (u_char *)buf; + key.data = (u_char *)tbuf; + for (cnt = 1; scan(fp, pw, &flags); ++cnt) { + + if (firsttime) { + /* Look like YP? */ + if ((pw->pw_name[0] == '+') || (pw->pw_name[0] == '-')) + hasyp++; + + /* Warn about potentially unsafe uid/gid overrides. */ + if (pw->pw_name[0] == '+') { + if (!(flags & _PASSWORD_NOUID) && !pw->pw_uid) + warnx("line %d: superuser override in " + "YP inclusion", cnt); + if (!(flags & _PASSWORD_NOGID) && !pw->pw_gid) + warnx("line %d: wheel override in " + "YP inclusion", cnt); + } + + /* Create V7 format password file entry. */ + if (oldfp != NULL) + if (fprintf(oldfp, "%s:*:%u:%u:%s:%s:%s\n", + pw->pw_name, pw->pw_uid, pw->pw_gid, + pw->pw_gecos, pw->pw_dir, pw->pw_shell) + == EOF) + error("write old"); + } + + /* Are we updating a specific record? */ + if (username) { + if (strcmp(username, pw->pw_name) != 0) + continue; + found = 1; + /* If the uid changed, remove the old record by uid. */ + if (olduid != UID_MAX && olduid != pw->pw_uid) { + tbuf[0] = _PW_KEYBYUID; + memcpy(tbuf + 1, &olduid, sizeof(olduid)); + key.size = sizeof(olduid) + 1; + (edp->del)(edp, &key, 0); + if (dp) + (dp->del)(dp, &key, 0); + } + /* XXX - should check to see if line number changed. */ + } + + /* Build the key. */ + tbuf[0] = keytype; + switch (keytype) { + case _PW_KEYBYNUM: + memmove(tbuf + 1, &cnt, sizeof(cnt)); + key.size = sizeof(cnt) + 1; + break; + + case _PW_KEYBYNAME: + len = strlen(pw->pw_name); + memmove(tbuf + 1, pw->pw_name, len); + key.size = len + 1; + break; + + case _PW_KEYBYUID: + memmove(tbuf + 1, &pw->pw_uid, sizeof(pw->pw_uid)); + key.size = sizeof(pw->pw_uid) + 1; + break; + } + +#define COMPACT(e) t = e; while ((*p++ = *t++)); + /* Create the secure record. */ + p = buf; + COMPACT(pw->pw_name); + COMPACT(pw->pw_passwd); + memmove(p, &pw->pw_uid, sizeof(uid_t)); + p += sizeof(uid_t); + memmove(p, &pw->pw_gid, sizeof(gid_t)); + p += sizeof(gid_t); + memmove(p, &pw->pw_change, sizeof(time_t)); + p += sizeof(time_t); + COMPACT(pw->pw_class); + COMPACT(pw->pw_gecos); + COMPACT(pw->pw_dir); + COMPACT(pw->pw_shell); + memmove(p, &pw->pw_expire, sizeof(time_t)); + p += sizeof(time_t); + memmove(p, &flags, sizeof(int)); + p += sizeof(int); + data.size = p - buf; + + /* Write the secure record. */ + if ((edp->put)(edp, &key, &data, dbmode) == -1) + error("put"); + + if (dp == NULL) + continue; + + /* Star out password to make insecure record. */ + p = buf + strlen(pw->pw_name) + 1; /* skip pw_name */ + len = strlen(pw->pw_passwd); + memset(p, 0, len); /* zero pw_passwd */ + t = p + len + 1; /* skip pw_passwd */ + if (len != 0) + *p++ = '*'; + *p++ = '\0'; + memmove(p, t, data.size - (t - buf)); + data.size -= len - 1; + + /* Write the insecure record. */ + if ((dp->put)(dp, &key, &data, dbmode) == -1) + error("put"); + } + if (firsttime) { + firsttime = 0; + if (username && !found && olduid != UID_MAX) + errorx("can't find user in master.passwd"); + } +} diff --git a/sa.tproj/PB.project b/sa.tproj/PB.project deleted file mode 100644 index 0158f5a..0000000 --- a/sa.tproj/PB.project +++ /dev/null @@ -1,26 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - HEADERSEARCH = ("$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd"); - OTHER_LINKED = (main.c, pdb.c, usrdb.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, sa.8, extern.h, pathnames.h); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_COMPILEROPTIONS = "-DKERNEL_PRIVATE"; - NEXTSTEP_INSTALLDIR = /usr/bin; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_INSTALLDIR = /bin; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = sa; - PROJECTTYPE = Tool; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_INSTALLDIR = /Library/Executables; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/sa.tproj/extern.h b/sa.tproj/extern.h deleted file mode 100644 index f77282b..0000000 --- a/sa.tproj/extern.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1994 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/sa/extern.h,v 1.5 2002/07/11 22:11:20 alfred Exp $ - */ - -#include -#include -#include - -/* structures */ - -struct cmdinfo { - char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */ - u_long ci_uid; /* user id */ - u_quad_t ci_calls; /* number of calls */ - u_quad_t ci_etime; /* elapsed time */ - u_quad_t ci_utime; /* user time */ - u_quad_t ci_stime; /* system time */ - u_quad_t ci_mem; /* memory use */ - u_quad_t ci_io; /* number of disk i/o ops */ - u_int ci_flags; /* flags; see below */ -}; -#define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */ - -struct userinfo { - u_long ui_uid; /* user id; for consistency */ - u_quad_t ui_calls; /* number of invocations */ - u_quad_t ui_utime; /* user time */ - u_quad_t ui_stime; /* system time */ - u_quad_t ui_mem; /* memory use */ - u_quad_t ui_io; /* number of disk i/o ops */ -}; - -/* typedefs */ - -typedef int (*cmpf_t)(const DBT *, const DBT *); - -/* external functions in pdb.c */ -int pacct_init(void); -void pacct_destroy(void); -int pacct_add(const struct cmdinfo *); -int pacct_update(void); -void pacct_print(void); - -/* external functions in usrdb.c */ -int usracct_init(void); -void usracct_destroy(void); -int usracct_add(const struct cmdinfo *); -int usracct_update(void); -void usracct_print(void); - -/* variables */ - -extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; -extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; -extern u_quad_t cutoff; -extern cmpf_t sa_cmp; - -/* some #defines to help with db's stupidity */ - -#define DB_CLOSE(db) \ - ((*(db)->close)(db)) -#define DB_GET(db, key, data, flags) \ - ((*(db)->get)((db), (key), (data), (flags))) -#define DB_PUT(db, key, data, flags) \ - ((*(db)->put)((db), (key), (data), (flags))) -#define DB_SYNC(db, flags) \ - ((*(db)->sync)((db), (flags))) -#define DB_SEQ(db, key, data, flags) \ - ((*(db)->seq)((db), (key), (data), (flags))) diff --git a/sa.tproj/main.c b/sa.tproj/main.c deleted file mode 100644 index 4bc068d..0000000 --- a/sa.tproj/main.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * Copyright (c) 1994 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1994 Christopher G. Demetriou\n\ - All rights reserved.\n"; -#endif - -#ifndef lint -static const char rcsid[] = - "$FreeBSD: src/usr.sbin/sa/main.c,v 1.12 2002/07/15 16:05:15 des Exp $"; -#endif /* not lint */ - -/* - * sa: system accounting - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "extern.h" -#include "pathnames.h" - -static int acct_load(char *, int); -static u_quad_t decode_comp_t(comp_t); -static int cmp_comm(const char *, const char *); -static int cmp_usrsys(const DBT *, const DBT *); -static int cmp_avgusrsys(const DBT *, const DBT *); -static int cmp_dkio(const DBT *, const DBT *); -static int cmp_avgdkio(const DBT *, const DBT *); -static int cmp_cpumem(const DBT *, const DBT *); -static int cmp_avgcpumem(const DBT *, const DBT *); -static int cmp_calls(const DBT *, const DBT *); -static void usage(void); - -int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; -int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; -u_quad_t cutoff = 1; - -static char *dfltargv[] = { NULL }; -static int dfltargc = (sizeof dfltargv/sizeof(char *)); - -/* default to comparing by sum of user + system time */ -cmpf_t sa_cmp = cmp_usrsys; - -int -main(int argc, char **argv) -{ - char ch; - char pathacct[] = _PATH_ACCT; - int error = 0; - - dfltargv[0] = pathacct; - - while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1) - switch (ch) { - case 'a': - /* print all commands */ - aflag = 1; - break; - case 'b': - /* sort by per-call user/system time average */ - bflag = 1; - sa_cmp = cmp_avgusrsys; - break; - case 'c': - /* print percentage total time */ - cflag = 1; - break; - case 'd': - /* sort by averge number of disk I/O ops */ - dflag = 1; - sa_cmp = cmp_avgdkio; - break; - case 'D': - /* print and sort by total disk I/O ops */ - Dflag = 1; - sa_cmp = cmp_dkio; - break; - case 'f': - /* force no interactive threshold comprison */ - fflag = 1; - break; - case 'i': - /* do not read in summary file */ - iflag = 1; - break; - case 'j': - /* instead of total minutes, give sec/call */ - jflag = 1; - break; - case 'k': - /* sort by cpu-time average memory usage */ - kflag = 1; - sa_cmp = cmp_avgcpumem; - break; - case 'K': - /* print and sort by cpu-storage integral */ - sa_cmp = cmp_cpumem; - Kflag = 1; - break; - case 'l': - /* separate system and user time */ - lflag = 1; - break; - case 'm': - /* print procs and time per-user */ - mflag = 1; - break; - case 'n': - /* sort by number of calls */ - sa_cmp = cmp_calls; - break; - case 'q': - /* quiet; error messages only */ - qflag = 1; - break; - case 'r': - /* reverse order of sort */ - rflag = 1; - break; - case 's': - /* merge accounting file into summaries */ - sflag = 1; - break; - case 't': - /* report ratio of user and system times */ - tflag = 1; - break; - case 'u': - /* first, print uid and command name */ - uflag = 1; - break; - case 'v': - /* cull junk */ - vflag = 1; - cutoff = atoi(optarg); - break; - case '?': - default: - usage(); - } - - argc -= optind; - argv += optind; - - /* various argument checking */ - if (fflag && !vflag) - errx(1, "only one of -f requires -v"); - if (fflag && aflag) - errx(1, "only one of -a and -v may be specified"); - /* XXX need more argument checking */ - - if (!uflag) { - /* initialize tables */ - if ((sflag || (!mflag && !qflag)) && pacct_init() != 0) - errx(1, "process accounting initialization failed"); - if ((sflag || (mflag && !qflag)) && usracct_init() != 0) - errx(1, "user accounting initialization failed"); - } - - if (argc == 0) { - argc = dfltargc; - argv = dfltargv; - } - - /* for each file specified */ - for (; argc > 0; argc--, argv++) { - int fd; - - /* - * load the accounting data from the file. - * if it fails, go on to the next file. - */ - fd = acct_load(argv[0], sflag); - if (fd < 0) - continue; - - if (!uflag && sflag) { -#ifndef DEBUG - sigset_t nmask, omask; - int unmask = 1; - - /* - * block most signals so we aren't interrupted during - * the update. - */ - if (sigfillset(&nmask) == -1) { - warn("sigfillset"); - unmask = 0; - error = 1; - } - if (unmask && - (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1)) { - warn("couldn't set signal mask"); - unmask = 0; - error = 1; - } -#endif /* DEBUG */ - - /* - * truncate the accounting data file ASAP, to avoid - * losing data. don't worry about errors in updating - * the saved stats; better to underbill than overbill, - * but we want every accounting record intact. - */ - if (ftruncate(fd, 0) == -1) { - warn("couldn't truncate %s", *argv); - error = 1; - } - - /* - * update saved user and process accounting data. - * note errors for later. - */ - if (pacct_update() != 0 || usracct_update() != 0) - error = 1; - -#ifndef DEBUG - /* - * restore signals - */ - if (unmask && - (sigprocmask(SIG_SETMASK, &omask, NULL) == -1)) { - warn("couldn't restore signal mask"); - error = 1; - } -#endif /* DEBUG */ - } - - /* - * close the opened accounting file - */ - if (close(fd) == -1) { - warn("close %s", *argv); - error = 1; - } - } - - if (!uflag && !qflag) { - /* print any results we may have obtained. */ - if (!mflag) - pacct_print(); - else - usracct_print(); - } - - if (!uflag) { - /* finally, deallocate databases */ - if (sflag || (!mflag && !qflag)) - pacct_destroy(); - if (sflag || (mflag && !qflag)) - usracct_destroy(); - } - - exit(error); -} - -static void -usage() -{ - (void)fprintf(stderr, - "usage: sa [-abcdDfijkKlmnqrstu] [-v cutoff] [file ...]\n"); - exit(1); -} - -static int -acct_load(pn, wr) - char *pn; - int wr; -{ - struct acct ac; - struct cmdinfo ci; - ssize_t rv; - int fd, i; - - /* - * open the file - */ - fd = open(pn, wr ? O_RDWR : O_RDONLY, 0); - if (fd == -1) { - warn("open %s %s", pn, wr ? "for read/write" : "read-only"); - return (-1); - } - - /* - * read all we can; don't stat and open because more processes - * could exit, and we'd miss them - */ - while (1) { - /* get one accounting entry and punt if there's an error */ - rv = read(fd, &ac, sizeof(struct acct)); - if (rv == -1) - warn("error reading %s", pn); - else if (rv > 0 && rv < (int)sizeof(struct acct)) - warnx("short read of accounting data in %s", pn); - if (rv != sizeof(struct acct)) - break; - - /* decode it */ - ci.ci_calls = 1; - for (i = 0; i < (int)sizeof ac.ac_comm && ac.ac_comm[i] != '\0'; - i++) { - char c = ac.ac_comm[i]; - - if (!isascii(c) || iscntrl(c)) { - ci.ci_comm[i] = '?'; - ci.ci_flags |= CI_UNPRINTABLE; - } else - ci.ci_comm[i] = c; - } - if (ac.ac_flag & AFORK) - ci.ci_comm[i++] = '*'; - ci.ci_comm[i++] = '\0'; - ci.ci_etime = decode_comp_t(ac.ac_etime); - ci.ci_utime = decode_comp_t(ac.ac_utime); - ci.ci_stime = decode_comp_t(ac.ac_stime); - ci.ci_uid = ac.ac_uid; - ci.ci_mem = ac.ac_mem; - ci.ci_io = decode_comp_t(ac.ac_io) / AHZ; - - if (!uflag) { - /* and enter it into the usracct and pacct databases */ - if (sflag || (!mflag && !qflag)) - pacct_add(&ci); - if (sflag || (mflag && !qflag)) - usracct_add(&ci); - } else if (!qflag) - printf("%6lu %12.2f cpu %12juk mem %12ju io %s\n", - ci.ci_uid, - (ci.ci_utime + ci.ci_stime) / (double) AHZ, - (uintmax_t)ci.ci_mem, (uintmax_t)ci.ci_io, - ci.ci_comm); - } - - /* finally, return the file descriptor for possible truncation */ - return (fd); -} - -static u_quad_t -decode_comp_t(comp) - comp_t comp; -{ - u_quad_t rv; - - /* - * for more info on the comp_t format, see: - * /usr/src/sys/kern/kern_acct.c - * /usr/src/sys/sys/acct.h - * /usr/src/usr.bin/lastcomm/lastcomm.c - */ - rv = comp & 0x1fff; /* 13 bit fraction */ - comp >>= 13; /* 3 bit base-8 exponent */ - while (comp--) - rv <<= 3; - - return (rv); -} - -/* sort commands, doing the right thing in terms of reversals */ -static int -cmp_comm(s1, s2) - const char *s1, *s2; -{ - int rv; - - rv = strcmp(s1, s2); - if (rv == 0) - rv = -1; - return (rflag ? rv : -rv); -} - -/* sort by total user and system time */ -static int -cmp_usrsys(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - u_quad_t t1, t2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - t1 = c1.ci_utime + c1.ci_stime; - t2 = c2.ci_utime + c2.ci_stime; - - if (t1 < t2) - return -1; - else if (t1 == t2) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by average user and system time */ -static int -cmp_avgusrsys(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - double t1, t2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - t1 = c1.ci_utime + c1.ci_stime; - t1 /= (double) (c1.ci_calls ? c1.ci_calls : 1); - - t2 = c2.ci_utime + c2.ci_stime; - t2 /= (double) (c2.ci_calls ? c2.ci_calls : 1); - - if (t1 < t2) - return -1; - else if (t1 == t2) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by total number of disk I/O operations */ -static int -cmp_dkio(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - if (c1.ci_io < c2.ci_io) - return -1; - else if (c1.ci_io == c2.ci_io) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by average number of disk I/O operations */ -static int -cmp_avgdkio(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - double n1, n2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - n1 = (double) c1.ci_io / (double) (c1.ci_calls ? c1.ci_calls : 1); - n2 = (double) c2.ci_io / (double) (c2.ci_calls ? c2.ci_calls : 1); - - if (n1 < n2) - return -1; - else if (n1 == n2) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by the cpu-storage integral */ -static int -cmp_cpumem(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - if (c1.ci_mem < c2.ci_mem) - return -1; - else if (c1.ci_mem == c2.ci_mem) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by the cpu-time average memory usage */ -static int -cmp_avgcpumem(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - u_quad_t t1, t2; - double n1, n2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - t1 = c1.ci_utime + c1.ci_stime; - t2 = c2.ci_utime + c2.ci_stime; - - n1 = (double) c1.ci_mem / (double) (t1 ? t1 : 1); - n2 = (double) c2.ci_mem / (double) (t2 ? t2 : 1); - - if (n1 < n2) - return -1; - else if (n1 == n2) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} - -/* sort by the number of invocations */ -static int -cmp_calls(d1, d2) - const DBT *d1, *d2; -{ - struct cmdinfo c1, c2; - - memcpy(&c1, d1->data, sizeof(c1)); - memcpy(&c2, d2->data, sizeof(c2)); - - if (c1.ci_calls < c2.ci_calls) - return -1; - else if (c1.ci_calls == c2.ci_calls) - return (cmp_comm(c1.ci_comm, c2.ci_comm)); - else - return 1; -} diff --git a/sa.tproj/pathnames.h b/sa.tproj/pathnames.h deleted file mode 100644 index 8cb7f44..0000000 --- a/sa.tproj/pathnames.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1994 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/sa/pathnames.h,v 1.4 1999/08/28 01:19:52 peter Exp $ - */ - -#define _PATH_ACCT "/var/account/acct" -#define _PATH_SAVACCT "/var/account/savacct" -#define _PATH_USRACCT "/var/account/usracct" diff --git a/sa.tproj/pdb.c b/sa.tproj/pdb.c deleted file mode 100644 index f0dd48b..0000000 --- a/sa.tproj/pdb.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) 1994 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef lint -static const char rcsid[] = - "$FreeBSD: src/usr.sbin/sa/pdb.c,v 1.9 2002/07/15 16:05:15 des Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "extern.h" -#include "pathnames.h" - -static int check_junk __P((struct cmdinfo *)); -static void add_ci __P((const struct cmdinfo *, struct cmdinfo *)); -static void print_ci __P((const struct cmdinfo *, const struct cmdinfo *)); - -static DB *pacct_db; - -int -pacct_init() -{ - DB *saved_pacct_db; - int error; - - pacct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL); - if (pacct_db == NULL) - return (-1); - - error = 0; - if (!iflag) { - DBT key, data; - int serr, nerr; - - saved_pacct_db = dbopen(_PATH_SAVACCT, O_RDONLY, 0, DB_BTREE, - NULL); - if (saved_pacct_db == NULL) { - error = errno == ENOENT ? 0 : -1; - if (error) - warn("retrieving process accounting summary"); - goto out; - } - - serr = DB_SEQ(saved_pacct_db, &key, &data, R_FIRST); - if (serr < 0) { - warn("retrieving process accounting summary"); - error = -1; - goto closeout; - } - while (serr == 0) { - nerr = DB_PUT(pacct_db, &key, &data, 0); - if (nerr < 0) { - warn("initializing process accounting stats"); - error = -1; - break; - } - - serr = DB_SEQ(saved_pacct_db, &key, &data, R_NEXT); - if (serr < 0) { - warn("retrieving process accounting summary"); - error = -1; - break; - } - } - -closeout: if (DB_CLOSE(saved_pacct_db) < 0) { - warn("closing process accounting summary"); - error = -1; - } - } - -out: if (error != 0) - pacct_destroy(); - return (error); -} - -void -pacct_destroy() -{ - if (DB_CLOSE(pacct_db) < 0) - warn("destroying process accounting stats"); -} - -int -pacct_add(ci) - const struct cmdinfo *ci; -{ - DBT key, data; - struct cmdinfo newci; - char keydata[sizeof ci->ci_comm]; - int rv; - - bcopy(ci->ci_comm, &keydata, sizeof keydata); - key.data = &keydata; - key.size = strlen(keydata); - - rv = DB_GET(pacct_db, &key, &data, 0); - if (rv < 0) { - warn("get key %s from process accounting stats", ci->ci_comm); - return (-1); - } else if (rv == 0) { /* it's there; copy whole thing */ - /* XXX compare size if paranoid */ - /* add the old data to the new data */ - bcopy(data.data, &newci, data.size); - } else { /* it's not there; zero it and copy the key */ - bzero(&newci, sizeof newci); - bcopy(key.data, newci.ci_comm, key.size); - } - - add_ci(ci, &newci); - - data.data = &newci; - data.size = sizeof newci; - rv = DB_PUT(pacct_db, &key, &data, 0); - if (rv < 0) { - warn("add key %s to process accounting stats", ci->ci_comm); - return (-1); - } else if (rv == 1) { - warnx("duplicate key %s in process accounting stats", - ci->ci_comm); - return (-1); - } - - return (0); -} - -int -pacct_update() -{ - DB *saved_pacct_db; - DBT key, data; - int error, serr, nerr; - - saved_pacct_db = dbopen(_PATH_SAVACCT, O_RDWR|O_CREAT|O_TRUNC, 0644, - DB_BTREE, NULL); - if (saved_pacct_db == NULL) { - warn("creating process accounting summary"); - return (-1); - } - - error = 0; - - serr = DB_SEQ(pacct_db, &key, &data, R_FIRST); - if (serr < 0) { - warn("retrieving process accounting stats"); - error = -1; - } - while (serr == 0) { - nerr = DB_PUT(saved_pacct_db, &key, &data, 0); - if (nerr < 0) { - warn("saving process accounting summary"); - error = -1; - break; - } - - serr = DB_SEQ(pacct_db, &key, &data, R_NEXT); - if (serr < 0) { - warn("retrieving process accounting stats"); - error = -1; - break; - } - } - - if (DB_SYNC(saved_pacct_db, 0) < 0) { - warn("syncing process accounting summary"); - error = -1; - } - if (DB_CLOSE(saved_pacct_db) < 0) { - warn("closing process accounting summary"); - error = -1; - } - return error; -} - -void -pacct_print() -{ - BTREEINFO bti; - DBT key, data, ndata; - DB *output_pacct_db; - struct cmdinfo *cip, ci, ci_total, ci_other, ci_junk; - int rv; - - bzero(&ci_total, sizeof ci_total); - strcpy(ci_total.ci_comm, ""); - bzero(&ci_other, sizeof ci_other); - strcpy(ci_other.ci_comm, "***other"); - bzero(&ci_junk, sizeof ci_junk); - strcpy(ci_junk.ci_comm, "**junk**"); - - /* - * Retrieve them into new DB, sorted by appropriate key. - * At the same time, cull 'other' and 'junk' - */ - bzero(&bti, sizeof bti); - bti.compare = sa_cmp; - output_pacct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti); - if (output_pacct_db == NULL) { - warn("couldn't sort process accounting stats"); - return; - } - - ndata.data = NULL; - ndata.size = 0; - rv = DB_SEQ(pacct_db, &key, &data, R_FIRST); - if (rv < 0) - warn("retrieving process accounting stats"); - while (rv == 0) { - cip = (struct cmdinfo *) data.data; - bcopy(cip, &ci, sizeof ci); - - /* add to total */ - add_ci(&ci, &ci_total); - - if (vflag && ci.ci_calls <= cutoff && - (fflag || check_junk(&ci))) { - /* put it into **junk** */ - add_ci(&ci, &ci_junk); - goto next; - } - if (!aflag && - ((ci.ci_flags & CI_UNPRINTABLE) != 0 || ci.ci_calls <= 1)) { - /* put into ***other */ - add_ci(&ci, &ci_other); - goto next; - } - rv = DB_PUT(output_pacct_db, &data, &ndata, 0); - if (rv < 0) - warn("sorting process accounting stats"); - -next: rv = DB_SEQ(pacct_db, &key, &data, R_NEXT); - if (rv < 0) - warn("retrieving process accounting stats"); - } - - /* insert **junk** and ***other */ - if (ci_junk.ci_calls != 0) { - data.data = &ci_junk; - data.size = sizeof ci_junk; - rv = DB_PUT(output_pacct_db, &data, &ndata, 0); - if (rv < 0) - warn("sorting process accounting stats"); - } - if (ci_other.ci_calls != 0) { - data.data = &ci_other; - data.size = sizeof ci_other; - rv = DB_PUT(output_pacct_db, &data, &ndata, 0); - if (rv < 0) - warn("sorting process accounting stats"); - } - - /* print out the total */ - print_ci(&ci_total, &ci_total); - - /* print out; if reversed, print first (smallest) first */ - rv = DB_SEQ(output_pacct_db, &data, &ndata, rflag ? R_FIRST : R_LAST); - if (rv < 0) - warn("retrieving process accounting report"); - while (rv == 0) { - cip = (struct cmdinfo *) data.data; - bcopy(cip, &ci, sizeof ci); - - print_ci(&ci, &ci_total); - - rv = DB_SEQ(output_pacct_db, &data, &ndata, - rflag ? R_NEXT : R_PREV); - if (rv < 0) - warn("retrieving process accounting report"); - } - DB_CLOSE(output_pacct_db); -} - -static int -check_junk(cip) - struct cmdinfo *cip; -{ - char *cp; - size_t len; - - fprintf(stderr, "%s (%ju) -- ", cip->ci_comm, (uintmax_t)cip->ci_calls); - cp = fgetln(stdin, &len); - - return (cp && (cp[0] == 'y' || cp[0] == 'Y')) ? 1 : 0; -} - -static void -add_ci(fromcip, tocip) - const struct cmdinfo *fromcip; - struct cmdinfo *tocip; -{ - tocip->ci_calls += fromcip->ci_calls; - tocip->ci_etime += fromcip->ci_etime; - tocip->ci_utime += fromcip->ci_utime; - tocip->ci_stime += fromcip->ci_stime; - tocip->ci_mem += fromcip->ci_mem; - tocip->ci_io += fromcip->ci_io; -} - -static void -print_ci(cip, totalcip) - const struct cmdinfo *cip, *totalcip; -{ - double t, c; - int uflow; - - c = cip->ci_calls ? cip->ci_calls : 1; - t = (cip->ci_utime + cip->ci_stime) / (double) AHZ; - if (t < 0.01) { - t = 0.01; - uflow = 1; - } else - uflow = 0; - - printf("%8ju ", (uintmax_t)cip->ci_calls); - if (cflag) { - if (cip != totalcip) - printf(" %4.2f%% ", - cip->ci_calls / (double) totalcip->ci_calls); - else - printf(" %4s ", ""); - } - - if (jflag) - printf("%11.2fre ", cip->ci_etime / (double) (AHZ * c)); - else - printf("%11.2fre ", cip->ci_etime / (60.0 * AHZ)); - if (cflag) { - if (cip != totalcip) - printf(" %4.2f%% ", - cip->ci_etime / (double) totalcip->ci_etime); - else - printf(" %4s ", ""); - } - - if (!lflag) { - if (jflag) - printf("%11.2fcp ", t / (double) cip->ci_calls); - else - printf("%11.2fcp ", t / 60.0); - if (cflag) { - if (cip != totalcip) - printf(" %4.2f%% ", - (cip->ci_utime + cip->ci_stime) / (double) - (totalcip->ci_utime + totalcip->ci_stime)); - else - printf(" %4s ", ""); - } - } else { - if (jflag) - printf("%11.2fu ", cip->ci_utime / (double) (AHZ * c)); - else - printf("%11.2fu ", cip->ci_utime / (60.0 * AHZ)); - if (cflag) { - if (cip != totalcip) - printf(" %4.2f%% ", cip->ci_utime / (double) totalcip->ci_utime); - else - printf(" %4s ", ""); - } - if (jflag) - printf("%11.2fs ", cip->ci_stime / (double) (AHZ * c)); - else - printf("%11.2fs ", cip->ci_stime / (60.0 * AHZ)); - if (cflag) { - if (cip != totalcip) - printf(" %4.2f%% ", cip->ci_stime / (double) totalcip->ci_stime); - else - printf(" %4s ", ""); - } - } - - if (tflag) { - if (!uflow) - printf("%8.2fre/cp ", - cip->ci_etime / - (double) (cip->ci_utime + cip->ci_stime)); - else - printf("*ignore* "); - } - - if (Dflag) - printf("%10jutio ", (uintmax_t)cip->ci_io); - else - printf("%8.0favio ", cip->ci_io / c); - - if (Kflag) - printf("%10juk*sec ", (uintmax_t)cip->ci_mem); - else - printf("%8.0fk ", cip->ci_mem / t); - - printf(" %s\n", cip->ci_comm); -} diff --git a/sa.tproj/sa.8 b/sa.tproj/sa.8 deleted file mode 100644 index 4ba9503..0000000 --- a/sa.tproj/sa.8 +++ /dev/null @@ -1,237 +0,0 @@ -.\" -.\" Copyright (c) 1994 Christopher G. Demetriou -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Christopher G. Demetriou. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/usr.sbin/sa/sa.8,v 1.15 2002/07/14 14:46:01 charnier Exp $ -.\" -.Dd February 25, 1994 -.Dt SA 8 -.Os -.Sh NAME -.Nm sa -.Nd print system accounting statistics -.Sh SYNOPSIS -.Nm -.Op Fl abcdDfijkKlmnqrstu -.Op Fl v Ar cutoff -.Op Ar -.Sh DESCRIPTION -The -.Nm -utility reports on, cleans up, -and generally maintains system -accounting files. -.Pp -The -.Nm -utility is able to condense the information in -.Pa /var/account/acct -into the summary files -.Pa /var/account/savacct -and -.Pa /var/account/usracct , -which contain system statistics according -to command name and login id, respectively. -This condensation is desirable because on a -large system, -.Pa /var/account/acct -can grow by hundreds of blocks per day. -The summary files are normally read before -the accounting file, so that reports include -all available information. -.Pp -If file names are supplied, they are read instead of -.Pa /var/account/acct . -After each file is read, if the summary -files are being updated, an updated summary will -be saved to disk. Only one report is printed, -after the last file is processed. -.Pp -The labels used in the output indicate the following, except -where otherwise specified by individual options: -.Bl -tag -width k*sec -.It Dv avio -Average number of I/O operations per execution -.It Dv cp -Sum of user and system time, in minutes -.It Dv cpu -Same as -.Dv cp -.It Dv k -CPU-time averaged core usage, in 1k units -.It Dv k*sec -CPU storage integral, in 1k-core seconds -.It Dv re -Real time, in minutes -.It Dv s -System time, in minutes -.It Dv tio -Total number of I/O operations -.It Dv u -User time, in minutes -.El -.Pp -The options to -.Nm -are: -.Bl -tag -width Ds -.It Fl a -List all command names, including those containing unprintable -characters and those used only once. By default, -.Nm -places all names containing unprintable characters and -those used only once under the name ``***other''. -.It Fl b -If printing command statistics, sort output by the sum of user and system -time divided by number of calls. -.It Fl c -In addition to the number of calls and the user, system and real times -for each command, print their percentage of the total over all commands. -.It Fl d -If printing command statistics, sort by the average number of disk -I/O operations. If printing user statistics, print the average number of -disk I/O operations per user. -.It Fl D -If printing command statistics, sort and print by the total number -of disk I/O operations. -.It Fl f -Force no interactive threshold comparison with the -.Fl v -option. -.It Fl i -Do not read in the summary files. -.It Fl j -Instead of the total minutes per category, give seconds per call. -.It Fl k -If printing command statistics, sort by the cpu-time average memory -usage. If printing user statistics, print the cpu-time average -memory usage. -.It Fl K -If printing command statistics, print and sort by the cpu-storage integral. -.It Fl l -Separate system and user time; normally they are combined. -.It Fl m -Print per-user statistics rather than per-command statistics. -.It Fl n -Sort by number of calls. -.It Fl q -Create no output other than error messages. -.It Fl r -Reverse order of sort. -.It Fl s -Truncate the accounting files when done and merge their data -into the summary files. -.It Fl t -For each command, report the ratio of real time to the sum -of user and system cpu times. -If the cpu time is too small to report, ``*ignore*'' appears in -this field. -.It Fl u -Superseding all other flags, for each entry -in the accounting file, print the user ID, total seconds of cpu usage, -total memory usage, number of I/O operations performed, and -command name. -.It Fl v Ar cutoff -For each command used -.Ar cutoff -times or fewer, print the command name and await a reply -from the terminal. If the reply begins with ``y'', add -the command to the category ``**junk**''. This flag is -used to strip garbage from the report. -.El -.Pp -By default, per-command statistics will be printed. The number of -calls, the total elapsed time in minutes, total cpu and user time -in minutes, average number of I/O operations, and CPU-time -averaged core usage will be printed. If the -.Fl m -option is specified, per-user statistics will be printed, including -the user name, the number of commands invoked, total cpu time used -(in minutes), total number of I/O operations, and CPU storage integral -for each user. If the -.Fl u -option is specified, the uid, user and system time (in seconds), -CPU storage integral, I/O usage, and command name will be printed -for each entry in the accounting data file. -.Pp -If the -.Fl u -flag is specified, all flags other than -.Fl q -are ignored. If the -.Fl m -flag is specified, only the -.Fl b , -.Fl d , -.Fl i , -.Fl k , -.Fl q , -and -.Fl s -flags are honored. -.Sh DIAGNOSTICS -.Ex -std -.Sh FILES -.Bl -tag -width /var/account/usracct -compact -.It Pa /var/account/acct -raw accounting data file -.It Pa /var/account/savacct -per-command accounting summary database -.It Pa /var/account/usracct -per-user accounting summary database -.El -.Sh SEE ALSO -.Xr lastcomm 1 , -.Xr acct 5 , -.Xr ac 8 , -.Xr accton 8 -.Sh BUGS -The number of options to this program is absurd, especially considering -that there's not much logic behind their lettering. -.Pp -The field labels should be more consistent. -.Pp -The VM system does not record the CPU storage integral. -.Sh CAVEATS -While the behavior of the options in this version of -.Nm -was modeled after the original version, there are some intentional -differences and undoubtedly some unintentional ones as well. In -particular, the -.Fl q -option has been added, and the -.Fl m -option now understands more options than it used to. -.Pp -The formats of the summary files created by this version of -.Nm -are very different from the those used by the original version. -This is not considered a problem, however, because the accounting record -format has changed as well (since user ids are now 32 bits). -.Sh AUTHORS -.An Chris G. Demetriou Aq cgd@postgres.berkeley.edu diff --git a/sa.tproj/usrdb.c b/sa.tproj/usrdb.c deleted file mode 100644 index dda96ae..0000000 --- a/sa.tproj/usrdb.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 1994 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef lint -static const char rcsid[] = - "$FreeBSD: src/usr.sbin/sa/usrdb.c,v 1.12 2002/07/15 16:05:15 des Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "extern.h" -#include "pathnames.h" - -static int uid_compare __P((const DBT *, const DBT *)); - -static DB *usracct_db; - -int -usracct_init() -{ - DB *saved_usracct_db; - BTREEINFO bti; - int error; - - bzero(&bti, sizeof bti); - bti.compare = uid_compare; - - usracct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti); - if (usracct_db == NULL) - return (-1); - - error = 0; - if (!iflag) { - DBT key, data; - int serr, nerr; - - saved_usracct_db = dbopen(_PATH_USRACCT, O_RDONLY, 0, DB_BTREE, - &bti); - if (saved_usracct_db == NULL) { - error = (errno == ENOENT) ? 0 : -1; - if (error) - warn("retrieving user accounting summary"); - goto out; - } - - serr = DB_SEQ(saved_usracct_db, &key, &data, R_FIRST); - if (serr < 0) { - warn("retrieving user accounting summary"); - error = -1; - goto closeout; - } - while (serr == 0) { - nerr = DB_PUT(usracct_db, &key, &data, 0); - if (nerr < 0) { - warn("initializing user accounting stats"); - error = -1; - break; - } - - serr = DB_SEQ(saved_usracct_db, &key, &data, R_NEXT); - if (serr < 0) { - warn("retrieving user accounting summary"); - error = -1; - break; - } - } - -closeout: - if (DB_CLOSE(saved_usracct_db) < 0) { - warn("closing user accounting summary"); - error = -1; - } - } - -out: - if (error != 0) - usracct_destroy(); - return (error); -} - -void -usracct_destroy() -{ - if (DB_CLOSE(usracct_db) < 0) - warn("destroying user accounting stats"); -} - -int -usracct_add(ci) - const struct cmdinfo *ci; -{ - DBT key, data; - struct userinfo newui; - u_long uid; - int rv; - - uid = ci->ci_uid; - key.data = &uid; - key.size = sizeof uid; - - rv = DB_GET(usracct_db, &key, &data, 0); - if (rv < 0) { - warn("get key %lu from user accounting stats", uid); - return (-1); - } else if (rv == 0) { /* it's there; copy whole thing */ - /* add the old data to the new data */ - bcopy(data.data, &newui, data.size); - if (newui.ui_uid != uid) { - warnx("key %lu != expected record number %lu", - newui.ui_uid, uid); - warnx("inconsistent user accounting stats"); - return (-1); - } - } else { /* it's not there; zero it and copy the key */ - bzero(&newui, sizeof newui); - newui.ui_uid = ci->ci_uid; - } - - newui.ui_calls += ci->ci_calls; - newui.ui_utime += ci->ci_utime; - newui.ui_stime += ci->ci_stime; - newui.ui_mem += ci->ci_mem; - newui.ui_io += ci->ci_io; - - data.data = &newui; - data.size = sizeof newui; - rv = DB_PUT(usracct_db, &key, &data, 0); - if (rv < 0) { - warn("add key %lu to user accounting stats", uid); - return (-1); - } else if (rv != 0) { - warnx("DB_PUT returned 1"); - return (-1); - } - - return (0); -} - -int -usracct_update() -{ - DB *saved_usracct_db; - DBT key, data; - BTREEINFO bti; - int error, serr, nerr; - - bzero(&bti, sizeof bti); - bti.compare = uid_compare; - - saved_usracct_db = dbopen(_PATH_USRACCT, O_RDWR|O_CREAT|O_TRUNC, 0644, - DB_BTREE, &bti); - if (saved_usracct_db == NULL) { - warn("creating user accounting summary"); - return (-1); - } - - error = 0; - - serr = DB_SEQ(usracct_db, &key, &data, R_FIRST); - if (serr < 0) { - warn("retrieving user accounting stats"); - error = -1; - } - while (serr == 0) { - nerr = DB_PUT(saved_usracct_db, &key, &data, 0); - if (nerr < 0) { - warn("saving user accounting summary"); - error = -1; - break; - } - - serr = DB_SEQ(usracct_db, &key, &data, R_NEXT); - if (serr < 0) { - warn("retrieving user accounting stats"); - error = -1; - break; - } - } - - if (DB_SYNC(saved_usracct_db, 0) < 0) { - warn("syncing process accounting summary"); - error = -1; - } - if (DB_CLOSE(saved_usracct_db) < 0) { - warn("closing process accounting summary"); - error = -1; - } - return error; -} - -void -usracct_print() -{ - DBT key, data; - struct userinfo uistore, *ui = &uistore; - double t; - int rv; - - rv = DB_SEQ(usracct_db, &key, &data, R_FIRST); - if (rv < 0) - warn("retrieving user accounting stats"); - - while (rv == 0) { - memcpy(ui, data.data, sizeof(struct userinfo)); - - printf("%-*s %9ju ", MAXLOGNAME - 1, - user_from_uid(ui->ui_uid, 0), (uintmax_t)ui->ui_calls); - - t = (double) (ui->ui_utime + ui->ui_stime) / - (double) AHZ; - if (t < 0.0001) /* kill divide by zero */ - t = 0.0001; - - printf("%12.2f%s ", t / 60.0, "cpu"); - - /* ui->ui_calls is always != 0 */ - if (dflag) - printf("%12ju%s", - (uintmax_t)(ui->ui_io / ui->ui_calls), "avio"); - else - printf("%12ju%s", (uintmax_t)ui->ui_io, "tio"); - - /* t is always >= 0.0001; see above */ - if (kflag) - printf("%12.0f%s", ui->ui_mem / t, "k"); - else - printf("%12ju%s", (uintmax_t)ui->ui_mem, "k*sec"); - - printf("\n"); - - rv = DB_SEQ(usracct_db, &key, &data, R_NEXT); - if (rv < 0) - warn("retrieving user accounting stats"); - } -} - -static int -uid_compare(k1, k2) - const DBT *k1, *k2; -{ - u_long d1, d2; - - bcopy(k1->data, &d1, sizeof d1); - bcopy(k2->data, &d2, sizeof d2); - - if (d1 < d2) - return -1; - else if (d1 == d2) - return 0; - else - return 1; -} diff --git a/sadc.tproj/Makefile b/sadc.tproj/Makefile new file mode 100644 index 0000000..f5649e6 --- /dev/null +++ b/sadc.tproj/Makefile @@ -0,0 +1,54 @@ +# +# Generated by the Apple Project Builder. +# +# NOTE: Do NOT change this file -- Project Builder maintains it. +# +# Put all of your customizations in files called Makefile.preamble +# and Makefile.postamble (both optional), and Makefile will include them. +# + +NAME = sadc + +PROJECTVERSION = 2.8 +PROJECT_TYPE = Tool + +HFILES = sadc.h + +CFILES = sadc.c + +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble sa1.8 sa1.sh\ + sa2.8 sa2.sh sadc.8 + + +MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles +CODE_GEN_STYLE = DYNAMIC +MAKEFILE = tool.make +NEXTSTEP_INSTALLDIR = /usr/lib/sa +WINDOWS_INSTALLDIR = /Library/Executables +PDO_UNIX_INSTALLDIR = /bin +LIBS = +DEBUG_LIBS = $(LIBS) +PROF_LIBS = $(LIBS) + +FRAMEWORKS = -framework CoreFoundation -framework IOKit + +PROJECT_HEADERS = sadc.h + + + +NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc +WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc +PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc +NEXTSTEP_JAVA_COMPILER = /usr/bin/javac +WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe +PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac + +include $(MAKEFILEDIR)/platform.make + +-include Makefile.preamble + +include $(MAKEFILEDIR)/$(MAKEFILE) + +-include Makefile.postamble + +-include Makefile.dependencies diff --git a/sadc.tproj/Makefile.postamble b/sadc.tproj/Makefile.postamble new file mode 100644 index 0000000..e7b87a9 --- /dev/null +++ b/sadc.tproj/Makefile.postamble @@ -0,0 +1,131 @@ +############################################################################### +# Makefile.postamble +# Copyright 1997, Apple Computer, Inc. +# +# Use this makefile, which is imported after all other makefiles, to +# override attributes for a project's Makefile environment. This allows you +# to take advantage of the environment set up by the other Makefiles. +# You can also define custom rules at the end of this file. +# +############################################################################### +# +# These variables are exported by the standard makefiles and can be +# used in any customizations you make. They are *outputs* of +# the Makefiles and should be used, not set. +# +# PRODUCTS: products to install. All of these products will be placed in +# the directory $(DSTROOT)$(INSTALLDIR) +# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. +# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. +# OFILE_DIR: Directory into which .o object files are generated. +# DERIVED_SRC_DIR: Directory used for all other derived files +# +# ALL_CFLAGS: flags to pass when compiling .c files +# ALL_MFLAGS: flags to pass when compiling .m files +# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files +# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files +# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files +# ALL_LDFLAGS: flags to pass when linking object files +# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files +# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files +# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files +# ALL_YFLAGS: flags to pass when processing .y (yacc) files +# ALL_LFLAGS: flags to pass when processing .l (lex) files +# +# NAME: name of application, bundle, subproject, palette, etc. +# LANGUAGES: langages in which the project is written (default "English") +# English_RESOURCES: localized resources (e.g. nib's, images) of project +# GLOBAL_RESOURCES: non-localized resources of project +# +# SRCROOT: base directory in which to place the new source files +# SRCPATH: relative path from SRCROOT to present subdirectory +# +# INSTALLDIR: Directory the product will be installed into by 'install' target +# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget +# to prefix this with DSTROOT when you use it. +# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget +# to prefix this with DSTROOT when you use it. +# +# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) +# +############################################################################### + +# Some compiler flags can be overridden here for certain build situations. +# +# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) + +WARNING_CFLAGS = -Wall + +# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults +# to -g) +# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) +# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults +# to -O) +# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults +# to -pg -DPROFILE) +# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to +# the include path (defaults to -I.) +# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags +# passed to ld/libtool (defaults to nothing) + + +# Library and Framework projects only: +# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked +# against the framework will run against the correct version even if +# the current version of the framework changes. You may override this +# to "" as an alternative to using the DYLD_LIBRARY_PATH during your +# development cycle, but be sure to restore it before installing. + + +# Ownership and permissions of files installed by 'install' target + +#INSTALL_AS_USER = root + # User/group ownership +#INSTALL_AS_GROUP = wheel + # (probably want to set both of these) +#INSTALL_PERMISSIONS = + # If set, 'install' chmod's executable to this + + +# Options to strip. Note: -S strips debugging symbols (executables can be stripped +# down further with -x or, if they load no bundles, with no options at all). + +#STRIPFLAGS = -S + + +######################################################################### +# Put rules to extend the behavior of the standard Makefiles here. Include them in +# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. +# +# You should avoid redefining things like "install" or "app", as they are +# owned by the top-level Makefile API and no context has been set up for where +# derived files should go. +# + +INSTALL_AS_USER = root +INSTALL_PERMISSIONS = 4555 +INSTALLDIR = /usr/lib/sa +LOGDIR = /private/var/log/sa +SHAREDIR = /usr/share +MANDIR = $(SHAREDIR)/man/man8 + + +sa1: sa1.sh + $(CP) sa1.sh ${SYM_DIR}/sa1 + +sa2: sa2.sh + $(CP) sa2.sh ${SYM_DIR}/sa2 + +install-shell-scripts: + $(MKDIRS) $(DSTROOT)/$(LOGDIR) + $(MKDIRS) $(DSTROOT)/$(INSTALLDIR) + $(CP) -p ${SYM_DIR}/sa1 $(DSTROOT)$(INSTALLDIR)/sa1 + $(CHMOD) 555 $(DSTROOT)$(INSTALLDIR)/sa1 + $(CP) -p ${SYM_DIR}/sa2 $(DSTROOT)$(INSTALLDIR)/sa2 + $(CHMOD) 555 $(DSTROOT)$(INSTALLDIR)/sa2 + +install-man-pages: + $(MKDIRS) $(DSTROOT)$(MANDIR) + install -c -m 444 sadc.8 $(DSTROOT)$(MANDIR)/sadc.8 + install -c -m 444 sa1.8 $(DSTROOT)$(MANDIR)/sa1.8 + install -c -m 444 sa2.8 $(DSTROOT)$(MANDIR)/sa2.8 diff --git a/sadc.tproj/Makefile.preamble b/sadc.tproj/Makefile.preamble new file mode 100644 index 0000000..43409d1 --- /dev/null +++ b/sadc.tproj/Makefile.preamble @@ -0,0 +1,143 @@ +############################################################################### +# Makefile.preamble +# Copyright 1997, Apple Computer, Inc. +# +# Use this makefile for configuring the standard application makefiles +# associated with ProjectBuilder. It is included before the main makefile. +# In Makefile.preamble you set attributes for a project, so they are available +# to the project's makefiles. In contrast, you typically write additional rules or +# override built-in behavior in the Makefile.postamble. +# +# Each directory in a project tree (main project plus subprojects) should +# have its own Makefile.preamble and Makefile.postamble. +############################################################################### +# +# Before the main makefile is included for this project, you may set: +# +# MAKEFILEDIR: Directory in which to find $(MAKEFILE) +# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) + +# Compiler/linker flags added to the defaults: The OTHER_* variables will be +# inherited by all nested sub-projects, but the LOCAL_ versions of the same +# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's +# Build Attributes inspector if at all possible. To override the default flags +# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The +# variables below are *inputs* to the build process and distinct from the override +# settings done (less often) in the Makefile.postamble. +# +# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler +# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, +# .cc, .cxx, .C, and .M files. There is no need to respecify the +# flags in OTHER_MFLAGS, etc. +# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files +# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files +# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files +# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when +# precompiling header files +# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool +# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap +# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen +# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc +# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex + +# These variables provide hooks enabling you to add behavior at almost every +# stage of the make: +# +# BEFORE_PREBUILD: targets to build before installing headers for a subproject +# AFTER_PREBUILD: targets to build after installing headers for a subproject +# BEFORE_BUILD_RECURSION: targets to make before building subprojects +# BEFORE_BUILD: targets to make before a build, but after subprojects +# AFTER_BUILD: targets to make after a build +# +# BEFORE_INSTALL: targets to build before installing the product + +BEFORE_INSTALL += sa1 sa2 + +# AFTER_INSTALL: targets to build after installing the product + +AFTER_INSTALL += install-shell-scripts install-man-pages + +# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject +# AFTER_POSTINSTALL: targts to build after postinstalling every subproject +# +# BEFORE_INSTALLHDRS: targets to build before installing headers for a +# subproject +# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject +# BEFORE_INSTALLSRC: targets to build before installing source for a subproject +# AFTER_INSTALLSRC: targets to build after installing source for a subproject +# +# BEFORE_DEPEND: targets to build before building dependencies for a +# subproject +# AFTER_DEPEND: targets to build after building dependencies for a +# subproject +# +# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is +# updated every time the project is built. If NO, the dependency +# file is only built when the depend target is invoked. + +# Framework-related variables: +# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates +# where to put the framework's DLL. This variable defaults to +# $(INSTALLDIR)/../Executables + +# Library-related variables: +# PUBLIC_HEADER_DIR: Determines where public exported header files +# should be installed. Do not include $(DSTROOT) in this value -- +# it is prefixed automatically. For library projects you should +# set this to something like /Developer/Headers/$(NAME). Do not set +# this variable for framework projects unless you do not want the +# header files included in the framework. +# PRIVATE_HEADER_DIR: Determines where private exported header files +# should be installed. Do not include $(DSTROOT) in this value -- +# it is prefixed automatically. +# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines +# whether the libraries produced are statically linked when they +# are used or if they are dynamically loadable. This defaults to +# DYNAMIC. +# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates +# where to put the library's DLL. This variable defaults to +# $(INSTALLDIR)/../Executables +# +# INSTALL_AS_USER: owner of the intalled products (default root) +# INSTALL_AS_GROUP: group of the installed products (default wheel) +# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) +# +# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be +# passed on the command line to recursive invocations of make. Note that +# the values in OTHER_*FLAGS are inherited by subprojects automatically -- +# you do not have to (and shouldn't) add OTHER_*FLAGS to +# OTHER_RECURSIVE_VARIABLES. + +# Additional headers to export beyond those in the PB.project: +# OTHER_PUBLIC_HEADERS +# OTHER_PROJECT_HEADERS +# OTHER_PRIVATE_HEADERS + +# Additional files for the project's product: <> +# OTHER_RESOURCES: (non-localized) resources for this project +# OTHER_OFILES: relocatables to be linked into this project +# OTHER_LIBS: more libraries to link against +# OTHER_PRODUCT_DEPENDS: other dependencies of this project +# OTHER_SOURCEFILES: other source files maintained by .pre/postamble +# OTHER_GARBAGE: additional files to be removed by `make clean' + +# Set this to YES if you don't want a final libtool call for a library/framework. +# BUILD_OFILES_LIST_ONLY + +# To include a version string, project source must exist in a directory named +# $(NAME).%d[.%d][.%d] and the following line must be uncommented. +# OTHER_GENERATED_OFILES = $(VERS_OFILE) + +# This definition will suppress stripping of debug symbols when an executable +# is installed. By default it is YES. +# STRIP_ON_INSTALL = NO + +# Uncomment to suppress generation of a KeyValueCoding index when installing +# frameworks (This index is used by WOB and IB to determine keys available +# for an object). Set to YES by default. +# PREINDEX_FRAMEWORK = NO + +# Change this definition to install projects somewhere other than the +# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems +# and "" on other systems. +DSTROOT = $(HOME) diff --git a/sadc.tproj/PB.project b/sadc.tproj/PB.project new file mode 100644 index 0000000..f81078b --- /dev/null +++ b/sadc.tproj/PB.project @@ -0,0 +1,38 @@ +{ + "DYNAMIC_CODE_GEN" = YES; + FILESTABLE = { + FRAMEWORKS = ("CoreFoundation.framework", "IOKit.framework"); + FRAMEWORKSEARCH = (); + "H_FILES" = ("sadc.h"); + LIBRARYSEARCH = (); + "OTHER_LINKED" = ("sadc.c"); + "OTHER_SOURCES" = ( + "Makefile.preamble", + Makefile, + "Makefile.postamble", + "sa1.8", + "sa1.sh", + "sa2.8", + "sa2.sh", + "sadc.8" + ); + "PROJECT_HEADERS" = ("sadc.h"); + }; + LANGUAGE = English; + MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; + "NEXTSTEP_BUILDTOOL" = "/usr/bin/gnumake"; + "NEXTSTEP_INSTALLDIR" = "/usr/lib/sa"; + "NEXTSTEP_JAVA_COMPILER" = "/usr/bin/javac"; + "NEXTSTEP_OBJCPLUS_COMPILER" = "/usr/bin/cc"; + "PDO_UNIX_BUILDTOOL" = "$NEXT_ROOT/Developer/bin/make"; + "PDO_UNIX_INSTALLDIR" = "/bin"; + "PDO_UNIX_JAVA_COMPILER" = "$(JDKBINDIR)/javac"; + "PDO_UNIX_OBJCPLUS_COMPILER" = "$(NEXTDEV_BIN)/gcc"; + PROJECTNAME = sadc; + PROJECTTYPE = Tool; + PROJECTVERSION = "2.8"; + "WINDOWS_BUILDTOOL" = "$NEXT_ROOT/Developer/Executables/make"; + "WINDOWS_INSTALLDIR" = "/Library/Executables"; + "WINDOWS_JAVA_COMPILER" = "$(JDKBINDIR)/javac.exe"; + "WINDOWS_OBJCPLUS_COMPILER" = "$(DEVDIR)/gcc"; +} diff --git a/sadc.tproj/sa1.8 b/sadc.tproj/sa1.8 new file mode 100644 index 0000000..6468af2 --- /dev/null +++ b/sadc.tproj/sa1.8 @@ -0,0 +1,83 @@ +.\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +.\" +.\" The contents of this file constitute Original Code as defined in and +.\" are subject to the Apple Public Source License Version 1.1 (the +.\" "License"). You may not use this file except in compliance with the +.\" License. Please obtain a copy of the License at +.\" http://www.apple.com/publicsource and read it before using this file. +.\" +.\" This Original Code and all software distributed under the License are +.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +.\" License for the specific language governing rights and limitations +.\" under the License. +.\" +.\" @(#)sadc.8 +.Dd Jul 25 2003 \" DATE +.Dt sa1 8 \" Program name and manual section number +.Os "Mac OS X" +.Sh NAME \" Section Header - required - don't modify +.Nm sa1 +.Nd Generate a system activity daily data file. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm /usr/lib/sa/sa1 +.Op Ar t n \" [t n] +.Sh DESCRIPTION \" Section Header - required - don't modify +The +.Nm +command is a shell script used to invoke the system +activity data collector, +.Nm sadc . +The binary sample data is collected at intervals +.Ar t +seconds apart, in a loop +.Ar n +times. +The binary sample data is written to the standard +daily data file, +.Ar /var/log/sa/sadd +where the +.Ar dd +represents the current day of the month. +.Pp \" Inserts a space +.Nm +is intended to be started by cron. +.Sh EXAMPLE CRON ENTRY +.Bd -literal +# Starting at 8am collect system activity records +# every 20 minutes for 12 hours +# 20 minutes = 1200 seconds +# 12 hours with 3 samples each hour = 36 loops + +0 8 * * 1-5 /usr/lib/sa/sa1 1200 36 + + +# After the 12 hour period, +# collect a system activity report + +30 20 * * 1-5 /usr/lib/sa/sa2 -A + +.Ed +.Pp +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/var/log/sa/sadd" -compact +.It Pa /var/log/sa/sadd +Default daily activity file that holds the binary sampling data. +.Ar dd +are digits that represent the day of the month. +.El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.Xr sa2 8 , +.Xr sadc 8 , +.Xr sar 1 , +.Xr iostat 8 , +.Xr vm_stat 1 , +.Xr netstat 1 , +.Xr top 1 , +.Xr sc_usage 1 , +.Xr fs_usage 1 , +.Xr crontab 1 , +.Xr crontab 5 diff --git a/sadc.tproj/sa1.sh b/sadc.tproj/sa1.sh new file mode 100644 index 0000000..22d46c1 --- /dev/null +++ b/sadc.tproj/sa1.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# /usr/lib/sa/sa1.sh +# Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +# +# @APPLE_LICENSE_HEADER_START@ +# +# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights +# Reserved. This file contains Original Code and/or Modifications of +# Original Code as defined in and that are subject to the Apple Public +# Source License Version 1.0 (the 'License'). You may not use this file +# except in compliance with the License. Please obtain a copy of the +# License at http://www.apple.com/publicsource and read it before using +# this file. +# +# The Original Code and all software distributed under the License are +# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +# License for the specific language governing rights and limitations +# under the License." +# +# @APPLE_LICENSE_HEADER_END@ +# +umask 0022 +DATE=`/bin/date +%d` +ENDIR=/usr/lib/sa +DFILE=/var/log/sa/sa${DATE} +cd ${ENDIR} +if [ $# = 0 ] +then + exec ${ENDIR}/sadc 1 1 ${DFILE} +else + exec ${ENDIR}/sadc $* ${DFILE} +fi diff --git a/sadc.tproj/sa2.8 b/sadc.tproj/sa2.8 new file mode 100644 index 0000000..b1849aa --- /dev/null +++ b/sadc.tproj/sa2.8 @@ -0,0 +1,98 @@ +.\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +.\" +.\" The contents of this file constitute Original Code as defined in and +.\" are subject to the Apple Public Source License Version 1.1 (the +.\" "License"). You may not use this file except in compliance with the +.\" License. Please obtain a copy of the License at +.\" http://www.apple.com/publicsource and read it before using this file. +.\" +.\" This Original Code and all software distributed under the License are +.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +.\" License for the specific language governing rights and limitations +.\" under the License. +.\" +.\" @(#)sadc.8 +.Dd Jul 25 2003 \" DATE +.Dt sa2 8 \" Program name and manual section number +.Os "Mac OS X" +.Sh NAME \" Section Header - required - don't modify +.Nm sa2 +.Nd Generate a system activity daily report file. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm /usr/lib/sa/sa2 +.Op Fl dgpu \" [-dgpu] +.Op Fl n Ar mode \" [-n mode ] +.Op Fl e Ar time \" [-e time] +.Op Fl f Ar filename \" [-f filename] +.Op Fl i Ar seconds \" [-i seconds] +.Op Fl s Ar time \" [-s time] +.Sh DESCRIPTION \" Section Header - required - don't modify +The +.Nm +command is a shell script used to invoke the system +activity reporter +.Nm sar +for purposes of generating the standard default +daily report file. +The report file generated is, +.Ar /var/log/sa/sardd +where the +.Ar dd +represents the current day of the month. +The +.Nm +options are the same as those documented in +.Nm sar(1) . +.Pp \" Inserts a space +When +.Nm +runs, it will also remove data and report files, +found in /var/log/sa, that are more than one week old. +.Pp +The +.Nm +command is intended to be started by cron. +.Pp +.Sh EXAMPLE CRON ENTRY +.Pp +.Bd -literal +# Starting at 8am collect system activity records +# every 20 minutes for 12 hours +# 20 minutes = 1200 seconds +# 12 hours with 3 samples each hour = 36 loops + +0 8 * * 1-5 /usr/lib/sa/sa1 1200 36 + +# After the 12 hour period, +# collect a system activity report + +30 20 * * 1-5 /usr/lib/sa/sa2 -A + +.Ed +.Pp +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/var/log/sa/sardd" -compact +.It Pa /var/log/sa/sardd +Default daily report file. +.It Pa /var/log/sa/sadd +Default daily data file. +.Pp +.Ar dd +are digits that represent the day of the month. +.El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.Xr sa1 8 , +.Xr sadc 8 , +.Xr sar 1 , +.Xr iostat 8 , +.Xr vm_stat 1 , +.Xr netstat 1 , +.Xr top 1 , +.Xr sc_usage 1 , +.Xr fs_usage 1 , +.Xr crontab 1 , +.Xr crontab 5 diff --git a/sadc.tproj/sa2.sh b/sadc.tproj/sa2.sh new file mode 100644 index 0000000..8bb9bbd --- /dev/null +++ b/sadc.tproj/sa2.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# /usr/lib/sa/sa2.sh +# Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +# +# @APPLE_LICENSE_HEADER_START@ +# +# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights +# Reserved. This file contains Original Code and/or Modifications of +# Original Code as defined in and that are subject to the Apple Public +# Source License Version 1.0 (the 'License'). You may not use this file +# except in compliance with the License. Please obtain a copy of the +# License at http://www.apple.com/publicsource and read it before using +# this file. +# +# The Original Code and all software distributed under the License are +# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +# License for the specific language governing rights and limitations +# under the License." +# +# @APPLE_LICENSE_HEADER_END@ +# +umask 0022 +DATE=`/bin/date +%d` +RPT=/var/log/sa/sar${DATE} +ENDIR=/usr/bin +DFILE=/var/log/sa/sa${DATE} +[ -f "$DFILE" ] || exit 0 +cd ${ENDIR} +${ENDIR}/sar $* -f ${DFILE} > ${RPT} +/usr/bin/find /var/log/sa \( -name 'sar??' -o -name 'sa??' \) -mtime +7 -exec /bin/rm -f {} \; diff --git a/sadc.tproj/sadc.8 b/sadc.tproj/sadc.8 new file mode 100644 index 0000000..2ec3ea2 --- /dev/null +++ b/sadc.tproj/sadc.8 @@ -0,0 +1,110 @@ +.\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +.\" +.\" The contents of this file constitute Original Code as defined in and +.\" are subject to the Apple Public Source License Version 1.1 (the +.\" "License"). You may not use this file except in compliance with the +.\" License. Please obtain a copy of the License at +.\" http://www.apple.com/publicsource and read it before using this file. +.\" +.\" This Original Code and all software distributed under the License are +.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +.\" License for the specific language governing rights and limitations +.\" under the License. +.\" +.\" @(#)sadc.8 +.Dd Jul 25 2003 \" DATE +.Dt sadc 8 \" Program name and manual section number +.Os "Mac OS X" +.Sh NAME \" Section Header - required - don't modify +.Nm sadc +.Nd system activity data collector +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm /usr/lib/sa/sadc +.Op Fl m Ar mode \" [-m mode] +.Op Ar t n \" [t n] +.Op Ar ofile \" [ofile] +.Sh DESCRIPTION \" Section Header - required - don't modify +The +.Nm +tool is used to collect cumulative system activity data. +The sample system data is collected at intervals +.Ar t +seconds apart, in a loop +.Ar n +times. +The binary sample data is written to +.Ar ofile +if specified. +Otherwise, the binary data is written to stdout. +If the +.Ar ofile +file does not exist, it is created, otherwise it is truncated. +.Pp \" Inserts a space +.Nm +is intended to be used as the engine behind the +.Nm sar(1) +command, and is not typically invoked on the command line. +Two shell scripts, +.Nm sa1 +and +.Nm sa2 +are provided to drive the typical sampling, saving, and +reporting process. +.Pp +.Sh OPTIONS +The following options modify the way data is collected by +.Nm sadc . +.Bl -tag -width -indent \" Begins a tagged list +.It Fl m Ar mode +Modify the collection of system statistics as specified by +.Ar mode . +Currently only one mode is supported. +.Bl -tag -width -indent \" Begins a tagged list +.It PPP +By default, the collection of ppp network interface statistics +is turned off. +This is because the number of ppp connections can be very high, +causing the raw data file to grow unexpectedly large, +especially when samples are collected at short intervals. +Use the +.Ar PPP +mode to turn the collection back on. +.El +.El +.Pp +.Sh EXAMPLES +/usr/lib/sa/sadc 15 20 /tmp/sample.out +.Pp +This call collects 20 samples at 15 second intervals. +The binary data is written to the /tmp/sample.out file +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/var/log/sa/sadd" -compact +.It Pa /var/log/sa/sadd +Default daily activity file that holds the binary sampling data. +.Ar dd +are digits that represent the day of the month. +.It Pa /usr/lib/sa/sa1 +Shell script used to drive the +.Nm sar +data collection. +.It Pa /usr/lib/sa/sa2 +Shell script used to drive the +.Nm sar +data reporting. +.El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.Xr sa1 8 , +.Xr sa2 8 , +.Xr sar 1 , +.Xr iostat 8 , +.Xr vm_stat 1 , +.Xr netstat 1 , +.Xr top 1 , +.Xr sc_usage 1 , +.Xr fs_usage 1 +.\" .Sh BUGS \" Document known, unremedied bugs + diff --git a/sadc.tproj/sadc.c b/sadc.tproj/sadc.c new file mode 100644 index 0000000..2f1eb87 --- /dev/null +++ b/sadc.tproj/sadc.c @@ -0,0 +1,1001 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#define IOKIT 1 /* to get io_name_t in device_types.h */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +extern int errno; + +FILE *data_fp = (FILE *)0; /* raw data output file pointer */ + + +#define REVISION_HISTORY_DATE 20030718 + +struct record_hdr restart_record = { SAR_RESTART, REVISION_HISTORY_DATE, 0, 0 }; +struct record_hdr timestamp_record = { SAR_TIMESTAMP, 1, 0, 0 }; +struct record_hdr vmstat_record = {SAR_VMSTAT, 1, 1, 0 }; +struct record_hdr cpu_record = {SAR_CPU, 1, 1, 0 }; +struct record_hdr drivestats_record = {SAR_DRIVESTATS, 1, 0, 0 }; +struct record_hdr drivepath_record = {SAR_DRIVEPATH, 1, 1, 0 }; +struct record_hdr netstats_record = {SAR_NETSTATS, 1, 0, 0}; + +/* Compile for verbose output */ + +int t_interval = 0; /* in seconds */ +int n_samples = 1; /* number of sample loops */ +char *ofile = NULL; /* output file */ +int ofd; /* output file descriptor */ +static mach_port_t myHost; +static mach_port_t masterPort; + +/* internal table of drive path mappings */ +struct drivepath *dp_table = NULL; + +/* number of entries in the dp_table */ +int dp_count = 0; + +/* internal table of network interface statistics */ +struct netstats *ns_table = NULL; +int ns_count = 0; + +static kvm_t *kvmd; +static struct nlist nlist_net[2]; +int kvm_init_failed = 0; + +static uid_t realuid; + +int network_mode = 0; + +/* Forward fuction declarations */ +static void exit_usage(); +static void open_datafile(char *); +static void write_record_hdr(struct record_hdr *); +static void write_record_data(char *, int); +static void get_all_stats(); +static void get_vmstat_sample(); +static void get_drivestat_sample(); +static int get_ndrives(); +static int record_device(io_registry_entry_t, struct drivestats *, int ndrives); +static int check_device_path (char *name, char *path, int ndrives); +static void get_netstat_sample(int pppflag); +static int kvm_init(); +static int kread(u_long addr, void *buf, size_t nbytes); + +int +main(argc, argv) + int argc; + char *argv[]; +{ + + char *p; + char ch; + + /* + * Stop being root ASAP. + */ + if (geteuid() != 0) + { + fprintf(stderr, "sadc: must be setuid root or root"); + exit(1); + } + + realuid = getuid(); + seteuid(realuid); + + setvbuf(stdout, (char *)NULL, _IONBF, 0); + + while ((ch=getopt(argc, argv, "m:")) != EOF) { + switch(ch) { + case 'm': + /* Only the PPP mode matters on this collector side */ + /* The reporter side deals with the DEV or EDEV modes */ + if (!strncmp(optarg, "PPP", 3)) + network_mode |= NET_PPP_MODE; + break; + default: + exit_usage(); + break; + } + } + + argc -= optind; + if (argc > 0) + { + if (isdigit(*argv[optind])) + { + /* we expect to have both an interval and a sample count */ + errno=0; + t_interval = strtol(argv[optind], &p, 0); + if (errno || (*p !='\0') || t_interval <= 0) + { + exit_usage(); + } + + optind++; + if ((argc < 2) || (!isdigit(*argv[optind]))) { + exit_usage(); + } + + errno=0; + n_samples = strtol(argv[optind], &p, 0); + if (errno || (*p != '\0') || n_samples <= 0) + { + exit_usage(); + } + + optind++; + if (argc == 3) + { + /* we have an output file */ + ofile = argv[optind]; + } + } + else + { + /* all we have is an output file */ + ofile = argv[optind]; + } + } + + + /* open the output file */ + (void)open_datafile(ofile); + + /* + * Get the Mach private port. + */ + myHost = mach_host_self(); + + /* + * Get the I/O Kit communication handle. + */ + IOMasterPort(bootstrap_port, &masterPort); + + + restart_record.rec_timestamp = time((time_t *)0); + write_record_hdr(&restart_record); + get_all_stats(); /* this is the initial stat collection */ + sleep(t_interval); + + if (n_samples > 0) + { + /* this init sample is not counted */ + timestamp_record.rec_data = time((time_t *)0); /* returns time in + * seconds */ +#if 0 + struct tm *tm; + tm = gmtime(&(timestamp_record.rec_data)); + fprintf(stderr, "timestamp=%ld\n", timestamp_record.rec_data); + fprintf(stderr, "GMTIME offset from UTC in seconds = %ld\n", tm->tm_gmtoff); + fprintf(stderr, "GMTIME secnds=%d, min=%d, hour=%d\n", tm->tm_sec, tm->tm_min, tm->tm_hour); + fprintf(stderr, "asctime = %s\n", asctime(tm)); + + tm=localtime(&(timestamp_record.rec_data)); + fprintf(stderr, "LOCTIME offset from UTC in seconds = %ld\n",tm->tm_gmtoff); + fprintf(stderr, "LOCTIME secnds=%d, min=%d, hour=%d\n", tm->tm_sec, tm->tm_min, tm->tm_hour); + fprintf(stderr, "asctime = %s\n", asctime(tm)); +#endif + + write_record_hdr(×tamp_record); + get_all_stats(); + } + + while (n_samples) + { + sleep(t_interval); + timestamp_record.rec_timestamp = time((time_t *)0); /* returns time in + * seconds */ + write_record_hdr(×tamp_record); + get_all_stats(); + n_samples--; + } + exit(EXIT_SUCCESS); +} + +static void +exit_usage() +{ + fprintf(stderr, "/usr/lib/sa/sadc [-m {PPP}] [t n] [ofile]\n"); + exit(EXIT_FAILURE); +} + +static void +open_datafile(char *path) +{ + if (path == NULL) + { + data_fp = stdout; + return; + } + else + data_fp = fopen(path, "w+"); + + if (!data_fp) + { + /* failed to open path */ + fprintf(stderr, "sadc: failed to open data file [%s]\n", path?path:"stdout"); + exit_usage(); + } +} + +static void +write_record_hdr(hdr) + struct record_hdr *hdr; +{ + errno = 0; + + if (fwrite(hdr, sizeof(struct record_hdr), 1, data_fp) != 1) + { + fprintf(stderr, "sadc: write_record_hdr failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + + fflush(data_fp); + return; +} + +static void +write_record_data(data, size) + char *data; + int size; +{ + errno = 0; + + if (fwrite(data, size, 1, data_fp) != 1) + { + fprintf(stderr, "sadc: write_record_data failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + + fflush(data_fp); + return; +} + + +static void +get_vmstat_sample() +{ + struct vm_statistics stat; + kern_return_t error; + mach_msg_type_number_t count; + + count = HOST_VM_INFO_COUNT; + error = host_statistics(myHost, HOST_VM_INFO, (host_info_t)&stat, &count); + if (error != KERN_SUCCESS) { + fprintf(stderr, "sadc: Error in vm host_statistics(): %s\n", + mach_error_string(error)); + exit(2); + } + + vmstat_record.rec_count = 1; + vmstat_record.rec_size = sizeof(vm_statistics_data_t); + write_record_hdr(&vmstat_record); + write_record_data((char *)&stat, sizeof(vm_statistics_data_t)); +} + +static void +get_cpu_sample() +{ + host_cpu_load_info_data_t cpuload; + kern_return_t error; + mach_msg_type_number_t count; + + count = HOST_CPU_LOAD_INFO_COUNT; + error = host_statistics(myHost, HOST_CPU_LOAD_INFO,(host_info_t)&cpuload, &count); + if (error != KERN_SUCCESS) { + fprintf(stderr, "sadc: Error in cpu host_statistics(): %s", + mach_error_string(error)); + exit(2); + } + + cpu_record.rec_count = 1; + cpu_record.rec_size = sizeof(host_cpu_load_info_data_t); + write_record_hdr(&cpu_record); + write_record_data((char *)&cpuload, sizeof(host_cpu_load_info_data_t)); +} + +static void +get_drivestat_sample() +{ + io_registry_entry_t drive; + io_iterator_t drivelist; + CFMutableDictionaryRef match; + int ndrives; + int i = 0; + long bufsize = 0; + char *buf; + struct drivestats *dbuf; + kern_return_t status; + int error; + + if ((ndrives = get_ndrives()) <= 0) + return; + + /* allocate space to collect stats for all the drives */ + bufsize = ndrives * sizeof(struct drivestats); + buf = (char *) malloc (bufsize); + dbuf = (struct drivestats *)buf; + if (buf) + bzero((char *)buf, bufsize); + else + return; + + /* + * Get an iterator for IOMedia objects. + */ + match = IOServiceMatching("IOMedia"); + + /* Get whole disk info */ + CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue); + + status = IOServiceGetMatchingServices(masterPort, match, &drivelist); + if (status != KERN_SUCCESS) + goto RETURN; + + /* + * Scan all of the IOMedia objects, and for each + * object that has a parent IOBlockStorageDriver, + * record the statistics + * + * XXX What about RAID devices? + */ + error = 1; + i = 0; + while ((drive = IOIteratorNext(drivelist))) + { + if (i < ndrives) + { + if (record_device(drive, &dbuf[i], ndrives)) + { + error = 0; + i++; + } + } + else + { + IOObjectRelease(drive); + break; + } + IOObjectRelease(drive); + } + IOObjectRelease(drivelist); + + if (! error) + { + drivestats_record.rec_count = i; + drivestats_record.rec_size = sizeof (struct drivestats); + write_record_hdr(&drivestats_record); + write_record_data((char *)buf, (i * sizeof(struct drivestats))); + } + + RETURN: + if (buf) + free(buf); + return; +} + +/* + * Determine whether an IORegistryEntry refers to a valid + * I/O device, and if so, record it. + * Return zero: no device recorded + * Return non-zero: device stats recorded + */ +static int +record_device(io_registry_entry_t drive, struct drivestats* drivestat, int ndrives) +{ + io_registry_entry_t parent; + CFDictionaryRef properties, statistics; + CFStringRef name; + CFNumberRef number; + UInt64 value; + kern_return_t status; + int retval = 0; + int drive_id; + io_string_t path; + char BSDName[MAXDRIVENAME + 1]; + + status = IORegistryEntryGetParentEntry(drive, kIOServicePlane, &parent); + if (status != KERN_SUCCESS) + { + /* device has no parent */ + return(retval); + } + + if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) + { + /* + * Get a unique device path identifier. + * Devices available at boot have an Open Firmware Device Tree path. + * The OF path is short and concise and should be first choice. + * Devices that show up after boot, are guaranteed to have + * a Service Plane, hardware unique path. + */ + + bzero(path, sizeof(io_string_t)); + if (IORegistryEntryGetPath(drive, kIODeviceTreePlane, path) != KERN_SUCCESS) + { + if(IORegistryEntryGetPath(drive, kIOServicePlane, path) != KERN_SUCCESS) + /* device has no unique path identifier */ + goto RETURN; + } + retval++; + + /* get drive properties */ + status = IORegistryEntryCreateCFProperties(drive, + (CFMutableDictionaryRef *)&properties, + kCFAllocatorDefault, + kNilOptions); + if (status != KERN_SUCCESS) + { + /* device has no properties */ + goto RETURN; + } + + bzero(BSDName, MAXDRIVENAME+1); + /* get name from properties */ + name = (CFStringRef)CFDictionaryGetValue(properties, + CFSTR(kIOBSDNameKey)); + if (name) { + CFStringGetCString(name, BSDName, + MAXDRIVENAME, CFStringGetSystemEncoding()); + retval++; + } + + /* get blocksize from properties */ + number = (CFNumberRef)CFDictionaryGetValue(properties, + CFSTR(kIOMediaPreferredBlockSizeKey)); + if (number != 0) { + CFNumberGetValue(number, + kCFNumberSInt64Type, &value); + drivestat->blocksize = value; + retval++; + } + CFRelease(properties); + } + else + goto RETURN; + + /* we should have a name and blocksize at a minimum */ + if (retval != 3) + { + retval = FALSE; + goto RETURN; + } + + drive_id = check_device_path (BSDName, path, ndrives); + if (drive_id == -1) + { + retval = FALSE; + goto RETURN; + } + else + drivestat->drivepath_id = drive_id; + + + /* get parent drive properties */ + status = IORegistryEntryCreateCFProperties(parent, + (CFMutableDictionaryRef *)&properties, + kCFAllocatorDefault, + kNilOptions); + if (status != KERN_SUCCESS) + { + /* device has no properties */ + goto RETURN; + } + + /* Obtain the statistics from the parent drive properties. */ + + statistics + = (CFDictionaryRef)CFDictionaryGetValue(properties, + CFSTR(kIOBlockStorageDriverStatisticsKey)); + + if (statistics != 0) + { + /* Get number of reads. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsReadsKey)); + if (number != 0) { + CFNumberGetValue(number, + kCFNumberSInt64Type, &value); + drivestat->Reads = value; + } + + /* Get bytes read. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->BytesRead = value; + } + + /* Get number of writes. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsWritesKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->Writes = value; + } + + /* Get bytes written. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->BytesWritten = value; + } + + /* Get LatentReadTime. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsLatentReadTimeKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->LatentReadTime = value; + } + + /* Get LatentWriteTime. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsLatentWriteTimeKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->LatentWriteTime = value; + } + + /* Get ReadErrors. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsReadErrorsKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->ReadErrors = value; + } + + /* Get WriteErrors. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsWriteErrorsKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->WriteErrors = value; + } + + /* Get ReadRetries. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsReadRetriesKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->ReadRetries = value; + } + + /* Get WriteRetries. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsWriteRetriesKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->WriteRetries = value; + } + + /* Get TotalReadTime. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsTotalReadTimeKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->TotalReadTime = value; + } + + /* Get WriteRetries. */ + number = + (CFNumberRef)CFDictionaryGetValue(statistics, + CFSTR(kIOBlockStorageDriverStatisticsTotalWriteTimeKey)); + if (number != 0) { + CFNumberGetValue(number, kCFNumberSInt64Type, &value); + drivestat->TotalWriteTime = value; + } + + CFRelease(properties); + } /* end if statistics != 0 */ + + RETURN: + IOObjectRelease(parent); + return(retval); +} + + +/* + * find IOMedia objects + * This routine always gives me a lower count on the number + * of disks. I don't know which one to use. + */ +static int +get_ndrives(void) +{ + io_iterator_t drivelist; + io_registry_entry_t drive; + io_registry_entry_t parent; + CFMutableDictionaryRef match; + int error, ndrives; + kern_return_t status; + + /* + * Get an iterator for IOMedia objects. + */ + match = IOServiceMatching("IOMedia"); + CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue); + status = IOServiceGetMatchingServices(masterPort, match, &drivelist); + if (status != KERN_SUCCESS) + return(0); + + /* + * Scan all of the IOMedia objects, and count each + * object that has a parent IOBlockStorageDriver + * + * XXX What about RAID devices? + */ + error = 1; + ndrives = 0; + while ((drive = IOIteratorNext(drivelist))) + { + /* get drive's parent */ + status = IORegistryEntryGetParentEntry(drive, + kIOServicePlane, &parent); + if (status != KERN_SUCCESS) + { + IOObjectRelease(drive); + continue; + } + + if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) + { + error = 0; + ndrives++; + } + IOObjectRelease(parent); + IOObjectRelease(drive); + } + + IOObjectRelease(drivelist); + + return(ndrives); +} + + +/* + * When getting the stats, do it in the order + * of their type. The types that have the most + * data come first in the list if possible. + * This makes the sar reporter tool more efficient, + * because in some cases, it will allocate a buffer + * and keep reusing it as long as the sample data fits. + * When a sample data doesn't fit, it reallocates the buffer + * to a bigger size etc. + */ +void +get_all_stats() +{ + + get_drivestat_sample(); + get_netstat_sample(network_mode); + get_vmstat_sample(); + get_cpu_sample(); +} + + +/* + * An internal table maps the BSDName to a unique ioregistry path. + * The table's index is then used as a unique compressed path, and + * helps track disks that come and go during the sampling intervals. + * This routine finds an entry that maps both the BSDName and the + * IOKit registry path. If no mapping is discovered, a new entry + * is created. An entry is never removed, this maintaining the + * unique index throughout the data collection. + * Success returns the map index. Failure returns -1. + */ +static int +check_device_path (char *name, char *path, int ndrives) +{ + int i; + int index; + int n; + + if (dp_table == NULL) + { + /* First setup of internal drivepath table */ + dp_table = (struct drivepath *)malloc (ndrives * sizeof(struct drivepath)); + if (dp_table == NULL) + return(-1); + else + { + bzero(dp_table, (ndrives * sizeof(struct drivepath))); + dp_count = ndrives; + drivepath_record.rec_size = sizeof(struct drivepath); + } + } + + for (i=0; i < dp_count; i++) + { + if (dp_table[i].state == DPSTATE_UNINITIALIZED) + { + /* This is a new drive entry that should be recorded */ + index = i; + goto NEW_ENTRY; + } + else if (!strcmp (dp_table[i].ioreg_path, path)) + { + /* Found a matching hardware path */ + if (!strcmp(dp_table[i].BSDName, name)) + { + /* The BSDName matches the entry in the table + * so there is no need to record this data. + */ + return(i); + } + else + { + /* The BSDName is different ... implies a change, + * like the drive was removed and now is back + */ + bzero((char *)dp_table[i].BSDName, MAXDRIVENAME+1); + dp_table[i].drivepath_id = i; + dp_table[i].state = DPSTATE_CHANGED; + strcpy(dp_table[i].BSDName, name); + write_record_hdr(&drivepath_record); + write_record_data((char *)&dp_table[i], sizeof(struct drivepath)); + return(i); + } + } + } /* end for loop */ + + /* + * If we reach this point, then we've run out of + * table entries. Double the size of the table. + */ + n = dp_count * 2; + dp_table = (struct drivepath *)realloc(dp_table, n * sizeof(struct drivepath)); + bzero(&dp_table[dp_count], dp_count * sizeof(struct drivepath)); + index = dp_count; + dp_count = n; + + /* This is a new drive entry that should be recorded */ + NEW_ENTRY: + dp_table[index].drivepath_id = index; + dp_table[index].state = DPSTATE_NEW; + strcpy(dp_table[index].BSDName, name); + strcpy(dp_table[index].ioreg_path, path); + write_record_hdr(&drivepath_record); + write_record_data((char *)&dp_table[index], sizeof(struct drivepath)); + return(index); +} + + +/* + * success - returns 1 + * failure - returns 0 + */ +static int +kvm_init() +{ + int retval = 1; + char errbuf[_POSIX2_LINE_MAX]; + + + /* + * Initialize the kvm descriptor and get the location of _ifnet in + * preparation for gathering network statistics. + * + * We become root again momentarily so that we have permission to + * open /dev/kmem. + */ + if (seteuid(0)) + { + fprintf(stderr, "sar: root privleges denied\n"); + retval = 0; + goto RETURN; + } + kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); + setuid(realuid); + + if (kvmd == NULL) { + fprintf(stderr, "sar: error in kvm_openfiles(): %s", errbuf); + retval = 0; + goto RETURN; + } + nlist_net[0].n_name = "_ifnet"; + nlist_net[1].n_name = NULL; + if (kvm_nlist(kvmd, nlist_net) < 0) { + fprintf(stderr,"sar: error in kvm_nlist(): %s", kvm_geterr(kvmd)); + retval = 0; + goto RETURN; + } + if (nlist_net[0].n_type == N_UNDF) { + fprintf(stderr, "sadc: No nlist for _ifnet"); + retval = 0; + goto RETURN; + } + RETURN: + return (retval); +} + +/* Read data from kernel memory. */ +static int +kread(u_long addr, void *buf, size_t nbytes) +{ + int retval = 0; + + if (kvm_read(kvmd, addr, buf, nbytes) != (ssize_t)nbytes) { + fprintf(stderr, "sadc: error in kvm_read(): %s\n", kvm_geterr(kvmd)); + retval = 1; + } + + return (retval); +} + + +/* + * Thus far, only the networking stats take an optional flag + * to modify the collection of data. The number of ppp + * interfaces can be very high, causing the raw data file to + * grow very large. We want this option to include ppp + * statistics to be off by default. When we see the -m PPP + * mode passed in, ppp collection will be turned on. + */ +static void +get_netstat_sample(int mode) +{ + + int n; + int ns_index = 0; + struct ifnet ifnet; + struct ifnethead ifnethead; + u_long off; + char tname[MAX_TNAME_SIZE + 1]; + char name[MAX_TNAME_UNIT_SIZE + 1]; + + if (ns_table == NULL) + { + /* this is our first sample -- do some init */ + + /* if kvm_init fails, we don't retry */ + if (kvm_init_failed || !kvm_init()) + { + kvm_init_failed = 1; + return; + } + + /* + * Set the starting table size to 100 entries + * That should be big enough for most cases, + * even with a lot of ppp connections. + */ + ns_count = 100; + ns_table = (struct netstats *) malloc(ns_count * sizeof (struct netstats)); + if (ns_table == NULL) + { + fprintf(stderr, "sadc: malloc netstat table failed\n"); + return; + } + } + + bzero(ns_table, ns_count * sizeof(struct netstats)); + if (nlist_net[0].n_value != 0 + && kread(nlist_net[0].n_value, &ifnethead, sizeof(ifnethead)) == 0) + { + for (ns_index = 0, off = (u_long)ifnethead.tqh_first; + off != 0; + off = (u_long)ifnet.if_link.tqe_next) + { + if (kread(off, &ifnet, sizeof(ifnet))) + { + break; + } + if (kread((u_long)ifnet.if_name, tname, sizeof(tname))) + { + break; + } + tname[MAX_TNAME_SIZE] = '\0'; + if (!(network_mode & NET_PPP_MODE)) + { + /* + * If the flag is set, include PPP connections. + * By default this collection is turned off + */ + if(!strncmp(tname, "ppp", 3)) + continue; + } + snprintf(name, MAX_TNAME_UNIT_SIZE, "%s%d", tname, ifnet.if_unit); + name[MAX_TNAME_UNIT_SIZE] = '\0'; + + if (ns_index == ns_count) + { + /* the stat table needs to grow */ + n = ns_count * 2; + ns_table = (struct netstats *)realloc(ns_table, n * sizeof(struct netstats)); + bzero(&ns_table[ns_count], ns_count * sizeof(struct netstats)); + ns_count = n; + } + + + /* + * As a means of helping to identify when interface unit numbers + * are reused, a generation counter may eventually be implemented. + * This will be especially helpful with ppp-x connections. + * In anticipation, we will reserve a space for it, but always + * set it to zero for now. + */ + ns_table[ns_index].gen_counter = 0; + + strncpy(ns_table[ns_index].tname_unit, name, MAX_TNAME_UNIT_SIZE); + ns_table[ns_index].tname_unit[MAX_TNAME_UNIT_SIZE] = '\0'; + ns_table[ns_index].net_ipackets = ifnet.if_ipackets; + ns_table[ns_index].net_ierrors = ifnet.if_ierrors; + ns_table[ns_index].net_opackets = ifnet.if_opackets; + ns_table[ns_index].net_oerrors = ifnet.if_oerrors; + ns_table[ns_index].net_collisions = ifnet.if_collisions; + ns_table[ns_index].net_ibytes = ifnet.if_ibytes; + ns_table[ns_index].net_obytes = ifnet.if_obytes; + ns_table[ns_index].net_imcasts = ifnet.if_imcasts; + ns_table[ns_index].net_omcasts = ifnet.if_omcasts; + ns_table[ns_index].net_drops = ifnet.if_snd.ifq_drops; + ns_index++; + } /* end for */ + + netstats_record.rec_count = ns_index; + netstats_record.rec_size = sizeof(struct netstats); + write_record_hdr(&netstats_record); + write_record_data((char *)ns_table, (ns_index * sizeof(struct netstats))); + } /* end if */ + return; +} diff --git a/sadc.tproj/sadc.h b/sadc.tproj/sadc.h new file mode 100644 index 0000000..15793c2 --- /dev/null +++ b/sadc.tproj/sadc.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include +#include +#include +#include +#include + +/* record types in sadc raw data output */ + +#define SAR_NOTSET 0 +#define SAR_RESTART 1 +#define SAR_TIMESTAMP 2 +#define SAR_NETSTATS 3 +#define SAR_DRIVEPATH 4 +#define SAR_DRIVESTATS 5 +#define SAR_VMSTAT 6 +#define SAR_CPU 7 + +struct record_hdr +{ + int rec_type; + int rec_version; + int rec_count; + long rec_size; +}; + +#define rec_data rec_size +#define rec_timestamp rec_size + +#define MAXDRIVENAME 31 /* largest drive name we allow */ + +#define DPSTATE_UNINITIALIZED 0 +#define DPSTATE_NEW 1 +#define DPSTATE_CHANGED 2 +#define DPSTATE_ACTIVE 3 + +struct drivepath +{ + int drivepath_id; /* compressed table id */ + int state; + char BSDName[MAXDRIVENAME + 1]; + io_string_t ioreg_path; /* unique id, hardware path */ +}; + + +struct drivestats +{ + io_registry_entry_t driver; + int drivepath_id; + u_int64_t blocksize; + + u_int64_t Reads; + u_int64_t BytesRead; + + u_int64_t Writes; + u_int64_t BytesWritten; + + u_int64_t LatentReadTime; + u_int64_t LatentWriteTime; + + u_int64_t ReadErrors; + u_int64_t WriteErrors; + + u_int64_t ReadRetries; + u_int64_t WriteRetries; + + u_int64_t TotalReadTime; + u_int64_t TotalWriteTime; +}; + + +/* + * netstat mode drives the + * collection of ppp interface data + */ + +#define NET_DEV_MODE 0x1 /* Turn on network interface counters */ +#define NET_EDEV_MODE 0x2 /* Turn on network interface error counters */ +#define NET_PPP_MODE 0x4 /* Include ppp interface counters - further + * modifies NET_DEV_MODE and NET_EDEV_MODE */ + +#define MAX_TNAME_SIZE 15 +#define MAX_TNAME_UNIT_SIZE 23 + +struct netstats +{ + char tname_unit[MAX_TNAME_UNIT_SIZE + 1]; + unsigned long gen_counter; /* unit generation counter */ + + unsigned long long net_ipackets; + unsigned long long net_ierrors; + unsigned long long net_opackets; + unsigned long long net_oerrors; + unsigned long long net_collisions; + unsigned long long net_ibytes; + unsigned long long net_obytes; + unsigned long long net_imcasts; + unsigned long long net_omcasts; + unsigned long long net_drops; +}; diff --git a/sa.tproj/Makefile b/sar.tproj/Makefile similarity index 66% rename from sa.tproj/Makefile rename to sar.tproj/Makefile index ba8402d..ffad6cd 100644 --- a/sa.tproj/Makefile +++ b/sar.tproj/Makefile @@ -7,15 +7,16 @@ # and Makefile.postamble (both optional), and Makefile will include them. # -NAME = sa +NAME = sar PROJECTVERSION = 2.8 PROJECT_TYPE = Tool -CFILES = main.c pdb.c usrdb.c +HFILES = sar.h -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble extern.h pathnames.h \ - sa.8 +CFILES = sar.c + +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble sar.1 MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles @@ -24,15 +25,14 @@ MAKEFILE = tool.make NEXTSTEP_INSTALLDIR = /usr/bin WINDOWS_INSTALLDIR = /Library/Executables PDO_UNIX_INSTALLDIR = /bin -LIBS = -lcurses +LIBS = DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) -HEADER_PATHS = -I$(NEXT_ROOT)/System/Library/System.framework/\ - -I$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders\ - -I$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd\ - -I$(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders/bsd +HEADER_PATHS = -I. +FRAMEWORKS = -framework Foundation + NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc diff --git a/sa.tproj/Makefile.postamble b/sar.tproj/Makefile.postamble similarity index 95% rename from sa.tproj/Makefile.postamble rename to sar.tproj/Makefile.postamble index 864cfa1..62d44ba 100644 --- a/sa.tproj/Makefile.postamble +++ b/sar.tproj/Makefile.postamble @@ -53,6 +53,9 @@ # Some compiler flags can be overridden here for certain build situations. # # WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) + +WARNING_CFLAGS = -Wall -Wno-long-double + # DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults # to -g) # DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) @@ -80,7 +83,7 @@ # User/group ownership #INSTALL_AS_GROUP = wheel # (probably want to set both of these) -#INSTALL_PERMISSIONS = 4555 +#INSTALL_PERMISSIONS = # If set, 'install' chmod's executable to this @@ -99,6 +102,9 @@ # derived files should go. # -install-man-page: - install -d $(DSTROOT)/usr/share/man/man8 - install -c -m 444 sa.8 $(DSTROOT)/usr/share/man/man8/sa.8 +SHAREDIR = /usr/share +MANDIR = $(SHAREDIR)/man/man1 + +install-man-pages: + $(MKDIRS) $(DSTROOT)$(MANDIR) + install -c -m 444 sar.1 $(DSTROOT)$(MANDIR)/sar.1 diff --git a/sa.tproj/Makefile.preamble b/sar.tproj/Makefile.preamble similarity index 99% rename from sa.tproj/Makefile.preamble rename to sar.tproj/Makefile.preamble index a4606c6..52be7f8 100644 --- a/sa.tproj/Makefile.preamble +++ b/sar.tproj/Makefile.preamble @@ -51,6 +51,9 @@ # # BEFORE_INSTALL: targets to build before installing the product # AFTER_INSTALL: targets to build after installing the product + +AFTER_INSTALL += install-man-pages + # BEFORE_POSTINSTALL: targets to build before postinstalling every subproject # AFTER_POSTINSTALL: targts to build after postinstalling every subproject # @@ -135,6 +138,3 @@ # standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems # and "" on other systems. DSTROOT = $(HOME) - -AFTER_INSTALL += install-man-page - diff --git a/sar.tproj/PB.project b/sar.tproj/PB.project new file mode 100644 index 0000000..a0a40f2 --- /dev/null +++ b/sar.tproj/PB.project @@ -0,0 +1,27 @@ +{ + "DYNAMIC_CODE_GEN" = YES; + FILESTABLE = { + FRAMEWORKS = ("Foundation.framework"); + HEADERSEARCH = ("."); + "H_FILES" = ("sar.h"); + "OTHER_LINKED" = ("sar.c"); + "OTHER_SOURCES" = ("Makefile.preamble", Makefile, "Makefile.postamble", "sar.1"); + }; + LANGUAGE = English; + MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; + "NEXTSTEP_BUILDTOOL" = "/usr/bin/gnumake"; + "NEXTSTEP_INSTALLDIR" = "/usr/bin"; + "NEXTSTEP_JAVA_COMPILER" = "/usr/bin/javac"; + "NEXTSTEP_OBJCPLUS_COMPILER" = "/usr/bin/cc"; + "PDO_UNIX_BUILDTOOL" = "$NEXT_ROOT/Developer/bin/make"; + "PDO_UNIX_INSTALLDIR" = "/bin"; + "PDO_UNIX_JAVA_COMPILER" = "$(JDKBINDIR)/javac"; + "PDO_UNIX_OBJCPLUS_COMPILER" = "$(NEXTDEV_BIN)/gcc"; + PROJECTNAME = sar; + PROJECTTYPE = Tool; + PROJECTVERSION = "2.8"; + "WINDOWS_BUILDTOOL" = "$NEXT_ROOT/Developer/Executables/make"; + "WINDOWS_INSTALLDIR" = "/Library/Executables"; + "WINDOWS_JAVA_COMPILER" = "$(JDKBINDIR)/javac.exe"; + "WINDOWS_OBJCPLUS_COMPILER" = "$(DEVDIR)/gcc"; +} diff --git a/sar.tproj/sar.1 b/sar.tproj/sar.1 new file mode 100644 index 0000000..2af8ff5 --- /dev/null +++ b/sar.tproj/sar.1 @@ -0,0 +1,208 @@ +.\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +.\" +.\" The contents of this file constitute Original Code as defined in and +.\" are subject to the Apple Public Source License Version 1.1 (the +.\" "License"). You may not use this file except in compliance with the +.\" License. Please obtain a copy of the License at +.\" http://www.apple.com/publicsource and read it before using this file. +.\" +.\" This Original Code and all software distributed under the License are +.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +.\" License for the specific language governing rights and limitations +.\" under the License. +.\" +.\" @(#)sadc.8 +.Dd Jul 25, 2003 \" DATE +.Dt sar 1 \" Program name and manual section number +.Os "Mac OS X" +.Sh NAME \" Section Header - required - don't modify +.Nm sar +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.\" Use .Nm macro to designate other names for the documented program. +.Nd system activity reporter +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl dgpu \" [-dgpu] +.Op Fl n Ar mode \" [-n mode] +.Op Fl o Ar filename \" [-o filename] +t \" t +.Op Ar n \" [ n ] +.Nm +.Op Fl dgpu \" [-dgpu] +.Op Fl n Ar mode \" [-n mode] +.Op Fl e Ar time \" [-e time] +.Op Fl f Ar filename \" [-f filename] +.Op Fl i Ar seconds \" [-i seconds] +.Op Fl s Ar time \" [-s time] +.Sh DESCRIPTION \" Section Header - required - don't modify +The +.Nm +command is used to sample and report various cumulative statistic counters +maintained by the operating system. It can be invoked in two different ways. +.Pp +In the first usage instance, +.Ar n +samples are reported at +.Ar t +second intervals. +If +.Ar n +is not specified, only one sample will be captured. +When the -o option is specified, +.Nm +will write the binary sampling data to the output file specified by +.Ar filename . +.Pp +In the second usage instance, there is no on-going sample interval to specify. +This is because the sampling input comes from a previously recorded, binary activity file. +The binary activity file can be specified using the -f +.Ar filename +option. +When the -f option isn't used, +.Nm +attempts to open a default binary activity file, +/var/log/sa/sadd, where +.Ar dd +represents the current day of the month. +The starting and ending time of the report can be restricted using the -e +and -s options. Here, the +.Ar time +field is specified in the form hh[:mm[:ss]]. +Finally, the -i option can be used to select the sampling interval. +Only records at least +.Ar seconds +apart will be reported. +When the -i option is not used, all of the previously recorded +interval samples are reported. +.Pp +Due to the nature of on-going sample collection, the data is reported in a +verbose mode when more than one sampling option is specified. +Column headers are printed at the beginning of the report and averages are +printed when the +.Nm +command terminates. +.Sh OPTIONS +The following options restrict the sample set that +.Nm +reports. +.Pp \" Inserts a space +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl d +Report disk activity. +.Pp +.Bl -tag -width -indent \" Begins a tagged list +.It device +The BSD name of the device. +.It r+w/s +The number of reads and writes per second. +.It blks/s +Number of blocks (in device's default blocksize) transferred to a device per second. +.El +.It Fl g +Report page-out activity. +.Pp +.Bl -tag -width -indent \" Begins a tagged list +.It pgout/s +The number of pages paged out per second. +.El +.It Fl p +Report page-in and page fault activity +.Pp +.Bl -tag -width -indent \" Begins a tagged list +.It pgin/s +The number of pages paged in per second. +.It pflts/s +The number of faults that caused a page to be copied in per second. +.It vflts/s +The number of times vm_fault routine has been called. +.El +.It Fl n Ar mode +Report network activity with modes +.Ar DEV , +.Ar EDEV , +or +.Ar PPP . +Multiple network modes can be specified. +.Pp +.Bl -tag -width -indent \" Begins a tagged list +.It DEV +The +.Ar DEV +mode reports network device statistics. The following +information is displayed for each interface. +.Pp +.Bl -tag -width "Obytes/s" \" Begins a tagged list +.It IFACE +The network interface name. +.It Ipkts/s +The number of packets received per second. +.It Ibytes/s +The number of bytes received per second. +.It Opkts/s +The number of packets sent per second. +.It Obytes/s +The number of bytes sent per second. +.El +.It EDEV +The +.Ar EDEV +mode reports network device error statistics. The +following information is displayed for each interface. +.Pp +.Bl -tag -width "Drops/s" \" Begins a tagged list +.It IFACE +The interface name. +.It Ierrs/s +The input errors per second. +.It Oerrs/s +The output errors per second. +.It Coll/s +The collisions that occurred per second. +.It Drops/s +The number of dropped packets per second. +.El +.It PPP +The +.Ar PPP +mode must be specified in order to display ppp connections +in the network statistics. This will also turn on the PPP modify +mode in +.Ar sadc +(8) when sampling data is not being read from a file. +By default, both the collection and reporting of ppp +statistics is turned off. See +.Ar sadc +(8). +.El +.Pp +.It Fl u +Report CPU activity (default) +.Pp +%usr, %sys, and %idle +.Pp +These report the percentage of time running in user mode, +system mode and idle. +.El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/var/log/sa/sadd" -compact +.It Pa /var/log/sa/sadd +Default daily activity file that holds the binary sampling data. +.Ar dd +are digits that represent the day of the month. +.El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.Xr sa1 8 , +.Xr sa2 8 , +.Xr sadc 8 , +.Xr iostat 8 , +.Xr vm_stat 1 , +.Xr netstat 1 , +.Xr top 1 , +.Xr sc_usage 1 , +.Xr fs_usage 1 +.\" .Sh BUGS \" Document known, unremedied bugs diff --git a/sar.tproj/sar.c b/sar.tproj/sar.c new file mode 100644 index 0000000..c3bb33f --- /dev/null +++ b/sar.tproj/sar.c @@ -0,0 +1,2325 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + cc -Wall -Wno-long-double -I. -I ../sadc.tproj -O -o sar sar.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#define IFNET_32_BIT_COUNTERS 1 + +/* Options used only for launching sadc */ +int t_interval = 5; /* in seconds */ +char * t_intervalp = "5"; +int n_samples = 1; /* number of sample loops */ +char * n_samplesp = "1"; + +/* Used only for storing the binary output after launching sadc */ +char *outfile = NULL; /* output file */ +int ofd = 0; /* output file descriptor */ + +/* + * When launching sadc, this file descriptor reads sadc's stdout + * via pipe. + * When not launching sadc, this file descriptor will be either + * the input file passed in with the -f flag + * or the standard input file /var/log/sa/saXX + */ +int ifd = 0; /* input file descriptor */ +char *infile = NULL; /* input file */ + + + +/* Used when we have to luanch sadc */ +pid_t pid; +int fd[2]; /* read from fd[0], write to fd[1] */ + +char *optionstring1 = "Adgn:puo:"; +char *optionstring1_usage = "/usr/bin/sar [-Adgpu] [-n { DEV | EDEV | PPP } ] [-o filename] t [n]"; +char *optionstring2 = "Adgn:pue:f:i:s:"; +char *optionstring2_usage = "/usr/bin/sar [-Adgpu] [-n { DEV | EDEV | PPP }] [-e time] [-f filename] [-i sec] [-s time]"; + + +/* option flags */ +int aflag = 0; +int Aflag = 0; +int bflag = 0; +int cflag = 0; +int dflag = 0; /* drive statistics */ +int gflag = 0; /* page-out activity */ +int kflag = 0; +int mflag = 0; + +int nflag = 0; /* network statistics */ +int network_mode = 0; +char *sadc_mflagp = "-m"; +char *sadc_ppp_modep = "PPP"; + +int pflag = 0; /* page-in activity */ +int qflag = 0; +int rflag = 0; +int uflag = 0; /* cpu utilization - this is the only default */ +int vflag = 0; +int wflag = 0; +int yflag = 0; +int set_default_flag = 1; +int flag_count = 0; + +/* + * To get the current time of day in seconds + * based on a 24 hour clock, pass in the time_t from time() + * the remainder is the current time in seconds +*/ +#define HOURS_PER_DAY 24 +#define MINS_PER_HOUR 60 +#define SECS_PER_MIN 60 +#define SECS_PER_DAY (SECS_PER_MIN * MINS_PER_HOUR * HOURS_PER_DAY) + +/* end time delimiter -- converted from hh:mm:ss to seconds */ +time_t end_time = 0; + +int iflag = 0; +int iseconds = 0; /* interval seconds, default = 0 implies all samples are + * printed */ + +/* start time delimiter -- converted from hh:mm:ss to seconds */ +time_t start_time = 0; + +int oflag = 0; +int fflag = 0; + +/* stat records average and previous */ +struct vm_statistics prev_vmstat, avg_vmstat, cur_vmstat; +host_cpu_load_info_data_t prev_cpuload, avg_cpuload, cur_cpuload; +struct drivestats_report *dr_head = NULL; + +/* internal table of drive path mappings */ +struct drivepath *dp_table = NULL; +int dp_count = 0; + +/* internal table of network interface statistics */ +struct netstats_report *nr_table = NULL; +int nr_count; +struct netstats *netstat_readbuf = NULL; +size_t netstat_readbuf_size = 0; + +int avg_counter = 0; +int avg_interval = 0; + +extern int errno; + +/* Forward function declarations */ +static void exit_usage(); +static void open_output_file(char *path); +static void open_input_file(char *path); +static void read_record_hdr(struct record_hdr *hdr, int writeflag); +static void read_record_data(char *buf, size_t size, int writeflag); +static void write_record_hdr(struct record_hdr *hdr); +static void write_record_data(char *buf, size_t size); +static long convert_hms(char *string); +static char *get_hms_string(time_t, char *); +static int find_restart_header(struct record_hdr *); +static void print_all_column_headings (time_t timestamp); +static void print_column_heading (int type, char *timebufptr, int mode); +static void read_sample_set(int, time_t, struct record_hdr *); +static void do_main_workloop(); +static int bypass_sample_set(struct record_hdr *, time_t); +static void skip_data(int); +static int get_cpu_sample(int flag, struct record_hdr *hdr); +static void print_cpu_sample(char *timebufptr); +static int get_vmstat_sample(int flag, struct record_hdr *hdr); +static void print_vmstat_sample(char *timebufptr); + +static int get_drivestats_sample(int flag, struct record_hdr *hdr); +static void init_drivestats(struct drivestats_report *dr); +static void print_drivestats_sample(char *timebufptr); +static int get_drivepath_sample(int flag, struct record_hdr *hdr); + +static void set_cur_netstats(struct netstats_report *nr, struct netstats *ns); +static void init_prev_netstats(struct netstats_report *nr); +static int get_netstats_sample(int flag, struct record_hdr *hdr); +static void print_netstats_sample(char *timebufptr); + +static void exit_average(); + +int +main(argc, argv) + int argc; + char *argv[]; +{ + + char ch; + + time_t curr_time; /* current time in seconds */ + char timebuf[26]; + char filenamebuf[20]; + char *optstring = NULL; + int optstringval; + int i; + + /* + * Detirmine which option string to use + */ + + optreset=0; + optstringval=0; + + while((ch=getopt(argc, argv, "aAbcdgkmn:pqruvwyo:e:f:i:s:")) != EOF) { + switch(ch) { + case 'o': + if (optstringval == 2) + exit_usage(); + optstring=optionstring1; + optstringval=1; + break; + case 'e': + case 'f': + case 'i': + case 's': + if (optstringval == 1) + exit_usage(); + optstring=optionstring2; + optstringval=2; + break; + default: + /* ignore for now */ + break; + } + } + + if (!optstring) + { + /* still trying to determine which option string to use */ + if (argc - optind > 0) + { + optstring=optionstring1; /* we should have a t_second value */ + optstringval=1; + } + else + { + optstring=optionstring2; + optstringval=2; + } + } + + optreset = optind = 1; + while ((ch=getopt(argc, argv, optstring)) != EOF) { + switch (ch) { + case 'a': + aflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'A': + Aflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'b': + bflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'c': + cflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'd': + dflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'g': + gflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'k': + kflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'm': + mflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'n': + nflag= 1; + if (!strncmp(optarg, "PPP", 3)) + network_mode |= NET_PPP_MODE; + else if (!strncmp(optarg, "DEV", 3)) + network_mode |= NET_DEV_MODE; + else if (!strncmp(optarg, "EDEV", 4)) + network_mode |= NET_EDEV_MODE; + else + exit_usage(); + set_default_flag = 0; + flag_count++; + break; + case 'p': + pflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'q': + qflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'r': + rflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'u': + uflag= 1; + set_default_flag = 0; + flag_count++; + break; + case 'v': + vflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'w': + wflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'y': + yflag = 1; + set_default_flag = 0; + flag_count++; + break; + case 'o': + /* open the output file */ + oflag = 1; + outfile=optarg; + (void)open_output_file(outfile); + break; + case 'e': /* eflag */ + end_time = convert_hms(optarg); + break; + case 'f': + fflag = 1; + infile=optarg; + break; + case 'i': + iflag = 1; + iseconds=atoi(optarg); + break; + case 's': + start_time = convert_hms(optarg); + break; + default: + exit_usage(); + break; + } + } + + /* setup default uflag option */ + if (Aflag) + { + dflag = gflag = pflag = uflag = 1; + if (!nflag) + { + /* + * Add network stats to the load + * but avoid PPP data by default. + */ + nflag = 1; + network_mode = NET_DEV_MODE | NET_EDEV_MODE;; + } + flag_count = 2; /* triggers column headings */ + } + else if (set_default_flag) + { + uflag=1; + flag_count++; + } + + if (nflag) + { + if (network_mode & NET_PPP_MODE) + { + if (!(network_mode & NET_DEV_MODE) && + !(network_mode & NET_EDEV_MODE)) + { + /* set defaults */ + network_mode |= NET_DEV_MODE; + network_mode |= NET_EDEV_MODE; + flag_count++; + } + } + } + + argc -= optind; + argv += optind; + + /* set up signal handlers */ + signal(SIGINT, exit_average); + signal(SIGQUIT, exit_average); + signal(SIGHUP, exit_average); + signal(SIGTERM, exit_average); + + if (optstringval == 1) + { + /* expecting a time interval */ + + char *p; + + if (argc >= 1) + { + errno = 0; + t_interval = strtol(argv[0], &p, 0); + t_intervalp = argv[0]; + if (errno || (*p != '\0') || t_interval <= 0 ) + exit_usage(); + if (argc >= 2) + { + errno=0; + n_samples = strtol(argv[1], &p, 0); + n_samplesp = argv[1]; + if (errno || (*p != '\0') || n_samples <= 0) + exit_usage(); + } + } + } + + /* where does the input come from */ + if (fflag) + { + (void)open_input_file(infile); + } + else if (optstringval == 2) + { + /* + * Create a filename of the form /var/log/sa/sadd + * where "dd" is the date of the month + */ + curr_time = time((time_t *)0); /* returns time in seconds */ + + /* + timebuf will be a 26-character string of the form: + Thu Nov 24 18:22:48 1986\n\0 + */ + + ctime_r(&curr_time, timebuf); + strncpy(filenamebuf, "/var/log/sa/sa", 14); + strncpy(&filenamebuf[14], &timebuf[8], 2); + if (filenamebuf[14] == ' ') + filenamebuf[14] = '0'; + filenamebuf[16]='\0'; + infile = filenamebuf; + (void)open_input_file(infile); + } + else if (optstringval == 1) + { + /* launch sadc */ + if (pipe(fd) == -1) + { + fprintf(stderr, "sar: pipe(2) failed, errno = (%d)\n",errno); + exit(1); + } + + if ((pid=fork()) == 0) + { +#if 0 + int efd; +#endif + + /* This is the child */ + /* Close all file descriptors except the one we need */ + + for (i=0; i <= KERN_MAXFILESPERPROC; i++) { + if ((i != fd[0]) && (i != fd[1])) + (void)close(i); + } +#if 0 + efd = open("/tmp/errlog", O_CREAT|O_APPEND|O_RDWR, 0666); + if (dup2(efd,2) == -1) { + exit(1); + } +#endif + /* Dup the two file descriptors to stdin and stdout */ + if (dup2(fd[0],0) == -1) { + exit(1); + } + if (dup2(fd[1],1) == -1) { + exit(1); + } + /* Exec the child process */ + if (network_mode & NET_PPP_MODE) + execl("/usr/lib/sa/sadc", "sadc", sadc_mflagp, sadc_ppp_modep, t_intervalp, n_samplesp, NULL); + else + execl("/usr/lib/sa/sadc", "sadc", t_intervalp, n_samplesp, NULL); + + perror("execlp sadc"); + exit(2); /* This call of exit(2) should never be reached... */ + } + else + { /* This is the parent */ + if (pid == -1) { + fprintf(stderr, "sar: fork(2) failed, errno = (%d)\n",errno); + exit(1); + } + close (fd[1]); /* parent does not write to the pipe */ + ifd = fd[0]; /* parent will read from the pipe */ + } + } + else + { + /* we're confused about source of input data - bail out */ + fprintf(stderr, "sar: no input file recognized\n"); + exit_usage(); + } + + /* start reading input data and format the output */ + (void)do_main_workloop(); + (void)exit_average(); + exit(0); +} + +static void +exit_usage() +{ + fprintf(stderr, "\n%s\n\n", optionstring1_usage); + fprintf(stderr, "%s\n", optionstring2_usage); + exit(EXIT_FAILURE); +} + +static void +open_output_file(char *path) +{ + if ((ofd = open(path, O_CREAT|O_APPEND|O_TRUNC|O_WRONLY, 0664)) == -1 ) + { + /* failed to open path */ + fprintf(stderr, "sar: failed to open output file [%s]\n", path); + exit_usage(); + } +} + + +static void +open_input_file(char *path) +{ + if ((ifd = open(path, O_RDONLY, 0)) == -1) + { + /* failed to open path */ + fprintf(stderr, "sar: failed to open input file [%d][%s]\n", ifd, path); + exit_usage(); + } +} + +static void +read_record_hdr(hdr, writeflag) + struct record_hdr *hdr; + int writeflag; +{ + errno = 0; + int num = 0; + int n = 0; + size_t size = 0; + + size = sizeof(struct record_hdr); + + while (size) + { + num = read(ifd, &hdr[n], size); + if (num > 0) + { + n += num; + size -= num; + } + else if (num == 0) + exit_average(); + else + { + fprintf(stderr, "sar: read_record_data failed, errno=%d num=%d, size=%d\n", (int)errno, (int)num, (int)size); + exit(EXIT_FAILURE); + } + } + + if (oflag && writeflag) + write_record_hdr(hdr); + + return; +} + +static void +read_record_data(buf, size, writeflag) + char * buf; + size_t size; + int writeflag; +{ + errno = 0; + size_t num = 0; + size_t n = 0; + + while (size) + { + num = read(ifd, &buf[n], size); + if (num > 0) + { + n += num; + size -= num; + } + else if (num == 0) /* EOF */ + exit_average(); + else + { + fprintf(stderr, "sar: read_record_data failed, errno=%d num=%d, size=%d\n", (int)errno, (int)num, (int)size); + exit(EXIT_FAILURE); + } + } + + if (oflag && writeflag) + write_record_data(buf, n); + + return; +} + +static void +write_record_hdr(hdr) + struct record_hdr *hdr; +{ + errno = 0; + int num; + + if ((num = write(ofd, hdr, sizeof(struct record_hdr))) == -1) + { + fprintf(stderr, "sar: write_record_hdr failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + return; +} + +static void +write_record_data(char *buf, size_t nbytes) +{ + errno = 0; + int num; + if ((num = write(ofd, buf, nbytes)) == -1) + { + fprintf(stderr, "sar: write_record_data failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + return; +} + +/* + * Convert a string of one of the forms + * hh hh:mm hh:mm:ss + * into the number of seconds. + * exit on error +*/ + +static time_t +convert_hms(string) + char *string; +{ + int hh = 0; /* hours */ + int mm = 0; /* minutes */ + int ss = 0; /* seconds */ + time_t seconds; + time_t timestamp; + struct tm *tm; + int i; + + if (string == NULL || *string == '\0') + goto convert_err; + + for (i=0; string[i] != '\0'; i++) + { + if ((!isdigit(string[i])) && (string[i] != ':')) + { + goto convert_err; + } + } + + if (sscanf(string, "%d:%d:%d", &hh, &mm, &ss) != 3) + { + if (sscanf(string, "%d:%d", &hh, &mm) != 2) + { + if (sscanf(string, "%d", &hh) != 1) + { + goto convert_err; + } + } + } + + if (hh < 0 || hh >= HOURS_PER_DAY || + mm < 0 || mm >= MINS_PER_HOUR || + ss < 0 || ss > SECS_PER_MIN) + { + goto convert_err; + } + + seconds = ((((hh * MINS_PER_HOUR) + mm) * SECS_PER_MIN) + ss); + timestamp = time((time_t *)0); + tm=localtime(×tamp); + seconds -= tm->tm_gmtoff; + + return(seconds); + + convert_err: + fprintf(stderr, "sar: time format usage is hh[:mm[:ss]]\n"); + exit_usage(); + return(0); +} + + +/* + * Use ctime_r to convert a time value into + * a 26-character string of the form: + * + * Thu Nov 24 18:22:48 1986\n\0 + */ + +static char * +get_hms_string(tdata, tbuf) + time_t tdata; + char *tbuf; +{ + time_t t; + char *p; + + t = tdata; + ctime_r(&t, tbuf); + p=&tbuf[11]; + tbuf[19] = 0; + + return(p); +} + + +/* sample set flags */ +#define INIT_SET 0 +#define PRINT_SET 1 +#define PRINT_AVG 2 + +static void +do_main_workloop() +{ + struct record_hdr hdr; + time_t cur_timestamp = 0; /* seconds - Coordinated Universal Time */ + time_t next_timestamp = 0; /* seconds - Coordinated Universal Time */ + + if (!find_restart_header(&hdr)) + exit(1); + + cur_timestamp = hdr.rec_timestamp; + + /* convert sflag's start_time from 24 hour clock time to UTC seconds */ + if (start_time < (cur_timestamp % SECS_PER_DAY)) + start_time = cur_timestamp; + else + start_time += cur_timestamp - (cur_timestamp % SECS_PER_DAY); + + /* convert end_time, from 24 hour clock time to UTC seconds */ + if (end_time != 0) + end_time += cur_timestamp - (cur_timestamp % SECS_PER_DAY); + +#if 0 + fprintf(stderr, "start = %ld, end = %ld, cur=%ld, [24hour - %ld]\n", + start_time, end_time, cur_timestamp,(cur_timestamp % SECS_PER_DAY)); +#endif + + while (cur_timestamp < start_time) + { + bypass_sample_set(&hdr, cur_timestamp); + cur_timestamp = hdr.rec_timestamp; + } + + next_timestamp = cur_timestamp + iseconds; + print_all_column_headings(cur_timestamp); + read_sample_set(INIT_SET, cur_timestamp, &hdr); + cur_timestamp = hdr.rec_timestamp; + + while ((end_time == 0) || (next_timestamp < end_time)) + { + if (cur_timestamp < next_timestamp) + { + bypass_sample_set (&hdr, cur_timestamp); + cur_timestamp = hdr.rec_timestamp; + } + else + { + /* need to know the seconds interval when printing averages */ + if (avg_interval == 0) + { + if (iseconds) + avg_interval = iseconds; + else + avg_interval = cur_timestamp - next_timestamp; + } + next_timestamp = cur_timestamp + iseconds; + read_sample_set(PRINT_SET, cur_timestamp, &hdr); + cur_timestamp = hdr.rec_timestamp; + } + } + exit_average(); +} + + +/* + * Find and fill in a restart header. We don't write + * the binary data when looking for SAR_RESTART. + * Return: 1 on success + * 0 on failure + */ +static int +find_restart_header (ret_hdr) + struct record_hdr *ret_hdr; +{ + struct record_hdr hdr; + int bufsize = 0; + char *buf = NULL; + + errno = 0; + + restart_loop: + read_record_hdr(&hdr, FALSE); /* exits on error */ + + if (hdr.rec_type == SAR_RESTART) + { + *ret_hdr = hdr; + if (oflag) + write_record_hdr(&hdr); /* writes the RESTART record */ + if (buf) + free(buf); + return(1); + } + + /* + * not the record we want... + * read past data and try again + */ + if (hdr.rec_count) + { + if (fflag) + { /* seek past data in the file */ + if ((lseek(ifd, (hdr.rec_count * hdr.rec_size), SEEK_CUR)) == -1) + { + /*exit on error */ + fprintf(stderr, "sar: lseek failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + + } + /* compute data size - malloc a new buf if it's not big enough */ + else + { + /* have to read from the pipe */ + if (bufsize < (hdr.rec_count * hdr.rec_size)) + { + if (buf) + free(buf); + bufsize = hdr.rec_count * hdr.rec_size; + if((buf = (char *)malloc(bufsize)) == NULL) + { + fprintf(stderr, "sar: malloc failed\n"); + return(0); + } + } + /* exits on error */ + read_record_data(buf, (hdr.rec_count * hdr.rec_size), FALSE); + } + } + goto restart_loop; +} + +static void +print_all_column_headings(timestamp) + time_t timestamp; +{ + char timebuf[26]; + char *timebufp; + + timebufp = get_hms_string (timestamp, timebuf); + + if (uflag) /* print cpu headers */ + print_column_heading(SAR_CPU, timebufp, 0); + + if (gflag) /* print page-out activity */ + print_column_heading(SAR_VMSTAT, timebufp, 0); + + if (pflag ) /* print page-in activity */ + print_column_heading(SAR_VMSTAT, timebufp, 1); + + if (dflag) /* print drive stats */ + print_column_heading(SAR_DRIVESTATS, timebufp, 0); + + if (nflag) /* print network stats */ + { + if (network_mode & NET_DEV_MODE) + print_column_heading(SAR_NETSTATS, timebufp, NET_DEV_MODE); + + if (network_mode & NET_EDEV_MODE) + print_column_heading(SAR_NETSTATS, timebufp, NET_EDEV_MODE); + } +} + + +/* + * Find and fill in a timestamp header. + * Write the binary data when looking for SAR_TIMESTAMP + * Don't do anything with the data, just read past it. + * Return: 1 on success + * 0 on failure + */ +static int +bypass_sample_set (ret_hdr, timestamp) + struct record_hdr *ret_hdr; + time_t timestamp; +{ + struct record_hdr hdr; + int bufsize = 0; + char *buf = NULL; + + bypass_loop: + read_record_hdr(&hdr, TRUE); /* exits on error */ + + if (hdr.rec_type == SAR_TIMESTAMP) + { + *ret_hdr = hdr; + if (buf) + free(buf); + return(1); + } + + /* + * not the record we want... + * read past data and try again + */ + if (hdr.rec_count) + { + if (fflag && !oflag) + { + /* + * we're reading from a file and we don't have to write the + * binary data so seek past data in the file + */ + errno = 0; + if ((lseek(ifd, (hdr.rec_count * hdr.rec_size), SEEK_CUR)) == -1) + { + /*exit on error */ + fprintf(stderr, "sar: lseek failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + } + else + { + /* + * We end up here when reading from pipe. + * malloc a new buffer if current is not big enough + */ + if (bufsize < (hdr.rec_count * hdr.rec_size)) + { + if (buf) + free(buf); + bufsize = hdr.rec_count * hdr.rec_size; + if((buf = (char *)malloc(bufsize)) == NULL) + { + fprintf(stderr, "sar: malloc failed\n"); + exit(EXIT_FAILURE); + } + } + + /* exits on error */ + read_record_data(buf, (hdr.rec_count * hdr.rec_size), TRUE); + } + } /* end if hdr.rec_count */ + goto bypass_loop; +} + + +/* + * INIT_SET: This initializes the first sample for each type. + * PRINT_SET: This read, compute and print out sample data. + */ +static void +read_sample_set(flag, timestamp, ret_hdr) + int flag; + time_t timestamp; + struct record_hdr *ret_hdr; +{ + struct record_hdr hdr; + char timebuf[26]; + char *timebufp; + char *indent_string; + char *indent_string_wide; + char *indent_string_narrow; + int sar_cpu = 0; + int sar_vmstat=0; + int sar_drivestats=0; + int sar_drivepath=0; + int sar_netstats = 0; + + indent_string_wide = " "; + indent_string_narrow = " "; + indent_string = indent_string_narrow; + + read_record_hdr(&hdr, TRUE); + + while (hdr.rec_type != SAR_TIMESTAMP) + { + switch (hdr.rec_type) + { + case SAR_CPU: + sar_cpu = get_cpu_sample(flag, &hdr); + break; + case SAR_VMSTAT: + sar_vmstat=get_vmstat_sample(flag, &hdr); + break; + case SAR_DRIVEPATH: + sar_drivepath = get_drivepath_sample(flag, &hdr); + if (sar_drivepath < 0) + fprintf(stderr, "sar: drivepath sync code error %d\n", sar_drivepath); + break; + case SAR_DRIVESTATS: + sar_drivestats = get_drivestats_sample(flag, &hdr); + break; + case SAR_NETSTATS: + sar_netstats = get_netstats_sample(flag, &hdr); + break; + default: + break; + } + + read_record_hdr(&hdr, TRUE); + } + + /* return the timestamp header */ + *ret_hdr = hdr; + + if (flag == PRINT_SET) + { + avg_counter++; + timebufp = get_hms_string(timestamp, timebuf); + + if (uflag && sar_cpu) + print_cpu_sample(timebufp); + + if((gflag || pflag) && sar_vmstat) + print_vmstat_sample(timebufp); + + if (dflag && sar_drivestats) + print_drivestats_sample(timebufp); + + if (nflag && sar_netstats) + print_netstats_sample(timebufp); + } +} + +static void +skip_data(bufsize) + int bufsize; +{ + char *buf = NULL; + + if (fflag) + { + /* seek past data in the file */ + if ((lseek(ifd, bufsize, SEEK_CUR) == -1)) + { + /*exit on error */ + fprintf(stderr, "sar: lseek failed, errno=%d\n", errno); + exit(EXIT_FAILURE); + } + } + else + { + /* have to read from the pipe */ + if((buf = (char *)malloc(bufsize)) == NULL) + { + fprintf(stderr, "sar: malloc failed\n"); + exit(EXIT_FAILURE); + } + /* even though we skip this data, we still write it if necessary */ + read_record_data(buf, bufsize, TRUE); + } + if (buf) + free(buf); + + return; +} + +static int +get_cpu_sample(flag, hdr) + int flag; + struct record_hdr *hdr; +{ + int datasize; + + datasize = hdr->rec_count * hdr->rec_size; + + if (datasize != sizeof(host_cpu_load_info_data_t)) + { + /* read past the data but don't do anything with it */ + skip_data(datasize); + return(0); + } + + read_record_data ((char *)&cur_cpuload, (int)sizeof(host_cpu_load_info_data_t), TRUE ); + + if (flag == INIT_SET) + { + prev_cpuload = cur_cpuload; + bzero(&avg_cpuload, sizeof(avg_cpuload)); + } + return(1); +} + +static void +print_cpu_sample(timebufptr) + char * timebufptr; +{ + + double time; + + time = 0.0; + cur_cpuload.cpu_ticks[CPU_STATE_USER] + -= prev_cpuload.cpu_ticks[CPU_STATE_USER]; + + prev_cpuload.cpu_ticks[CPU_STATE_USER] + += cur_cpuload.cpu_ticks[CPU_STATE_USER]; + + time += cur_cpuload.cpu_ticks[CPU_STATE_USER]; + + cur_cpuload.cpu_ticks[CPU_STATE_SYSTEM] + -= prev_cpuload.cpu_ticks[CPU_STATE_SYSTEM]; + + prev_cpuload.cpu_ticks[CPU_STATE_SYSTEM] + += cur_cpuload.cpu_ticks[CPU_STATE_SYSTEM]; + + time += cur_cpuload.cpu_ticks[CPU_STATE_SYSTEM]; + + cur_cpuload.cpu_ticks[CPU_STATE_IDLE] + -= prev_cpuload.cpu_ticks[CPU_STATE_IDLE]; + + prev_cpuload.cpu_ticks[CPU_STATE_IDLE] + += cur_cpuload.cpu_ticks[CPU_STATE_IDLE]; + + time += cur_cpuload.cpu_ticks[CPU_STATE_IDLE]; + + avg_cpuload.cpu_ticks[CPU_STATE_USER] += rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_USER] + / (time ? time : 1)); + + avg_cpuload.cpu_ticks[CPU_STATE_SYSTEM] += rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_SYSTEM] + / (time ? time : 1)); + + avg_cpuload.cpu_ticks[CPU_STATE_IDLE] += rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_IDLE] + / (time ? time : 1)); + + if(flag_count > 1) + print_column_heading(SAR_CPU, timebufptr, 0); + + fprintf(stdout, "%s%5.0f ", timebufptr, + rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_USER] + / (time ? time : 1))); + + fprintf(stdout, "%4.0f ", + rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_SYSTEM] + / (time ? time : 1))); + + fprintf(stdout, "%4.0f\n", + rint(100. * cur_cpuload.cpu_ticks[CPU_STATE_IDLE] + / (time ? time : 1))); +} + +static int +get_vmstat_sample(flag, hdr) + int flag; + struct record_hdr *hdr; +{ + int datasize; + + datasize = hdr->rec_count * hdr->rec_size; + + if (datasize != sizeof(struct vm_statistics)) + { + /* read past the data but don't do anything with it */ + skip_data(datasize); + return(0); + } + + read_record_data ((char *)&cur_vmstat, (int)sizeof(struct vm_statistics), TRUE ); + + if (flag == INIT_SET) + { + prev_vmstat = cur_vmstat; + bzero(&avg_vmstat, sizeof(avg_vmstat)); + } + return(1); +} + + +static void +print_vmstat_sample(char *timebufptr) +{ + + cur_vmstat.faults -= prev_vmstat.faults; + prev_vmstat.faults += cur_vmstat.faults; + avg_vmstat.faults += cur_vmstat.faults; + + cur_vmstat.cow_faults -= prev_vmstat.cow_faults; + prev_vmstat.cow_faults += cur_vmstat.cow_faults; + avg_vmstat.cow_faults += cur_vmstat.cow_faults; + + cur_vmstat.zero_fill_count -= prev_vmstat.zero_fill_count; + prev_vmstat.zero_fill_count += cur_vmstat.zero_fill_count; + avg_vmstat.zero_fill_count += cur_vmstat.zero_fill_count; + + cur_vmstat.reactivations -= prev_vmstat.reactivations; + prev_vmstat.reactivations += cur_vmstat.reactivations; + avg_vmstat.reactivations += cur_vmstat.reactivations; + + cur_vmstat.pageins -= prev_vmstat.pageins; + prev_vmstat.pageins += cur_vmstat.pageins; + avg_vmstat.pageins += cur_vmstat.pageins; + + cur_vmstat.pageouts -= prev_vmstat.pageouts; + prev_vmstat.pageouts += cur_vmstat.pageouts; + avg_vmstat.pageouts += cur_vmstat.pageouts; + + + if (gflag) + { + if (flag_count > 1) + print_column_heading(SAR_VMSTAT, timebufptr, 0); + fprintf(stdout, "%s %8.1f \n", timebufptr, (float)((float)cur_vmstat.pageouts/avg_interval)); + } + + if (pflag) + { + if (flag_count > 1) + print_column_heading(SAR_VMSTAT, timebufptr, 1); + fprintf(stdout, "%s %8.1f %8.1f %8.1f\n", timebufptr, + (float)((float)cur_vmstat.pageins / avg_interval), + (float)((float)cur_vmstat.cow_faults/avg_interval), + (float)((float)cur_vmstat.faults/avg_interval)); + } + fflush(stdout); +} + +static int +get_drivestats_sample(flag, hdr) + int flag; + struct record_hdr *hdr; +{ + struct drivestats *databuf; + struct drivestats_report *dr; + size_t datasize; + int datacount; + int index; + int i; + + datasize = hdr->rec_count * hdr->rec_size; + datacount = hdr->rec_count; + + if (hdr->rec_size != sizeof(struct drivestats)) + { + /* something isn't right... read past the data but don't analyze it */ + skip_data(datasize); + return(0); + } + + /* malloc read buffer */ + if ((databuf = (struct drivestats *)malloc(datasize)) == NULL) + { + fprintf(stderr, "sar: malloc failed\n"); + exit (EXIT_FAILURE); + } + + bzero(databuf, datasize); + + read_record_data ((char *)databuf, datasize, TRUE ); + + /* clear all global current fields */ + for(dr = dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + dr->present = 0; + dr->cur_Reads = 0; + dr->cur_BytesRead = 0; + dr->cur_Writes = 0; + dr->cur_BytesWritten = 0; + dr->cur_LatentReadTime = 0; + dr->cur_LatentWriteTime = 0; + dr->cur_ReadErrors = 0; + dr->cur_WriteErrors = 0; + dr->cur_ReadRetries = 0; + dr->cur_WriteRetries = 0; + dr->cur_TotalReadTime = 0; + dr->cur_TotalWriteTime=0; + } + + /* By this point, we have read in a complete set of diskstats from the sadc + * data collector. + * The order of the drives in not guaranteed. + * The global report structure is a linked list, but may need initialization + * We need to traverse this list and transfer the current + * read data. If a disk entry isn't found, then we need to allocate one + * initilize it. + */ + for (i=0; i< datacount; i++) + { + struct drivestats_report *dr_last = NULL; + + index = databuf[i].drivepath_id; /* use this as index into dp_table */ + + /* find disk entry or allocate new one*/ + for(dr = dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + dr_last = dr; + if(index == dr->drivepath_id) + break; + } + + if (dr == NULL) + { + /* allocate new entry */ + if((dr = (struct drivestats_report *)malloc(sizeof(struct drivestats_report))) == NULL) + { + fprintf(stderr, "sar: malloc error\n"); + exit(EXIT_FAILURE); + } + bzero((char *)dr, sizeof(struct drivestats_report)); + dr->blocksize = databuf[i].blocksize; + dr->drivepath_id = index; + dr->next = NULL; + dr->avg_count = 0; + + /* get the BSDName which should be in the table by now */ + if ((index < dp_count) && (dp_table[index].state != DPSTATE_UNINITIALIZED)) + strncpy(dr->name, dp_table[index].BSDName, MAXDRIVENAME+1); + else + strcpy(dr->name, "disk??"); + + if (dr_head == NULL) + { + dr_head = dr; + dr_head->next = NULL; + } + else + { + dr_last->next = (char *)dr; + } + } /* end if dr == NULL */ + + dr->present = TRUE; + dr->cur_Reads = databuf[i].Reads; + dr->cur_BytesRead = databuf[i].BytesRead; + dr->cur_Writes = databuf[i].Writes; + dr->cur_BytesWritten = databuf[i].BytesWritten; + dr->cur_LatentReadTime = databuf[i].LatentReadTime; + dr->cur_LatentWriteTime = databuf[i].LatentWriteTime; + dr->cur_ReadErrors = databuf[i].ReadErrors; + dr->cur_WriteErrors = databuf[i].WriteErrors; + dr->cur_ReadRetries = databuf[i].ReadRetries; + dr->cur_WriteRetries = databuf[i].WriteRetries; + dr->cur_TotalReadTime = databuf[i].TotalReadTime; + dr->cur_TotalWriteTime=databuf[i].TotalWriteTime; + } /* end for loop */ + + /* Reinitialize the prev and avg fields when + * This is a new disk + * This is a changed disk - name change implies disk swapping + * This disk is not present in this sample + */ + for(dr = dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + if (dr->drivepath_id >= dp_count) + { + /* something is amiss */ + continue; + } + else + { + index = dr->drivepath_id; /* use this as index into dp_table */ + } + + if ((flag == INIT_SET) || + (dp_table[index].state == DPSTATE_NEW) || + (dp_table[index].state == DPSTATE_CHANGED) || + (!dr->present)) + { + /* + * prev will be set to cur + * activate the state in dp_table + */ + if (dr->present) + dp_table[index].state = DPSTATE_ACTIVE; + + init_drivestats(dr); + } + } + return(1); +} + +static void +init_drivestats(struct drivestats_report *dr) +{ + dr->avg_count = 0; + dr->prev_Reads = dr->cur_Reads; + dr->avg_Reads = 0; + dr->prev_BytesRead = dr->cur_BytesRead; + dr->avg_BytesRead = 0; + dr->prev_Writes = dr->cur_Writes; + dr->avg_Writes = 0; + dr->prev_BytesWritten = dr->cur_BytesWritten; + dr->avg_BytesWritten = 0; + dr->prev_LatentReadTime = dr->cur_LatentReadTime; + dr->avg_LatentReadTime = 0; + dr->prev_LatentWriteTime = dr->cur_LatentWriteTime ; + dr->avg_LatentWriteTime = 0; + dr->prev_ReadErrors = dr->cur_ReadErrors ; + dr->avg_ReadErrors = 0; + dr->prev_WriteErrors = dr->cur_WriteErrors ; + dr->avg_WriteErrors = 0; + dr->prev_ReadRetries = dr->cur_ReadRetries ; + dr->avg_ReadRetries = 0; + dr->prev_WriteRetries = dr->cur_WriteRetries ; + dr->avg_WriteRetries = 0; + dr->prev_TotalReadTime = dr->cur_TotalReadTime ; + dr->avg_TotalReadTime = 0; + dr->prev_TotalWriteTime = dr->cur_TotalWriteTime ; + dr->avg_TotalWriteTime = 0; +} + + +static void +print_drivestats_sample(char *timebufptr) +{ + struct drivestats_report *dr; + long double transfers_per_second; + long double kb_per_transfer, mb_per_second; + u_int64_t interval_bytes, interval_transfers, interval_blocks; + u_int64_t interval_time; + long double blocks_per_second, ms_per_transaction; + + if (flag_count > 1) + print_column_heading(SAR_DRIVESTATS, timebufptr, 0); + + for (dr=dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + if(!dr->present) + continue; + + /* + * This sanity check is for drives that get removed and then + * returned during the sampling sleep interval. If anything + * looks out of sync, reinit and skip this entry. There is + * no way to guard against this entirely. + */ + if ((dr->cur_Reads < dr->prev_Reads) || + (dr->cur_BytesRead < dr->prev_BytesRead) || + (dr->cur_Writes < dr->prev_Writes) || + (dr->cur_BytesWritten < dr->prev_BytesWritten)) + { + init_drivestats(dr); + continue; + } + + dr->avg_count++; + + dr->cur_Reads -= dr->prev_Reads; + dr->prev_Reads += dr->cur_Reads; + dr->avg_Reads += dr->cur_Reads; + + dr->cur_BytesRead -= dr->prev_BytesRead; + dr->prev_BytesRead += dr->cur_BytesRead; + dr->avg_BytesRead += dr->cur_BytesRead; + + dr->cur_Writes -= dr->prev_Writes ; + dr->prev_Writes += dr->cur_Writes ; + dr->avg_Writes += dr->cur_Writes ; + + dr->cur_BytesWritten -= dr->prev_BytesWritten ; + dr->prev_BytesWritten += dr->cur_BytesWritten ; + dr->avg_BytesWritten += dr->cur_BytesWritten ; + + dr->cur_LatentReadTime -= dr->prev_LatentReadTime ; + dr->prev_LatentReadTime += dr->cur_LatentReadTime ; + dr->avg_LatentReadTime += dr->cur_LatentReadTime ; + + dr->cur_LatentWriteTime -= dr->prev_LatentWriteTime ; + dr->prev_LatentWriteTime += dr->cur_LatentWriteTime ; + dr->avg_LatentWriteTime += dr->cur_LatentWriteTime ; + + dr->cur_ReadErrors -= dr->prev_ReadErrors ; + dr->prev_ReadErrors += dr->cur_ReadErrors ; + dr->avg_ReadErrors += dr->cur_ReadErrors ; + + dr->cur_WriteErrors -= dr->prev_WriteErrors ; + dr->prev_WriteErrors += dr->cur_WriteErrors ; + dr->avg_WriteErrors += dr->cur_WriteErrors ; + + dr->cur_ReadRetries -= dr->prev_ReadRetries ; + dr->prev_ReadRetries += dr->cur_ReadRetries ; + dr->avg_ReadRetries += dr->cur_ReadRetries ; + + dr->cur_WriteRetries -= dr->prev_WriteRetries ; + dr->prev_WriteRetries += dr->cur_WriteRetries; + dr->avg_WriteRetries += dr->cur_WriteRetries; + + dr->cur_TotalReadTime -= dr->prev_TotalReadTime ; + dr->prev_TotalReadTime += dr->cur_TotalReadTime ; + dr->avg_TotalReadTime += dr->cur_TotalReadTime ; + + dr->cur_TotalWriteTime -= dr->prev_TotalWriteTime ; + dr->prev_TotalWriteTime += dr->cur_TotalWriteTime ; + dr->avg_TotalWriteTime += dr->cur_TotalWriteTime ; + + /* I/O volume */ + interval_bytes = dr->cur_BytesRead + dr->cur_BytesWritten; + + /* I/O counts */ + interval_transfers = dr->cur_Reads + dr->cur_Writes; + + /* I/O time */ + interval_time = dr->cur_LatentReadTime + dr->cur_LatentWriteTime; + + interval_blocks = interval_bytes / dr->blocksize; + blocks_per_second = interval_blocks / avg_interval; + transfers_per_second = interval_transfers / avg_interval; + mb_per_second = (interval_bytes / avg_interval) / (1024 *1024); + + kb_per_transfer = (interval_transfers > 0) ? + ((long double)interval_bytes / interval_transfers) + / 1024 : 0; + + /* times are in nanoseconds, convert to milliseconds */ + ms_per_transaction = (interval_transfers > 0) ? + ((long double)interval_time / interval_transfers) + / 1000 : 0; + + /* print device name */ + fprintf(stdout, "%s %-10s", timebufptr, dr->name); + + /* print transfers per second */ + fprintf(stdout, "%4.0Lf ", transfers_per_second); + + /* print blocks per second - in device blocksize */ + fprintf(stdout, "%4.0Lf\n", blocks_per_second); + } +} + +/* + * Print averages before exiting. + */ +static void +exit_average() +{ + int i; + + if (avg_counter <= 0 ) + exit(0); + + if (oflag) + { + if (ofd) + close (ofd); + ofd = 0; + } + + if (uflag) /* print cpu averages */ + { + if(flag_count > 1) + print_column_heading(SAR_CPU, 0, 0); + + fprintf(stdout, "Average: %5d ", + (int)avg_cpuload.cpu_ticks[CPU_STATE_USER] + / (avg_counter ? avg_counter : 1)); + + fprintf(stdout, "%4d ", + (int)avg_cpuload.cpu_ticks[CPU_STATE_SYSTEM] + / (avg_counter ? avg_counter : 1)); + + fprintf(stdout, "%4d \n", + (int)avg_cpuload.cpu_ticks[CPU_STATE_IDLE] + / (avg_counter ? avg_counter : 1)); + + fflush(stdout); + } + + + if (gflag) /* print page-out averages */ + { + if (flag_count > 1) + print_column_heading(SAR_VMSTAT, 0, 0); + + fprintf(stdout, "Average: %8.1f\n", + (float)((avg_vmstat.pageouts / (avg_counter ? avg_counter : 1)) / avg_interval)); + fflush(stdout); + } + + if (pflag) /* print page-in averages */ + { + if (flag_count > 1) + print_column_heading(SAR_VMSTAT, 0, 1); + + fprintf(stdout, "Average: %8.1f %8.1f %8.1f\n", + (float)(((float)avg_vmstat.pageins / (avg_counter ? avg_counter : 1)) / avg_interval), + (float)(((float)avg_vmstat.cow_faults / (avg_counter ? avg_counter : 1)) / avg_interval), + (float)(((float)avg_vmstat.faults / (avg_counter ? avg_counter : 1)) / avg_interval)); + fflush(stdout); + } + + if (dflag) /* print drivestats averages */ + { + struct drivestats_report *dr; + long double transfers_per_second; + long double kb_per_transfer, mb_per_second; + u_int64_t total_bytes, total_transfers, total_blocks; + u_int64_t total_time; + long double blocks_per_second, ms_per_transaction; + int msdig; + + if (flag_count > 1) + print_column_heading(SAR_DRIVESTATS, 0, 0); + + for (dr=dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + /* don't bother to print out averages for disks that were removed */ + if (!dr->present) + continue; + + fprintf(stdout, " %s %s\n", + dp_table[dr->drivepath_id].BSDName, dp_table[dr->drivepath_id].ioreg_path); + + /* I/O volume */ + total_bytes = dr->avg_BytesRead + dr->avg_BytesWritten; + + /* I/O counts */ + total_transfers = dr->avg_Reads + dr->avg_Writes; + + /* I/O time */ + total_time = dr->avg_LatentReadTime + dr->avg_LatentWriteTime; + + total_blocks = total_bytes / dr->blocksize; + blocks_per_second = total_blocks / avg_interval; + transfers_per_second = total_transfers / avg_interval; + mb_per_second = (total_bytes / avg_interval) / (1024 *1024); + + kb_per_transfer = (total_transfers > 0) ? + ((long double)total_bytes / total_transfers) + / 1024 : 0; + + /* times are in nanoseconds, convert to milliseconds */ + ms_per_transaction = (total_transfers > 0) ? + ((long double)total_time / total_transfers) + / 1000 : 0; + msdig = (ms_per_transaction < 100.0) ? 1 : 0; + fprintf(stdout, "Average: %-10s %4.0Lf %4.0Lf\n", + dr->name, + (transfers_per_second / dr->avg_count), + (blocks_per_second / dr->avg_count)); + + fflush(stdout); + } + } /* end if dflag */ + + if (nflag) + { + int avg_count; + + if (network_mode & NET_DEV_MODE) + { + if (flag_count > 1) + print_column_heading(SAR_NETSTATS, 0, NET_DEV_MODE); + for (i = 0; i < nr_count; i++) + { + if (!nr_table[i].valid) + continue; + + if(nr_table[i].avg_count == 0) + avg_count = 1; + else + avg_count = nr_table[i].avg_count; + + fprintf(stdout, "Average: %-8.8s", nr_table[i].tname_unit); + + fprintf (stdout, "%8llu ", + ((nr_table[i].avg_ipackets / avg_count) / avg_interval)); + + fprintf (stdout, "%10llu ", + ((nr_table[i].avg_ibytes / avg_count) / avg_interval)); + + fprintf (stdout, "%8llu ", + ((nr_table[i].avg_opackets / avg_count) / avg_interval)); + + fprintf (stdout, "%10llu\n", + ((nr_table[i].avg_obytes / avg_count) / avg_interval)); + + fflush(stdout); + } + } + + if (network_mode & NET_EDEV_MODE) + { + + if(flag_count > 1) + print_column_heading(SAR_NETSTATS, 0, NET_EDEV_MODE); + + for (i = 0; i < nr_count; i++) + { + if (!nr_table[i].valid) + continue; + + if(nr_table[i].avg_count == 0) + avg_count = 1; + else + avg_count = nr_table[i].avg_count; + + fprintf(stdout, "Average: %-8.8s ", nr_table[i].tname_unit); + + fprintf (stdout, "%7llu ", + ((nr_table[i].avg_ierrors / avg_count) / avg_interval)); + + fprintf (stdout, "%7llu ", + ((nr_table[i].avg_oerrors / avg_count) / avg_interval)); + + fprintf (stdout, "%5llu ", + ((nr_table[i].avg_collisions / avg_count) / avg_interval)); + + fprintf (stdout, " %5llu\n", + ((nr_table[i].avg_drops / avg_count) / avg_interval)); + + fflush(stdout); + } + } + + } /* end if nflag */ + exit(0); +} + + +/* + * Return < 0 failure, debugging purposes only + * Return = 0 data skipped + * Return > 0 success + */ + +static int +get_drivepath_sample(flag, hdr) + int flag; + struct record_hdr *hdr; +{ + size_t datasize; + struct drivepath dp; + struct drivestats_report *dr; + int i, n; + + datasize = hdr->rec_count * hdr->rec_size; + + if (datasize != sizeof(struct drivepath)) + { + /* read past the data but don't do anything with it */ + skip_data(datasize); + return(0); + } + + read_record_data ((char *)&dp, (int)sizeof(struct drivepath), TRUE ); + + /* + * If state is new -- put a new entry in the dp_table. + * If state is changed -- traverse the drivestats_report table + * and copy new name. + */ + if (dp.state == DPSTATE_NEW) + { + + if (dp_table == NULL) + { + if (dp.drivepath_id != 0) + return(-1); + /* First setup of internal drivepath table */ + dp_table = (struct drivepath *)malloc(sizeof(struct drivepath)); + if (dp_table == NULL) + return(-2); + dp_count = 1; + } + + if (dflag) + fprintf(stdout, "New Disk: [%s] %s\n", dp.BSDName, dp.ioreg_path); + + /* traverse table and find next uninitialized entry */ + for (i = 0; i< dp_count; i++) + { + if (dp_table[i].state == DPSTATE_UNINITIALIZED) + { + if (dp.drivepath_id != i) + { + /* the table is out of sync - this should not happen */ + return (-3); + } + dp_table[i] = dp; + return(1); + } + } + /* + * If we get here, we've run out of table entries. + * Double the size of the table, then assign the next entry. + */ + if (dp.drivepath_id != i) + { + /* the table is out of sync - this should not happen */ + return (-4); + } + n = dp_count * 2; + dp_table = (struct drivepath *)realloc(dp_table, n * sizeof(struct drivepath)); + bzero(&dp_table[dp_count], dp_count * sizeof(struct drivepath)); + dp_table[dp_count] = dp; + dp_count = n; + return(1); + + } + else if (dp.state == DPSTATE_CHANGED) + { + + /* Update the name in the table */ + if ((dp.drivepath_id < dp_count) && (dp_table[dp.drivepath_id].state != DPSTATE_UNINITIALIZED)) + { + if (strcmp(dp_table[dp.drivepath_id].ioreg_path, dp.ioreg_path) != 0) + { + /* something is amiss */ + return (-5); + } + else + { + if (dflag) + { + fprintf(stdout, "Change: [%s] %s\n", dp.BSDName, + dp_table[dp.drivepath_id].ioreg_path); + } + strcpy(dp_table[dp.drivepath_id].BSDName, dp.BSDName); + + for(dr = dr_head; dr; dr=(struct drivestats_report *)dr->next) + { + if (dr->drivepath_id == dp.drivepath_id) + strcpy(dr->name, dp.BSDName); + } + return(1); + } + } + else + return(-6); + } + return(-7); +} + +/* + * Bytes and packet counts are used to track + * counter wraps. So, don't enforce the + * NET_DEV_MODE or NET_EDEV_MODE in here. + * Maintain all the stats. + */ +static void +set_cur_netstats(struct netstats_report *nr, struct netstats *ns) +{ + + nr->cur_ipackets = ns->net_ipackets; + nr->cur_ibytes = ns->net_ibytes; + nr->cur_opackets = ns->net_opackets; + nr->cur_obytes = ns->net_obytes; + + nr->cur_ierrors = ns->net_ierrors; + nr->cur_oerrors = ns->net_oerrors; + nr->cur_collisions = ns->net_collisions; + nr->cur_drops = ns->net_drops; + + nr->cur_imcasts = ns->net_imcasts; + nr->cur_omcasts = ns->net_omcasts; + +} + +static void +init_prev_netstats(struct netstats_report *nr) +{ + nr->avg_count = 0; + nr->valid = 1; + nr->present = 1; + + nr->prev_ipackets = nr->cur_ipackets; + nr->avg_ipackets = 0; + nr->prev_ibytes = nr->cur_ibytes; + nr->avg_ibytes = 0; + nr->prev_opackets = nr->cur_opackets; + nr->avg_opackets = 0; + nr->prev_obytes = nr->cur_obytes; + nr->avg_obytes = 0; + + nr->prev_ierrors = nr->cur_ierrors; + nr->avg_ierrors = 0; + nr->prev_oerrors = nr->cur_oerrors ; + nr->avg_oerrors = 0; + nr->prev_collisions = nr->cur_collisions ; + nr->avg_collisions = 0; + nr->prev_drops = nr->cur_drops ; + nr->avg_drops = 0; + + /* track these, but never displayed */ + nr->prev_imcasts = nr->cur_imcasts; + nr->avg_imcasts = 0; + nr->prev_omcasts = nr->cur_omcasts; + nr->avg_omcasts = 0; +} + +/* + * Success : 1 + * Failure : 0 + */ +static int +get_netstats_sample(flag, hdr) + int flag; + struct record_hdr *hdr; +{ + struct netstats *databuf = NULL; + size_t datasize; + int datacount; + int i, j; + + datasize = hdr->rec_count * hdr->rec_size; + datacount = hdr->rec_count; + + if (hdr->rec_size != sizeof(struct netstats)) + { + /* something isn't right... read past the data but don't analyze it */ + skip_data(datasize); + return(0); + } + + /* malloc new or bigger read buffer */ + if((netstat_readbuf == NULL) || (netstat_readbuf_size < datasize)) + { + if (netstat_readbuf) + free (netstat_readbuf); + + if ((netstat_readbuf = (struct netstats *)malloc(datasize)) == NULL) + { + fprintf(stderr, "sar: malloc failed\n"); + exit (EXIT_FAILURE); + } + netstat_readbuf_size = datasize; + } + + bzero(netstat_readbuf, netstat_readbuf_size); + databuf = netstat_readbuf; + + read_record_data ((char *)databuf, datasize, TRUE ); + + if (nr_table == NULL) + { + /* initial internal table setup */ + nr_table = (struct netstats_report *)malloc(datacount * sizeof(struct netstats_report)); + nr_count = datacount; + bzero(nr_table, (datacount * sizeof(struct netstats_report))); + + /* on first init, this is faster than finding our way to NEW_ENTRY */ + for (i = 0; i < datacount; i++) + { + if (!(network_mode & NET_PPP_MODE)) + { + if (!strncmp(databuf[i].tname_unit, "ppp", 3)) + continue; /* + * Skip ppp interfaces. + * ie don't even put them in this internal table. + */ + } + strncpy(nr_table[i].tname_unit, databuf[i].tname_unit, MAX_TNAME_UNIT_SIZE); + nr_table[i].tname_unit[MAX_TNAME_UNIT_SIZE] = '\0'; + set_cur_netstats(&nr_table[i], &databuf[i]); + init_prev_netstats(&nr_table[i]); + } + return(1); + } + + /* + * clear all the present flags. + * As we traverse the current sample set + * and update the internal table, the flag + * is reset. + */ + for (i = 0; i < nr_count; i++) + { + nr_table[i].present = 0; + } + + /* + * Find and update table entries. + * Init new entries. + */ + for (i=0; i 1)) + fprintf(stdout, "\n"); + + if (network_mode & NET_DEV_MODE) + { + if (flag_count > 1) + print_column_heading(SAR_NETSTATS, timebufptr, NET_DEV_MODE); + + for (i=0; i < nr_count; i++) + { + if (!nr_table[i].valid) + continue; + + if (!(network_mode & NET_PPP_MODE)) + { + if (!strncmp(nr_table[i].tname_unit, "ppp", 3)) + { + continue; /* skip any ppp interfaces */ + } + } + + /* print the interface name */ + fprintf(stdout, "%s %-8.8s", timebufptr, nr_table[i].tname_unit); + + fprintf (stdout, "%8llu ", + (nr_table[i].cur_ipackets / avg_interval)); + + fprintf (stdout, "%10llu ", + (nr_table[i].cur_ibytes / avg_interval)); + + fprintf (stdout, "%8llu ", + (nr_table[i].cur_opackets / avg_interval)); + + fprintf (stdout, "%10llu\n", + (nr_table[i].cur_obytes / avg_interval)); + } + } + + + if (network_mode & NET_EDEV_MODE) + { + if(flag_count > 1) + { + print_column_heading(SAR_NETSTATS, timebufptr, NET_EDEV_MODE); + } + + for (i=0; i < nr_count; i++) + { + if (!nr_table[i].valid) + continue; + + if (!(network_mode & NET_PPP_MODE)) + { + if (!strncmp(nr_table[i].tname_unit, "ppp", 3)) + { + continue; /* skip any ppp interfaces */ + } + } + + /* print the interface name */ + fprintf(stdout, "%s %-8.8s ", timebufptr, nr_table[i].tname_unit); + + fprintf (stdout, "%7llu ", + (nr_table[i].cur_ierrors / avg_interval)); + + fprintf (stdout, "%7llu ", + (nr_table[i].cur_oerrors / avg_interval)); + + fprintf (stdout, "%5llu ", + (nr_table[i].cur_collisions / avg_interval)); + + fprintf (stdout, " %5llu\n", + (nr_table[i].cur_drops / avg_interval)); + } + fflush(stdout); + } +} + +static void +print_column_heading(int type, char *timebufptr, int mode) +{ + char *p; + + p = timebufptr; + + if (p == NULL) + p = "Average:"; + + if (!(flag_count > 1)) + fprintf(stdout, "\n"); + + switch (type) + { + case SAR_CPU: + fprintf (stdout, "\n%s %%usr %%sys %%idle\n", p); + break; + + case SAR_VMSTAT: + if (mode == 0) /* gflag */ + fprintf(stdout, "\n%s pgout/s\n", p); + else if (mode == 1) /* pflag */ + fprintf(stdout, "\n%s pgin/s pflt/s vflt/s\n", p); + break; + case SAR_DRIVESTATS: + fprintf(stdout, "\n%s device r+w/s blks/s\n", p); + break; + case SAR_NETSTATS: + if (mode == NET_DEV_MODE) + { + fprintf(stdout, "\n%s %-8.8s %8.8s %10.10s %8.8s %10.10s\n", p, + " IFACE", "Ipkts/s", "Ibytes/s", "Opkts/s", "Obytes/s"); + } + else if (mode == NET_EDEV_MODE) + { + fprintf(stdout, "\n%s %-8.8s %7.7s %7.7s %5s %s\n", p, + " IFACE", "Ierrs/s", "Oerrs/s", "Coll/s", "Drop/s"); + } + break; + default: + break; + } +} + diff --git a/sar.tproj/sar.h b/sar.tproj/sar.h new file mode 100644 index 0000000..6f9ebc5 --- /dev/null +++ b/sar.tproj/sar.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include +#include +#include +#include +#include + +#define MAXDRIVENAME 31 /* largest drive name we allow */ + + +struct drivestats_report +{ + char *next; + int present; + int avg_count; + int drivepath_id; + char name[MAXDRIVENAME+1]; + u_int64_t blocksize; + + u_int64_t cur_Reads; + u_int64_t prev_Reads; + u_int64_t avg_Reads; + + u_int64_t cur_BytesRead; + u_int64_t prev_BytesRead; + u_int64_t avg_BytesRead; + + u_int64_t cur_Writes; + u_int64_t prev_Writes; + u_int64_t avg_Writes; + + u_int64_t cur_BytesWritten; + u_int64_t prev_BytesWritten; + u_int64_t avg_BytesWritten; + + u_int64_t cur_LatentReadTime; + u_int64_t prev_LatentReadTime; + u_int64_t avg_LatentReadTime; + + u_int64_t cur_LatentWriteTime; + u_int64_t prev_LatentWriteTime; + u_int64_t avg_LatentWriteTime; + + u_int64_t cur_ReadErrors; + u_int64_t prev_ReadErrors; + u_int64_t avg_ReadErrors; + + u_int64_t cur_WriteErrors; + u_int64_t prev_WriteErrors; + u_int64_t avg_WriteErrors; + + u_int64_t cur_ReadRetries; + u_int64_t prev_ReadRetries; + u_int64_t avg_ReadRetries; + + u_int64_t cur_WriteRetries; + u_int64_t prev_WriteRetries; + u_int64_t avg_WriteRetries; + + u_int64_t cur_TotalReadTime; + u_int64_t prev_TotalReadTime; + u_int64_t avg_TotalReadTime; + + u_int64_t cur_TotalWriteTime; + u_int64_t prev_TotalWriteTime; + u_int64_t avg_TotalWriteTime; +}; + +struct netstats_report +{ + int valid; + int present; + int avg_count; + unsigned long gen_counter; + char tname_unit[MAX_TNAME_UNIT_SIZE +1 ]; + + unsigned long long cur_ipackets; + unsigned long long prev_ipackets; + unsigned long long avg_ipackets; + + unsigned long long cur_ierrors; + unsigned long long prev_ierrors; + unsigned long long avg_ierrors; + + unsigned long long cur_opackets; + unsigned long long prev_opackets; + unsigned long long avg_opackets; + + unsigned long long cur_oerrors; + unsigned long long prev_oerrors; + unsigned long long avg_oerrors; + + unsigned long long cur_collisions; + unsigned long long prev_collisions; + unsigned long long avg_collisions; + + unsigned long long cur_ibytes; + unsigned long long prev_ibytes; + unsigned long long avg_ibytes; + + unsigned long long cur_obytes; + unsigned long long prev_obytes; + unsigned long long avg_obytes; + + unsigned long long cur_imcasts; + unsigned long long prev_imcasts; + unsigned long long avg_imcasts; + + unsigned long long cur_omcasts; + unsigned long long prev_omcasts; + unsigned long long avg_omcasts; + + unsigned long long cur_drops; + unsigned long long prev_drops; + unsigned long long avg_drops; + + +}; diff --git a/sc_usage.tproj/sc_usage.c b/sc_usage.tproj/sc_usage.c index adab8fa..95cfe4d 100644 --- a/sc_usage.tproj/sc_usage.c +++ b/sc_usage.tproj/sc_usage.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/sc_usage.tproj/trace.codes b/sc_usage.tproj/trace.codes index 714ae4a..f68df12 100644 --- a/sc_usage.tproj/trace.codes +++ b/sc_usage.tproj/trace.codes @@ -693,7 +693,9 @@ 0x40c025c BSC_getpgid 0x40c0260 BSC_setprivexec 0x40c0264 BSC_pread +0x40e0264 BSC_pread_extended 0x40c0268 BSC_pwrite +0x40e0268 BSC_pwrite_extended 0x40c026c BSC_nfssvc 0x40c0270 BSC_getdirentries 0x40c0274 BSC_statfs diff --git a/shutdown.tproj/Makefile.postamble b/shutdown.tproj/Makefile.postamble index 29865de..42bdd1f 100644 --- a/shutdown.tproj/Makefile.postamble +++ b/shutdown.tproj/Makefile.postamble @@ -1,2 +1,2 @@ INSTALL_AS_GROUP = operator # (probably want to set both of these) -INSTALL_PERMISSIONS = 4550 # If set, 'install' chmod's executable to this +INSTALL_PERMISSIONS = 0555 # If set, 'install' chmod's executable to this diff --git a/shutdown.tproj/pathnames.h b/shutdown.tproj/pathnames.h index 2bb5f01..4056ffe 100644 --- a/shutdown.tproj/pathnames.h +++ b/shutdown.tproj/pathnames.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/sync.tproj/sync.c b/sync.tproj/sync.c index 9a242f3..b61e1ba 100644 --- a/sync.tproj/sync.c +++ b/sync.tproj/sync.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/sysctl.tproj/sysctl.8 b/sysctl.tproj/sysctl.8 index b5151c1..eac32d6 100644 --- a/sysctl.tproj/sysctl.8 +++ b/sysctl.tproj/sysctl.8 @@ -39,15 +39,21 @@ .Nd get or set kernel state .Sh SYNOPSIS .Nm sysctl -.Op Fl n +.Op Fl bn .Ar name ... .Nm sysctl -.Op Fl n +.Op Fl bn .Fl w .Ar name=value ... .Nm sysctl -.Op Fl n -.Fl aA +.Op Fl bn +.Fl a +.Nm sysctl +.Op Fl bn +.Fl A +.Nm sysctl +.Op Fl bn +.Fl X .Sh DESCRIPTION The .Nm sysctl @@ -56,33 +62,42 @@ appropriate privilege to set kernel state. The state to be retrieved or set is described using a ``Management Information Base'' (``MIB'') style name, described as a dotted set of components. -The -.Fl a -flag can be used to list all the currently available string or integer values. -The -.Fl A -flag will list all the known MIB names including tables. -Those with string or integer values will be printed as with the -.Fl a -flag; for the table values, -the name of the utility to retrieve them is given. .Pp -The -.Fl n -flag specifies that the printing of the field name should be -suppressed and that only its value should be output. -This flag is useful for setting shell variables. -For example, to save the pagesize in variable psize, use: -.Bd -literal -offset indent -compact -set psize=`sysctl -n hw.pagesize` -.Ed +The following options are available: +.Bl -tag -width indent +.It Fl A +List all MIB variables including opaque variables (which are normally suppressed). +The format and length are printed, as well as a hex dump of the first sixteen bytes of the value. +.It Fl a +List all the currently available non-opaque values. +This option is ignored if one or more variable names are specified on +the command line. +.It Fl b +Force the value of the variable(s) to be output in raw, binary format. +No names are printed and no terminating newlines are output. +This is mostly useful with a single variable. +.It Fl n +Show only variable values, not their names. +This option is useful for setting shell variables. +For instance, to save the pagesize in variable +.Va psize , +use: +.Pp +.Dl "set psize=`sysctl -n hw.pagesize`" +.It Fl X +Same as +.Fl A +but prints a hex dump of the entire value instead of just the first few bytes. +.It Fl w Ar name=value +Used to set values. The MIB name ( +.Ar name +) followed by an equal sign and the new value ( +.Ar value +) to be used. +.El .Pp If just a MIB style name is given, the corresponding value is retrieved. -If a value is to be set, the -.Fl w -flag must be specified and the MIB name followed -by an equal sign and the new value to be used. .Pp The information available from .Nm sysctl diff --git a/sysctl.tproj/sysctl.c b/sysctl.tproj/sysctl.c index b1b8e75..8060eb0 100644 --- a/sysctl.tproj/sysctl.c +++ b/sysctl.tproj/sysctl.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -146,9 +147,9 @@ struct list secondlevel[] = { { kernname, KERN_MAXID }, /* CTL_KERN */ { vmname, VM_MAXID }, /* CTL_VM */ { 0, 0 }, /* CTL_VFS */ - { 0, 0 }, /* CTL_NET */ + { 0, 0 }, /* CTL_NET */ { 0, CTL_DEBUG_MAXID }, /* CTL_DEBUG */ - { hwname, HW_MAXID }, /* CTL_HW */ + { 0, 0 }, /* CTL_HW */ #ifdef CTL_MACHDEP_NAMES { machdepname, CPU_MAXID }, /* CTL_MACHDEP */ #else @@ -169,7 +170,7 @@ void usage(); static void parse(char *string, int flags); static int oidfmt(int *, int, char *, u_int *); -static int show_var(int *, int); +static int show_var(int *, int, int); static int sysctl_all (int *oid, int len); static int name2oid(char *, int *); @@ -350,7 +351,7 @@ old_parse(string, flags) break; case CTL_VM: - if (mib[1] == VM_LOADAVG) { + if (mib[1] == VM_LOADAVG) { /* XXX this is bogus */ double loads[3]; getloadavg(loads, 3); @@ -693,7 +694,7 @@ parse(char *string, int flags) foundSome = 1; old_parse (string, flags); } else { - i = show_var(mib, len); + i = show_var(mib, len, 1); if (!i && !bflag) putchar('\n'); } @@ -730,7 +731,7 @@ parse(char *string, int flags) kind & CTLTYPE); } - i = show_var(mib, len); + i = show_var(mib, len, 1); if (sysctl(mib, len, 0, 0, newval, newsize) == -1) { if (!i && !bflag) putchar('\n'); @@ -753,7 +754,7 @@ parse(char *string, int flags) printf(" -> "); i = nflag; nflag = 1; - j = show_var(mib, len); + j = show_var(mib, len, 1); if (!j && !bflag) putchar('\n'); nflag = i; @@ -886,7 +887,7 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind) */ static int -show_var(int *oid, int nlen) +show_var(int *oid, int nlen, int show_masked) { u_char buf[BUFSIZ], *val, *mval, *p; char name[BUFSIZ], /* descr[BUFSIZ], */ *fmt; @@ -932,11 +933,21 @@ show_var(int *oid, int nlen) err(1, "sysctl fmt %d %d %d", i, j, errno); kind = *(u_int *)buf; + if (!show_masked && (kind & CTLFLAG_MASKED)) { + retval = 1; + goto RETURN; + } fmt = (char *)(buf + sizeof(u_int)); p = val; switch (*fmt) { + case '-': + /* deprecated, do not print */ + retval = 0; + goto RETURN; + + case 'A': if (!nflag) printf("%s: ", name); @@ -985,6 +996,24 @@ show_var(int *oid, int nlen) retval = 0; goto RETURN; + case 'Q': + if (!nflag) + printf("%s: ", name); + fmt++; + val = ""; + while (len >= sizeof(long long)) { + if(*fmt == 'U') + printf("%s%llu", val, *(unsigned long long *)p); + else + printf("%s%lld", val, *(long long *)p); + val = " "; + len -= sizeof (long long); + p += sizeof (long long); + } + retval = 0; + goto RETURN; + + case 'T': case 'S': i = 0; @@ -1060,7 +1089,7 @@ sysctl_all (int *oid, int len) if (name2[i] != oid[i]) return 0; - i = show_var(name2, l2); + i = show_var(name2, l2, 0); if (!i && !bflag) putchar('\n'); diff --git a/update.tproj/update.c b/update.tproj/update.c index 980a7da..7afb397 100644 --- a/update.tproj/update.c +++ b/update.tproj/update.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vipw.tproj/pw_util.c b/vipw.tproj/pw_util.c index e0514a0..b6a1277 100644 --- a/vipw.tproj/pw_util.c +++ b/vipw.tproj/pw_util.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -235,7 +236,7 @@ pw_error(name, err, eval) int err, eval; { if (err) - warn(name); + warn("%s", name); warnx("%s: unchanged", _PATH_MASTERPASSWD); (void)unlink(tempname); diff --git a/vipw.tproj/pw_util.h b/vipw.tproj/pw_util.h index b5811b0..bd59553 100644 --- a/vipw.tproj/pw_util.h +++ b/vipw.tproj/pw_util.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vipw.tproj/vipw.c b/vipw.tproj/vipw.c index d15932b..9301626 100644 --- a/vipw.tproj/vipw.c +++ b/vipw.tproj/vipw.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vm_stat.tproj/vm_stat.c b/vm_stat.tproj/vm_stat.c index 6bad7ca..611924c 100644 --- a/vm_stat.tproj/vm_stat.c +++ b/vm_stat.tproj/vm_stat.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zdump.tproj/zdump.c b/zdump.tproj/zdump.c index ce849c4..5c8cd68 100644 --- a/zdump.tproj/zdump.c +++ b/zdump.tproj/zdump.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/datfiles/africa b/zic.tproj/datfiles/africa index 6ce6106..e8223f7 100644 --- a/zic.tproj/datfiles/africa +++ b/zic.tproj/datfiles/africa @@ -1,6 +1,4 @@ -# @(#)africa 7.34 - -# $FreeBSD: src/share/zoneinfo/africa,v 1.12 2000/10/25 19:36:48 wollman Exp $ +# @(#)africa 7.36 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -12,7 +10,7 @@ # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -57,7 +55,7 @@ # I invented the following abbreviations; corrections are welcome! # 2:00 WAST West Africa Summer Time # 2:30 BEAT British East Africa Time (no longer used) -# 2:45 BEAUT British East Africa Unified Time (no longer used) +# 2:44:45 BEAUT British East Africa Unified Time (no longer used) # 3:00 CAST Central Africa Summer Time (no longer used) # 3:00 SAST South Africa Summer Time (no longer used) # 3:00 EAT East Africa Time @@ -103,7 +101,7 @@ Zone Africa/Algiers 0:12:12 - LMT 1891 Mar 15 0:01 # Angola # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Luanda 0:52:56 - LMT 1892 - 0:52:04 - LMT 1911 May 26 # Luanda Mean Time? + 0:52:04 - AOT 1911 May 26 # Angola Time 1:00 - WAT # Benin @@ -278,7 +276,7 @@ Zone Africa/Bissau -1:02:20 - LMT 1911 May 26 Zone Africa/Nairobi 2:27:16 - LMT 1928 Jul 3:00 - EAT 1930 2:30 - BEAT 1940 - 2:45 - BEAUT 1960 + 2:44:45 - BEAUT 1960 3:00 - EAT # Lesotho @@ -289,9 +287,9 @@ Zone Africa/Maseru 1:50:00 - LMT 1903 Mar 2:00 - SAST # Liberia -# From Paul Eggert (1993-11-18): +# From Paul Eggert (2001-07-17): # In 1972 Liberia was the last country to switch -# from a UTC offset that was not a multiple of 15 minutes. +# from a UTC offset that was not a multiple of 15 or 20 minutes. # Howse reports that it was in honor of their president's birthday. # Shanks reports the date as May 1, whereas Howse reports Jan; go with Shanks. # For Liberia before 1972, Shanks reports -0:44, whereas Howse and Whitman @@ -483,6 +481,12 @@ Zone Africa/Dakar -1:09:44 - LMT 1912 # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria 4:00 - SCT # Seychelles Time +# From Paul Eggert (2001-05-30): +# Aldabra, Farquhar, and Desroches, originally dependencies of the +# Seychelles, were transferred to the British Indian Ocean Territory +# in 1965 and returned to Seychelles control in 1976. We don't know +# whether this affected their time zone, so omit this for now. +# Possibly the islands were uninhabited. # Sierra Leone # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -544,7 +548,7 @@ Zone Africa/Mbabane 2:04:24 - LMT 1903 Mar # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Dar_es_Salaam 2:37:08 - LMT 1931 3:00 - EAT 1948 - 2:45 - BEAUT 1961 + 2:44:45 - BEAUT 1961 3:00 - EAT # Togo @@ -587,7 +591,7 @@ Zone Africa/Tunis 0:40:44 - LMT 1881 May 12 Zone Africa/Kampala 2:09:40 - LMT 1928 Jul 3:00 - EAT 1930 2:30 - BEAT 1948 - 2:45 - BEAUT 1957 + 2:44:45 - BEAUT 1957 3:00 - EAT # Zambia diff --git a/zic.tproj/datfiles/antarctica b/zic.tproj/datfiles/antarctica index c98e528..b5c12cb 100644 --- a/zic.tproj/datfiles/antarctica +++ b/zic.tproj/datfiles/antarctica @@ -1,4 +1,4 @@ -# @(#)antarctica 7.21 +# @(#)antarctica 7.23 # From Paul Eggert (1999-11-15): # To keep things manageable, we list only locations occupied year-round; see @@ -39,8 +39,8 @@ Rule ArgAQ 1974 only - Jan 23 0:00 1:00 S Rule ArgAQ 1974 only - May 1 0:00 0 - Rule ArgAQ 1974 1976 - Oct Sun<=7 0:00 1:00 S Rule ArgAQ 1975 1977 - Apr Sun<=7 0:00 0 - -Rule ChileAQ 1969 1997 - Oct Sun>=9 0:00 1:00 S -Rule ChileAQ 1970 1998 - Mar Sun>=9 0:00 0 - +Rule ChileAQ 1966 1997 - Oct Sun>=9 0:00 1:00 S +Rule ChileAQ 1967 1998 - Mar Sun>=9 0:00 0 - Rule ChileAQ 1998 only - Sep 27 0:00 1:00 S Rule ChileAQ 1999 only - Apr 4 0:00 0 - Rule ChileAQ 1999 max - Oct Sun>=9 0:00 1:00 S @@ -92,11 +92,13 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb 13 # Brazil - year-round base # Ferraz, King George Island, since 1983/4 -# Chile - year-round bases +# Chile - year-round bases and towns # Escudero, South Shetland Is, -621157-0585735, since 1994 -# Frei, King George Is, -6214-05848, since 1969 +# Frei, King George Island, -6214-05848, since 1969-03-07 # O'Higgins, Antarctic Peninsula, -6319-05704, since 1948-02 # Prat, -6230-05941 +# Villa Las Estrellas (a town), King George Island, since 1984-04-09 +# These locations have always used Santiago time; use TZ='America/Santiago'. # China - year-round bases # Great Wall, King George Island, since 1985-02-20 @@ -219,6 +221,15 @@ Rule NZAQ 1990 max - Mar Sun>=15 2:00s 0 S # of GMT). This is a time zone I think two hours east of Moscow. The # natural time zone is in between the two: 8 hours ahead of GMT.'' # +# From Paul Eggert (2001-05-04): +# This seems to be hopelessly confusing, so I asked Lee Hotz about it +# in person. He said that some Antartic locations set their local +# time so that noon is the warmest part of the day, and that this +# changes during the year and does not necessarily correspond to mean +# solar noon. So the Vostok time might have been whatever the clocks +# happened to be during their visit. So we still don't really know what time +# it is at Vostok. But we'll guess UTC+6. +# Zone Antarctica/Vostok 0 - zzz 1957 Dec 16 6:00 - VOST # Vostok time @@ -244,6 +255,13 @@ Zone Antarctica/Vostok 0 - zzz 1957 Dec 16 # Halley is on a moving ice shelf and is periodically relocated # so that it is never more than 10km from its nominal location. # Rothera, Adelaide Island, -6734-6808, since 1976-12-01 +# +# From Paul Eggert (2002-10-22) +# says Rothera is -03 all year. +# +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 + -3:00 - ROTT # Rothera time # Uruguay - year round base # Artigas, King George Island, -621104-0585107 diff --git a/zic.tproj/datfiles/asia b/zic.tproj/datfiles/asia index cfefc19..92a9aa1 100644 --- a/zic.tproj/datfiles/asia +++ b/zic.tproj/datfiles/asia @@ -1,6 +1,4 @@ -# @(#)asia 7.63 - -# $FreeBSD: src/share/zoneinfo/asia,v 1.18 2001/04/06 16:46:52 wollman Exp $ +# @(#)asia 7.71 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -12,7 +10,7 @@ # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -31,19 +29,23 @@ # I invented the abbreviations marked `*' in the following table; # the rest are from earlier versions of this file, or from other sources. # Corrections are welcome! -# std dst -# LMT Local Mean Time -# 2:00 EET EEST Eastern European Time -# 2:00 IST IDT Israel -# 3:00 AST ADT Arabia* -# 4:00 GST Gulf* -# 5:30 IST India -# 7:00 ICT Indochina* -# 8:00 CST China -# 9:00 CJT Central Japanese Time (1896/1937)* -# 9:00 JST Japan -# 9:00 KST Korea -# 9:30 CST (Australian) Central Standard Time +# std dst +# LMT Local Mean Time +# 2:00 EET EEST Eastern European Time +# 2:00 IST IDT Israel +# 3:00 AST ADT Arabia* +# 3:30 IRST IRDT Iran +# 4:00 GST Gulf* +# 5:30 IST India +# 7:00 ICT Indochina* +# 7:00 WIT west Indonesia +# 8:00 CIT central Indonesia +# 8:00 CST China +# 9:00 CJT Central Japanese Time (1896/1937)* +# 9:00 EIT east Indonesia +# 9:00 JST Japan +# 9:00 KST Korea +# 9:30 CST (Australian) Central Standard Time # # See the `europe' file for Russia and Turkey in Asia. @@ -133,9 +135,11 @@ Zone Asia/Thimphu 5:58:36 - LMT 1947 Aug 15 # or Thimbu 6:00 - BTT # Bhutan Time # British Indian Ocean Territory -# From Whitman: +# Whitman and the 1995 CIA time zone map say 5:00, but the +# 1997 and later maps say 6:00. Assume the switch occurred in 1996. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Chagos 5:00 - IOT # BIOT Time +Zone Indian/Chagos 5:00 - IOT 1996 # BIOT Time + 6:00 - IOT # Brunei # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -169,7 +173,7 @@ Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jun 9 # China is across 4 physical time zones, before Feb 1, 1986 only the # Peking (Bejing) time zone was recognized. Since that date, China # has two of 'em -- Peking's and Urumqi (named after the capital of -# the Xinjiang Uighur Autonomous Region). I don't know about DST for it. +# the Xinjiang Uyghur Autonomous Region). I don't know about DST for it. # # . . .I just deleted the DST table and this editor makes it too # painful to suck in another copy.. So, here is what I have for @@ -197,26 +201,38 @@ Rule PRC 1949 only - Jan 1 0:00 0 S Rule PRC 1986 only - May 4 0:00 1:00 D Rule PRC 1986 1991 - Sep Sun>=11 0:00 0 S Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] +# +# From Anthony Fok (2001-12-20): +# BTW, I did some research on-line and found some info regarding these five +# historic timezones from some Taiwan websites. And yes, there are official +# Chinese names for these locales (before 1949): +# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) Zone Asia/Harbin 8:26:44 - LMT 1928 # or Haerbin - 8:30 - HART 1932 Mar # Harbin Time + 8:30 - CHAT 1932 Mar # Changbai Time 8:00 - CST 1940 - 9:00 - HART 1966 May - 8:30 - HART 1980 May + 9:00 - CHAT 1966 May + 8:30 - CHAT 1980 May 8:00 PRC C%sT +# Zhongyuan Time ("Central plain Time") Zone Asia/Shanghai 8:05:52 - LMT 1928 8:00 Shang C%sT 1949 8:00 PRC C%sT -Zone Asia/Chungking 7:06:20 - LMT 1928 # or Chongqing - 7:00 - CHUT 1980 May # Chungking Time +# Long-shu Time (probably due to Long and Shu being two names of that area) +Zone Asia/Chongqing 7:06:20 - LMT 1928 # or Chungking + 7:00 - LONT 1980 May # Long-shu Time 8:00 PRC C%sT +# Xin-zang Time ("Xinjiang-Tibet Time") Zone Asia/Urumqi 5:50:20 - LMT 1928 # or Urumchi 6:00 - URUT 1980 May # Urumqi Time 8:00 PRC C%sT +# Kunlun Time Zone Asia/Kashgar 5:03:56 - LMT 1928 # or Kashi or Kaxgar 5:30 - KAST 1940 # Kashgar Time 5:00 - KAST 1980 May 8:00 PRC C%sT + # Hong Kong (Xianggang) # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule HK 1946 only - Apr 20 3:30 1:00 S @@ -260,28 +276,28 @@ Rule Taiwan 1974 1975 - Oct 1 0:00 0 S Rule Taiwan 1980 only - Jun 30 0:00 1:00 D Rule Taiwan 1980 only - Sep 30 0:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Taipei 8:06:00 - LMT 1896 +Zone Asia/Taipei 8:06:00 - LMT 1896 # or Taibei or T'ai-pei 8:00 Taiwan C%sT -# Macao (Macau, Aomen) +# Macau (Macao, Aomen) # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Macao 1961 1962 - Mar Sun>=16 3:30 1:00 S -Rule Macao 1961 1964 - Nov Sun>=1 3:30 0 - -Rule Macao 1963 only - Mar Sun>=16 0:00 1:00 S -Rule Macao 1964 only - Mar Sun>=16 3:30 1:00 S -Rule Macao 1965 only - Mar Sun>=16 0:00 1:00 S -Rule Macao 1965 only - Oct 31 0:00 0 - -Rule Macao 1966 1971 - Apr Sun>=16 3:30 1:00 S -Rule Macao 1966 1971 - Oct Sun>=16 3:30 0 - -Rule Macao 1972 1974 - Apr Sun>=15 0:00 1:00 S -Rule Macao 1972 1973 - Oct Sun>=15 0:00 0 - -Rule Macao 1974 1977 - Oct Sun>=15 3:30 0 - -Rule Macao 1975 1977 - Apr Sun>=15 3:30 1:00 S -Rule Macao 1978 1980 - Apr Sun>=15 0:00 1:00 S -Rule Macao 1978 1980 - Oct Sun>=15 0:00 0 - +Rule Macau 1961 1962 - Mar Sun>=16 3:30 1:00 S +Rule Macau 1961 1964 - Nov Sun>=1 3:30 0 - +Rule Macau 1963 only - Mar Sun>=16 0:00 1:00 S +Rule Macau 1964 only - Mar Sun>=16 3:30 1:00 S +Rule Macau 1965 only - Mar Sun>=16 0:00 1:00 S +Rule Macau 1965 only - Oct 31 0:00 0 - +Rule Macau 1966 1971 - Apr Sun>=16 3:30 1:00 S +Rule Macau 1966 1971 - Oct Sun>=16 3:30 0 - +Rule Macau 1972 1974 - Apr Sun>=15 0:00 1:00 S +Rule Macau 1972 1973 - Oct Sun>=15 0:00 0 - +Rule Macau 1974 1977 - Oct Sun>=15 3:30 0 - +Rule Macau 1975 1977 - Apr Sun>=15 3:30 1:00 S +Rule Macau 1978 1980 - Apr Sun>=15 0:00 1:00 S +Rule Macau 1978 1980 - Oct Sun>=15 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Macao 7:34:20 - LMT 1912 - 8:00 Macao MO%sT 1999 Dec 20 # return to China +Zone Asia/Macau 7:34:20 - LMT 1912 + 8:00 Macau MO%sT 1999 Dec 20 # return to China 8:00 PRC C%sT @@ -359,7 +375,7 @@ Zone Asia/Dili 8:22:20 - LMT 1912 8:00 - TPT 1942 Feb 21 23:00 # E Timor Time 9:00 - JST 1945 Aug 9:00 - TPT 1976 May 3 - 8:00 - TPT 2000 Sep 17 00:00 + 8:00 - CIT 2000 Sep 17 00:00 9:00 - TPT # India @@ -376,112 +392,136 @@ Zone Asia/Calcutta 5:53:28 - LMT 1880 # Nicobar Is # Indonesia +# +# From Gwillim Law (2001-05-28), overriding Shanks: +# +# says that Indonesia's time zones changed on 1988-01-01. Looking at some +# time zone maps, I think that must refer to Western Borneo (Kalimantan Barat +# and Kalimantan Tengah) switching from UTC+8 to UTC+7. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Jakarta 7:07:12 - LMT 1867 Aug 10 # Shanks says the next transition was at 1924 Jan 1 0:13, # but this must be a typo. 7:07:12 - JMT 1923 Dec 31 23:47:12 # Jakarta 7:20 - JAVT 1932 Nov # Java Time - 7:30 - JAVT 1942 Mar 23 + 7:30 - WIT 1942 Mar 23 + 9:00 - JST 1945 Aug + 7:30 - WIT 1948 May + 8:00 - WIT 1950 May + 7:30 - WIT 1964 + 7:00 - WIT +Zone Asia/Pontianak 7:17:20 - LMT 1908 May + 7:17:20 - PMT 1932 Nov # Pontianak MT + 7:30 - WIT 1942 Jan 29 9:00 - JST 1945 Aug - 7:30 - JAVT 1948 May - 8:00 - JAVT 1950 May - 7:30 - JAVT 1964 - 7:00 - JAVT -Zone Asia/Ujung_Pandang 7:57:36 - LMT 1920 + 7:30 - WIT 1948 May + 8:00 - WIT 1950 May + 7:30 - WIT 1964 + 8:00 - CIT 1988 Jan 1 + 7:00 - WIT +Zone Asia/Makassar 7:57:36 - LMT 1920 7:57:36 - MMT 1932 Nov # Macassar MT - 8:00 - BORT 1942 Feb 9 # Borneo Time + 8:00 - CIT 1942 Feb 9 9:00 - JST 1945 Aug - 8:00 - BORT + 8:00 - CIT Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov - 9:00 - JAYT 1944 # Jayapura Time + 9:00 - EIT 1944 9:30 - CST 1964 - 9:00 - JAYT + 9:00 - EIT # Iran -# From Paul Eggert (2000-06-12), following up a suggestion by Rich Wales: -# Ahmea Alavi in -# -# TAGHVEEM (1993-07-12) -# -# writes ``Daylight saving time in Iran starts from the first day -# of Farvardin and ends the first day of Mehr.'' This disagrees with the SSIM: -# -# DST start DST end -# year SSIM Alavi SSIM Alavi -# 1991 05-03!= 03-21 09-20!= 09-23 -# 1992 03-22!= 03-21 09-23 09-23 -# 1993 03-21 03-21 09-23 09-23 -# 1994 03-21 03-21 09-22!= 09-23 -# 1995 03-21 03-21 09-22!= 09-23 -# 1996 03-21!= 03-20 09-22 09-22 -# 1997 03-22!= 03-21 09-22!= 09-23 -# 1998 03-21 03-21 09-21!= 09-23 -# 1999 03-22!= 03-21 09-22!= 09-23 -# 2000 03-21!= 03-20 09-21!= 09-22 -# 2001 03-19!= 03-21 09-19!= 09-23 -# 2002 03-18!= 03-21 09-18!= 09-23 -# -# Go with Alavi starting with 1992. -# I used Ed Reingold's cal-persia in GNU Emacs 19.34 to compute Persian dates. + +# From Roozbeh Pournader (2003-03-15): +# This is an English translation of what I just found (originally in Persian). +# The Gregorian dates in brackets are mine: +# +# Official Newspaper No. 13548-1370/6/25 [1991-09-16] +# No. 16760/T233 H 1370/6/10 [1991-09-01] +# +# The Rule About Change of the Official Time of the Country +# +# The Board of Ministers, in the meeting dated 1370/5/23 [1991-08-14], +# based on the suggestion number 2221/D dated 1370/4/22 [1991-07-13] +# of the Country's Organization for Official and Employment Affairs, +# and referring to the law for equating the working hours of workers +# and officers in the whole country dated 1359/4/23 [1980-07-14], and +# for synchronizing the official times of the country, agreed that: +# +# The official time of the country will should move forward one hour +# at the 24[:00] hours of the first day of Farvardin and should return +# to its previous state at the 24[:00] hours of the 30th day of +# Shahrivar. +# +# First Deputy to the President - Hassan Habibi +# +# From personal experience, that agrees with what has been followed +# for at least the last 5 years. Before that, for a few years, the +# date used was the first Thursday night of Farvardin and the last +# Thursday night of Shahrivar, but I can't give exact dates.... +# I have also changed the abbreviations to what is considered correct +# here in Iran, IRST for regular time and IRDT for daylight saving time. + +# From Paul Eggert (2003-03-15) +# Go with Shanks before September 1991, and with Pournader thereafter. +# I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates. # The Persian calendar is based on the sun, and dates after around 2050 # are approximate; stop after 2037 when 32-bit time_t's overflow. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iran 1978 1980 - Mar 21 0:00 1:00 S -Rule Iran 1978 only - Oct 21 0:00 0 - -Rule Iran 1979 only - Sep 19 0:00 0 - -Rule Iran 1980 only - Sep 23 0:00 0 - -Rule Iran 1991 only - May 3 0:00s 1:00 S -Rule Iran 1991 only - Sep 20 0:00s 0 - -Rule Iran 1992 1995 - Mar 21 0:00 1:00 S -Rule Iran 1992 1995 - Sep 23 0:00 0 - -Rule Iran 1996 only - Mar 20 0:00 1:00 S -Rule Iran 1996 only - Sep 22 0:00 0 - -Rule Iran 1997 1999 - Mar 21 0:00 1:00 S -Rule Iran 1997 1999 - Sep 23 0:00 0 - -Rule Iran 2000 only - Mar 20 0:00 1:00 S -Rule Iran 2000 only - Sep 22 0:00 0 - -Rule Iran 2001 2003 - Mar 21 0:00 1:00 S -Rule Iran 2001 2003 - Sep 23 0:00 0 - -Rule Iran 2004 only - Mar 20 0:00 1:00 S -Rule Iran 2004 only - Sep 22 0:00 0 - -Rule Iran 2005 2007 - Mar 21 0:00 1:00 S -Rule Iran 2005 2007 - Sep 23 0:00 0 - -Rule Iran 2008 only - Mar 20 0:00 1:00 S -Rule Iran 2008 only - Sep 22 0:00 0 - -Rule Iran 2009 2011 - Mar 21 0:00 1:00 S -Rule Iran 2009 2011 - Sep 23 0:00 0 - -Rule Iran 2012 only - Mar 20 0:00 1:00 S -Rule Iran 2012 only - Sep 22 0:00 0 - -Rule Iran 2013 2015 - Mar 21 0:00 1:00 S -Rule Iran 2013 2015 - Sep 23 0:00 0 - -Rule Iran 2016 only - Mar 20 0:00 1:00 S -Rule Iran 2016 only - Sep 22 0:00 0 - -Rule Iran 2017 2019 - Mar 21 0:00 1:00 S -Rule Iran 2017 2019 - Sep 23 0:00 0 - -Rule Iran 2020 only - Mar 20 0:00 1:00 S -Rule Iran 2020 only - Sep 22 0:00 0 - -Rule Iran 2021 2023 - Mar 21 0:00 1:00 S -Rule Iran 2021 2023 - Sep 23 0:00 0 - -Rule Iran 2024 2025 - Mar 20 0:00 1:00 S -Rule Iran 2024 2025 - Sep 22 0:00 0 - -Rule Iran 2026 2027 - Mar 21 0:00 1:00 S -Rule Iran 2026 2027 - Sep 23 0:00 0 - -Rule Iran 2028 2029 - Mar 20 0:00 1:00 S -Rule Iran 2028 2029 - Sep 22 0:00 0 - -Rule Iran 2030 2031 - Mar 21 0:00 1:00 S -Rule Iran 2030 2031 - Sep 23 0:00 0 - -Rule Iran 2032 2033 - Mar 20 0:00 1:00 S -Rule Iran 2032 2033 - Sep 22 0:00 0 - -Rule Iran 2034 2035 - Mar 21 0:00 1:00 S -Rule Iran 2034 2035 - Sep 23 0:00 0 - -Rule Iran 2036 2037 - Mar 20 0:00 1:00 S -Rule Iran 2036 2037 - Sep 22 0:00 0 - +Rule Iran 1978 1980 - Mar 21 0:00 1:00 D +Rule Iran 1978 only - Oct 21 0:00 0 S +Rule Iran 1979 only - Sep 19 0:00 0 S +Rule Iran 1980 only - Sep 23 0:00 0 S +Rule Iran 1991 only - May 3 0:00 1:00 D +Rule Iran 1992 1995 - Mar 22 0:00 1:00 D +Rule Iran 1991 1995 - Sep 22 0:00 0 S +Rule Iran 1996 only - Mar 21 0:00 1:00 D +Rule Iran 1996 only - Sep 21 0:00 0 S +Rule Iran 1997 1999 - Mar 22 0:00 1:00 D +Rule Iran 1997 1999 - Sep 22 0:00 0 S +Rule Iran 2000 only - Mar 21 0:00 1:00 D +Rule Iran 2000 only - Sep 21 0:00 0 S +Rule Iran 2001 2003 - Mar 22 0:00 1:00 D +Rule Iran 2001 2003 - Sep 22 0:00 0 S +Rule Iran 2004 only - Mar 21 0:00 1:00 D +Rule Iran 2004 only - Sep 21 0:00 0 S +Rule Iran 2005 2007 - Mar 22 0:00 1:00 D +Rule Iran 2005 2007 - Sep 22 0:00 0 S +Rule Iran 2008 only - Mar 21 0:00 1:00 D +Rule Iran 2008 only - Sep 21 0:00 0 S +Rule Iran 2009 2011 - Mar 22 0:00 1:00 D +Rule Iran 2009 2011 - Sep 22 0:00 0 S +Rule Iran 2012 only - Mar 21 0:00 1:00 D +Rule Iran 2012 only - Sep 21 0:00 0 S +Rule Iran 2013 2015 - Mar 22 0:00 1:00 D +Rule Iran 2013 2015 - Sep 22 0:00 0 S +Rule Iran 2016 only - Mar 21 0:00 1:00 D +Rule Iran 2016 only - Sep 21 0:00 0 S +Rule Iran 2017 2019 - Mar 22 0:00 1:00 D +Rule Iran 2017 2019 - Sep 22 0:00 0 S +Rule Iran 2020 only - Mar 21 0:00 1:00 D +Rule Iran 2020 only - Sep 21 0:00 0 S +Rule Iran 2021 2023 - Mar 22 0:00 1:00 D +Rule Iran 2021 2023 - Sep 22 0:00 0 S +Rule Iran 2024 2025 - Mar 21 0:00 1:00 D +Rule Iran 2024 2025 - Sep 21 0:00 0 S +Rule Iran 2026 2027 - Mar 22 0:00 1:00 D +Rule Iran 2026 2027 - Sep 22 0:00 0 S +Rule Iran 2028 2029 - Mar 21 0:00 1:00 D +Rule Iran 2028 2029 - Sep 21 0:00 0 S +Rule Iran 2030 2031 - Mar 22 0:00 1:00 D +Rule Iran 2030 2031 - Sep 22 0:00 0 S +Rule Iran 2032 2033 - Mar 21 0:00 1:00 D +Rule Iran 2032 2033 - Sep 21 0:00 0 S +Rule Iran 2034 2035 - Mar 22 0:00 1:00 D +Rule Iran 2034 2035 - Sep 22 0:00 0 S +Rule Iran 2036 2037 - Mar 21 0:00 1:00 D +Rule Iran 2036 2037 - Sep 21 0:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1946 # Tehran Mean Time - 3:30 - IRT 1977 Nov + 3:30 - IRST 1977 Nov 4:00 Iran IR%sT 1979 3:30 Iran IR%sT @@ -696,6 +736,46 @@ Zone Asia/Jerusalem 2:20:56 - LMT 1880 2:20:40 - JMT 1918 # Jerusalem Mean Time? 2:00 Zion I%sT +# From Ephraim Silverberg (2002-07-07): +# +# The Israeli government today adopted a proposal by Minister of Interior +# Eli Yishai to shorten the period of Daylight Savings Time for the year +# 2002 (only -- the dates for 2003 and 2004 are, so far, unaffected). +# +# The proposed date to Daylight Savings Time is September 13, 2002 instead +# of the current date: October 7, 2002. The hour of changeover has not +# yet been decided. +# +# (2002-07-10): +# While today the Knesset passed the initial proposal to reduce DST by +# some three weeks, a new compromise is being worked out between +# Minister of Justice Meir Sheetrit and Minister of Interior Eli +# Yishai to revert to standard time for a period of 48-96 _hours_ +# (sic) around the Yom Kippur fast day (September 15-16) and then go +# *back* to DST until the end of October. The details of the proposal +# have yet to be worked out, but the second and final readings of the +# bill have until July 24 to pass. +# +# (2002-07-25): +# Thanks go to Yitschak Goldberg from E&M for bringing this (Hebrew) article +# to my attention: +# +# http://www.ynet.co.il/articles/0,7340,L-2019315,00.html +# +# Hence, the proposal to shorten DST was withdrawn yesterday and the timezone +# files that have been in effect since July 2000 are still valid for all of +# 2002. +# +# Please note that the article mentions that the Shas MK's intend to +# bring up their amendment for future years (2003 and beyond). What this +# means exactly is anyone's guess since there are no set dates yet beyond +# 2004 and the end day set for 2003 and 2004 is already the 7th of Tishrei +# (i.e. before the fast of Yom Kippur). The only thing they may want to +# change is the start date of DST in 2003 from Mar.28.03 (24th of Adar II) +# to Apr.18.03 (16th of Nisan) so that the Passover Seder will take place +# during Standard Time. The start date for 2004 is already Nisan 16th. + + ############################################################################### @@ -798,31 +878,71 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time # IATA SSIM mentions a third time zone in Kazakhstan. # +# From Paul Eggert (2001-10-18): +# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses +# RussiaAsia rules, instead of switching at 00:00 as the IATA has it. +# Go with Shanks, who has them always using RussiaAsia rules. +# Also go with the following claims of Shanks: +# +# - Kazakhstan did not observe DST in 1991. +# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00. +# - Oral switched from +5:00 to +4:00 in spring 1989. +# +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] +# +# Almaty (formerly Alma-Ata), representing most locations in Kazakhstan Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata - 5:00 - ALMT 1957 Mar # Alma-Ata Time - 6:00 RussiaAsia ALM%sT 1991 Mar 31 2:00s - 5:00 1:00 ALMST 1991 Sep 29 2:00s - 5:00 - ALMT 1992 Jan 19 2:00s - 6:00 E-EurAsia ALM%sT + 5:00 - ALMT 1930 Jun 21 # Alma-Ata Time + 6:00 RussiaAsia ALM%sT 1991 + 6:00 - ALMT 1992 + 6:00 RussiaAsia ALM%sT +# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) +Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 + 4:00 - KIZT 1930 Jun 21 # Kizilorda Time + 5:00 - KIZT 1981 Apr 1 + 5:00 1:00 KIZST 1981 Oct 1 + 6:00 - KIZT 1982 Apr 1 + 5:00 RussiaAsia KIZ%sT 1991 + 5:00 - KIZT 1991 Dec 16 # independence + 5:00 - QYZT 1992 Jan 19 2:00 + 6:00 RussiaAsia QYZ%sT +# Aqtobe (aka Aktobe, formerly Akt'ubinsk) Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 - 4:00 - AKT 1957 Mar # Aktyubinsk Time - 5:00 RussiaAsia AK%sT 1991 Mar 31 2:00s - 4:00 1:00 AKTST 1991 Sep 29 2:00s - 4:00 - AQTT 1992 Jan 19 2:00s # Aqtobe Time - 5:00 E-EurAsia AQT%sT -Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 # or Aktau - 4:00 - SHET 1957 Mar # Fort Shevchenko Time - 5:00 RussiaAsia SHE%sT 1991 Mar 31 2:00s - 4:00 1:00 AQTST 1991 Sep 29 2:00s - 4:00 - AQTT 1992 Jan 19 2:00s # Aqtau Time - 5:00 E-EurAsia AQT%sT 1995 Sep lastSun - 4:00 E-EurAsia AQT%sT + 4:00 - AKTT 1930 Jun 21 # Aktyubinsk Time + 5:00 - AKTT 1981 Apr 1 + 5:00 1:00 AKTST 1981 Oct 1 + 6:00 - AKTT 1982 Apr 1 + 5:00 RussiaAsia AKT%sT 1991 + 5:00 - AKTT 1991 Dec 16 # independence + 5:00 RussiaAsia AQT%sT # Aqtobe Time +# Mangghystau +# Aqtau was not founded until 1963, but it represents an inhabited region, +# so include time stamps before 1963. +Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 + 4:00 - FORT 1930 Jun 21 # Fort Shevchenko T + 5:00 - FORT 1963 + 5:00 - SHET 1981 Oct 1 # Shevchenko Time + 6:00 - SHET 1982 Apr 1 + 5:00 RussiaAsia SHE%sT 1991 + 5:00 - SHET 1991 Dec 16 # independence + 5:00 RussiaAsia AQT%sT 1995 Sep lastSun # Aqtau Time + 4:00 RussiaAsia AQT%sT +# West Kazakhstan +Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk + 4:00 - URAT 1930 Jun 21 # Ural'sk time + 5:00 - URAT 1981 Apr 1 + 5:00 1:00 URAST 1981 Oct 1 + 6:00 - URAT 1982 Apr 1 + 5:00 RussiaAsia URA%sT 1989 Mar 26 2:00 + 4:00 RussiaAsia URA%sT 1991 + 4:00 - URAT 1991 Dec 16 # independence + 4:00 RussiaAsia ORA%sT # Oral Time # Kyrgyzstan (Kirgizstan) # Transitions through 1991 are from Shanks. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Kirgiz 1992 1996 - Apr Sun>=7 0:00 1:00 S +Rule Kirgiz 1992 1996 - Apr Sun>=7 0:00s 1:00 S Rule Kirgiz 1992 1996 - Sep lastSun 0:00 0 - Rule Kirgiz 1997 max - Mar lastSun 2:30 1:00 S Rule Kirgiz 1997 max - Oct lastSun 2:30 0 - @@ -913,9 +1033,11 @@ Zone Asia/Beirut 2:22:00 - LMT 1880 # Malaysia # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NBorneo 1935 1941 - Sep 14 0:00 0:20 TS +Rule NBorneo 1935 1941 - Sep 14 0:00 0:20 TS # one-Third Summer Rule NBorneo 1935 1941 - Dec 14 0:00 0 - +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] +# peninsular Malaysia Zone Asia/Kuala_Lumpur 6:46:48 - LMT 1880 6:55:24 - SMT 1905 Jun # Singapore Mean Time 7:00 - MALT 1933 # Malaya Time @@ -924,6 +1046,7 @@ Zone Asia/Kuala_Lumpur 6:46:48 - LMT 1880 7:20 - MALT 1950 7:30 - MALT 1982 May 8:00 - MYT # Malaysia Time +# Sabah & Sarawak Zone Asia/Kuching 7:21:20 - LMT 1926 Mar 7:30 - BORT 1933 # Borneo Time 8:00 NBorneo BOR%sT 1942 @@ -962,38 +1085,51 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Male # Suhbaatar, and possibly Khentij. # From Paul Eggert (1999-12-15): -# For now, we'll comment out the east zone (Choybalsan) -# and use Shanks's and the IATA's data for the daylight-saving rules. # Naming and spelling is tricky in Mongolia. # We'll use Hovd (also spelled Chovd and Khovd) to represent the west zone; # the capital of the Hovd province is sometimes called Hovd, sometimes Dund-Us, # and sometimes Jirgalanta (with variant spellings), but the name Hovd # is good enough for our purposes. +# From Rives McDow (2001-05-13): +# In addition to Mongolia starting daylight savings as reported earlier +# (adopted DST on 2001-04-27 02:00 local time, ending 2001-09-28), +# there are three time zones. +# +# Provinces [at 7:00]: Bayan-ulgii, Uvs, Khovd, Zavkhan, Govi-Altai +# Provinces [at 8:00]: Khovsgol, Bulgan, Arkhangai, Khentii, Tov, +# Bayankhongor, Ovorkhangai, Dundgovi, Dornogovi, Omnogovi +# Provinces [at 9:00]: Dornod, Sukhbaatar +# +# [The province of Selenge is omitted from the above lists.] + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Mongol 1981 1984 - Apr 1 0:00 1:00 S -Rule Mongol 1981 1984 - Oct 1 0:00 0 - -Rule Mongol 1985 1990 - Mar lastSun 2:00 1:00 S -Rule Mongol 1985 1990 - Sep lastSun 3:00 0 - -Rule Mongol 1991 1998 - Mar lastSun 0:00 1:00 S -Rule Mongol 1991 1995 - Sep lastSun 0:00 0 - -# IATA SSIM (1996-09) says 1996-10-25; go with Shanks. -Rule Mongol 1996 only - Oct lastSun 0:00 0 - -Rule Mongol 1997 1998 - Sep lastSun 0:00 0 - +Rule Mongol 1983 1984 - Apr 1 0:00 1:00 S +Rule Mongol 1983 only - Oct 1 0:00 0 - +# IATA SSIM says 1990s switches occurred at 00:00, but Shanks (1995) lists +# them at 02:00s, and McDow says the 2001 switches also occurred at 02:00. +# Also, IATA SSIM (1996-09) says 1996-10-25. Go with Shanks through 1998. +Rule Mongol 1985 1998 - Mar lastSun 2:00s 1:00 S +Rule Mongol 1984 1998 - Sep lastSun 2:00s 0 - # IATA SSIM (1999-09) says Mongolia no longer observes DST. +Rule Mongol 2001 only - Apr 27 2:00s 1:00 S +Rule Mongol 2001 only - Sep 28 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta Zone Asia/Hovd 6:06:36 - LMT 1905 Aug 6:00 - HOVT 1978 # Hovd Time 7:00 Mongol HOV%sT +# Ulaanbaatar, a.k.a. Ulan Bataar, Ulan Bator, Urga Zone Asia/Ulaanbaatar 7:07:32 - LMT 1905 Aug 7:00 - ULAT 1978 # Ulaanbaatar Time 8:00 Mongol ULA%sT -# We're not sure about this entry yet, so we'll omit it for now. -#Zone Asia/Choybalsan 7:38:00 - LMT 1905 Aug -# 8:00 - CHOT 1978 # Choybalsan Time -# 9:00 Mongol CHO%sT 19?? -# 8:00 Mongol ULA%sT +# Choibalsan, a.k.a. Bajan Tuemen, Bajan Tumen, Chojbalsan, +# Choybalsan, Sanbejse, Tchoibalsan +Zone Asia/Choibalsan 7:38:00 - LMT 1905 Aug + 7:00 - ULAT 1978 + 8:00 - ULAT 1983 Apr + 9:00 Mongol CHO%sT # Choibalsan Time # Nepal # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1007,13 +1143,53 @@ Zone Asia/Muscat 3:54:20 - LMT 1920 4:00 - GST # Pakistan + +# From Rives McDow (2002-03-13): +# I have been advised that Pakistan has decided to adopt dst on a +# TRIAL basis for one year, starting 00:01 local time on April 7, 2002 +# and ending at 00:01 local time October 6, 2002. This is what I was +# told, but I believe that the actual time of change may be 00:00; the +# 00:01 was to make it clear which day it was on. + +# From Paul Eggert (2002-03-15): +# Jesper Norgaard found this URL: +# http://www.pak.gov.pk/public/news/app/app06_dec.htm +# (dated 2001-12-06) which says that the Cabinet adopted a scheme "to +# advance the clocks by one hour on the night between the first +# Saturday and Sunday of April and revert to the original position on +# 15th October each year". This agrees with McDow's 04-07 at 00:00, +# but disagrees about the October transition, and makes it sound like +# it's not on a trial basis. Also, the "between the first Saturday +# and Sunday of April" phrase, if taken literally, means that the +# transition takes place at 00:00 on the first Sunday on or after 04-02. + +# From Paul Eggert (2003-02-09): +# DAWN reported on 2002-10-05 +# that 2002 DST ended that day at midnight. Go with McDow for now. + +# From Steffen Thorsen (2003-03-14): +# According to http://www.dawn.com/2003/03/07/top15.htm +# there will be no DST in Pakistan this year: +# +# ISLAMABAD, March 6: Information and Media Development Minister Sheikh +# Rashid Ahmed on Thursday said the cabinet had reversed a previous +# decision to advance clocks by one hour in summer and put them back by +# one hour in winter with the aim of saving light hours and energy. +# +# The minister told a news conference that the experiment had rather +# shown 8 per cent higher consumption of electricity. + + +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Pakistan 2002 only - Apr Sun>=2 0:01 1:00 S +Rule Pakistan 2002 only - Oct Sun>=2 0:01 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Karachi 4:28:12 - LMT 1907 5:30 - IST 1942 Sep 5:30 1:00 IST 1945 Oct 15 5:30 - IST 1951 Sep 30 5:00 - KART 1971 Mar 26 # Karachi Time - 5:00 - PKT # Pakistan Time + 5:00 Pakistan PK%sT # Pakistan Time # Palestine diff --git a/zic.tproj/datfiles/australasia b/zic.tproj/datfiles/australasia index f0db6a9..5fc7b1b 100644 --- a/zic.tproj/datfiles/australasia +++ b/zic.tproj/datfiles/australasia @@ -1,12 +1,14 @@ -# @(#)australasia 7.64 +# @(#)australasia 7.68 # This file also includes Pacific islands. -# $FreeBSD: src/share/zoneinfo/australasia,v 1.19 2001/05/01 14:10:12 schweikh Exp $ + # Notes are at the end of this file ############################################################################### # Australia +# Please see the notes below for the controversy about "EST" versus "AEST" etc. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Aus 1917 only - Jan 1 0:01 1:00 - Rule Aus 1917 only - Mar 25 2:00 0 - @@ -295,6 +297,17 @@ Zone Pacific/Noumea 11:05:48 - LMT 1912 Jan 13 ############################################################################### # New Zealand +# +# From Paul Eggert (2002-10-23): +# The Department of Internal Affairs (DIA) maintains a brief history; +# see tz-link.htm for the full reference. +# +# Shanks gives 1868 for the introduction of standard time; go with the +# DIA's more-precise 1868-11-02. The DIA says that clocks were +# advanced by half an hour in 1941; go with Shanks's more-precise +# 1940-09-29 02:00. The DIA says that starting in 1933 DST began the +# first Sunday in September; go with Shanks's last Sunday starting in +# 1934. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Shanks gives 1927 Nov 6 - 1928 Mar 4, 1928 Oct 14 - 1929 Mar 17, @@ -309,17 +322,17 @@ Rule NZ 1930 1933 - Oct Sun>=8 2:00 0:30 HD # didn't change until 1945 Apr 30; go with Shanks. Rule NZ 1934 1940 - Apr lastSun 2:00 0 S Rule NZ 1934 1939 - Sep lastSun 2:00 0:30 HD -Rule NZ 1974 only - Nov 3 2:00s 1:00 D +Rule NZ 1974 only - Nov Sun>=1 2:00s 1:00 D +Rule NZ 1975 only - Feb lastSun 2:00s 0 S Rule NZ 1975 1988 - Oct lastSun 2:00s 1:00 D -Rule NZ 1989 only - Oct 8 2:00s 1:00 D -Rule NZ 1990 max - Oct Sun>=1 2:00s 1:00 D -Rule NZ 1975 only - Feb 23 2:00s 0 S Rule NZ 1976 1989 - Mar Sun>=1 2:00s 0 S +Rule NZ 1989 only - Oct Sun>=8 2:00s 1:00 D +Rule NZ 1990 max - Oct Sun>=1 2:00s 1:00 D Rule NZ 1990 max - Mar Sun>=15 2:00s 0 S Rule Chatham 1990 max - Oct Sun>=1 2:45s 1:00 D Rule Chatham 1991 max - Mar Sun>=15 2:45s 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Auckland 11:39:04 - LMT 1868 +Zone Pacific/Auckland 11:39:04 - LMT 1868 Nov 2 11:30 NZ NZ%sT 1940 Sep 29 2:00 12:00 NZ NZ%sT Zone Pacific/Chatham 12:45 Chatham CHA%sT @@ -359,7 +372,7 @@ Zone Pacific/Palau 8:57:56 - LMT 1901 # Koror # Papua New Guinea # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Port_Moresby 9:48:40 - LMT 1880 - 9:48:40 - PMMT 1895 # Port Moresby Mean Time + 9:48:32 - PMMT 1895 # Port Moresby Mean Time 10:00 - PGT # Papua New Guinea Time # Pitcairn @@ -397,8 +410,8 @@ Zone Pacific/Fakaofo -11:24:56 - LMT 1901 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Tonga 1999 only - Oct 7 2:00s 1:00 S Rule Tonga 2000 only - Mar 19 2:00s 0 - -Rule Tonga 2000 only - Nov 4 2:00s 1:00 S -Rule Tonga 2001 only - Jan 27 2:00s 0 - +Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 S +Rule Tonga 2001 2002 - Jan lastSun 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Tongatapu 12:19:20 - LMT 1901 12:20 - TOT 1941 # Tonga Time @@ -473,7 +486,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -535,12 +548,93 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # prefixed by the word `Australian' when referring to local times; # time announcements on that service, naturally enough, are made in UTC. -# From Arthur David Olson (March 8 1992): +# From Arthur David Olson (1992-03-08): # Given the above, what's chosen for year-round use is: # CST for any place operating at a GMTOFF of 9:30 # WST for any place operating at a GMTOFF of 8:00 # EST for any place operating at a GMTOFF of 10:00 +# From Paul Eggert (2001-04-05), summarizing a long discussion about "EST" +# versus "AEST" etc.: +# +# I see the following points of dispute: +# +# * How important are unique time zone abbreviations? +# +# Here I tend to agree with the point (most recently made by Chris +# Newman) that unique abbreviations should not be essential for proper +# operation of software. We have other instances of ambiguity +# (e.g. "IST" denoting both "Israel Standard Time" and "Indian +# Standard Time"), and they are not likely to go away any time soon. +# In the old days, some software mistakenly relied on unique +# abbreviations, but this is becoming less true with time, and I don't +# think it's that important to cater to such software these days. +# +# On the other hand, there is another motivation for unambiguous +# abbreviations: it cuts down on human confusion. This is +# particularly true for Australia, where "EST" can mean one thing for +# time T and a different thing for time T plus 1 second. +# +# * Does the relevant legislation indicate which abbreviations should be used? +# +# Here I tend to think that things are a mess, just as they are in +# many other countries. We Americans are currently disagreeing about +# which abbreviation to use for the newly legislated Chamorro Standard +# Time, for example. +# +# Personally, I would prefer to use common practice; I would like to +# refer to legislation only for examples of common practice, or as a +# tiebreaker. +# +# * Do Australians more often use "Eastern Daylight Time" or "Eastern +# Summer Time"? Do they typically prefix the time zone names with +# the word "Australian"? +# +# My own impression is that both "Daylight Time" and "Summer Time" are +# common and are widely understood, but that "Summer Time" is more +# popular; and that the leading "A" is also common but is omitted more +# often than not. I just used AltaVista advanced search and got the +# following count of page hits: +# +# 1,103 "Eastern Summer Time" AND domain:au +# 971 "Australian Eastern Summer Time" AND domain:au +# 613 "Eastern Daylight Time" AND domain:au +# 127 "Australian Eastern Daylight Time" AND domain:au +# +# Here "Summer" seems quite a bit more popular than "Daylight", +# particularly when we know the time zone is Australian and not US, +# say. The "Australian" prefix seems to be popular for Eastern Summer +# Time, but unpopular for Eastern Daylight Time. +# +# For abbreviations, tools like AltaVista are less useful because of +# ambiguity. Many hits are not really time zones, unfortunately, and +# many hits denote US time zones and not Australian ones. But here +# are the hit counts anyway: +# +# 161,304 "EST" and domain:au +# 25,156 "EDT" and domain:au +# 18,263 "AEST" and domain:au +# 10,416 "AEDT" and domain:au +# +# 14,538 "CST" and domain:au +# 5,728 "CDT" and domain:au +# 176 "ACST" and domain:au +# 29 "ACDT" and domain:au +# +# 7,539 "WST" and domain:au +# 68 "AWST" and domain:au +# +# This data suggest that Australians tend to omit the "A" prefix in +# practice. The situation for "ST" versus "DT" is less clear, given +# the ambiguities involved. +# +# * How do Australians feel about the abbreviations in the tz database? +# +# If you just count Australians on this list, I count 2 in favor and 3 +# against. One of the "against" votes (David Keegel) counseled delay, +# saying that both AEST/AEDT and EST/EST are widely used and +# understood in Australia. + # From Paul Eggert (1995-12-19): # Shanks reports 2:00 for all autumn changes in Australia and New Zealand. # Mark Prior writes that his newspaper @@ -655,6 +749,38 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # From Arthur David Olson (1992-03-08): # The chosen rules the union of the 1971/1972 change and the 1989-1992 changes. +# From Rives McDow (2002-04-09): +# The most interesting region I have found consists of three towns on the +# southern coast of Australia, population 10 at last report, along with +# 50,000 sheep, about 100 kilometers long and 40 kilometers into the +# continent. The primary town is Madura, with the other towns being +# Mundrabilla and Eucla. According to the sheriff of Madura, the +# residents got tired of having to change the time so often, as they are +# located in a strip overlapping the border of South Australia and Western +# Australia. South Australia observes daylight saving time; Western +# Australia does not. The two states are one and a half hours apart. The +# residents decided to forget about this nonsense of changing the clock so +# much and set the local time 20 hours and 45 minutes from the +# international date line, or right in the middle of the time of South +# Australia and Western Australia. As it only affects about 10 people and +# tourists staying at the Madura Motel, it has never really made as big an +# impact as Broken Hill. However, as tourist visiting there or anyone +# calling the local sheriff will attest, they do keep time in this way. +# +# From Paul Eggert (2002-04-09): +# This is confirmed by the section entitled +# "What's the deal with time zones???" in +# , +# which says a few other things: +# +# * Border Village, SA also is 45 minutes ahead of Perth. +# * The locals call this time zone "central W.A. Time" (presumably "CWAT"). +# * The locals also call Western Australia time "Perth time". +# +# It's not clear from context whether everyone in Western Australia +# knows of this naming convention, or whether it's just the people in +# this subregion. + # South Australia, Tasmania, Victoria # From Arthur David Olson (1992-03-08): @@ -756,6 +882,28 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # # The state of VICTORIA.. [ Courtesy of Vic. Dept of Premier + Cabinet ] # # [ Nov 1990 ] +# From Scott Harrington (2001-08-29): +# On KQED's "City Arts and Lectures" program last night I heard an +# interesting story about daylight savings time. Dr. John Heilbron was +# discussing his book "The Sun in the Church: Cathedrals as Solar +# Observatories"[1], and in particular the Shrine of Remembrance[2] located +# in Melbourne, Australia. +# +# Apparently the shrine's main purpose is a beam of sunlight which +# illuminates a special spot on the floor at the 11th hour of the 11th day +# of the 11th month (Remembrance Day) every year in memory of Australia's +# fallen WWI soldiers. And if you go there on Nov. 11, at 11am local time, +# you will indeed see the sunbeam illuminate the special spot at the +# expected time. +# +# However, that is only because of some special mirror contraption that had +# to be employed, since due to daylight savings time, the true solar time of +# the remembrance moment occurs one hour later (or earlier?). Perhaps +# someone with more information on this jury-rig can tell us more. +# +# [1] http://www.hup.harvard.edu/catalog/HEISUN.html +# [2] http://www.shrine.org.au + # New South Wales # From Arthur David Olson: @@ -868,7 +1016,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Lord Howe Island Board (controlling authority for the Island) is # seeking the community's views on various options for summer time # arrangements on the Island, e.g. advance clocks by 1 full hour -# instead of only 30 minutes. Dependent on the wishes of residents +# instead of only 30 minutes. Dependant on the wishes of residents # the Board may approach the NSW government to change the existing # arrangements. The starting date for summer time on the Island will # however always coincide with the rest of NSW. @@ -1120,6 +1268,15 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # From Rives McDow (2000-12-01): # Tonga is observing DST as of 2000-11-04 and will stop on 2001-01-27. +# From Sione Moala-Mafi (2001-09-20) via Rives McDow: +# At 2:00am on the first Sunday of November, the standard time in the Kingdom +# shall be moved forward by one hour to 3:00am. At 2:00am on the last Sunday +# of January the standard time in the Kingdom shall be moved backward by one +# hour to 1:00am. + +# From Pulu 'Anau (2002-11-05): +# The law was for 3 years, supposedly to get renewed. It wasn't. + ############################################################################### # The International Date Line diff --git a/zic.tproj/datfiles/backward b/zic.tproj/datfiles/backward index 0bfa872..eace5ab 100644 --- a/zic.tproj/datfiles/backward +++ b/zic.tproj/datfiles/backward @@ -1,4 +1,4 @@ -# @(#)backward 7.20 +# @(#)backward 7.23 # This file provides links between current names for time zones # and their old names. Many names changed in late 1993. @@ -8,9 +8,13 @@ Link America/Tijuana America/Ensenada Link America/Indianapolis America/Fort_Wayne Link America/Indiana/Knox America/Knox_IN Link America/Rio_Branco America/Porto_Acre +Link America/Cordoba America/Rosario Link America/St_Thomas America/Virgin -Link Asia/Dhaka Asia/Dacca Link Asia/Ashgabat Asia/Ashkhabad +Link Asia/Chongqing Asia/Chungking +Link Asia/Dhaka Asia/Dacca +Link Asia/Macau Asia/Macao +Link Asia/Makassar Asia/Ujung_Pandang Link Asia/Jerusalem Asia/Tel_Aviv Link Asia/Thimphu Asia/Thimbu Link Asia/Ulaanbaatar Asia/Ulan_Bator @@ -43,9 +47,9 @@ Link Pacific/Easter Chile/EasterIsland Link America/Havana Cuba Link Africa/Cairo Egypt Link Europe/Dublin Eire +Link Europe/Chisinau Europe/Tiraspol Link Europe/London GB Link Europe/London GB-Eire -Link Europe/Chisinau Europe/Tiraspol Link Etc/GMT+0 GMT+0 Link Etc/GMT-0 GMT-0 Link Etc/GMT0 GMT0 @@ -65,9 +69,9 @@ Link America/Denver Navajo Link Pacific/Auckland NZ Link Pacific/Chatham NZ-CHAT Link Pacific/Pago_Pago Pacific/Samoa -Link Asia/Shanghai PRC Link Europe/Warsaw Poland Link Europe/Lisbon Portugal +Link Asia/Shanghai PRC Link Asia/Taipei ROC Link Asia/Seoul ROK Link Asia/Singapore Singapore diff --git a/zic.tproj/datfiles/europe b/zic.tproj/datfiles/europe index 04a8f84..50fe876 100644 --- a/zic.tproj/datfiles/europe +++ b/zic.tproj/datfiles/europe @@ -1,6 +1,4 @@ -# @(#)europe 7.78 - -# $FreeBSD: src/share/zoneinfo/europe,v 1.22 2001/04/06 16:46:52 wollman Exp $ +# @(#)europe 7.83 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -11,7 +9,7 @@ # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -35,17 +33,20 @@ # I invented the abbreviations marked `*' in the following table; # the rest are from earlier versions of this file, or from other sources. # Corrections are welcome! -# std dst -# LMT Local Mean Time -# -4:00 AST Atlantic -# -3:00 WGT WGST Western Greenland* -# -1:00 EGT EGST Eastern Greenland* -# 0:00 GMT BST Greenwich, British Summer -# 0:00 GMT IST Greenwich, Irish Summer -# 0:00 WET WEST Western Europe -# 1:00 CET CEST Central Europe -# 2:00 EET EEST Eastern Europe -# 3:00 MSK MSD Moscow +# std dst 2dst +# LMT Local Mean Time +# -4:00 AST ADT Atlantic +# -3:00 WGT WGST Western Greenland* +# -1:00 EGT EGST Eastern Greenland* +# 0:00 GMT BST BDST Greenwich, British Summer +# 0:00 GMT IST Greenwich, Irish Summer +# 0:00 WET WEST WEMT Western Europe +# 0:19:32.13 AMT NST Amsterdam, Netherlands Summer (1835-1937)* +# 0:20 NET NEST Netherlands (1937-1940)* +# 1:00 CET CEST CEMT Central Europe +# 1:00:14 SET Swedish (1879-1899)* +# 2:00 EET EEST Eastern Europe +# 3:00 MSK MSD Moscow # # A reliable and entertaining source about time zones, especially in Britain, # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). @@ -195,7 +196,7 @@ # and extending this list, which can be found in # # History of legal time in Britain -# (2000-02-12). +# # From Joseph S. Myers (1998-01-06): # @@ -205,7 +206,7 @@ # (Lords Hansard 11 June 1997 columns 964 to 976) # . -# From Paul Eggert (2000-02-17): +# From Paul Eggert (2001-07-18): # # For lack of other data, we'll follow Shanks for Eire in 1940-1948. # @@ -233,6 +234,12 @@ # # # Whitman says Dublin Mean Time was -0:25:21, which is more precise than Shanks. +# Perhaps this was Dunsink Observatory Time, as Dunsink Observatory +# (8 km NW of Dublin's center) seemingly was to Dublin as Greenwich was +# to London. For example: +# +# "Timeball on the ballast office is down. Dunsink time." +# -- James Joyce, Ulysses # From Paul Eggert (1999-03-28): # Clive Feather (, 1997-03-31) @@ -373,14 +380,14 @@ Zone Europe/London -0:01:15 - LMT 1847 Dec 1 0:00 GB-Eire %s 1996 0:00 EU GMT/BST Zone Europe/Belfast -0:23:40 - LMT 1880 Aug 2 - -0:25:21 - DMT 1916 May 21 2:00 # Dublin MT + -0:25:21 - DMT 1916 May 21 2:00 # Dublin/Dunsink MT -0:25:21 1:00 IST 1916 Oct 1 2:00s # Irish Summer Time 0:00 GB-Eire %s 1968 Oct 27 1:00 - BST 1971 Oct 31 2:00u 0:00 GB-Eire %s 1996 0:00 EU GMT/BST -Zone Europe/Dublin -0:25:21 - LMT 1880 Aug 2 - -0:25:21 - DMT 1916 May 21 2:00 # Dublin MT +Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 + -0:25:21 - DMT 1916 May 21 2:00 -0:25:21 1:00 IST 1916 Oct 1 2:00s 0:00 GB-Eire %s 1921 Dec 6 # independence 0:00 GB-Eire GMT/IST 1940 Feb 25 2:00 @@ -551,20 +558,30 @@ Zone Europe/Andorra 0:06:04 - LMT 1901 1:00 EU CE%sT # Austria + +# From Paul Eggert (2003-02-28): Shanks gives 1918-06-16 and +# 1945-11-18, but the Austrian Federal Office of Metrology and +# Surveying (BEV) gives 1918-09-16 and for Vienna gives the "alleged" +# date of 1945-04-12 with no time. For the 1980-04-06 transition +# Shanks gives 02:00, the BEV 00:00. Go with the BEV, and guess 02:00 +# for 1945-04-12. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Austria 1920 only - Apr 5 2:00s 1:00 S Rule Austria 1920 only - Sep 13 2:00s 0 - -Rule Austria 1945 only - Apr 2 2:00s 1:00 S -Rule Austria 1945 only - Nov 18 2:00s 0 - Rule Austria 1946 only - Apr 14 2:00s 1:00 S Rule Austria 1946 1948 - Oct Sun>=1 2:00s 0 - Rule Austria 1947 only - Apr 6 2:00s 1:00 S Rule Austria 1948 only - Apr 18 2:00s 1:00 S +Rule Austria 1980 only - Apr 6 0:00 1:00 S +Rule Austria 1980 only - Sep 28 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Vienna 1:05:20 - LMT 1893 Apr - 1:00 C-Eur CE%sT 1918 Jun 16 3:00 - 1:00 Austria CE%sT 1940 Apr 1 2:00 - 1:00 C-Eur CE%sT 1945 Apr 2 2:00 + 1:00 C-Eur CE%sT 1920 + 1:00 Austria CE%sT 1940 Apr 1 2:00s + 1:00 C-Eur CE%sT 1945 Apr 2 2:00s + 1:00 1:00 CEST 1945 Apr 12 2:00s + 1:00 - CET 1946 1:00 Austria CE%sT 1981 1:00 EU CE%sT @@ -647,7 +664,7 @@ Zone Europe/Brussels 0:17:30 - LMT 1880 1:00 EU CE%sT # Bosnia and Herzegovina -# see Yugoslavia +# see Serbia and Montenegro # Bulgaria # @@ -674,7 +691,7 @@ Zone Europe/Sofia 1:33:16 - LMT 1880 2:00 EU EE%sT # Croatia -# see Yugosloavia +# see Serbia and Montenegro # Czech Republic # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -727,12 +744,74 @@ Zone Atlantic/Faeroe -0:27:04 - LMT 1908 Jan 11 # Torshavn # used C-Eur rules after 1980, but IATA SSIM (1991/1996) says they use EU # rules since at least 1991. Assume EU rules since 1980. +# From Gwillin Law (2001-06-06), citing +# (2001-03-15), +# and with translations corrected by Steffen Thorsen: +# +# Greenland has four local times, and the relation to UTC +# is according to the following time line: +# +# The military zone near Thule UTC-4 +# Standard Greenland time UTC-3 +# Scoresbysund UTC-1 +# Danmarkshavn UTC +# +# In the military area near Thule and in Danmarkshavn DST will not be +# introduced. + +# From Rives McDow (2001-11-01): +# +# I correspond regularly with the Dansk Polarcenter, and wrote them at +# the time to clarify the situation in Thule. Unfortunately, I have +# not heard back from them regarding my recent letter. [But I have +# info from earlier correspondence.] +# +# According to the center, a very small local time zone around Thule +# Air Base keeps the time according to UTC-4, implementing daylight +# savings using North America rules, changing the time at 02:00 local time.... +# +# The east coast of Greenland north of the community of Scoresbysund +# uses UTC in the same way as in Iceland, year round, with no dst. +# There are just a few stations on this coast, including the +# Danmarkshavn ICAO weather station mentioned in your September 29th +# email. The other stations are two sledge patrol stations in +# Mestersvig and Daneborg, the air force base at Station Nord, and the +# DPC research station at Zackenberg. +# +# Scoresbysund and two small villages nearby keep time UTC-1 and use +# the same daylight savings time period as in West Greenland (Godthab). +# +# The rest of Greenland, including Godthab (this area, although it +# includes central Greenland, is known as west Greenland), keeps time +# UTC-3, with daylight savings methods according to European rules. +# +# It is common procedure to use UTC 0 in the wilderness of East and +# North Greenland, because it is mainly Icelandic aircraft operators +# maintaining traffic in these areas. However, the official status of +# this area is that it sticks with Godthab time. This area might be +# considered a dual time zone in some respects because of this. + +# From Rives McDow (2001-11-19): +# I heard back from someone stationed at Thule; the time change took place +# there at 2:00 AM. + +# From Paul Eggert (2001-11-19): +# The 1997 CIA map shows Danmarkshavn on GMT; the 1995 map as like Godthab. +# For lack of better info, assume they were like Godthab before 1996. +# startkart.no says Thule does not observe DST, but this is clearly an error, +# so go with Shanks for all Thule transitions. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Thule 1991 1992 - Mar lastSun 2:00 1:00 D +Rule Thule 1991 1992 - Sep lastSun 2:00 0 S Rule Thule 1993 max - Apr Sun>=1 2:00 1:00 D Rule Thule 1993 max - Oct lastSun 2:00 0 S # # Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone America/Danmarkshavn -1:14:40 - LMT 1916 Jul 28 + -3:00 - WGT 1980 Apr 6 2:00 + -3:00 EU WG%sT 1996 + 0:00 - GMT Zone America/Scoresbysund -1:29:00 - LMT 1916 Jul 28 # Ittoqqortoormiit -2:00 - CGT 1980 Apr 6 2:00 -2:00 C-Eur CG%sT 1981 Mar 29 @@ -784,6 +863,13 @@ Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik air base # no. 206 (1998-09-22) and thus sticks Estonia to +02:00 GMT for all # the year round. The regulation is effective 1999-11-01. +# From Toomas Soome (2002-02-21): +# The Estonian government has changed once again timezone politics. +# Now we are using again EU rules. +# +# From Urmet Jaanes (2002-03-28): +# The legislative reference is Government decree No. 84 on 2002-02-21. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Tallinn 1:39:00 - LMT 1880 1:39:00 - TMT 1918 Feb # Tallinn Mean Time @@ -796,7 +882,8 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880 2:00 1:00 EEST 1989 Sep 24 2:00s 2:00 C-Eur EE%sT 1998 Sep 22 2:00 EU EE%sT 1999 Nov 1 - 2:00 - EET + 2:00 - EET 2002 Feb 21 + 2:00 EU EE%sT # Finland # @@ -914,25 +1001,29 @@ Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 # From Markus Kuhn (1998-09-29): # The German time zone web site by the Physikalisch-Technische # Bundesanstalt contains DST information back to 1916. -# -# -# Realisation of Legal Time in Germany -# +# [See tz-link.htm for the URL.] + +# From Joerg Schilling (2002-10-23): +# In 1945, Berlin was switched to Moscow Summer time (GMT+4) by +# General [Nikolai] Bersarin. + +# From Paul Eggert (2003-03-08): +# +# says that Bersarin issued an order to use Moscow time on May 20. +# However, Moscow did not observe daylight saving in 1945, so +# this was equivalent to CEMT (GMT+3), not GMT+4. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Germany 1945 only - Apr 2 2:00s 1:00 S -# Shanks says 05-24 2:00 to 09-24 3:00 for DDST; go with the PTB, who quotes -# the Archiv fuer publizist. Arbeit (Munzinger-Archiv) 652 (Zeitsystem) -# (1961-11-25), which gives dates only. Guess 3:00 transition times. -Rule Germany 1945 only - May 31 3:00 2:00 M # Midsummer -Rule Germany 1945 only - Sep 23 3:00 1:00 S +Rule Germany 1945 only - May 24 2:00 2:00 M # Midsummer +Rule Germany 1945 only - Sep 24 3:00 1:00 S Rule Germany 1945 only - Nov 18 2:00s 0 - Rule Germany 1946 only - Apr 14 2:00s 1:00 S Rule Germany 1946 only - Oct 7 2:00s 0 - Rule Germany 1947 1949 - Oct Sun>=1 2:00s 0 - Rule Germany 1947 only - Apr 6 2:00s 1:00 S -# The PTB gives 3:00 CET and 3:00 CEST for the midsummer transition times; -# go with Shanks. Rule Germany 1947 only - May 11 2:00s 2:00 M Rule Germany 1947 only - Jun 29 3:00 1:00 S Rule Germany 1948 only - Apr 18 2:00s 1:00 S @@ -1080,7 +1171,7 @@ Zone Atlantic/Reykjavik -1:27:24 - LMT 1837 # # From Paul Eggert (2001-03-06): # Sicily and Sardinia each had their own time zones from 1866 to 1893, -# called ``Palermo Time'' (+0053) and ``Cagliari Time'' (+0038). +# called Palermo Time (+00:53:28) and Cagliari Time (+00:36:32). # During World War II, German-controlled Italy used German time. # But these events all occurred before the 1970 cutoff, # so record only the time in Rome. @@ -1264,6 +1355,15 @@ Zone Europe/Vaduz 0:38:04 - LMT 1894 Jun # Fact File, Lithuanian State Department of Tourism # (2000-03-27): Local time is GMT+2 hours ..., no daylight saving. +# From a user via Klaus Marten (2003-02-07): +# As a candidate for membership of the European Union, Lithuania will +# observe Summer Time in 2003, changing its clocks at the times laid +# down in EU Directive 2000/84 of 19.I.01 (i.e. at the same times as its +# neighbour Latvia). The text of the Lithuanian government Order of +# 7.XI.02 to this effect can be found at +# http://www.lrvk.lt/nut/11/n1749.htm + + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Vilnius 1:41:16 - LMT 1880 1:24:00 - WMT 1917 # Warsaw Mean Time @@ -1278,7 +1378,8 @@ Zone Europe/Vilnius 1:41:16 - LMT 1880 2:00 C-Eur EE%sT 1998 2:00 - EET 1998 Mar 29 1:00u 1:00 EU CE%sT 1999 Oct 31 1:00u - 2:00 - EET + 2:00 - EET 2003 Jan 1 + 2:00 EU EE%sT # Luxembourg # Whitman disagrees with most of these dates in minor ways; go with Shanks. @@ -1316,7 +1417,7 @@ Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun 1:00 EU CE%sT # Macedonia -# see Yugoslavia +# see Serbia and Montenegro # Malta # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1373,22 +1474,59 @@ Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 1:00 EU CE%sT # Netherlands + # Howse writes that the Netherlands' railways used GMT between 1892 and 1940, # but for other purposes the Netherlands used Amsterdam mean time. -# The data before 1945 is taken from + +# However, Robert H. van Gent writes (2001-04-01): +# Howse's statement is only correct up to 1909. From 1909-05-01 (00:00:00 +# Amsterdam mean time) onwards, the whole of the Netherlands (including +# the Dutch railways) was required by law to observe Amsterdam mean time +# (19 minutes 32.13 seconds ahead of GMT). This had already been the +# common practice (except for the railways) for many decades but it was +# not until 1909 when the Dutch government finally defined this by law. +# On 1937-07-01 this was changed to 20 minutes (exactly) ahead of GMT and +# was generally known as Dutch Time ("Nederlandse Tijd"). +# +# (2001-04-08): +# 1892-05-01 was the date when the Dutch railways were by law required to +# observe GMT while the remainder of the Netherlands adhered to the common +# practice of following Amsterdam mean time. +# +# (2001-04-09): +# In 1835 the authorities of the province of North Holland requested the +# municipal authorities of the towns and cities in the province to observe +# Amsterdam mean time but I do not know in how many cases this request was +# actually followed. +# +# From 1852 onwards the Dutch telegraph offices were by law required to +# observe Amsterdam mean time. As the time signals from the observatory of +# Leiden were also distributed by the telegraph system, I assume that most +# places linked up with the telegraph (and railway) system automatically +# adopted Amsterdam mean time. +# +# Although the early Dutch railway companies initially observed a variety +# of times, most of them had adopted Amsterdam mean time by 1858 but it +# was not until 1866 when they were all required by law to observe +# Amsterdam mean time. + +# The data before 1945 are taken from # . + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Neth 1916 only - May 1 0:00 1:00 NST # Netherlands Summer Time Rule Neth 1916 only - Oct 1 0:00 0 AMT # Amsterdam Mean Time Rule Neth 1917 only - Apr 16 2:00s 1:00 NST Rule Neth 1917 only - Sep 17 2:00s 0 AMT Rule Neth 1918 1921 - Apr Mon>=1 2:00s 1:00 NST -Rule Neth 1918 1921 - Sep lastSun 2:00s 0 AMT +Rule Neth 1918 1921 - Sep lastMon 2:00s 0 AMT Rule Neth 1922 only - Mar lastSun 2:00s 1:00 NST Rule Neth 1922 1936 - Oct Sun>=2 2:00s 0 AMT Rule Neth 1923 only - Jun Fri>=1 2:00s 1:00 NST Rule Neth 1924 only - Mar lastSun 2:00s 1:00 NST Rule Neth 1925 only - Jun Fri>=1 2:00s 1:00 NST +# From 1926 through 1939 DST began 05-15, except that it was delayed by a week +# in years when 05-15 fell in the Pentecost weekend. Rule Neth 1926 1931 - May 15 2:00s 1:00 NST Rule Neth 1932 only - May 22 2:00s 1:00 NST Rule Neth 1933 1936 - May 15 2:00s 1:00 NST @@ -1398,10 +1536,13 @@ Rule Neth 1937 1939 - Oct Sun>=2 2:00s 0 - Rule Neth 1938 1939 - May 15 2:00s 1:00 S Rule Neth 1945 only - Apr 2 2:00s 1:00 S Rule Neth 1945 only - Sep 16 2:00s 0 - +# +# Amsterdam Mean Time was +00:19:32.13 exactly, but the .13 is omitted +# below because the current format requires GMTOFF to be an integer. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Amsterdam 0:19:28 - LMT 1892 May - 0:19:28 Neth %s 1937 Jul - 0:20 Neth NE%sT 1940 May 17 0:00 +Zone Europe/Amsterdam 0:19:32 - LMT 1835 + 0:19:32 Neth %s 1937 Jul 1 + 0:20 Neth NE%sT 1940 May 16 0:00 # Dutch Time 1:00 C-Eur CE%sT 1945 Apr 2 2:00 1:00 Neth CE%sT 1977 1:00 EU CE%sT @@ -1419,17 +1560,62 @@ Rule Norway 1959 1964 - Mar Sun>=15 2:00s 1:00 S Rule Norway 1959 1965 - Sep Sun>=15 2:00s 0 - Rule Norway 1965 only - Apr 25 2:00s 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Oslo 0:43:00 - LMT 1895 +Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 1:00 Norway CE%sT 1940 Aug 10 23:00 1:00 C-Eur CE%sT 1945 Apr 2 2:00 1:00 Norway CE%sT 1980 1:00 EU CE%sT # Svalbard & Jan Mayen + +# From Steffen Thorsen (2001-05-01): +# Although I could not find it explicitly, it seems that Jan Mayen and +# Svalbard have been using the same time as Norway at least since the +# time they were declared as parts of Norway. Svalbard was declared +# as a part of Norway by law of 1925-07-17 no 11, section 4 and Jan +# Mayen by law of 1930-02-27 no 2, section 2. (From +# http://www.lovdata.no/all/nl-19250717-011.html and +# http://www.lovdata.no/all/nl-19300227-002.html). The law/regulation +# for normal/standard time in Norway is from 1894-06-29 no 1 (came +# into operation on 1895-01-01) and Svalbard/Jan Mayen seem to be a +# part of this law since 1925/1930. (From +# http://www.lovdata.no/all/nl-18940629-001.html ) I have not been +# able to find if Jan Mayen used a different time zone (e.g. -0100) +# before 1930. Jan Mayen has only been "inhabitated" since 1921 by +# Norwegian meteorologists and maybe used the same time as Norway ever +# since 1921. Svalbard (Arctic/Longyearbyen) has been inhabited since +# before 1895, and therefore probably changed the local time somewhere +# between 1895 and 1925 (inclusive). + +# From Paul Eggert (2001-05-01): +# +# Actually, Jan Mayen was never occupied by Germany during World War II, +# so it must have diverged from Oslo time during the war, as Olso was +# keeping Berlin time. +# +# says that the meteorologists +# burned down their station in 1940 and left the island, but returned in +# 1941 with a small Norwegian garrison and continued operations despite +# frequent air ttacks from Germans. In 1943 the Americans established a +# radiolocating station on the island, called "Atlantic City". Possibly +# the UTC offset changed during the war, but I think it unlikely that +# Jan Mayen used German daylight-saving rules. +# +# Svalbard is more complicated, as it was raided in August 1941 by an +# Allied party that evacuated the civilian population to England (says +# ). The Svalbard FAQ +# says that the Germans were +# expelled on 1942-05-14. However, small parties of Germans did return, +# and according to Wilhelm Dege's book "War North of 80" (1954) +# +# the German armed forces at the Svalbard weather station code-named +# Haudegen did not surrender to the Allies until September 1945. +# +# All these events predate our cutoff date of 1970. Unless we can +# come up with more definitive info about the timekeeping during the +# war years it's probably best just do do the following for now: Link Europe/Oslo Arctic/Longyearbyen -# From Whitman: -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Jan_Mayen -1:00 - EGT +Link Europe/Oslo Atlantic/Jan_Mayen # Poland # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1573,14 +1759,14 @@ Zone Europe/Lisbon -0:36:32 - LMT 1884 1:00 EU CE%sT 1996 Mar 31 1:00u 0:00 EU WE%sT Zone Atlantic/Azores -1:42:40 - LMT 1884 # Ponta Delgada - -1:55 - HMT 1911 May 24 # Horta Mean Time + -1:54:32 - HMT 1911 May 24 # Horta Mean Time -2:00 Port AZO%sT 1966 Apr 3 2:00 # Azores Time -1:00 Port AZO%sT 1983 Sep 25 1:00s -1:00 W-Eur AZO%sT 1992 Sep 27 1:00s 0:00 EU WE%sT 1993 Mar 28 1:00u -1:00 EU AZO%sT Zone Atlantic/Madeira -1:07:36 - LMT 1884 # Funchal - -1:08 - FMT 1911 May 24 # Funchal Mean Time + -1:07:36 - FMT 1911 May 24 # Funchal Mean Time -1:00 Port MAD%sT 1966 Apr 3 2:00 # Madeira Time 0:00 Port WE%sT 1983 Sep 25 1:00s 0:00 EU WE%sT @@ -1621,6 +1807,12 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # are from Andrey A. Chernov. The rest is from Shanks, except we follow # Chernov's report that 1992 DST transitions were Sat 23:00, not Sun 02:00s. # +# From Stanislaw A. Kuzikowski (1994-06-29): +# But now it is some months since Novosibirsk is 3 hours ahead of Moscow! +# I do not know why they have decided to make this change; +# as far as I remember it was done exactly during winter->summer switching +# so we (Novosibirsk) simply did not switch. +# # From Andrey A. Chernov (1996-10-04): # `MSK' and `MSD' were born and used initially on Moscow computers with # Unix-like OSes by several developer groups (e.g. Demos group, Kiae group).... @@ -1639,12 +1831,44 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # the rest of Russia for two weeks--even soldiers stationed here began # enforcing curfew at the wrong time. # +# From Gwillim Law (2001-06-05): +# There's considerable evidence that Sakhalin Island used to be in +# UTC+11, and has changed to UTC+10, in this decade. I start with the +# SSIM, which listed Yuzhno-Sakhalinsk in zone RU10 along with Magadan +# until February 1997, and then in RU9 with Khabarovsk and Vladivostok +# since September 1997.... Although the Kuril Islands are +# administratively part of Sakhalin oblast', they appear to have +# remained on UTC+11 along with Magadan. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Kaliningrad 1:22:00 - LMT 1893 Apr +# +# Kaliningradskaya oblast'. +Zone Europe/Kaliningrad 1:22:00 - LMT 1893 Apr 1:00 C-Eur CE%sT 1945 2:00 Poland CE%sT 1946 3:00 Russia MSK/MSD 1991 Mar 31 2:00s 2:00 Russia EE%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Respublika Adygeya, Arkhangel'skaya oblast', Astrakhanskaya oblast', +# Belgorodskaya oblast', Bryanskaya oblast', Vladimirskaya oblast', +# Volgogradskaya oblast', Vologodskaya oblast', Voronezhskaya oblast', +# Respublika Dagestan, Ivanovskaya oblast', Respublika Ingushetiya, +# Kabarbino-Balkarskaya Respublika, Respublika Kalmykiya, +# Kalyzhskaya oblast', Respublika Karachaevo-Cherkessiya, +# Respublika Kareliya, Kirovskaya oblast', Respublika Komi, +# Kostromskaya oblast', Krasnodarskij kraj, Kurskaya oblast', +# Leningradskaya oblast', Lipetskaya oblast', Respublika Marij El, +# Respublika Mordoviya, Moskva, Moskovskaya oblast', +# Murmanskaya oblast', Nenetskij avtonomnyj okrug, +# Nizhegorodskaya oblast', Novgorodskaya oblast', Orlovskaya oblast', +# Penzenskaya oblast', Pskovskaya oblast', Rostovskaya oblast', +# Ryazanskaya oblast', Sankt-Peterburg, Saratovskaya oblast', +# Respublika Severnaya Osetiya, Smolenskaya oblast', +# Stavropol'skij kraj, Tambovskaya oblast', Respublika Tatarstan, +# Tverskaya oblast', Tyl'skaya oblast', Ul'yanovskaya oblast', +# Chechenskaya Respublika, Chuvashskaya oblast', +# Yaroslavskaya oblast' Zone Europe/Moscow 2:30:20 - LMT 1880 2:30 - MMT 1916 Jul 3 # Moscow Mean Time 2:30:48 Russia %s 1919 Jul 1 2:00 @@ -1653,6 +1877,9 @@ Zone Europe/Moscow 2:30:20 - LMT 1880 3:00 Russia MSK/MSD 1991 Mar 31 2:00s 2:00 Russia EE%sT 1992 Jan 19 2:00s 3:00 Russia MSK/MSD +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Samarskaya oblast', Udmyrtskaya respublika Zone Europe/Samara 3:20:36 - LMT 1919 Jul 1 2:00 3:00 - KUYT 1930 Jun 21 # Kuybyshev 4:00 Russia KUY%sT 1989 Mar 26 2:00s @@ -1660,59 +1887,115 @@ Zone Europe/Samara 3:20:36 - LMT 1919 Jul 1 2:00 2:00 Russia KUY%sT 1991 Sep 29 2:00s 3:00 - KUYT 1991 Oct 20 3:00 4:00 Russia SAM%sT # Samara Time +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Respublika Bashkortostan, Komi-Permyatskij avtonomnyj okrug, +# Kurganskaya oblast', Orenburgskaya oblast', Permskaya oblast', +# Sverdlovskaya oblast', Tyumenskaya oblast', +# Khanty-Manskijskij avtonomnyj okrug, Chelyabinskaya oblast', +# Yamalo-Nenetskij avtonomnyj okrug. Zone Asia/Yekaterinburg 4:02:24 - LMT 1919 Jul 15 4:00 4:00 - SVET 1930 Jun 21 # Sverdlovsk Time 5:00 Russia SVE%sT 1991 Mar 31 2:00s 4:00 Russia SVE%sT 1992 Jan 19 2:00s 5:00 Russia YEK%sT # Yekaterinburg Time +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Respublika Altaj, Altajskij kraj, Omskaya oblast'. Zone Asia/Omsk 4:53:36 - LMT 1919 Nov 14 5:00 - OMST 1930 Jun 21 # Omsk TIme 6:00 Russia OMS%sT 1991 Mar 31 2:00s 5:00 Russia OMS%sT 1992 Jan 19 2:00s 6:00 Russia OMS%sT -# From Stanislaw A. Kuzikowski (1994-06-29): -# But now it is some months since Novosibirsk is 3 hours ahead of Moscow! -# I do not know why they have decided to make this change; -# as far as I remember it was done exactly during winter->summer switching -# so we (Novosibirsk) simply did not switch. +# +# Novosibirskaya oblast'. Zone Asia/Novosibirsk 5:31:40 - LMT 1919 Dec 14 6:00 6:00 - NOVT 1930 Jun 21 # Novosibirsk Time 7:00 Russia NOV%sT 1991 Mar 31 2:00s 6:00 Russia NOV%sT 1992 Jan 19 2:00s 7:00 Russia NOV%sT 1993 May 23 # says Shanks 6:00 Russia NOV%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Kemerovskaya oblast', Krasnoyarskij kraj, +# Tajmyrskij (Dolgano-Nenetskij) avtonomnyj okrug, Tomskaya oblast', +# Respublika Tuva, Respublika Khakasiya, Evenkijskij avtonomnyj okrug. Zone Asia/Krasnoyarsk 6:11:20 - LMT 1920 Jan 6 6:00 - KRAT 1930 Jun 21 # Krasnoyarsk Time 7:00 Russia KRA%sT 1991 Mar 31 2:00s 6:00 Russia KRA%sT 1992 Jan 19 2:00s 7:00 Russia KRA%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Respublika Buryatiya, Irkutskaya oblast', +# Ust'-Ordynskij Buryatskij avtonomnyj okrug. Zone Asia/Irkutsk 6:57:20 - LMT 1880 6:57:20 - IMT 1920 Jan 25 # Irkutsk Mean Time 7:00 - IRKT 1930 Jun 21 # Irkutsk Time 8:00 Russia IRK%sT 1991 Mar 31 2:00s 7:00 Russia IRK%sT 1992 Jan 19 2:00s 8:00 Russia IRK%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Aginskij Buryatskij avtonomnyj okrug, Amurskaya oblast', +# [parts of] Respublika Sakha (Yakutiya), Chitinskaya oblast'. +# +# From Alan Pritchard (2001-08-24): [The Sakha districts are:] +# Aldansky, Amginsky, Anabarsky, Bulunsky, Churapchinsky, +# Eveno-Bytantaisky, Gorny, Khangalassky, Kobyaisky, Lensky, +# Megino-Kangalassky, Mirninsky, Namsky, Nyurbinsky, Olenyoksky, +# Olyokminsky, Srednekolymsky, Suntarsky, Tattinsky, Ust-Aldansky, +# Verkhnekolymsky, Verkhnevilyuisky, Vilyuisky, Zhigansky. Zone Asia/Yakutsk 8:38:40 - LMT 1919 Dec 15 8:00 - YAKT 1930 Jun 21 # Yakutsk Time 9:00 Russia YAK%sT 1991 Mar 31 2:00s 8:00 Russia YAK%sT 1992 Jan 19 2:00s 9:00 Russia YAK%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Evrejskaya avtonomnaya oblast', Khabarovskij kraj, Primorskij kraj, +# [parts of] Respublika Sakha (Yakutiya). +# +# From Alan Pritchard (2001-08-24): [The Sakha districts are:] +# Tomponsky, Ust-Maisky, Ust-Yansky, Verkhoyansky. Zone Asia/Vladivostok 8:47:44 - LMT 1922 Nov 15 9:00 - VLAT 1930 Jun 21 # Vladivostok Time 10:00 Russia VLA%sT 1991 Mar 31 2:00s 9:00 Russia VLA%sST 1992 Jan 19 2:00s 10:00 Russia VLA%sT +# +# Sakhalinskaya oblast'. +# The Zone name should be Yuzhno-Sakhalinsk, but that's too long. +Zone Asia/Sakhalin 9:30:48 - LMT 1905 Aug 23 + 9:00 - CJT 1938 + 9:00 - JST 1945 Aug 25 + 11:00 Russia SAK%sT 1991 Mar 31 2:00s # Sakhalin T. + 10:00 Russia SAK%sT 1992 Jan 19 2:00s + 11:00 Russia SAK%sT 1997 Mar lastSun 2:00s + 10:00 Russia SAK%sT +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Magadanskaya oblast', Respublika Sakha (Yakutiya). +# +# From Alan Pritchard (2001-08-24): [The Sakha districts are:] +# Abyisky, Allaikhovsky, Momsky, Nizhnekolymsky, Oimyakonsky. Zone Asia/Magadan 10:03:12 - LMT 1924 May 2 10:00 - MAGT 1930 Jun 21 # Magadan Time 11:00 Russia MAG%sT 1991 Mar 31 2:00s 10:00 Russia MAG%sT 1992 Jan 19 2:00s 11:00 Russia MAG%sT -# This name should be Asia/Petropavlovsk-Kamchatski, but that's too long. +# +# From Oscar van Vlijmen (2001-08-25): [This region consists of] +# Kamchatskaya oblast', Koryakskij avtonomnyj okrug. +# +# The Zone name should be Asia/Petropavlovsk-Kamchatski, but that's too long. Zone Asia/Kamchatka 10:34:36 - LMT 1922 Nov 10 11:00 - PETT 1930 Jun 21 # P-K Time 12:00 Russia PET%sT 1991 Mar 31 2:00s 11:00 Russia PET%sT 1992 Jan 19 2:00s 12:00 Russia PET%sT +# +# Chukotskij avtonomnyj okrug Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 12:00 - ANAT 1930 Jun 21 # Anadyr Time 13:00 Russia ANA%sT 1982 Apr 1 0:00s @@ -1720,11 +2003,27 @@ Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 11:00 Russia ANA%sT 1992 Jan 19 2:00s 12:00 Russia ANA%sT +# Serbia and Montenegro +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone Europe/Belgrade 1:22:00 - LMT 1884 + 1:00 - CET 1941 Apr 18 23:00 + 1:00 C-Eur CE%sT 1945 May 8 2:00s + 1:00 1:00 CEST 1945 Sep 16 2:00s +# Metod Kozelj reports that the legal date of +# transition to EU rules was 1982-11-27, for all of Yugoslavia at the time. +# Shanks doesn't give as much detail, so go with Kozelj. + 1:00 - CET 1982 Nov 27 + 1:00 EU CE%sT +Link Europe/Belgrade Europe/Ljubljana # Slovenia +Link Europe/Belgrade Europe/Sarajevo # Bosnia and Herzegovina +Link Europe/Belgrade Europe/Skopje # Macedonia +Link Europe/Belgrade Europe/Zagreb # Croatia + # Slovakia Link Europe/Prague Europe/Bratislava # Slovenia -# see Yugoslavia +# see Serbia and Montenegro # Spain # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1797,11 +2096,56 @@ Zone Atlantic/Canary -1:01:36 - LMT 1922 Mar # Las Palmas de Gran C. # Ignore this for now, as the Canaries are part of the EU. # Sweden + +# From Ivan Nilsson (2001-04-13), superseding Shanks: +# +# The law "Svensk forfattningssamling 1878, no 14" about standard time in 1879: +# From the beginning of 1879 (that is 01-01 00:00) the time for all +# places in the country is "the mean solar time for the meridian at +# three degrees, or twelve minutes of time, to the west of the +# meridian of the Observatory of Stockholm". The law is dated 1878-05-31. +# +# The observatory at that time had the meridian 18 degrees 03' 30" +# eastern longitude = 01:12:14 in time. Less 12 minutes gives the +# national standard time as 01:00:14 ahead of GMT.... +# +# About the beginning of CET in Sweden. The lawtext ("Svensk +# forfattningssamling 1899, no 44") states, that "from the beginning +# of 1900... ... the same as the mean solar time for the meridian at +# the distance of one hour of time from the meridian of the English +# observatory at Greenwich, or at 12 minutes 14 seconds to the west +# from the meridian of the Observatory of Stockholm". The law is dated +# 1899-06-16. In short: At 1900-01-01 00:00:00 the new standard time +# in Sweden is 01:00:00 ahead of GMT. +# +# 1916: The lawtext ("Svensk forfattningssamling 1916, no 124") states +# that "1916-05-15 is considered to begin one hour earlier". It is +# pretty obvious that at 05-14 23:00 the clocks are set to 05-15 00:00.... +# Further the law says, that "1916-09-30 is considered to end one hour later". +# +# The laws regulating [DST] are available on the site of the Swedish +# Parliament beginning with 1985 - the laws regulating 1980/1984 are +# not available on the site (to my knowledge they are only available +# in Swedish): (type +# "sommartid" without the quotes in the field "Fritext" and then click +# the Sok-button). +# +# (2001-05-13): +# +# I have now found a newspaper stating that at 1916-10-01 01:00 +# summertime the church-clocks etc were set back one hour to show +# 1916-10-01 00:00 standard time. The article also reports that some +# people thought the switch to standard time would take place already +# at 1916-10-01 00:00 summer time, but they had to wait for another +# hour before the event took place. +# +# Source: The newspaper "Dagens Nyheter", 1916-10-01, page 7 upper left. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Stockholm 1:12:12 - LMT 1878 May 31 - 1:12:12 - SMT 1900 Jan 1 1:00 # Stockholm MT - 1:00 - CET 1916 Apr 14 23:00s - 1:00 1:00 CEST 1916 Sep 30 23:00s +Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 + 1:00:14 - SET 1900 Jan 1 # Swedish Time + 1:00 - CET 1916 May 14 23:00 + 1:00 1:00 CEST 1916 Oct 1 01:00 1:00 - CET 1980 1:00 EU CE%sT @@ -1887,6 +2231,15 @@ Zone Europe/Istanbul 1:55:52 - LMT 1880 Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # Ukraine +# +# From Igor Karpov, who works for the Ukranian Ministry of Justice, +# via Garrett Wollman (2003-01-27): +# BTW, I've found the official document on this matter. It's goverment +# regulations number 509, May 13, 1996. In my poor translation it says: +# "Time in Ukraine is set to second timezone (Kiev time). Each last Sunday +# of March at 3am the time is changing to 4am and each last Sunday of +# October the time at 4am is changing to 3am" + # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Most of Ukraine since 1970 has been like Kiev. Zone Europe/Kiev 2:02:04 - LMT 1880 @@ -1945,22 +2298,6 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 3:00 - MSK 1997 Mar lastSun 1:00u 2:00 EU EE%sT -# Yugoslavia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Belgrade 1:22:00 - LMT 1884 - 1:00 - CET 1941 Apr 18 23:00 - 1:00 C-Eur CE%sT 1945 May 8 2:00s - 1:00 1:00 CEST 1945 Sep 16 2:00s -# Metod Kozelj reports that the legal date of -# transition to EU rules was 1982-11-27, for all of Yugoslavia at the time. -# Shanks doesn't give as much detail, so go with Kozelj. - 1:00 - CET 1982 Nov 27 - 1:00 EU CE%sT -Link Europe/Belgrade Europe/Ljubljana # Slovenia -Link Europe/Belgrade Europe/Sarajevo # Bosnia and Herzegovina -Link Europe/Belgrade Europe/Skopje # Macedonia -Link Europe/Belgrade Europe/Zagreb # Croatia - ############################################################################### # One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from diff --git a/zic.tproj/datfiles/leapseconds b/zic.tproj/datfiles/leapseconds index 390f9cb..c5306a6 100644 --- a/zic.tproj/datfiles/leapseconds +++ b/zic.tproj/datfiles/leapseconds @@ -1,6 +1,4 @@ -# @(#)leapseconds 7.13 - -# $FreeBSD: src/share/zoneinfo/leapseconds,v 1.6 2001/04/06 16:46:52 wollman Exp $ +# @(#)leapseconds 7.15 # Allowance for leapseconds added to each timezone file. @@ -45,8 +43,9 @@ Leap 1994 Jun 30 23:59:60 + S Leap 1995 Dec 31 23:59:60 + S Leap 1997 Jun 30 23:59:60 + S Leap 1998 Dec 31 23:59:60 + S -# INTERNATIONAL EARTH ROTATION SERVICE (IERS) -# SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE + +# INTERNATIONAL EARTH ROTATION SERVICE (IERS) +# SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE # # SERVICE DE LA ROTATION TERRESTRE # OBSERVATOIRE DE PARIS @@ -55,12 +54,27 @@ Leap 1998 Dec 31 23:59:60 + S # FAX : 33 (0) 1 40 51 22 91 # Internet : iers@obspm.fr # -# Paris, 11 January 2001 +# Paris, 14 January 2002 +# +# Bulletin C 23 +# +# To authorities responsible +# for the measurement and +# distribution of time # -# Bulletin C 21 +# INFORMATION ON UTC - TAI # -# To authorities responsible for the measurement and distribution of time +# NO positive leap second will be introduced at the end of June 2002. +# The difference between UTC and the International Atomic Time TAI is : +# +# from 1999 January 1, 0h UTC, until further notice : UTC-TAI = -32 s # -# INFORMATION ON UTC - TAI +# Leap seconds can be introduced in UTC at the end of the months of December +# or June, depending on the evolution of UT1-TAI. Bulletin C is mailed every +# six months, either to announce a time step in UTC, or to confirm that there +# will be no time step at the next possible date. # -# NO positive leap second will be introduced at the end of June 2001. +# Daniel GAMBIS +# Director +# Earth Orientation Center of IERS +# Observatoire de Paris, France diff --git a/zic.tproj/datfiles/northamerica b/zic.tproj/datfiles/northamerica index 8630edb..ff36fe4 100644 --- a/zic.tproj/datfiles/northamerica +++ b/zic.tproj/datfiles/northamerica @@ -1,8 +1,6 @@ -# @(#)northamerica 7.58 +# @(#)northamerica 7.62 # also includes Central America and the Caribbean -# $FreeBSD: src/share/zoneinfo/northamerica,v 1.18 2001/04/06 16:46:52 wollman Exp $ - # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to # tz@elsie.nci.nih.gov for general use in the future). @@ -83,12 +81,29 @@ # From Joseph Gallant , citing # George H. Douglas, _The Early Days of Radio Broadcasting_ (1987): # At 7 P.M. (Eastern War Time) [on 1945-08-14], the networks were set -# to switch to London for Atlee's address, but the American people +# to switch to London for Attlee's address, but the American people # never got to hear his speech live. According to one press account, # CBS' Bob Trout was first to announce the word of Japan's surrender, # but a few seconds later, NBC, ABC and Mutual also flashed the word # of surrender, all of whom interrupting the bells of Big Ben in -# London which were to precede Mr. Atlee's speech. +# London which were to precede Mr. Attlee's speech. + +# From Paul Eggert (2003-02-09): It was Robert St John, not Bob Trout. From +# Myrna Oliver's obituary of St John on page B16 of today's Los Angeles Times: +# +# ... a war-weary U.S. clung to radios, awaiting word of Japan's surrender. +# Any announcement from Asia would reach St. John's New York newsroom on a +# wire service teletype machine, which had prescribed signals for major news. +# Associated Press, for example, would ring five bells before spewing out +# typed copy of an important story, and 10 bells for news "of transcendental +# importance." +# +# On Aug. 14, stalling while talking steadily into the NBC networks' open +# microphone, St. John heard five bells and waited only to hear a sixth bell, +# before announcing confidently: "Ladies and gentlemen, World War II is over. +# The Japanese have agreed to our surrender terms." +# +# He had scored a 20-second scoop on other broadcasters. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule US 1918 1919 - Mar lastSun 2:00 1:00 D @@ -187,21 +202,15 @@ Rule US 1987 max - Apr Sun>=1 2:00 1:00 D # "Chamorro Standard Time" for time in Guam and the Northern Marianas. # See the file "australasia". -# From Ryan Alessi of the Thousand Oaks Star (2001-02-15) via Rives McDow: -# Brad Sherman, D-Sherman Oaks, introduced a bill in Congress on -# Wednesday that could have California operating on Denver time as -# early as this summer.... The options include keeping -# daylight-saving time all year long, or setting clocks back two hours -# -- instead of just one -- during the existing daylight-saving time. - -# US Eastern time, represented by New York +# US eastern time, represented by New York # Connecticut, Delaware, District of Columbia, most of Florida, -# Georgia, far southeastern Indiana, eastern Kentucky, Maine, -# Maryland, Massachusetts, New Hampshire, New Jersey, New York, North -# Carolina, Ohio, Pennsylvania, Rhode Island, South Carolina, eastern -# Tennessee, Vermont, Virginia, West Virginia +# Georgia, southeast Indiana (Clark, Dearborn, Floyd, Harrison, and +# Ohio counties), eastern Kentucky, Maine, Maryland, Massachusetts, +# New Hampshire, New Jersey, New York, North Carolina, Ohio, +# Pennsylvania, Rhode Island, South Carolina, eastern Tennessee, +# Vermont, Virginia, West Virginia # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule NYC 1920 only - Mar lastSun 2:00 1:00 D @@ -217,13 +226,14 @@ Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:00 -5:00 NYC E%sT 1967 -5:00 US E%sT -# US Central time, represented by Chicago +# US central time, represented by Chicago # Alabama, Arkansas, Florida panhandle, Illinois, western Indiana -# corners, Iowa, most of Kansas, western Kentucky, Louisiana, -# Minnesota, Mississippi, Missouri, eastern Nebraska, eastern North -# Dakota, Oklahoma, eastern South Dakota, western Tennessee, most of -# Texas, Wisconsin +# (Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer, +# Vanderburgh, and Warrick counties), Iowa, most of Kansas, western +# Kentucky, Louisiana, Minnesota, Mississippi, Missouri, eastern +# Nebraska, eastern North Dakota, Oklahoma, eastern South Dakota, +# western Tennessee, most of Texas, Wisconsin # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Chicago 1920 only - Jun 13 2:00 1:00 D @@ -241,11 +251,16 @@ Zone America/Chicago -5:50:36 - LMT 1883 Nov 18 12:00 -6:00 US C%sT 1946 -6:00 Chicago C%sT 1967 -6:00 US C%sT +# Oliver County, ND switched from mountain to central time on 1992-10-25. +Zone America/North_Dakota/Center -6:45:12 - LMT 1883 Nov 18 12:00 + -7:00 US M%sT 1992 Oct 25 02:00 + -6:00 US C%sT -# US Mountain time, represented by Denver +# US mountain time, represented by Denver # # Colorado, southern Idaho, far western Kansas, Montana, western -# Nebraska, New Mexico, southwestern North Dakota, far eastern Oregon, +# Nebraska, Nevada border (Jackpot, Owyhee, and Mountain City), +# New Mexico, southwestern North Dakota, far eastern Oregon, # western South Dakota, far western Texas (El Paso County, Hudspeth County, # and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming # @@ -265,7 +280,7 @@ Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00 # US Pacific time, represented by Los Angeles # -# California, northern Idaho, Nevada, most of Oregon, and Washington +# California, northern Idaho, most of Nevada, most of Oregon, and Washington # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule CA 1948 only - Mar 14 2:00 1:00 D @@ -282,7 +297,7 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:00 # Alaska # AK%sT is the modern abbreviation for -9:00 per USNO. # -# From Paul Eggert (2001-04-01): +# From Paul Eggert (2001-05-30): # Howse writes that Alaska switched from the Julian to the Gregorian calendar, # and from east-of-GMT to west-of-GMT days, when the US bought it from Russia. # This was on 1867-10-18, a Friday; the previous day was 1867-10-06 Julian, @@ -290,6 +305,13 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:00 # ignoring the switch from Julian to Gregorian, since we can't represent # the Julian calendar. # +# As far as we know, none of the exact locations mentioned below were +# permanently inhabited in 1867 by anyone using either calendar. +# (Yakutat was colonized by the Russians in 1799, but the settlement +# was destroyed in 1805 by a Yakutat-kon war party.) However, there +# were nearby inhabitants in some cases and for our purposes perhaps +# it's best to simply use the official transition. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Juneau 15:02:19 - LMT 1867 Oct 18 -8:57:41 - LMT 1900 Aug 20 12:00 @@ -354,12 +376,32 @@ Zone Pacific/Honolulu -10:31:26 - LMT 1900 Jan 1 12:00 # Now we turn to US areas that have diverged from the consensus since 1970. # Arizona mostly uses MST. + +# From Paul Eggert (2002-10-20): +# +# The information in the rest of this paragraph is derived from the +# +# Daylight Saving Time web page (2002-01-23) maintained by the +# Arizona State Library, Archives and Public Records. +# Between 1944-01-01 and 1944-04-01 the State of Arizona used standard +# time, but by federal law railroads, airlines, bus lines, military +# personnel, and some engaged in interstate commerce continued to +# observe war (i.e., daylight saving) time. The 1944-03-17 Phoenix +# Gazette says that was the date the law changed, and that 04-01 was +# the date the state's clocks would change. In 1945 the State of +# Arizona used standard time all year, again with exceptions only as +# mandated by federal law. Arizona observed DST in 1967, but Arizona +# Laws 1968, ch. 183 (effective 1968-03-21) repealed DST. +# +# Shanks says the 1944 experiment came to an end on 1944-03-17. +# Go with the Arizona State Library instead. + Zone America/Phoenix -7:28:18 - LMT 1883 Nov 18 12:00 -7:00 US M%sT 1944 Jan 1 00:01 - -7:00 - MST 1944 Mar 17 00:01 + -7:00 - MST 1944 Apr 1 00:01 -7:00 US M%sT 1944 Oct 1 00:01 -7:00 - MST 1967 - -7:00 US M%sT 1968 + -7:00 US M%sT 1968 Mar 21 -7:00 - MST # From Arthur David Olson (1988-02-13): # A writer from the Inter Tribal Council of Arizona, Inc., @@ -409,7 +451,7 @@ Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:00 # Pam Belluck reported in the New York Times (2001-01-31) that the # Indiana Legislature is considering a bill to adopt DST statewide. # Her article mentioned Vevay, whose post office observes a different -# time zone than Danner's Hardware across the street. +# time zone from Danner's Hardware across the street. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Indianapolis 1941 only - Jun 22 2:00 1:00 D @@ -513,6 +555,13 @@ Link America/Louisville America/Kentucky/Louisville # Wayne County (central Kentucky) is switching from Central (-0600) to Eastern # (-0500) time. They won't "fall back" this year. See Sara Shipley, # The difference an hour makes, Nando Times (2000-08-29 15:33 -0400). +# +# From Paul Eggert (2001-07-16): +# The final rule was published in the +# +# Federal Register 65, 160 (2000-08-17), page 50154-50158. +# +# Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:00 -6:00 US C%sT 1946 -6:00 - CST 1968 @@ -528,13 +577,20 @@ Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:00 # Oliver County, ND (from MST to CST) ... 1992-10 # West Wendover, NV (from PST TO MST) ... 1999-10 # Wayne County, KY (from CST to EST) ... 2000-10 -# There is another change in the offing; Mercer County, ND is looking -# to change from MT to CT. It is possible that two other ND counties -# (Sioux and Morton) will look to change also. If made, the earliest -# a change would be effective is October 2001. # -# From Paul Eggert (2000-10-02): -# FIXME: I haven't yet had time to incorporate all the above changes. +# From Paul Eggert (2001-07-17): +# We don't know where the line used to be within Kearny County, KS, +# so omit that change for now. +# See America/Indiana/Knox for the Starke County, IN change. +# See America/North_Dakota/Center for the Oliver County, ND change. +# West Wendover, NV officially switched from Pacific to mountain time on +# 1999-10-31. See the +# +# Federal Register 64, 203 (1999-10-21), page 56705-56707. +# +# However, the Federal Register says that West Wendover already operated +# on mountain time, and the rule merely made this official; +# hence a separate tz entry is not needed. # Michigan # @@ -591,10 +647,11 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 -6:00 US C%sT # Navassa +# administered by the US Fish and Wildlife Service # claimed by US under the provisions of the 1856 Guano Islands Act # also claimed by Haiti # occupied 1857/1900 by the Navassa Phosphate Co -# US lighthouse 1917/1997-01 +# US lighthouse 1917/1996-09 # currently uninhabited # see Mark Fineman, ``An Isle Rich in Guano and Discord'', # _Los Angeles Times_ (1998-11-10), A1, A10; it cites @@ -619,7 +676,7 @@ Link Pacific/Honolulu HST # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -1078,9 +1135,9 @@ Zone America/Dawson_Creek -8:00:56 - LMT 1884 # From Paul Eggert (1999-09-20): # # Basic Facts: The New Territory -# (1999) reports that Pangnirtung operates on Eastern time, +# (1999) reports that Pangnirtung operates on eastern time, # and that Coral Harbour does not observe DST. We don't know when -# Pangnirtung switched to Eastern time; we'll guess 1995. +# Pangnirtung switched to eastern time; we'll guess 1995. # We'll ignore the claim about Coral Harbour for now, # since we have no further info. @@ -1335,6 +1392,21 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # References: "Diario de Monterrey" # Palabra (2001-03-31) +# From Reuters (2001-09-04): +# Mexico's Supreme Court on Tuesday declared that daylight savings was +# unconstitutional in Mexico City, creating the possibility the +# capital will be in a different time zone from the rest of the nation +# next year.... The Supreme Court's ruling takes effect at 2:00 +# a.m. (0800 GMT) on Sept. 30, when Mexico is scheduled to revert to +# standard time. "This is so residents of the Federal District are not +# subject to unexpected time changes," a statement from the court said. + +# From Jesper Norgaard Welen (2002-03-12): +# ... consulting my local grocery store(!) and my coworkers, they all insisted +# that a new decision had been made to reinstate US style DST in Mexico.... +# http://www.conae.gob.mx/ahorro/horaver2001_m1_2002.html (2002-02-20) +# confirms this. Sonora as usual is the only state where DST is not applied. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Mexico 1939 only - Feb 5 0:00 1:00 D Rule Mexico 1939 only - Jun 25 0:00 0 S @@ -1346,8 +1418,10 @@ Rule Mexico 1950 only - Feb 12 0:00 1:00 D Rule Mexico 1950 only - Jul 30 0:00 0 S Rule Mexico 1996 2000 - Apr Sun>=1 2:00 1:00 D Rule Mexico 1996 2000 - Oct lastSun 2:00 0 S -Rule Mexico 2001 max - May Sun>=1 2:00 1:00 D -Rule Mexico 2001 max - Sep lastSun 2:00 0 S +Rule Mexico 2001 only - May Sun>=1 2:00 1:00 D +Rule Mexico 2001 only - Sep lastSun 2:00 0 S +Rule Mexico 2002 max - Apr Sun>=1 2:00 1:00 D +Rule Mexico 2002 max - Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Quintana Roo Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56 @@ -1371,6 +1445,8 @@ Zone America/Mexico_City -6:36:36 - LMT 1922 Jan 1 0:23:24 -7:00 - MST 1931 May 1 23:00 -6:00 - CST 1931 Oct -7:00 - MST 1932 Apr 1 + -6:00 Mexico C%sT 2001 Sep 30 02:00 + -6:00 - CST 2002 Feb 20 -6:00 Mexico C%sT # Chihuahua Zone America/Chihuahua -7:04:20 - LMT 1921 Dec 31 23:55:40 @@ -1422,7 +1498,8 @@ Zone America/Tijuana -7:48:04 - LMT 1922 Jan 1 0:11:56 -8:00 - PST 1976 -8:00 US P%sT 1996 -8:00 Mexico P%sT 2001 - -8:00 US P%sT + -8:00 US P%sT 2002 Feb 20 + -8:00 Mexico P%sT # From Paul Eggert (2001-03-05): # Formerly there was an America/Ensenada zone, which differed from # America/Tijuana only in that it did not observe DST from 1976 @@ -1672,7 +1749,7 @@ Zone America/Jamaica -5:07:12 - LMT 1890 # Kingston # Martinique # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Martinique -4:04:20 - LMT 1890 # Fort-de-France - -4:04 - FFMT 1911 May # Fort-de-France MT + -4:04:20 - FFMT 1911 May # Fort-de-France MT -4:00 - AST 1980 Apr 6 -4:00 1:00 ADT 1980 Sep 28 -4:00 - AST @@ -1698,7 +1775,7 @@ Rule Nic 1992 only - Jan 1 4:00 1:00 D Rule Nic 1992 only - Sep 24 0:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Managua -5:45:08 - LMT 1890 - -5:45 - MMT 1934 Jun 23 # Managua Mean Time + -5:45:12 - MMT 1934 Jun 23 # Managua Mean Time? -6:00 - CST 1973 May -5:00 - EST 1975 Feb 16 -6:00 Nic C%sT 1993 Jan 1 4:00 @@ -1708,7 +1785,7 @@ Zone America/Managua -5:45:08 - LMT 1890 # Panama # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Panama -5:18:08 - LMT 1890 - -5:20 - PMT 1908 Apr 22 # Panama Mean Time + -5:19:36 - CMT 1908 Apr 22 # Colon Mean Time -5:00 - EST # Puerto Rico @@ -1727,7 +1804,7 @@ Zone America/St_Kitts -4:10:52 - LMT 1912 Mar 2 # Basseterre # St Lucia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/St_Lucia -4:04:00 - LMT 1890 # Castries - -4:04 - CMT 1912 # Castries Mean Time + -4:04:00 - CMT 1912 # Castries Mean Time -4:00 - AST # St Pierre and Miquelon diff --git a/zic.tproj/datfiles/southamerica b/zic.tproj/datfiles/southamerica index 96e371d..3210556 100644 --- a/zic.tproj/datfiles/southamerica +++ b/zic.tproj/datfiles/southamerica @@ -1,6 +1,4 @@ -# @(#)southamerica 7.40 - -# $FreeBSD: src/share/zoneinfo/southamerica,v 1.16 2001/04/06 16:46:52 wollman Exp $ +# @(#)southamerica 7.46 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -11,7 +9,7 @@ # Thomas G. Shanks, The International Atlas (5th edition), # San Diego: ACS Publications, Inc. (1999). # -# Gwillim Law writes that a good source +# Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries @@ -81,18 +79,11 @@ Rule Arg 1963 only - Oct 1 0:00 0 - Rule Arg 1963 only - Dec 15 0:00 1:00 S Rule Arg 1964 1966 - Mar 1 0:00 0 - Rule Arg 1964 1966 - Oct 15 0:00 1:00 S -Rule Arg 1967 only - Apr 1 0:00 0 - +Rule Arg 1967 only - Apr 2 0:00 0 - Rule Arg 1967 1968 - Oct Sun>=1 0:00 1:00 S Rule Arg 1968 1969 - Apr Sun>=1 0:00 0 - Rule Arg 1974 only - Jan 23 0:00 1:00 S Rule Arg 1974 only - May 1 0:00 0 - -Rule Arg 1974 1976 - Oct Sun>=1 0:00 1:00 S -Rule Arg 1975 1977 - Apr Sun>=1 0:00 0 - -Rule Arg 1985 only - Nov 2 0:00 1:00 S -Rule Arg 1986 only - Mar 14 0:00 0 - -Rule Arg 1986 1987 - Oct 25 0:00 1:00 S -Rule Arg 1987 only - Feb 13 0:00 0 - -Rule Arg 1988 only - Feb 7 0:00 0 - Rule Arg 1988 only - Dec 1 0:00 1:00 S # # From Hernan G. Otero (1995-06-26): @@ -127,76 +118,120 @@ Rule Arg 2000 only - Mar Sun>=1 0:00 0 - # de la Rua on March 2, 2000, because it would make people spend more energy # in the winter time, rather than less. The change took effect on March 3. # +# From Mariano Absatz (2001-06-06): +# one of the major newspapers here in Argentina said that the 1999 +# Timezone Law (which never was effectively applied) will (would?) be +# in effect.... The article is at +# http://ar.clarin.com/diario/2001-06-06/e-01701.htm +# ... The Law itself is "Ley No 25155", sanctioned on 1999-08-25, enacted +# 1999-09-17, and published 1999-09-21. The official publication is at: +# http://www.boletin.jus.gov.ar/BON/Primera/1999/09-Septiembre/21/PDF/BO21-09-99LEG.PDF +# Regretfully, you have to subscribe (and pay) for the on-line version.... +# +# (2001-06-12): +# the timezone for Argentina will not change next Sunday. +# Apparently it will do so on Sunday 24th.... +# http://ar.clarin.com/diario/2001-06-12/s-03501.htm +# +# (2001-06-25): +# Last Friday (yes, the last working day before the date of the change), the +# Senate annulled the 1999 law that introduced the changes later postponed. +# http://www.clarin.com.ar/diario/2001-06-22/s-03601.htm +# It remains the vote of the Deputies..., but it will be the same.... +# This kind of things had always been done this way in Argentina. +# We are still -03:00 all year round in all of the country. +# +# +# From Paul Eggert (2002-01-22): +# +# Hora de verano para la Republica Argentina (2000-10-01) +# says that standard time in Argentina from 1894-10-31 +# to 1920-05-01 was -4:16:48.25. Go with this more-precise value +# over Shanks. + +# Unless otherwise specified, data are from Shanks through 1992, from +# the IATA otherwise. As noted below, Shanks says that +# America/Cordoba split into 7 subregions during 1991/1992, but we +# haven't verified this yet so for now we'll keep it a single region. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] # # Buenos Aires (BA), Capital Federal (CF), Santa Cruz (SC), # Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF) -Zone America/Buenos_Aires -3:53:48 - LMT 1894 Nov - -4:16:44 - CMT 1920 May # Cordoba Mean Time +Zone America/Buenos_Aires -3:53:48 - LMT 1894 Oct 31 + -4:16:48 - CMT 1920 May # Cordoba Mean Time -4:00 - ART 1930 Dec -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 + -3:00 Arg AR%sT 1999 Oct 3 + -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # # Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN), Chaco (CC), -# Formosa (FM), La Pampa (LP), Chubut (CH) -Zone America/Rosario -4:02:40 - LMT 1894 Nov - -4:16:44 - CMT 1920 May +# Formosa (FM), Salta (SA), Tucuman (TM), Santiago del Estero (SE), +# Cordoba (CB), La Rioja (LR), San Juan (SJ), San Luis (SL), La Pampa (LP), +# Neuquen (NQ), Rio Negro (RN), Chubut (CH) +# +# Shanks also makes the following claims, which we haven't verified: +# - Formosa switched to -3:00 on 1991-01-07. +# - La Rioja and San Juan switched to -4:00 on 1991-03-01 +# and then to -3:00 on 1991-05-07. +# - Misiones switched to -3:00 on 1990-12-29. +# - Chaco switched to -3:00 on 1991-01-04. +# - San Luis switched to -4:00 on 1990-03-14, then to -3:00 on 1990-10-15, +# then to -4:00 on 1991-03-01, then to -3:00 on 1991-06-01. +# - Santiago del Estero switched to -4:00 on 1991-04-01, +# then to -3:00 on 1991-04-26. +# If we need to add Zones for these areas, we may need to have a subdirectory +# for Argentina, as e.g. "America/San_Luis" is too ambiguious. +# +Zone America/Cordoba -4:16:48 - LMT 1894 Oct 31 + -4:16:48 - CMT 1920 May -4:00 - ART 1930 Dec -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1991 Jul - -3:00 - ART 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 - -3:00 - ART -# -# Cordoba (CB), Santiago del Estero (SE), Salta (SA), Tucuman (TM), La Rioja (LR), San Juan (SJ), San Luis (SL), -# Neuquen (NQ), Rio Negro (RN) -Zone America/Cordoba -4:16:44 - LMT 1894 Nov - -4:16:44 - CMT 1920 May - -4:00 - ART 1930 Dec - -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1990 Jul - -3:00 - ART 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 + -3:00 Arg AR%sT 1991 Mar 3 + -4:00 - WART 1991 Oct 20 + -3:00 Arg AR%sT 1999 Oct 3 + -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # # Jujuy (JY) -Zone America/Jujuy -4:21:12 - LMT 1894 Nov - -4:16:44 - CMT 1920 May +Zone America/Jujuy -4:21:12 - LMT 1894 Oct 31 + -4:16:48 - CMT 1920 May -4:00 - ART 1930 Dec -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1991 Mar 3 + -3:00 Arg AR%sT 1990 Mar 4 + -4:00 - WART 1990 Oct 28 + -4:00 1:00 WARST 1991 Mar 17 -4:00 - WART 1991 Oct 6 - -4:00 1:00 WARST 1992 Mar 15 - -4:00 - WART 1992 Oct 18 - -3:00 - ART 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 + -3:00 1:00 ARST 1992 + -3:00 Arg AR%sT 1999 Oct 3 + -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # # Catamarca (CT) -Zone America/Catamarca -4:23:08 - LMT 1894 Nov - -4:16:44 - CMT 1920 May +Zone America/Catamarca -4:23:08 - LMT 1894 Oct 31 + -4:16:48 - CMT 1920 May -4:00 - ART 1930 Dec -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1990 Jul - -3:00 - ART 1991 Jul - -3:00 Arg AR%sT 1992 Jul - -3:00 - ART 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 + -3:00 Arg AR%sT 1991 Mar 3 + -4:00 - WART 1991 Oct 20 + -3:00 Arg AR%sT 1999 Oct 3 + -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # # Mendoza (MZ) -Zone America/Mendoza -4:35:16 - LMT 1894 Nov - -4:16:44 - CMT 1920 May +Zone America/Mendoza -4:35:16 - LMT 1894 Oct 31 + -4:16:48 - CMT 1920 May -4:00 - ART 1930 Dec -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1991 Mar 3 + -3:00 Arg AR%sT 1990 Mar 4 + -4:00 - WART 1990 Oct 15 + -4:00 1:00 WARST 1991 Mar 1 -4:00 - WART 1991 Oct 15 -4:00 1:00 WARST 1992 Mar 1 -4:00 - WART 1992 Oct 18 - -3:00 - ART 1999 Oct 3 0:00 - -4:00 Arg AR%sT 2000 Mar 3 0:00 + -3:00 Arg AR%sT 1999 Oct 3 + -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # Aruba @@ -208,7 +243,7 @@ Zone America/Aruba -4:40:24 - LMT 1912 Feb 12 # Oranjestad # Bolivia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/La_Paz -4:32:36 - LMT 1890 - -4:32:36 - LPMT 1931 Oct 15 # La Paz Mean Time + -4:32:36 - CMT 1931 Oct 15 # Calamarca MT -4:32:36 1:00 BOST 1932 Mar 21 # Bolivia ST -4:00 - BOT # Bolivia Time @@ -257,11 +292,28 @@ Zone America/La_Paz -4:32:36 - LMT 1890 # http://pcdsh01.on.br/Fusbr.htm # http://pcdsh01.on.br/Fusbrhv.htm -# From Paul Eggert (2000-10-02): -# The official decrees referenced below are taken from +# From Celso Doria via David Madeo (2002-10-09): +# The reason for the delay this year has to do with elections in Brazil. +# +# Unlike in the United States, elections in Brazil are 100% computerized and +# the results are known almost immediately. Yesterday, it was the first +# round of the elections when 115 million Brazilians voted for President, +# Governor, Senators, Federal Deputies, and State Deputies. Nobody is +# counting (or re-counting) votes anymore and we know there will be a second +# round for the Presidency and also for some Governors. The 2nd round will +# take place on October 27th. +# +# The reason why the DST will only begin November 3rd is that the thousands +# of electoral machines used cannot have their time changed, and since the +# Constitution says the elections must begin at 8:00 AM and end at 5:00 PM, +# the Government decided to postpone DST, instead of changing the Constitution +# (maybe, for the next elections, it will be possible to change the clock)... + +# From Paul Eggert (2002-10-10): +# The official decrees referenced below are mostly taken from # # Decretos sobre o Horario de Verao no Brasil -# (1999-10-04, in Portuguese). +# (2001-09-20, in Portuguese). # The official site for all decrees, including those not related to time, is # # Presidencia da Republica, Subchefia para Assuntos Juridicos, Decretos @@ -384,11 +436,20 @@ Rule Brazil 2000 only - Feb 27 0:00 0 - # repeals DST in PE and RR, effective 2000-10-15 00:00. # Decree 3,632 (2000-10-17) # repeals DST in SE, AL, PB, RN, CE, PI and MA, effective 2000-10-22 00:00. +# Decree 3,916 +# (2001-09-13) reestablishes DST in AL, CE, MA, PB, PE, PI, RN, SE. +Rule Brazil 2000 2001 - Oct Sun>=8 0:00 1:00 S +Rule Brazil 2001 max - Feb Sun>=15 0:00 0 - +# Decree 4,399 (2002-10-01) repeals DST in AL, CE, MA, PB, PE, PI, RN, SE. +# +Rule Brazil 2002 only - Nov 3 0:00 1:00 S # -# These give only one year's rules. After that, the rules are guesses +Rule Brazil 2003 max - Oct Sun>=8 0:00 1:00 S +# The latest decree listed above says that the following states observe DST: +# BA, DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP, TO. +# +# For dates after mid-2003, the above rules with TO="max" are guesses # and are quite possibly wrong, but are more likely than no DST at all. -Rule Brazil 2000 max - Oct Sun>=8 0:00 1:00 S -Rule Brazil 2001 max - Feb Sun>=15 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -411,6 +472,8 @@ Zone America/Fortaleza -2:34:00 - LMT 1914 -3:00 Brazil BR%sT 1990 Sep 17 -3:00 - BRT 1999 Sep 30 -3:00 Brazil BR%sT 2000 Oct 22 + -3:00 - BRT 2001 Sep 13 + -3:00 Brazil BR%sT 2002 Oct 1 -3:00 - BRT # # Pernambuco (PE) (except Atlantic islands) @@ -418,6 +481,8 @@ Zone America/Recife -2:19:36 - LMT 1914 -3:00 Brazil BR%sT 1990 Sep 17 -3:00 - BRT 1999 Sep 30 -3:00 Brazil BR%sT 2000 Oct 15 + -3:00 - BRT 2001 Sep 13 + -3:00 Brazil BR%sT 2002 Oct 1 -3:00 - BRT # # Tocantins (TO) @@ -433,6 +498,8 @@ Zone America/Maceio -2:22:52 - LMT 1914 -3:00 Brazil BR%sT 1996 Sep 4 -3:00 - BRT 1999 Sep 30 -3:00 Brazil BR%sT 2000 Oct 22 + -3:00 - BRT 2001 Sep 13 + -3:00 Brazil BR%sT 2002 Oct 1 -3:00 - BRT # # Bahia (BA), Goias (GO), Distrito Federal (DF), Minas Gerais (MG), @@ -443,7 +510,7 @@ Zone America/Sao_Paulo -3:06:28 - LMT 1914 -3:00 1:00 BRST 1964 -3:00 Brazil BR%sT # -# Mato Grosso, Mato Grosso do Sul +# Mato Grosso (MT), Mato Grosso do Sul (MS) Zone America/Cuiaba -3:44:20 - LMT 1914 -4:00 Brazil AM%sT # @@ -495,25 +562,39 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # Because of the same drought, the government decided to end DST later, # on April 3, (one-time change). -# From Gwillim Law (2001-02-20): -# I came across a Chilean on-line newspaper, La Tercera. Its -# -# 1998-03-13 issue -# , says (my translation): -# "At 24:00 (midnight) tomorrow (Saturday) - 22:00 in the insular -# territory [Easter Island, Juan Fernandez, etc.] - winter time will -# begin in the entire country." - -# From Paul Eggert (2001-02-21): +# From Gwillim Law (2001-05-04): +# I came across another article in "La Tercera" about Chilean DST. +# +# It clearly confirms my earlier suggestion, that DST begins at 22:00 +# on Easter Island.... But it also seems to be saying that the +# observance of DST in Chile began in 1966, rather than 1969 as +# ... [Shanks] has it.... +# +# My translation: +# +# "The Chilean Army has announced that summer time will begin tomorrow, +# Saturday, October 14 in continental Chile, insular Chile, and +# Antarctica, as provided by Supreme Decree 25 of January 11, 1966. +# By the preceding, official time in continental Chile and Chilean +# Antarctic, and official time in Western Insular Chile, which applies +# to Easter Island and Sala y Gomez Island, will be set forward at +# midnight and at 22:00, respectively, by 20 minutes." + +# From Paul Eggert (2001-05-04): +# Go with this article in preference to Shanks's 1969 date for modern DST. # Assume this rule has been used since DST was introduced in the islands. +# From Paul Eggert (2002-10-24): +# gives many details that +# disagree with the following table, but we haven't had time to compare them. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Chile 1918 only - Sep 1 0:00 1:00 S Rule Chile 1919 only - Jul 2 0:00 0 - Rule Chile 1927 1931 - Sep 1 0:00 1:00 S Rule Chile 1928 1932 - Apr 1 0:00 0 - -Rule Chile 1969 1997 - Oct Sun>=9 4:00u 1:00 S -Rule Chile 1970 1998 - Mar Sun>=9 3:00u 0 - +Rule Chile 1966 1997 - Oct Sun>=9 4:00u 1:00 S +Rule Chile 1967 1998 - Mar Sun>=9 3:00u 0 - Rule Chile 1998 only - Sep 27 4:00u 1:00 S Rule Chile 1999 only - Apr 4 3:00u 0 - Rule Chile 1999 max - Oct Sun>=9 4:00u 1:00 S @@ -530,10 +611,9 @@ Zone Pacific/Easter -7:17:28 - LMT 1890 # Mataveri -7:00 Chile EAS%sT 1982 Mar 14 # Easter I Time -6:00 Chile EAS%sT # -# Whitman says Juan Fernandez Is are like America/Santiago. -# San Ambrosio, San Felix -# no information; probably like America/Santiago - +# Sala y Gomez Island is like Pacific/Easter. +# Other Chilean locations, including Juan Fernandez Is, San Ambrosio, +# San Felix, and Antarctic bases, are like America/Santiago. # Colombia # Shanks specifies 24:00 for 1992 transition times; go with IATA, @@ -690,12 +770,19 @@ Rule Para 1996 only - Mar 1 0:00 0 - # From Jesper Norgaard (2001-03-06) [an official URL saying similar things]: # http://gateway.abc.com.py:8000/pub/pag04.mbr/artic?FHA=2001-03-03-02.24.52.900592 # -Rule Para 1996 max - Oct Sun>=1 0:00 1:00 S +Rule Para 1996 2001 - Oct Sun>=1 0:00 1:00 S # IATA SSIM (1997-09) says Mar 1; go with Shanks. Rule Para 1997 only - Feb lastSun 0:00 0 - # Shanks says 1999-02-28; IATA SSIM (1999-02) says 1999-02-27, but # (1999-09) reports no date; go with above sources and Gerd Knops (2001-02-27). -Rule Para 1998 max - Mar Sun>=1 0:00 0 - +Rule Para 1998 2001 - Mar Sun>=1 0:00 0 - +# From Rives McDow (2002-02-28): +# A decree was issued in Paraguay (no. 16350) on 2002-02-26 that changed the +# dst method to be from the first Sunday in September to the first Sunday in +# April. +Rule Para 2002 max - Apr Sun>=1 0:00 0 - +Rule Para 2002 max - Sep Sun>=1 0:00 1:00 S + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Asuncion -3:50:40 - LMT 1890 @@ -719,7 +806,7 @@ Rule Peru 1994 only - Jan 1 0:00 1:00 S Rule Peru 1994 only - Apr 1 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Lima -5:08:12 - LMT 1890 - -5:09 - LMT 1908 Jul 28 # Lima Mean Time + -5:08:36 - LMT 1908 Jul 28 # Lima Mean Time? -5:00 Peru PE%sT # Peru Time # South Georgia @@ -804,6 +891,6 @@ Zone America/Montevideo -3:44:44 - LMT 1898 Jun 28 # Venezuela # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Caracas -4:27:44 - LMT 1890 - -4:27:44 - CMT 1912 Feb 12 # Caracas Mean Time + -4:27:40 - CMT 1912 Feb 12 # Caracas Mean Time? -4:30 - VET 1965 # Venezuela Time -4:00 - VET diff --git a/zic.tproj/datfiles/yearistype.sh b/zic.tproj/datfiles/yearistype.sh index 7a29a99..8d796f1 100755 --- a/zic.tproj/datfiles/yearistype.sh +++ b/zic.tproj/datfiles/yearistype.sh @@ -1,27 +1,37 @@ #! /bin/sh -# $OpenBSD: yearistype.sh,v 1.3 1997/01/14 04:36:58 millert Exp $ -: '@(#)yearistype.sh 7.4' +: '@(#)yearistype.sh 7.7' + +case $#-$1 in + 2-|2-0*|2-*[!0-9]*) + echo "$0: wild year - $1" >&2 + exit 1 ;; +esac case $#-$2 in - 2-even) case $1 in - *[24680]) exit 0 ;; - *) exit 1 ;; - esac ;; - 2-nonpres) case $1 in - *[02468][048]|*[13579][26]) exit 1 ;; - *) exit 0 ;; - esac ;; - 2-odd) case $1 in - *[13579]) exit 0 ;; - *) exit 1 ;; - esac ;; - 2-uspres) case $1 in - *[02468][048]|*[13579][26]) exit 0 ;; - *) exit 1 ;; - esac ;; - 2-*) echo "$0: wild type - $2" >&2 - exit 1 ;; - *) echo "$0: usage is $0 year type" >&2 - exit 1 ;; + 2-even) + case $1 in + *[24680]) exit 0 ;; + *) exit 1 ;; + esac ;; + 2-nonpres|2-nonuspres) + case $1 in + *[02468][048]|*[13579][26]) exit 1 ;; + *) exit 0 ;; + esac ;; + 2-odd) + case $1 in + *[13579]) exit 0 ;; + *) exit 1 ;; + esac ;; + 2-uspres) + case $1 in + *[02468][048]|*[13579][26]) exit 0 ;; + *) exit 1 ;; + esac ;; + 2-*) + echo "$0: wild type - $2" >&2 ;; esac + +echo "$0: usage is $0 year even|odd|uspres|nonpres|nonuspres" >&2 +exit 1 diff --git a/zic.tproj/ialloc.c b/zic.tproj/ialloc.c index 490d2fa..f82638f 100644 --- a/zic.tproj/ialloc.c +++ b/zic.tproj/ialloc.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/private.h b/zic.tproj/private.h index db7990d..51f379d 100644 --- a/zic.tproj/private.h +++ b/zic.tproj/private.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/scheck.c b/zic.tproj/scheck.c index 8407656..bfb5ab2 100644 --- a/zic.tproj/scheck.c +++ b/zic.tproj/scheck.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/tzfile.h b/zic.tproj/tzfile.h index 25220c6..1702d15 100644 --- a/zic.tproj/tzfile.h +++ b/zic.tproj/tzfile.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/zic.c b/zic.tproj/zic.c index a381bd4..5bf725b 100644 --- a/zic.tproj/zic.c +++ b/zic.tproj/zic.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.0 (the 'License'). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License." + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zprint.tproj/Makefile b/zprint.tproj/Makefile index b857921..5d92632 100644 --- a/zprint.tproj/Makefile +++ b/zprint.tproj/Makefile @@ -14,7 +14,7 @@ PROJECT_TYPE = Tool CFILES = zprint.c -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble zprint.1 MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles diff --git a/zprint.tproj/Makefile.postamble b/zprint.tproj/Makefile.postamble index 411cde6..503bd8b 100644 --- a/zprint.tproj/Makefile.postamble +++ b/zprint.tproj/Makefile.postamble @@ -98,3 +98,7 @@ # owned by the top-level Makefile API and no context has been set up for where # derived files should go. # + +install-man-page: + install -d $(DSTROOT)/usr/share/man/man1 + install -c -m 444 zprint.1 $(DSTROOT)/usr/share/man/man1/zprint.1 diff --git a/zprint.tproj/Makefile.preamble b/zprint.tproj/Makefile.preamble index c1624b4..44fbaaa 100644 --- a/zprint.tproj/Makefile.preamble +++ b/zprint.tproj/Makefile.preamble @@ -135,3 +135,5 @@ # standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems # and "" on other systems. DSTROOT = $(HOME) + +AFTER_INSTALL += install-man-page diff --git a/zprint.tproj/zprint.1 b/zprint.tproj/zprint.1 new file mode 100644 index 0000000..3f35069 --- /dev/null +++ b/zprint.tproj/zprint.1 @@ -0,0 +1,40 @@ +.TH ZPRINT 1 27/02/87 +.CM 4 +.SH NAME +zprint \- show information about kernel zones +.SH SYNOPSIS +\fBzprint\fP [\fB-w\fP] [\fB-s\fP] [\fB-c\fP] [\fB-h\fP] [name] +.SH DESCRIPTION +\fIzprint(1)\fR displays data about Mach zones. By default, +\fIzprint\fR will print out information about all Mach zones. If the +optional \fIname\fR is specified, \fIzprint\fR will print information +about each zone for which \fIname\fR is a substring of the zone's +name. +.PP +\fIzprint\fR interprets the following options: +.TP 8 +.B \-w +For each zone, \fIzprint\fR calculates how much space is allocated but +not currently in use, the space wasted by the zone. +.TP 8 +.B \-s +\fIzprint\fR sorts the zones, showing the wasting the most memory first. +.TP 8 +.B \-c +(Default) +\fIzprint\fR prints zone info in columns. Long zone names are truncated +with '$', and spaces are replaced with '.', to allow for sorting by column. +Pageable and collectible zones are shown with 'P' and 'C' +on the far right. Zones with preposterously large maximum +sizes are shown with '----' in the max size and max num elts fields. +.TP 8 +.B \-h +(Default) +Shows headings for the columns printed with the -c option. +It may be useful to override this option when sorting by column. +.PP +Any option (including default options) can be overridden +by specifying the option in upper-case; for example, -C overrides +the (default) option -c. +.SH "SEE ALSO" +host_zone_info(2). -- 2.45.2