OpenBSD CVS

CVS log for src/usr.bin/chpass/chpass.c


[BACK] Up to [local] / src / usr.bin / chpass

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.50 / (download) - annotate - [select for diffs], Wed Mar 8 04:43:10 2023 UTC (14 months, 1 week ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, HEAD
Changes since 1.49: +1 -2 lines
Diff to previous 1.49 (colored)

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@

Revision 1.49 / (download) - annotate - [select for diffs], Sun Dec 4 23:50:47 2022 UTC (17 months, 2 weeks ago) by cheloha
Branch: MAIN
Changes since 1.48: +1 -2 lines
Diff to previous 1.48 (colored)

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.  Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@.  With help from dlg@ and millert@.

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

ok naddy@ millert@ dlg@

Revision 1.48 / (download) - annotate - [select for diffs], Sun Oct 24 21:24:16 2021 UTC (2 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert

Revision 1.47 / (download) - annotate - [select for diffs], Mon Jul 12 15:09:19 2021 UTC (2 years, 10 months ago) by beck
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.46: +8 -8 lines
Diff to previous 1.46 (colored)

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@

Revision 1.46 / (download) - annotate - [select for diffs], Sat Sep 14 17:47:00 2019 UTC (4 years, 8 months ago) by semarie
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

correct some unveil(2) violations due to "login.conf.db" access (the .db version
of "login.conf"), and stat(2) on _PATH_MASTERPASSWD_LOCK (via pw_mkdb(3)).

problem initially noted by myself for passwd(1)
millert@ reported similar problem on chpass(1), su(1), doas(1) and encrypt(1)
mestre@ noted chpass(1) too

ok mestre@ millert@

Revision 1.45 / (download) - annotate - [select for diffs], Tue Apr 30 18:28:45 2019 UTC (5 years ago) by mestre
Branch: MAIN
Changes since 1.44: +17 -3 lines
Diff to previous 1.44 (colored)

add unveil(2):

chpass(1) without parameters enters in edit mode by default, in here it will
need to execute _PATH_BSHELL to spawn a new EDITOR, _PATH_SHELLS to check
(read) if we are changing from/to a non-standard shell (in case we are not
root) and read access to `tempname' to verify if the file has valid entries and
create to unlink it.

If -s is used to change a user's shell then it will need read access to
_PATH_SHELLS by the same reason already mentioned above.

Unconditionally we need to unveil _PATH_MASTERPASSWD_LOCK with write/create
permissions, _PATH_MASTERPASSWD with read and _PATH_PWD_MKDB to execute
pwd_mkdb(8).

In the -a case I'm not unveiling /etc/spwd.db since we can get it through
pledge "getpw", which can be added later for completeness of all code paths.
Note also that the first pledges need "unveil" since we will call unveil(2)
afterwards.

"looks good" deraadt@

Revision 1.44 / (download) - annotate - [select for diffs], Fri Dec 8 17:04:15 2017 UTC (6 years, 5 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.43: +3 -15 lines
Diff to previous 1.43 (colored)

Convert snprintf+write into dprintf.  It is simply easier to read, and
provides retry on short-write file descriptors.
ok florian, previous versions seen by millert

Revision 1.43 / (download) - annotate - [select for diffs], Thu Nov 26 19:01:47 2015 UTC (8 years, 5 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.42: +21 -65 lines
Diff to previous 1.42 (colored)

Delete YP password related code.  As a result, these can also be
pledged.  Keep an eye out for regressions, because they could be
uncomfortable.
ok beck semarie

Revision 1.42 / (download) - annotate - [select for diffs], Wed Nov 18 19:26:45 2015 UTC (8 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.41: +4 -4 lines
Diff to previous 1.41 (colored)

needs _shadow so it can rewrite the master.passwd file

Revision 1.41 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:06 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.40: +1 -2 lines
Diff to previous 1.40 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.40 / (download) - annotate - [select for diffs], Sun Oct 26 20:38:13 2014 UTC (9 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.39: +3 -3 lines
Diff to previous 1.39 (colored)

Prefer mkostemp(O_CLOEXEC) over mkstemp()+fcntl(F_SETFD)
Prefer fopen("re") over fopen("r")+fcntl(F_SETFD)

ok otto@ millert@

Revision 1.39 / (download) - annotate - [select for diffs], Thu Apr 18 16:23:25 2013 UTC (11 years, 1 month ago) by okan
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.38: +4 -4 lines
Diff to previous 1.38 (colored)

- use FD_CLOEXEC instead of 1
- use O_CLOEXEC with open() instead of open/fcntl

from David Hill

ok otto@

Revision 1.38 / (download) - annotate - [select for diffs], Wed Jun 20 21:32:27 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Correct English just like jsing@ did it in passwd/local_passwd.c rev. 1.38
on April 27, 2008.  While here, fix a typo and drop an obsolete BUGS section.

"my typo so OK millert@ :-)" and OK jmc@

Revision 1.37 / (download) - annotate - [select for diffs], Tue Oct 27 23:59:36 2009 UTC (14 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.36: +1 -15 lines
Diff to previous 1.36 (colored)

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms

Revision 1.36 / (download) - annotate - [select for diffs], Tue Jul 8 21:30:15 2008 UTC (15 years, 10 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.35: +4 -4 lines
Diff to previous 1.35 (colored)

fix double "usage:"

Revision 1.35 / (download) - annotate - [select for diffs], Thu Jun 19 19:16:04 2008 UTC (15 years, 11 months ago) by tobias
Branch: MAIN
Changes since 1.34: +9 -3 lines
Diff to previous 1.34 (colored)

Moved the unset of TZ environment variable out of atot into main, removing
an unused static var and test out of atot.

With input by jsing and millert, ok millert

Revision 1.34 / (download) - annotate - [select for diffs], Tue Mar 27 07:22:33 2007 UTC (17 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.33: +7 -5 lines
Diff to previous 1.33 (colored)

-a requires a separate synopsis;
from Daniel Polak via henning

ok henning

Revision 1.33 / (download) - annotate - [select for diffs], Mon Jan 15 08:14:21 2007 UTC (17 years, 4 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.32: +7 -4 lines
Diff to previous 1.32 (colored)

Fix -a when given an entry with an already existing user. Also, give
error message if a user arg has been given with -a. Noted by Dan
Brosemer. ok millert@ jaredy@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Dec 12 20:43:10 2005 UTC (18 years, 5 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.31: +3 -2 lines
Diff to previous 1.31 (colored)

ARGSUSED on signal handler

Revision 1.31 / (download) - annotate - [select for diffs], Mon May 10 20:05:48 2004 UTC (20 years ago) by wilfried
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.30: +10 -10 lines
Diff to previous 1.30 (colored)

unbreak chsh, ok millert

Revision 1.30 / (download) - annotate - [select for diffs], Tue Apr 20 23:21:23 2004 UTC (20 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.29: +12 -5 lines
Diff to previous 1.29 (colored)

Adapt to new pw_copy() API, closes PR 3698.

Revision 1.29 / (download) - annotate - [select for diffs], Wed Nov 26 00:33:58 2003 UTC (20 years, 5 months ago) by espie
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.28: +3 -3 lines
Diff to previous 1.28 (colored)

This is ISO C, use string concatenation, instead of bogus use of __CONCAT.
(hint: "a" and "b" can't be pasted as a valid C token...)
okay millert@

Revision 1.28 / (download) - annotate - [select for diffs], Tue Jul 1 01:01:28 2003 UTC (20 years, 10 months ago) by avsm
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.27: +4 -4 lines
Diff to previous 1.27 (colored)

- no need for pathnames.h, just use <paths.h> instead
- bump mktemp randomness slightly from 8 -> 10
millert@ ok

Revision 1.27 / (download) - annotate - [select for diffs], Tue Jun 3 02:56:06 2003 UTC (20 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.26: +3 -7 lines
Diff to previous 1.26 (colored)

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

Revision 1.26 / (download) - annotate - [select for diffs], Wed Jul 31 22:08:41 2002 UTC (21 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.25: +16 -3 lines
Diff to previous 1.25 (colored)

When I got removed the use of atexit() I missed the fact that edit()
calls pw_error() which in turn calls exit().  Now edit() returns
its status so the temp file gets cleaned up nicely if the user makes
no changes or if an error occurred.  Problem noticed by deraadt@

Revision 1.25 / (download) - annotate - [select for diffs], Thu Jun 27 22:02:08 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.24: +6 -10 lines
Diff to previous 1.24 (colored)

move protos

Revision 1.24 / (download) - annotate - [select for diffs], Thu Jun 27 19:16:50 2002 UTC (21 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.23: +6 -15 lines
Diff to previous 1.23 (colored)

There is absolutely no reason for the "tempname" or dfd variables
to exist outside the scope of the 'op == EDITENTRY' code block.
This allows us to get rid of the atexit() call and tempcleanup().

Revision 1.23 / (download) - annotate - [select for diffs], Thu Jun 27 19:02:40 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.22: +11 -14 lines
Diff to previous 1.22 (colored)

cleanup; mpech & millert ok

Revision 1.22 / (download) - annotate - [select for diffs], Thu Mar 14 06:51:41 2002 UTC (22 years, 2 months ago) by mpech
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

Remove \n from err/errx/warn/warnx().

millert@ ok

Revision 1.21 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:44 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.20: +8 -8 lines
Diff to previous 1.20 (colored)

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 1.20 / (download) - annotate - [select for diffs], Mon Aug 27 02:57:07 2001 UTC (22 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.19: +12 -37 lines
Diff to previous 1.19 (colored)

Instead of prompting the user whether or not they wish to continue to
wait for the lock on password file just tell the user to interrupt with
^C.  This simplifies the locking loop a bit.

Update man page to this effect.

Revision 1.19 / (download) - annotate - [select for diffs], Thu Aug 16 18:29:27 2001 UTC (22 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (colored)

extra arg to pw_mkdb

Revision 1.18 / (download) - annotate - [select for diffs], Thu Aug 16 16:14:35 2001 UTC (22 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.17: +6 -4 lines
Diff to previous 1.17 (colored)

At Theo's request only print 'Please wait' if don't get the lock
on the first try.

Revision 1.17 / (download) - annotate - [select for diffs], Wed Aug 15 20:47:53 2001 UTC (22 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.16: +80 -20 lines
Diff to previous 1.16 (colored)

Move locking of the passwd file *after* we have gotten a new password
from the user.  Set real/effective/saved uids to 0 and block all signals
so the lock cannot be kept longer than necessary.  If we cannot lock,
try again every 1/4 second for 2 seconds and then ask the user what
they wish to do (keep trying, quit).

Same as in local_passwd.c but here we need to remove a temp file
in the SIGINT handler because _exit() doesn't call atexit() routines.

Revision 1.16 / (download) - annotate - [select for diffs], Sun Nov 26 01:29:43 2000 UTC (23 years, 5 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

Update for pw_mkdb(3) interface change.  All but vipw and userdel can
specify a username (and thus avoid rebuilding the while database).

Revision 1.15 / (download) - annotate - [select for diffs], Tue Nov 21 13:36:14 2000 UTC (23 years, 6 months ago) by aaron
Branch: MAIN
Changes since 1.14: +6 -5 lines
Diff to previous 1.14 (colored)

Sync usage() output with man page; mpech@prosoft.org.lv

Revision 1.14 / (download) - annotate - [select for diffs], Sun Dec 5 20:18:35 1999 UTC (24 years, 5 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.13: +13 -5 lines
Diff to previous 1.13 (colored)

Fix temp file unlinking.  We use atexit() since the libutil passwd
routines do their own exit.

Revision 1.13 / (download) - annotate - [select for diffs], Mon Aug 3 17:09:46 1998 UTC (25 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.12: +6 -3 lines
Diff to previous 1.12 (colored)

use __progname

Revision 1.12 / (download) - annotate - [select for diffs], Sun Aug 2 03:35:07 1998 UTC (25 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.11: +6 -6 lines
Diff to previous 1.11 (colored)

add close on exec flag to all opens

Revision 1.11 / (download) - annotate - [select for diffs], Fri May 29 16:37:51 1998 UTC (25 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

put temp file _PATH_VARTMP

Revision 1.10 / (download) - annotate - [select for diffs], Mon Mar 30 06:59:28 1998 UTC (26 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.9: +4 -2 lines
Diff to previous 1.9 (colored)

Y2K fixes from Andreas.Gunnarsson@emw.ericsson.se; culled from various places

Revision 1.9 / (download) - annotate - [select for diffs], Tue Jun 17 20:49:55 1997 UTC (26 years, 11 months ago) by kstailey
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.8: +7 -7 lines
Diff to previous 1.8 (colored)

(foo *)NULL -> NULL

Revision 1.8 / (download) - annotate - [select for diffs], Thu Feb 13 17:28:39 1997 UTC (27 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.7: +9 -8 lines
Diff to previous 1.7 (colored)

fix YP and non-YP cases to exit/warn nicely

Revision 1.7 / (download) - annotate - [select for diffs], Wed Jan 15 23:42:18 1997 UTC (27 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.6: +3 -3 lines
Diff to previous 1.6 (colored)

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

Revision 1.6 / (download) - annotate - [select for diffs], Sun Oct 20 23:45:50 1996 UTC (27 years, 7 months ago) by millert
Branch: MAIN
Changes since 1.5: +8 -4 lines
Diff to previous 1.5 (colored)

better error message if unable to create password temp file.

Revision 1.5 / (download) - annotate - [select for diffs], Mon Sep 23 05:40:47 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.4: +5 -3 lines
Diff to previous 1.4 (colored)

pw_abort() after yp change, does unlock

Revision 1.4 / (download) - annotate - [select for diffs], Sat Aug 31 01:55:32 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.3: +6 -6 lines
Diff to previous 1.3 (colored)

kill leaks; help from das33@cornell.edu

Revision 1.3 / (download) - annotate - [select for diffs], Wed Jun 26 05:31:54 1996 UTC (27 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +2 -1 lines
Diff to previous 1.2 (colored)

rcsid

Revision 1.2 / (download) - annotate - [select for diffs], Wed May 22 11:35:18 1996 UTC (28 years ago) by deraadt
Branch: MAIN
Changes since 1.1: +23 -41 lines
Diff to previous 1.1 (colored)

libutil

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Wed Oct 18 08:44:59 1995 UTC (28 years, 7 months ago) by deraadt
CVS Tags: netbsd_1_1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

initial import of NetBSD tree

Revision 1.1 / (download) - annotate - [select for diffs], Wed Oct 18 08:44:59 1995 UTC (28 years, 7 months ago) by deraadt
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.