diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2023-01-22 22:01:51 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2023-01-22 22:01:51 +0200 |
commit | 8be69b967c91de5b5529a0e4a4b5ed862fbe7c7e (patch) | |
tree | 1ee3d89e3ec04f7a115799588395d5185f5732f0 | |
parent | cb8aed59b60f39f1ecfd5f283a02aa25fadfa58f (diff) | |
parent | 6e195e45a972b9c88ab8c5627d09049268b29df0 (diff) | |
download | gawk-8be69b967c91de5b5529a0e4a4b5ed862fbe7c7e.tar.gz |
Merge branch 'gawk-5.2-stable'
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | doc/ChangeLog | 8 | ||||
-rw-r--r-- | doc/gawk.info | 549 | ||||
-rw-r--r-- | doc/gawk.texi | 63 | ||||
-rw-r--r-- | doc/gawktexi.in | 63 | ||||
-rw-r--r-- | extension/ChangeLog | 10 | ||||
-rw-r--r-- | extension/configh.in | 3 | ||||
-rwxr-xr-x | extension/configure | 6 | ||||
-rw-r--r-- | extension/configure.ac | 4 | ||||
-rw-r--r-- | extension/time.3am | 66 | ||||
-rw-r--r-- | extension/time.c | 71 | ||||
-rw-r--r-- | main.c | 39 | ||||
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/makepmafile.c | 4 | ||||
-rw-r--r-- | test/time.awk | 30 | ||||
-rw-r--r-- | test/time.ok | 2 |
17 files changed, 587 insertions, 350 deletions
@@ -1,3 +1,11 @@ +2023-01-22 Arnold D. Robbins <arnold@skeeve.com> + + * main.c: Update copyright year. + (check_pma_security): New routine. + (main): Call it. + (UPDATE_YEAR): Bump to 2023. + (NEWS): Updated. + 2023-01-03 Arnold D. Robbins <arnold@skeeve.com> * README: Updated with texinfo.tex and makeinfo versions. @@ -36,7 +36,10 @@ Changes from 5.2.1 to 5.2.2 5. PROCINFO["pma"] exists if the PMA allocator is compiled into gawk. Its value is the PMA version. -6. As usual, there have been several minor code cleanups and bug fixes. +6. The time extension is no longer deprecated. The strptime() function + from gawkextlib's timex extension has been added to it. + +7. As usual, there have been several minor code cleanups and bug fixes. See the ChangeLog for details. Changes from 5.2.0 to 5.2.1 diff --git a/doc/ChangeLog b/doc/ChangeLog index f2705517..395c5153 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2023-01-22 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Persistent Memory): Document that root can't + use persistent memory and we recommend chmod 600 on the file. + Also, update the copyright year. + (Extension Sample Time): Undeprecate time extension. Add + strptime() doc. + 2023-01-03 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Updated to latest version from ftp.gnu.org. diff --git a/doc/gawk.info b/doc/gawk.info index 59a0e397..3f893bca 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -1,6 +1,6 @@ This is gawk.info, produced by makeinfo version 7.0.1 from gawk.texi. -Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2022 +Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2023 Free Software Foundation, Inc. @@ -37,7 +37,7 @@ General Introduction This file documents ‘awk’, a program that you can use to select particular records in a file and perform operations upon them. - Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2022 + Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2023 Free Software Foundation, Inc. @@ -22269,14 +22269,19 @@ the tests pass, please let the maintainer know. $ truncate -s 4G data.pma - 2. Provide the path to the data file in the ‘GAWK_PERSIST_FILE’ + 2. It is recommended (but not required) to change the permissions on + the file so that only the owner can read and write it: + + $ chmod 0600 data.pma + + 3. Provide the path to the data file in the ‘GAWK_PERSIST_FILE’ environment variable. This is best done by placing the value in the environment just for the run of ‘gawk’, like so: $ GAWK_PERSIST_FILE=data.pma gawk 'BEGIN { print ++i }' 1 - 3. Use the same data file in subsequent runs to use the preserved data + 4. Use the same data file in subsequent runs to use the preserved data values: $ GAWK_PERSIST_FILE=data.pma gawk 'BEGIN { print ++i }' @@ -22319,7 +22324,9 @@ information the persistent memory allocator will print. ‘gawk’ sets the default to one. See the ‘support/pma.c’ source code to understand what the different verbosity levels are. - NOTE: If you use MPFR mode (the ‘-M’ option) on the first run of a + There are a few constraints on the use of persistent memory: + + • If you use MPFR mode (the ‘-M’ option) on the first run of a program using persistent memory, you _must_ continue to use it on all subsequent runs. Similarly, if you don’t use ‘-M’ on the first run, do not use it on any subsequent runs. @@ -22328,9 +22335,13 @@ the different verbosity levels are. backing file is not allowed. ‘gawk’ detects such a situation and issues a fatal error message. - Additionally, the GNU/Linux CIFS filesystem is known to not work - well with the PMA allocator. Don’t use a backing file on a CIFS - filesystem. + • The GNU/Linux CIFS filesystem is known to not work well with the + PMA allocator. Don’t use a backing file on a CIFS filesystem. + + • If ‘gawk’ is run by the ‘root’ user, then persistent memory is not + allowed. This is to avoid the possibility of private data + “leaking” into the backing file and being recovered later by an + attacker. Terence Kelly has provided a separate ‘Persistent-Memory ‘gawk’ User Manual’ document, which is included in the ‘gawk’ distribution. It is @@ -29607,17 +29618,8 @@ File: gawk.info, Node: Extension Sample Time, Next: Extension Sample API Tests 17.7.11 Extension Time Functions -------------------------------- - CAUTION: As ‘gawk’ version 5.1.0, this extension is considered to - be obsolete. It is replaced by the ‘timex’ extension in - ‘gawkextlib’ (*note gawkextlib::). - - For version 5.1, no warning will be issued if this extension is - used. For the next major release, a warning will be issued. In - the release after that this extension will be removed from the - distribution. - - The ‘time’ extension adds two functions, named ‘gettimeofday()’ and -‘sleep()’, as follows: +The ‘time’ extension adds three functions, named ‘gettimeofday()’ +‘sleep()’, and ‘strptime()’, as follows: ‘@load "time"’ This is how you load the extension. @@ -29641,6 +29643,21 @@ File: gawk.info, Node: Extension Sample Time, Next: Extension Sample API Tests function tries to use ‘nanosleep()’ or ‘select()’ to implement the delay. +‘timeval = strptime(STRING, FORMAT)’ + This function takes two arguments, a string representing a date and + time, and a format string describing the data in the string. It + calls the C library ‘strptime()’ function with the given values. + If the parsing succeeds, the results are passed to the C library + ‘mktime()’ function, and its result is returned, expressing the + time in seconds since the epoch in the current local timezone, + regardless of any timezone specified in the string arguments. + (This is the same as ‘gawk’’s built-in ‘systime()’ function.) + Otherwise it returns −1 upon error. In the latter case, + + Note that the underlying ‘strptime()’ C library routine apparently + ignores any time zone indication in the date string, producing + values relative to the current time zone. + File: gawk.info, Node: Extension Sample API Tests, Prev: Extension Sample Time, Up: Extension Samples @@ -37171,9 +37188,9 @@ Index * environment variables, REALLY_USE_PERSIST_MALLOC: Persistent Memory. (line 29) * environment variables, GAWK_PERSIST_FILE <1>: Persistent Memory. - (line 45) + (line 50) * environment variables, PMA_VERBOSITY <1>: Persistent Memory. - (line 89) + (line 94) * environment variables, LANGUAGE: Explaining gettext. (line 120) * environment variables, GAWK_LOCALE_DIR <1>: Explaining gettext. (line 132) @@ -37669,7 +37686,7 @@ Index * GAWK_PERSIST_FILE environment variable: Other Environment Variables. (line 15) * GAWK_PERSIST_FILE environment variable <1>: Persistent Memory. - (line 45) + (line 50) * GAWK_READ_TIMEOUT environment variable: Other Environment Variables. (line 19) * GAWK_READ_TIMEOUT environment variable <1>: Read Timeout. (line 71) @@ -37728,7 +37745,7 @@ Index * gettext library, locale categories: Explaining gettext. (line 81) * gettext() function (C library): Explaining gettext. (line 63) * gettimeofday() extension function: Extension Sample Time. - (line 21) + (line 12) * git utility: gawkextlib. (line 31) * git utility <1>: Other Versions. (line 18) * git utility <2>: Accessing The Source. @@ -37928,8 +37945,8 @@ Index * Kahrs, Jürgen: Acknowledgments. (line 60) * Kahrs, Jürgen <1>: Contributors. (line 71) * Kasal, Stepan: Acknowledgments. (line 60) -* Kelly, Terence: Persistent Memory. (line 71) -* Kelly, Terence <1>: Persistent Memory. (line 116) +* Kelly, Terence: Persistent Memory. (line 76) +* Kelly, Terence <1>: Persistent Memory. (line 127) * Kelly, Terence <2>: Feature History. (line 508) * Kenobi, Obi-Wan: Undocumented. (line 6) * Kernighan, Brian: History. (line 17) @@ -38369,7 +38386,7 @@ Index * PMA memory allocator <1>: Persistent Memory. (line 6) * PMA_VERBOSITY environment variable: Other Environment Variables. (line 29) -* PMA_VERBOSITY environment variable <1>: Persistent Memory. (line 89) +* PMA_VERBOSITY environment variable <1>: Persistent Memory. (line 94) * pointers to functions: Indirect Calls. (line 6) * portability, #! (executable scripts): Executable Scripts. (line 29) * portability, ARGV variable: Executable Scripts. (line 55) @@ -38931,7 +38948,7 @@ Index * Skywalker, Luke: Undocumented. (line 6) * sleep utility: Alarm Program. (line 109) * sleep() extension function: Extension Sample Time. - (line 31) + (line 22) * Smith, Gavin: Acknowledgments. (line 75) * Solaris, POSIX-compliant awk: Other Versions. (line 100) * sort array: String Functions. (line 41) @@ -39029,6 +39046,8 @@ Index * strings, merging arrays into: Join Function. (line 6) * strings, for localization: Programmer i18n. (line 13) * strings, extracting: String Extraction. (line 6) +* strptime() extension function: Extension Sample Time. + (line 31) * strtonum: String Functions. (line 412) * strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data. (line 35) @@ -39727,244 +39746,244 @@ Ref: Two-way I/O-Footnote-2920488 Node: TCP/IP Networking920570 Node: Profiling923750 Node: Persistent Memory933460 -Ref: Persistent Memory-Footnote-1941974 -Node: Extension Philosophy942105 -Node: Advanced Features Summary943640 -Node: Internationalization945910 -Node: I18N and L10N947616 -Node: Explaining gettext948311 -Ref: Explaining gettext-Footnote-1954464 -Ref: Explaining gettext-Footnote-2954659 -Node: Programmer i18n954824 -Ref: Programmer i18n-Footnote-1959937 -Node: Translator i18n959986 -Node: String Extraction960822 -Ref: String Extraction-Footnote-1962000 -Node: Printf Ordering962098 -Ref: Printf Ordering-Footnote-1964960 -Node: I18N Portability965028 -Ref: I18N Portability-Footnote-1967602 -Node: I18N Example967673 -Ref: I18N Example-Footnote-1971073 -Ref: I18N Example-Footnote-2971149 -Node: Gawk I18N971266 -Node: I18N Summary971922 -Node: Debugger973323 -Node: Debugging974347 -Node: Debugging Concepts974796 -Node: Debugging Terms976622 -Node: Awk Debugging979235 -Ref: Awk Debugging-Footnote-1980212 -Node: Sample Debugging Session980352 -Node: Debugger Invocation980904 -Node: Finding The Bug982533 -Node: List of Debugger Commands989219 -Node: Breakpoint Control990596 -Node: Debugger Execution Control994428 -Node: Viewing And Changing Data997908 -Node: Execution Stack1001646 -Node: Debugger Info1003327 -Node: Miscellaneous Debugger Commands1007626 -Node: Readline Support1012879 -Node: Limitations1013825 -Node: Debugging Summary1016469 -Node: Namespaces1017772 -Node: Global Namespace1018899 -Node: Qualified Names1020344 -Node: Default Namespace1021379 -Node: Changing The Namespace1022154 -Node: Naming Rules1023848 -Node: Internal Name Management1025763 -Node: Namespace Example1026833 -Node: Namespace And Features1029416 -Node: Namespace Summary1030873 -Node: Arbitrary Precision Arithmetic1032386 -Node: Computer Arithmetic1033905 -Ref: table-numeric-ranges1037722 -Ref: table-floating-point-ranges1038220 -Ref: Computer Arithmetic-Footnote-11038879 -Node: Math Definitions1038938 -Ref: table-ieee-formats1041983 -Node: MPFR features1042557 -Node: MPFR On Parole1043010 -Ref: MPFR On Parole-Footnote-11043854 -Node: MPFR Intro1044013 -Node: FP Math Caution1045703 -Ref: FP Math Caution-Footnote-11046777 -Node: Inexactness of computations1047154 -Node: Inexact representation1048185 -Node: Comparing FP Values1049568 -Node: Errors accumulate1050826 -Node: Strange values1052293 -Ref: Strange values-Footnote-11054959 -Node: Getting Accuracy1055064 -Node: Try To Round1057801 -Node: Setting precision1058708 -Ref: table-predefined-precision-strings1059413 -Node: Setting the rounding mode1061298 -Ref: table-gawk-rounding-modes1061680 -Ref: Setting the rounding mode-Footnote-11065738 -Node: Arbitrary Precision Integers1065921 -Ref: Arbitrary Precision Integers-Footnote-11069133 -Node: Checking for MPFR1069289 -Node: POSIX Floating Point Problems1070779 -Ref: POSIX Floating Point Problems-Footnote-11075643 -Node: Floating point summary1075681 -Node: Dynamic Extensions1077945 -Node: Extension Intro1079544 -Node: Plugin License1080852 -Node: Extension Mechanism Outline1081665 -Ref: figure-load-extension1082116 -Ref: figure-register-new-function1083696 -Ref: figure-call-new-function1084801 -Node: Extension API Description1086920 -Node: Extension API Functions Introduction1088649 -Ref: table-api-std-headers1090547 -Node: General Data Types1095011 -Ref: General Data Types-Footnote-11104179 -Node: Memory Allocation Functions1104494 -Ref: Memory Allocation Functions-Footnote-11109219 -Node: Constructor Functions1109318 -Node: API Ownership of MPFR and GMP Values1113223 -Node: Registration Functions1114784 -Node: Extension Functions1115488 -Node: Exit Callback Functions1121064 -Node: Extension Version String1122383 -Node: Input Parsers1123078 -Node: Output Wrappers1136452 -Node: Two-way processors1141160 -Node: Printing Messages1143521 -Ref: Printing Messages-Footnote-11144735 -Node: Updating ERRNO1144890 -Node: Requesting Values1145689 -Ref: table-value-types-returned1146442 -Node: Accessing Parameters1147551 -Node: Symbol Table Access1148835 -Node: Symbol table by name1149351 -Ref: Symbol table by name-Footnote-11152562 -Node: Symbol table by cookie1152694 -Ref: Symbol table by cookie-Footnote-11156975 -Node: Cached values1157039 -Ref: Cached values-Footnote-11160683 -Node: Array Manipulation1160840 -Ref: Array Manipulation-Footnote-11161943 -Node: Array Data Types1161980 -Ref: Array Data Types-Footnote-11164802 -Node: Array Functions1164902 -Node: Flattening Arrays1169931 -Node: Creating Arrays1176983 -Node: Redirection API1181833 -Node: Extension API Variables1184854 -Node: Extension Versioning1185579 -Ref: gawk-api-version1186016 -Node: Extension GMP/MPFR Versioning1187804 -Node: Extension API Informational Variables1189510 -Node: Extension API Boilerplate1190671 -Node: Changes from API V11194807 -Node: Finding Extensions1196441 -Node: Extension Example1197016 -Node: Internal File Description1197840 -Node: Internal File Ops1202164 -Ref: Internal File Ops-Footnote-11213722 -Node: Using Internal File Ops1213870 -Ref: Using Internal File Ops-Footnote-11216301 -Node: Extension Samples1216579 -Node: Extension Sample File Functions1218148 -Node: Extension Sample Fnmatch1226286 -Node: Extension Sample Fork1227881 -Node: Extension Sample Inplace1229157 -Node: Extension Sample Ord1232829 -Node: Extension Sample Readdir1233705 -Ref: table-readdir-file-types1234602 -Node: Extension Sample Revout1235740 -Node: Extension Sample Rev2way1236337 -Node: Extension Sample Read write array1237089 -Node: Extension Sample Readfile1240363 -Node: Extension Sample Time1241494 -Node: Extension Sample API Tests1243310 -Node: gawkextlib1243818 -Node: Extension summary1246854 -Node: Extension Exercises1250712 -Node: Language History1251990 -Node: V7/SVR3.11253704 -Node: SVR41256054 -Node: POSIX1257586 -Node: BTL1259011 -Node: POSIX/GNU1259780 -Node: Feature History1266311 -Node: Common Extensions1285674 -Node: Ranges and Locales1287043 -Ref: Ranges and Locales-Footnote-11291844 -Ref: Ranges and Locales-Footnote-21291871 -Ref: Ranges and Locales-Footnote-31292110 -Node: Contributors1292333 -Node: History summary1298538 -Node: Installation1299984 -Node: Gawk Distribution1300948 -Node: Getting1301440 -Node: Extracting1302439 -Node: Distribution contents1304151 -Node: Unix Installation1312231 -Node: Quick Installation1313053 -Node: Compiling with MPFR1315599 -Node: Shell Startup Files1316305 -Node: Additional Configuration Options1317462 -Node: Configuration Philosophy1319849 -Node: Compiling from Git1322351 -Node: Building the Documentation1322910 -Node: Non-Unix Installation1324322 -Node: PC Installation1324798 -Node: PC Binary Installation1325671 -Node: PC Compiling1326576 -Node: PC Using1327754 -Node: Cygwin1331482 -Node: MSYS1332738 -Node: OpenVMS Installation1333370 -Node: OpenVMS Compilation1334051 -Ref: OpenVMS Compilation-Footnote-11335534 -Node: OpenVMS Dynamic Extensions1335596 -Node: OpenVMS Installation Details1337232 -Node: OpenVMS Running1339667 -Node: OpenVMS GNV1343804 -Node: Bugs1344559 -Node: Bug definition1345483 -Node: Bug address1349134 -Node: Usenet1352725 -Node: Performance bugs1353956 -Node: Asking for help1356974 -Node: Maintainers1358965 -Node: Other Versions1359992 -Node: Installation summary1368924 -Node: Notes1370308 -Node: Compatibility Mode1371118 -Node: Additions1371940 -Node: Accessing The Source1372885 -Node: Adding Code1374420 -Node: New Ports1381556 -Node: Derived Files1386066 -Ref: Derived Files-Footnote-11391913 -Ref: Derived Files-Footnote-21391948 -Ref: Derived Files-Footnote-31392565 -Node: Future Extensions1392679 -Node: Implementation Limitations1393351 -Node: Extension Design1394593 -Node: Old Extension Problems1395757 -Ref: Old Extension Problems-Footnote-11397333 -Node: Extension New Mechanism Goals1397394 -Ref: Extension New Mechanism Goals-Footnote-11400890 -Node: Extension Other Design Decisions1401091 -Node: Extension Future Growth1403290 -Node: Notes summary1403914 -Node: Basic Concepts1405127 -Node: Basic High Level1405812 -Ref: figure-general-flow1406094 -Ref: figure-process-flow1406796 -Ref: Basic High Level-Footnote-11410192 -Node: Basic Data Typing1410381 -Node: Glossary1413799 -Node: Copying1446921 -Node: GNU Free Documentation License1484682 -Node: Index1510005 +Ref: Persistent Memory-Footnote-1942418 +Node: Extension Philosophy942549 +Node: Advanced Features Summary944084 +Node: Internationalization946354 +Node: I18N and L10N948060 +Node: Explaining gettext948755 +Ref: Explaining gettext-Footnote-1954908 +Ref: Explaining gettext-Footnote-2955103 +Node: Programmer i18n955268 +Ref: Programmer i18n-Footnote-1960381 +Node: Translator i18n960430 +Node: String Extraction961266 +Ref: String Extraction-Footnote-1962444 +Node: Printf Ordering962542 +Ref: Printf Ordering-Footnote-1965404 +Node: I18N Portability965472 +Ref: I18N Portability-Footnote-1968046 +Node: I18N Example968117 +Ref: I18N Example-Footnote-1971517 +Ref: I18N Example-Footnote-2971593 +Node: Gawk I18N971710 +Node: I18N Summary972366 +Node: Debugger973767 +Node: Debugging974791 +Node: Debugging Concepts975240 +Node: Debugging Terms977066 +Node: Awk Debugging979679 +Ref: Awk Debugging-Footnote-1980656 +Node: Sample Debugging Session980796 +Node: Debugger Invocation981348 +Node: Finding The Bug982977 +Node: List of Debugger Commands989663 +Node: Breakpoint Control991040 +Node: Debugger Execution Control994872 +Node: Viewing And Changing Data998352 +Node: Execution Stack1002090 +Node: Debugger Info1003771 +Node: Miscellaneous Debugger Commands1008070 +Node: Readline Support1013323 +Node: Limitations1014269 +Node: Debugging Summary1016913 +Node: Namespaces1018216 +Node: Global Namespace1019343 +Node: Qualified Names1020788 +Node: Default Namespace1021823 +Node: Changing The Namespace1022598 +Node: Naming Rules1024292 +Node: Internal Name Management1026207 +Node: Namespace Example1027277 +Node: Namespace And Features1029860 +Node: Namespace Summary1031317 +Node: Arbitrary Precision Arithmetic1032830 +Node: Computer Arithmetic1034349 +Ref: table-numeric-ranges1038166 +Ref: table-floating-point-ranges1038664 +Ref: Computer Arithmetic-Footnote-11039323 +Node: Math Definitions1039382 +Ref: table-ieee-formats1042427 +Node: MPFR features1043001 +Node: MPFR On Parole1043454 +Ref: MPFR On Parole-Footnote-11044298 +Node: MPFR Intro1044457 +Node: FP Math Caution1046147 +Ref: FP Math Caution-Footnote-11047221 +Node: Inexactness of computations1047598 +Node: Inexact representation1048629 +Node: Comparing FP Values1050012 +Node: Errors accumulate1051270 +Node: Strange values1052737 +Ref: Strange values-Footnote-11055403 +Node: Getting Accuracy1055508 +Node: Try To Round1058245 +Node: Setting precision1059152 +Ref: table-predefined-precision-strings1059857 +Node: Setting the rounding mode1061742 +Ref: table-gawk-rounding-modes1062124 +Ref: Setting the rounding mode-Footnote-11066182 +Node: Arbitrary Precision Integers1066365 +Ref: Arbitrary Precision Integers-Footnote-11069577 +Node: Checking for MPFR1069733 +Node: POSIX Floating Point Problems1071223 +Ref: POSIX Floating Point Problems-Footnote-11076087 +Node: Floating point summary1076125 +Node: Dynamic Extensions1078389 +Node: Extension Intro1079988 +Node: Plugin License1081296 +Node: Extension Mechanism Outline1082109 +Ref: figure-load-extension1082560 +Ref: figure-register-new-function1084140 +Ref: figure-call-new-function1085245 +Node: Extension API Description1087364 +Node: Extension API Functions Introduction1089093 +Ref: table-api-std-headers1090991 +Node: General Data Types1095455 +Ref: General Data Types-Footnote-11104623 +Node: Memory Allocation Functions1104938 +Ref: Memory Allocation Functions-Footnote-11109663 +Node: Constructor Functions1109762 +Node: API Ownership of MPFR and GMP Values1113667 +Node: Registration Functions1115228 +Node: Extension Functions1115932 +Node: Exit Callback Functions1121508 +Node: Extension Version String1122827 +Node: Input Parsers1123522 +Node: Output Wrappers1136896 +Node: Two-way processors1141604 +Node: Printing Messages1143965 +Ref: Printing Messages-Footnote-11145179 +Node: Updating ERRNO1145334 +Node: Requesting Values1146133 +Ref: table-value-types-returned1146886 +Node: Accessing Parameters1147995 +Node: Symbol Table Access1149279 +Node: Symbol table by name1149795 +Ref: Symbol table by name-Footnote-11153006 +Node: Symbol table by cookie1153138 +Ref: Symbol table by cookie-Footnote-11157419 +Node: Cached values1157483 +Ref: Cached values-Footnote-11161127 +Node: Array Manipulation1161284 +Ref: Array Manipulation-Footnote-11162387 +Node: Array Data Types1162424 +Ref: Array Data Types-Footnote-11165246 +Node: Array Functions1165346 +Node: Flattening Arrays1170375 +Node: Creating Arrays1177427 +Node: Redirection API1182277 +Node: Extension API Variables1185298 +Node: Extension Versioning1186023 +Ref: gawk-api-version1186460 +Node: Extension GMP/MPFR Versioning1188248 +Node: Extension API Informational Variables1189954 +Node: Extension API Boilerplate1191115 +Node: Changes from API V11195251 +Node: Finding Extensions1196885 +Node: Extension Example1197460 +Node: Internal File Description1198284 +Node: Internal File Ops1202608 +Ref: Internal File Ops-Footnote-11214166 +Node: Using Internal File Ops1214314 +Ref: Using Internal File Ops-Footnote-11216745 +Node: Extension Samples1217023 +Node: Extension Sample File Functions1218592 +Node: Extension Sample Fnmatch1226730 +Node: Extension Sample Fork1228325 +Node: Extension Sample Inplace1229601 +Node: Extension Sample Ord1233273 +Node: Extension Sample Readdir1234149 +Ref: table-readdir-file-types1235046 +Node: Extension Sample Revout1236184 +Node: Extension Sample Rev2way1236781 +Node: Extension Sample Read write array1237533 +Node: Extension Sample Readfile1240807 +Node: Extension Sample Time1241938 +Node: Extension Sample API Tests1244228 +Node: gawkextlib1244736 +Node: Extension summary1247772 +Node: Extension Exercises1251630 +Node: Language History1252908 +Node: V7/SVR3.11254622 +Node: SVR41256972 +Node: POSIX1258504 +Node: BTL1259929 +Node: POSIX/GNU1260698 +Node: Feature History1267229 +Node: Common Extensions1286592 +Node: Ranges and Locales1287961 +Ref: Ranges and Locales-Footnote-11292762 +Ref: Ranges and Locales-Footnote-21292789 +Ref: Ranges and Locales-Footnote-31293028 +Node: Contributors1293251 +Node: History summary1299456 +Node: Installation1300902 +Node: Gawk Distribution1301866 +Node: Getting1302358 +Node: Extracting1303357 +Node: Distribution contents1305069 +Node: Unix Installation1313149 +Node: Quick Installation1313971 +Node: Compiling with MPFR1316517 +Node: Shell Startup Files1317223 +Node: Additional Configuration Options1318380 +Node: Configuration Philosophy1320767 +Node: Compiling from Git1323269 +Node: Building the Documentation1323828 +Node: Non-Unix Installation1325240 +Node: PC Installation1325716 +Node: PC Binary Installation1326589 +Node: PC Compiling1327494 +Node: PC Using1328672 +Node: Cygwin1332400 +Node: MSYS1333656 +Node: OpenVMS Installation1334288 +Node: OpenVMS Compilation1334969 +Ref: OpenVMS Compilation-Footnote-11336452 +Node: OpenVMS Dynamic Extensions1336514 +Node: OpenVMS Installation Details1338150 +Node: OpenVMS Running1340585 +Node: OpenVMS GNV1344722 +Node: Bugs1345477 +Node: Bug definition1346401 +Node: Bug address1350052 +Node: Usenet1353643 +Node: Performance bugs1354874 +Node: Asking for help1357892 +Node: Maintainers1359883 +Node: Other Versions1360910 +Node: Installation summary1369842 +Node: Notes1371226 +Node: Compatibility Mode1372036 +Node: Additions1372858 +Node: Accessing The Source1373803 +Node: Adding Code1375338 +Node: New Ports1382474 +Node: Derived Files1386984 +Ref: Derived Files-Footnote-11392831 +Ref: Derived Files-Footnote-21392866 +Ref: Derived Files-Footnote-31393483 +Node: Future Extensions1393597 +Node: Implementation Limitations1394269 +Node: Extension Design1395511 +Node: Old Extension Problems1396675 +Ref: Old Extension Problems-Footnote-11398251 +Node: Extension New Mechanism Goals1398312 +Ref: Extension New Mechanism Goals-Footnote-11401808 +Node: Extension Other Design Decisions1402009 +Node: Extension Future Growth1404208 +Node: Notes summary1404832 +Node: Basic Concepts1406045 +Node: Basic High Level1406730 +Ref: figure-general-flow1407012 +Ref: figure-process-flow1407714 +Ref: Basic High Level-Footnote-11411110 +Node: Basic Data Typing1411299 +Node: Glossary1414717 +Node: Copying1447839 +Node: GNU Free Documentation License1485600 +Node: Index1510923 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index fb23f98b..059d5fe8 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -308,13 +308,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2022 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2023 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2022 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2023 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -31136,6 +31136,14 @@ utility: $ @kbd{truncate -s 4G data.pma} @end example +@item +It is recommended (but not required) to change the permissions on the +file so that only the owner can read and write it: + +@example +$ @kbd{chmod 0600 data.pma} +@end example + @cindex @env{GAWK_PERSIST_FILE} environment variable @cindex environment variables @subentry @env{GAWK_PERSIST_FILE} @item @@ -31211,7 +31219,10 @@ and error information the persistent memory allocator will print. @command{gawk} sets the default to one. See the @file{support/pma.c} source code to understand what the different verbosity levels are. -@quotation NOTE +There are a few constraints on the use of persistent memory: + +@itemize @bullet +@item If you use MPFR mode (the @option{-M} option) on the first run of a program using persistent memory, you @emph{must} continue to use it on all subsequent runs. Similarly, if you don't use @option{-M} @@ -31221,10 +31232,17 @@ Mixing and matching MPFR mode and regular mode with the same backing file is not allowed. @command{gawk} detects such a situation and issues a fatal error message. -Additionally, the GNU/Linux CIFS filesystem is known to not +@item +The GNU/Linux CIFS filesystem is known to not work well with the PMA allocator. Don't use a backing file on a CIFS filesystem. -@end quotation + +@item +If @command{gawk} is run by the @command{root} user, then +persistent memory is not allowed. This is to avoid the possibility +of private data ``leaking'' into the backing file and being +recovered later by an attacker. +@end itemize Terence Kelly has provided a separate @cite{@value{PMGAWKTITLE}} document, which is included in the @command{gawk} @@ -40319,18 +40337,8 @@ if (contents == "" && ERRNO != "") @{ @node Extension Sample Time @subsection Extension Time Functions -@quotation CAUTION -As @command{gawk} @value{PVERSION} 5.1.0, this extension is considered to be obsolete. -It is replaced by the @code{timex} extension in @code{gawkextlib} -(@pxref{gawkextlib}). - -For @value{PVERSION} 5.1, no warning will be issued if this extension is used. -For the next major release, a warning will be issued. In the release after that -this extension will be removed from the distribution. -@end quotation - -The @code{time} extension adds two functions, named @code{gettimeofday()} -and @code{sleep()}, as follows: +The @code{time} extension adds three functions, named @code{gettimeofday()} +@code{sleep()}, and @code{strptime()}, as follows: @table @code @item @@load "time" @@ -40354,6 +40362,27 @@ Otherwise, return zero after sleeping for the indicated amount of time. Note that @var{seconds} may be a floating-point (nonintegral) value. Implementation details: depending on platform availability, this function tries to use @code{nanosleep()} or @code{select()} to implement the delay. + +@cindex @code{strptime()} extension function +@item timeval = strptime(@var{string}, @var{format}) +This function takes two arguments, a string representing a date and +time, and a format string describing the data in the string. It +calls the C library @code{strptime()} function with the given values. +If the parsing succeeds, the results are passed to the C library +@code{mktime()} function, and its result is returned, expressing +the time in seconds since the epoch in the current local timezone, +regardless of any timezone specified in the string arguments. (This +is the same as @command{gawk}'s built-in @code{systime()} function.) +Otherwise it returns @minus{}1 upon error. In the latter case, + +Note that the underlying @code{strptime()} C library routine apparently +ignores any time zone indication in the date string, producing values +relative to the current time zone. +@ignore +It might be better to have this +routine return a string similar to what @command{gawk}'s @code{mktime()} +function expects, but we ran out of energy. +@end ignore @end table @node Extension Sample API Tests diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 81a9e6e2..bfba6cff 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -303,13 +303,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2022 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2023 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2022 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2023 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -30091,6 +30091,14 @@ utility: $ @kbd{truncate -s 4G data.pma} @end example +@item +It is recommended (but not required) to change the permissions on the +file so that only the owner can read and write it: + +@example +$ @kbd{chmod 0600 data.pma} +@end example + @cindex @env{GAWK_PERSIST_FILE} environment variable @cindex environment variables @subentry @env{GAWK_PERSIST_FILE} @item @@ -30166,7 +30174,10 @@ and error information the persistent memory allocator will print. @command{gawk} sets the default to one. See the @file{support/pma.c} source code to understand what the different verbosity levels are. -@quotation NOTE +There are a few constraints on the use of persistent memory: + +@itemize @bullet +@item If you use MPFR mode (the @option{-M} option) on the first run of a program using persistent memory, you @emph{must} continue to use it on all subsequent runs. Similarly, if you don't use @option{-M} @@ -30176,10 +30187,17 @@ Mixing and matching MPFR mode and regular mode with the same backing file is not allowed. @command{gawk} detects such a situation and issues a fatal error message. -Additionally, the GNU/Linux CIFS filesystem is known to not +@item +The GNU/Linux CIFS filesystem is known to not work well with the PMA allocator. Don't use a backing file on a CIFS filesystem. -@end quotation + +@item +If @command{gawk} is run by the @command{root} user, then +persistent memory is not allowed. This is to avoid the possibility +of private data ``leaking'' into the backing file and being +recovered later by an attacker. +@end itemize Terence Kelly has provided a separate @cite{@value{PMGAWKTITLE}} document, which is included in the @command{gawk} @@ -39235,18 +39253,8 @@ if (contents == "" && ERRNO != "") @{ @node Extension Sample Time @subsection Extension Time Functions -@quotation CAUTION -As @command{gawk} @value{PVERSION} 5.1.0, this extension is considered to be obsolete. -It is replaced by the @code{timex} extension in @code{gawkextlib} -(@pxref{gawkextlib}). - -For @value{PVERSION} 5.1, no warning will be issued if this extension is used. -For the next major release, a warning will be issued. In the release after that -this extension will be removed from the distribution. -@end quotation - -The @code{time} extension adds two functions, named @code{gettimeofday()} -and @code{sleep()}, as follows: +The @code{time} extension adds three functions, named @code{gettimeofday()} +@code{sleep()}, and @code{strptime()}, as follows: @table @code @item @@load "time" @@ -39270,6 +39278,27 @@ Otherwise, return zero after sleeping for the indicated amount of time. Note that @var{seconds} may be a floating-point (nonintegral) value. Implementation details: depending on platform availability, this function tries to use @code{nanosleep()} or @code{select()} to implement the delay. + +@cindex @code{strptime()} extension function +@item timeval = strptime(@var{string}, @var{format}) +This function takes two arguments, a string representing a date and +time, and a format string describing the data in the string. It +calls the C library @code{strptime()} function with the given values. +If the parsing succeeds, the results are passed to the C library +@code{mktime()} function, and its result is returned, expressing +the time in seconds since the epoch in the current local timezone, +regardless of any timezone specified in the string arguments. (This +is the same as @command{gawk}'s built-in @code{systime()} function.) +Otherwise it returns @minus{}1 upon error. In the latter case, + +Note that the underlying @code{strptime()} C library routine apparently +ignores any time zone indication in the date string, producing values +relative to the current time zone. +@ignore +It might be better to have this +routine return a string similar to what @command{gawk}'s @code{mktime()} +function expects, but we ran out of energy. +@end ignore @end table @node Extension Sample API Tests diff --git a/extension/ChangeLog b/extension/ChangeLog index 403f0bfb..abc2bf95 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,13 @@ +2023-01-22 Arnold D. Robbins <arnold@skeeve.com> + + * configure.ac: Check also for strptime. + Update copyright year. + * time.3am: Update copyright. Undeprecate this extension. + Add strptime() doc. + * time.c (issue_warning): Removed function and use. + (do_strptime): Added. + (ext_version): Bump to 1.2. + 2022-11-17 Arnold D. Robbins <arnold@skeeve.com> * 5.2.1: Release tar ball made. diff --git a/extension/configh.in b/extension/configh.in index f732c3b2..77c8167b 100644 --- a/extension/configh.in +++ b/extension/configh.in @@ -112,6 +112,9 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strptime' function. */ +#undef HAVE_STRPTIME + /* Define to 1 if `st_blksize' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLKSIZE diff --git a/extension/configure b/extension/configure index 6e28f0db..ffc0c7a4 100755 --- a/extension/configure +++ b/extension/configure @@ -17565,6 +17565,12 @@ then : printf "%s\n" "#define HAVE_GETSYSTEMTIMEASFILETIME 1" >>confdefs.h fi +ac_fn_c_check_func "$LINENO" "strptime" "ac_cv_func_strptime" +if test "x$ac_cv_func_strptime" = xyes +then : + printf "%s\n" "#define HAVE_STRPTIME 1" >>confdefs.h + +fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 diff --git a/extension/configure.ac b/extension/configure.ac index 0f86caeb..fe863621 100644 --- a/extension/configure.ac +++ b/extension/configure.ac @@ -1,7 +1,7 @@ dnl dnl configure.ac --- autoconf input file for gawk dnl -dnl Copyright (C) 2012-2021 the Free Software Foundation, Inc. +dnl Copyright (C) 2012-2021, 2023 the Free Software Foundation, Inc. dnl dnl This file is part of GAWK, the GNU implementation of the dnl AWK Programming Language. @@ -123,7 +123,7 @@ esac AC_SEARCH_LIBS(fmod, m) AC_CHECK_FUNCS(fdopendir fmod fnmatch getdtablesize \ gettimeofday nanosleep select statvfs \ - GetSystemTimeAsFileTime) + GetSystemTimeAsFileTime strptime) GAWK_FUNC_DIRFD GAWK_PREREQ_DIRFD diff --git a/extension/time.3am b/extension/time.3am index 884f56f4..d60cb743 100644 --- a/extension/time.3am +++ b/extension/time.3am @@ -1,4 +1,4 @@ -.TH TIME 3am "Jul 11 2022" "Free Software Foundation" "GNU Awk Extension Modules" +.TH TIME 3am "Jan 16 2023" "Free Software Foundation" "GNU Awk Extension Modules" .SH NAME time \- time functions for gawk .SH SYNOPSIS @@ -8,24 +8,17 @@ time \- time functions for gawk time = gettimeofday() .br ret = sleep(amount) +.br +timeval = strptime(string, format) .ft R -.SH CAUTION -This extension is deprecated in favor of the -.B timex -extension in the -.I gawkextlib -project. -Loading it issues a warning. -It will be removed from the -.I gawk -distribution in the next major release. .SH DESCRIPTION The .I time -extension adds two functions named +extension adds three functions named .B gettimeofday() -and .BR sleep() , +and +.BR stptrime() , as follows. .TP .B gettimeofday() @@ -45,15 +38,51 @@ then it returns \-1 and sets .BR ERRNO . Otherwise, the function should return 0 after sleeping for the indicated amount of time. +.TP +.B strptime() +This function takes two arguments, a string representing a date and time, +and a format string describing the data in the string. It calls the +C library +.IR strptime (3) +function with the given values. +If the parsing succeeds, the results are passed to the C library +.IR mktime (3) +function, and its result is returned, expressing the time in seconds +since the epoch in the current local timezone, regardless +of any timezone specified in the string arguments. +(This is the same as +.IR gawk 's +built-in +.B systime() +function.) +Otherwise it returns \-1 upon error. In the latter case, +.B ERRNO +indicates the problem. .\" .SH NOTES -.\" .SH BUGS +.SH BUGS +The underlying +.IR strptime (3) +C library routine apparently ignores any time zone indication +in the date string, producing values relative to the current time zone. +It might be better to have this routine return a string similar +to what +.IR gawk 's +.B mktime() +function expects, but we ran out of energy. .SH EXAMPLE .ft CW .nf @load "time" \&... printf "It is now %g seconds since the Epoch\en", gettimeofday() +\&... printf "Pausing for a while... " ; sleep(2.5) ; print "done" +\&... +format = "%b %d %H:%M:%S %Z %Y" +now = systime() +print now, "<" (result = strftime(format, now)) ">", +then = strptime(result, format) +print strftime(format, then) .fi .ft R .SH "SEE ALSO" @@ -70,13 +99,18 @@ printf "Pausing for a while... " ; sleep(2.5) ; print "done" .PP .IR gettimeofday (2), .IR nanosleep (2), -.IR select (2). +.IR select (2), +and +.IR strptime (3). .SH AUTHOR Arnold Robbins, .BR arnold@skeeve.com . .SH COPYING PERMISSIONS -Copyright \(co 2012, 2013, 2018, 2022, +Copyright \(co 2012, 2013, 2018, 2022, 2023, Free Software Foundation, Inc. +.br +Copyright \(co 2019, +Arnold David Robbins. .PP Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission diff --git a/extension/time.c b/extension/time.c index 7122c1c8..9271c99f 100644 --- a/extension/time.c +++ b/extension/time.c @@ -81,9 +81,8 @@ vms_fake_nanosleep(struct timespec *rqdly, struct timespec *rmdly) static const gawk_api_t *api; /* for convenience macros to work */ static awk_ext_id_t ext_id; -static const char *ext_version = "time extension: version 1.1"; -static awk_bool_t issue_warning(void); -static awk_bool_t (*init_func)(void) = issue_warning; +static const char *ext_version = "time extension: version 1.2"; +static awk_bool_t (*init_func)(void) = NULL; int plugin_is_GPL_compatible; @@ -99,16 +98,6 @@ int plugin_is_GPL_compatible; #include <windows.h> #endif -/* issue_warning --- issue a warning that this extension is obsolete */ - -static awk_bool_t -issue_warning(void) -{ - warning(ext_id, _("The time extension is obsolete. Use the timex extension from gawkextlib instead.")); - - return awk_true; -} - /* * Returns time since 1/1/1970 UTC as a floating point value; should * have sub-second precision, but the actual precision will vary based @@ -217,9 +206,65 @@ do_sleep(int nargs, awk_value_t *result, struct awk_ext_func *unused) return make_number(rc, result); } +#ifdef HAVE_STRPTIME + +/* do_strptime --- call strptime */ + +static awk_value_t * +do_strptime(int nargs, awk_value_t *result, struct awk_ext_func *unused) +{ + awk_value_t string, format; + + assert(result != NULL); + make_number(0.0, result); + + if (do_lint) { + if (nargs == 0) { + lintwarn(ext_id, _("strptime: called with no arguments")); + make_number(-1.0, result); + goto done0; + } + } + + /* string is first arg, format is second arg */ + if (! get_argument(0, AWK_STRING, & string)) { + fprintf(stderr, _("do_strptime: argument 1 is not a string\n")); + errno = EINVAL; + goto done1; + } + if (! get_argument(1, AWK_STRING, & format)) { + fprintf(stderr, _("do_strptime: argument 2 is not a string\n")); + errno = EINVAL; + goto done1; + } + + struct tm broken_time; + memset(& broken_time, 0, sizeof(broken_time)); + broken_time.tm_isdst = -1; + if (strptime(string.str_value.str, format.str_value.str, & broken_time) == NULL) { + make_number(-1.0, result); + goto done0; + } + + time_t epoch_time = mktime(& broken_time); + make_number((double) epoch_time, result); + goto done0; + +done1: + update_ERRNO_int(errno); + +done0: + return result; +} + +#endif + static awk_ext_func_t func_table[] = { { "gettimeofday", do_gettimeofday, 0, 0, awk_false, NULL }, { "sleep", do_sleep, 1, 1, awk_false, NULL }, +#ifdef HAVE_STRPTIME + { "strptime", do_strptime, 2, 2, awk_false, NULL }, +#endif }; /* define the dl_load function using the boilerplate macro */ @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2022, + * Copyright (C) 1986, 1988, 1989, 1991-2023, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -25,7 +25,7 @@ */ /* FIX THIS BEFORE EVERY RELEASE: */ -#define UPDATE_YEAR 2022 +#define UPDATE_YEAR 2023 #include "awk.h" #include "getopt.h" @@ -56,6 +56,7 @@ static void init_fds(void); static void init_groupset(void); static void save_argv(int, char **); static const char *platform_name(); +static void check_pma_security(const char *pma_file); /* These nodes store all the special variables AWK uses */ NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node; @@ -221,10 +222,11 @@ main(int argc, char **argv) myname = gawk_name(argv[0]); + check_pma_security(persist_file); + int pma_result = pma_init(1, persist_file); if (pma_result != 0) { - // don't use 'fatal' routine, it seems to need to - // allocate memory + // don't use 'fatal' routine, memory can't be allocated fprintf(stderr, _("%s: fatal: persistent memory allocator failed to initialize: return value %d, pma.c line: %d.\n"), myname, pma_result, pma_errno); exit(EXIT_FATAL); @@ -249,6 +251,7 @@ main(int argc, char **argv) mtrace(); #endif /* HAVE_MTRACE */ #endif /* HAVE_MCHECK_H */ + os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */ if (argc < 2) @@ -1883,3 +1886,31 @@ set_current_namespace(const char *new_namespace) current_namespace = new_namespace; } + +/* check_pma_security --- make some minimal security checks */ + +static void +check_pma_security(const char *pma_file) +{ +#ifdef USE_PERSISTENT_MALLOC + struct stat sbuf; + int euid = geteuid(); + + // don't use 'fatal' routine, it seems to need to allocate memory + // and we haven't initialized PMA yet. + + if (pma_file == NULL) + return; + else if (stat(pma_file, & sbuf) < 0) { + fprintf(stderr, _("%s: fatal: cannot stat %s: %s\n"), + myname, pma_file, strerror(errno)); + exit(EXIT_FATAL); + } else if (euid == 0) { + fprintf(stderr, _("%s: fatal: using persistent memory is not allowed when running as root.\n"), myname); + exit(EXIT_FATAL); + } else if (sbuf.st_uid != euid) { + fprintf(stderr, _("%s: warning: %s is not owned by euid %d.\n"), + myname, pma_file, euid); + } +#endif /* USE_PERSISTENT_MALLOC */ +} diff --git a/test/ChangeLog b/test/ChangeLog index 8ea42359..4b750869 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2023-01-22 Arnold D. Robbins <arnold@skeeve.com> + + * makepmafile.c (main): Make the file mode 0600. + Update copyright year. + * time.awk, time.ok: Add test for strptime(). + 2022-11-25 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am: Use `grep -E' instead of egrep in some of the test diff --git a/test/makepmafile.c b/test/makepmafile.c index c6df717d..8f7d2257 100644 --- a/test/makepmafile.c +++ b/test/makepmafile.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2022, + * Copyright (C) 2022, 2023, * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -38,7 +38,7 @@ main(int argc, char **argv) { size_t four_meg = 1024 * 1024 * 4; char c = 0; - int fd = creat("test.pma", 0666); + int fd = creat("test.pma", 0600); if (fd < 0) { fprintf(stderr, "%s: could not create test.pma: %s\n", diff --git a/test/time.awk b/test/time.awk index 517377e2..377aba45 100644 --- a/test/time.awk +++ b/test/time.awk @@ -4,19 +4,25 @@ # gettimeofday() before systime() to make sure the subtraction gives 0 # without risk of rolling over to the next second. function timecheck(st,res) { - res = gettimeofday() - st = systime() - printf "gettimeofday - systime = %d\n", res-st - return res + res = gettimeofday() + st = systime() + printf "gettimeofday - systime = %d\n", res-st + return res } BEGIN { - delta = 1.3 - t0 = timecheck() - printf "sleep(%s) = %s\n",delta,sleep(delta) - t1 = timecheck() - slept = t1-t0 - if ((slept < 0.9*delta) || (slept > 1.3*delta)) - printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n", - delta,slept + delta = 1.3 + t0 = timecheck() + printf "sleep(%s) = %s\n",delta,sleep(delta) + t1 = timecheck() + slept = t1-t0 + if ((slept < 0.9*delta) || (slept > 1.3*delta)) + printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n", + delta,slept + + format = "%b %d %H:%M:%S %Y" + the_date = "Feb 11 13:12:11 1990" + then = strptime(the_date, format) + when = strftime(format, then) + print "<" the_date ">", "<<" when ">>" } diff --git a/test/time.ok b/test/time.ok index ffd21696..b781f212 100644 --- a/test/time.ok +++ b/test/time.ok @@ -1,4 +1,4 @@ -gawk: time.awk:2: warning: The time extension is obsolete. Use the timex extension from gawkextlib instead. gettimeofday - systime = 0 sleep(1.3) = 0 gettimeofday - systime = 0 +<Feb 11 13:12:11 1990> <<Feb 11 13:12:11 1990>> |