History log of /openbsd-current/usr.bin/touch/touch.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.27 29-Jan-2022 cheloha

touch(1): don't leak file descriptor if futimens(2) fails

This conditional chain short-circuits if futimens(2) fails, leaving the
file descriptor open. We need to evaluate each system call in the chain
separately to ensure we attempt to close(2) the descriptor.

With input from guenther@ and millert@.

Thread: https://marc.info/?l=openbsd-tech&m=164332809900558&w=2

ok millert@, probably ok guenther@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.26 10-Mar-2019 schwarze

Delete a useless call to setlocale(3): strptime(3) is only called
with %F and %T, neither of which is locale-dependent, and nothing
else in the code depends on the locale either, since most of the
parsing is done by hand and only supports numerical formats in the
first place.

While here, make usage() static and return from main rather than exit(3).

Patch from Jan Stary <hans at stare dot cz>.

tedu@ agrees.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.25 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.24 06-Oct-2015 deraadt

use tame "stdio rpath wpath cpath fattr". There is some timezone
database stuff here which goes further than most programs, but the
neccessary files are readable using "rpath".


Revision tags: OPENBSD_5_8_BASE
# 1.23 17-Mar-2015 millert

Eliminate use of TM_YEAR_BASE. OK guenther@ deraadt@ miod@


# 1.22 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 31-Aug-2011 jmc

use the same format/text, as far as possible, for date strings;
help/ok guenther millert


# 1.20 30-Aug-2011 guenther

Make the code match the manpage and POSIX spec when the year is specified
but the century isn't: century is 1900 if year >= 69; else 2000

ok millert@


# 1.19 21-Aug-2011 guenther

With gettimeofday() removed from the top of main(), need to call time()
for the defaulting of the year to work in the -t and arg1 forms that were
broken by previous change

ok millert@


# 1.18 20-Aug-2011 guenther

Add nanosecond precision and support for -d option (new in POSIX 2008)

ok millert@, manpage fixes jmc@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.17 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


# 1.16 18-Jun-2007 millert

Fix typo introduced in seconds parsing. From Tim van der Molen.


# 1.15 25-May-2007 millert

Sanity check time spec and if no century is specified, just use the
current one.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 08-Mar-2006 henning

even betterer
From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


# 1.13 07-Mar-2006 henning

KNF & cleanup
mostly From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 20-Apr-2005 deraadt

spacing


# 1.11 20-Apr-2005 otto

Remove redundant rw() function, which is unsafe and, well, redundant.
ok tedu@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.10 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.9 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.8 10-Jan-2003 henning

typo in comment; Jim Geovedi


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.6 13-Oct-2000 pjanzen

Missed one TM_YEAR_BASE in previous commit; pointed out by peters@telia.net
in PR 1445.


# 1.5 20-Sep-2000 pjanzen

use TM_YEAR_BASE and set seconds to zero in obsolescent "compatibility" case;
from NetBSD.


# 1.4 20-Sep-2000 pjanzen

Y2K fix for obsolescent time format: found by Camiel Dobbelaar.


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_5_BASE
# 1.26 10-Mar-2019 schwarze

Delete a useless call to setlocale(3): strptime(3) is only called
with %F and %T, neither of which is locale-dependent, and nothing
else in the code depends on the locale either, since most of the
parsing is done by hand and only supports numerical formats in the
first place.

While here, make usage() static and return from main rather than exit(3).

Patch from Jan Stary <hans at stare dot cz>.

tedu@ agrees.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.25 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.24 06-Oct-2015 deraadt

use tame "stdio rpath wpath cpath fattr". There is some timezone
database stuff here which goes further than most programs, but the
neccessary files are readable using "rpath".


Revision tags: OPENBSD_5_8_BASE
# 1.23 17-Mar-2015 millert

Eliminate use of TM_YEAR_BASE. OK guenther@ deraadt@ miod@


# 1.22 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 31-Aug-2011 jmc

use the same format/text, as far as possible, for date strings;
help/ok guenther millert


# 1.20 30-Aug-2011 guenther

Make the code match the manpage and POSIX spec when the year is specified
but the century isn't: century is 1900 if year >= 69; else 2000

ok millert@


# 1.19 21-Aug-2011 guenther

With gettimeofday() removed from the top of main(), need to call time()
for the defaulting of the year to work in the -t and arg1 forms that were
broken by previous change

ok millert@


# 1.18 20-Aug-2011 guenther

Add nanosecond precision and support for -d option (new in POSIX 2008)

ok millert@, manpage fixes jmc@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.17 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


# 1.16 18-Jun-2007 millert

Fix typo introduced in seconds parsing. From Tim van der Molen.


# 1.15 25-May-2007 millert

Sanity check time spec and if no century is specified, just use the
current one.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 08-Mar-2006 henning

even betterer
From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


# 1.13 07-Mar-2006 henning

KNF & cleanup
mostly From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 20-Apr-2005 deraadt

spacing


# 1.11 20-Apr-2005 otto

Remove redundant rw() function, which is unsafe and, well, redundant.
ok tedu@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.10 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.9 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.8 10-Jan-2003 henning

typo in comment; Jim Geovedi


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.6 13-Oct-2000 pjanzen

Missed one TM_YEAR_BASE in previous commit; pointed out by peters@telia.net
in PR 1445.


# 1.5 20-Sep-2000 pjanzen

use TM_YEAR_BASE and set seconds to zero in obsolescent "compatibility" case;
from NetBSD.


# 1.4 20-Sep-2000 pjanzen

Y2K fix for obsolescent time format: found by Camiel Dobbelaar.


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.25 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.24 06-Oct-2015 deraadt

use tame "stdio rpath wpath cpath fattr". There is some timezone
database stuff here which goes further than most programs, but the
neccessary files are readable using "rpath".


Revision tags: OPENBSD_5_8_BASE
# 1.23 17-Mar-2015 millert

Eliminate use of TM_YEAR_BASE. OK guenther@ deraadt@ miod@


# 1.22 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 31-Aug-2011 jmc

use the same format/text, as far as possible, for date strings;
help/ok guenther millert


# 1.20 30-Aug-2011 guenther

Make the code match the manpage and POSIX spec when the year is specified
but the century isn't: century is 1900 if year >= 69; else 2000

ok millert@


# 1.19 21-Aug-2011 guenther

With gettimeofday() removed from the top of main(), need to call time()
for the defaulting of the year to work in the -t and arg1 forms that were
broken by previous change

ok millert@


# 1.18 20-Aug-2011 guenther

Add nanosecond precision and support for -d option (new in POSIX 2008)

ok millert@, manpage fixes jmc@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.17 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


# 1.16 18-Jun-2007 millert

Fix typo introduced in seconds parsing. From Tim van der Molen.


# 1.15 25-May-2007 millert

Sanity check time spec and if no century is specified, just use the
current one.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 08-Mar-2006 henning

even betterer
From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


# 1.13 07-Mar-2006 henning

KNF & cleanup
mostly From: Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 20-Apr-2005 deraadt

spacing


# 1.11 20-Apr-2005 otto

Remove redundant rw() function, which is unsafe and, well, redundant.
ok tedu@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.10 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.9 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.8 10-Jan-2003 henning

typo in comment; Jim Geovedi


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.6 13-Oct-2000 pjanzen

Missed one TM_YEAR_BASE in previous commit; pointed out by peters@telia.net
in PR 1445.


# 1.5 20-Sep-2000 pjanzen

use TM_YEAR_BASE and set seconds to zero in obsolescent "compatibility" case;
from NetBSD.


# 1.4 20-Sep-2000 pjanzen

Y2K fix for obsolescent time format: found by Camiel Dobbelaar.


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision