diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-05-02 16:00:07 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-05-02 16:00:07 -0400 |
commit | f3dab068fce37270e5e4e1a00e5a44e30f00baf7 (patch) | |
tree | d6b8c70074d440e56c1d7cdbfc7b68d8b96bda96 /chpass | |
parent | 6b46c62f4663c84790120a4e74e155a6ef16b41c (diff) | |
download | pw-darwin-f3dab068fce37270e5e4e1a00e5a44e30f00baf7.tar.gz pw-darwin-f3dab068fce37270e5e4e1a00e5a44e30f00baf7.tar.zst pw-darwin-f3dab068fce37270e5e4e1a00e5a44e30f00baf7.zip |
Recommit everything, add chpass, improve history (except for a few files that git-filter-repo dislikes for some reason [_secure_path.c and login_cap.h])
Diffstat (limited to 'chpass')
-rw-r--r-- | chpass/Makefile | 87 | ||||
-rw-r--r-- | chpass/chpass.c | 62 |
2 files changed, 61 insertions, 88 deletions
diff --git a/chpass/Makefile b/chpass/Makefile index bd5baa3..1f88e51 100644 --- a/chpass/Makefile +++ b/chpass/Makefile @@ -1,45 +1,42 @@ -# @(#)Makefile 8.2 (Berkeley) 4/2/94 -# $FreeBSD$ - -.include <src.opts.mk> - -.PATH: ${SRCTOP}/lib/libc/gen - -PROG= chpass -SRCS= chpass.c edit.c field.c pw_scan.c table.c util.c -BINOWN= root -BINMODE=4555 -PRECIOUSPROG= -.if ${MK_NIS} != "no" -CFLAGS+= -DYP -.endif -#Some people need this, uncomment to activate -#CFLAGS+=-DRESTRICT_FULLNAME_CHANGE -CFLAGS+=-I${SRCTOP}/lib/libc/gen -I. - -LIBADD= crypt util -.if ${MK_NIS} != "no" -LIBADD+= ypclnt -.endif - -SYMLINKS= chpass ${BINDIR}/chfn -SYMLINKS+= chpass ${BINDIR}/chsh -.if ${MK_NIS} != "no" -SYMLINKS+= chpass ${BINDIR}/ypchfn -SYMLINKS+= chpass ${BINDIR}/ypchpass -SYMLINKS+= chpass ${BINDIR}/ypchsh -.endif - -MLINKS= chpass.1 chfn.1 chpass.1 chsh.1 -.if ${MK_NIS} != "no" -MLINKS+= chpass.1 ypchpass.1 chpass.1 ypchfn.1 chpass.1 ypchsh.1 -.endif - -beforeinstall: -.for i in chpass chfn chsh ypchpass ypchfn ypchsh -.if exists(${DESTDIR}${BINDIR}/$i) - -chflags noschg ${DESTDIR}${BINDIR}/$i -.endif -.endfor - -.include <bsd.prog.mk> +CC ?= aarch64-apple-darwin-clang +STRIP ?= aarch64-apple-darwin-strip +LDID ?= ldid +CFLAGS ?= -arch arm64 -isysroot /home/cameron/Documents/SDK/iPhoneOS14.3.sdk -miphoneos-version-min=13.0 +LDFLAGS ?= +GINSTALL ?= install +PREFIX ?= /usr +DESTDIR ?= + +SRC := chpass.c \ + edit.c \ + field.c \ + table.c \ + util.c \ + ../libutil/pw_util.c \ + ../libutil/flopen.c \ + ../libc/gen/pw_scan.c + +all: chpass + +install: install-chpass + +chpass: $(SRC:%.c=%.o) ../ent.xml + $(CC) $(LDFLAGS) -o $@ -lcrypt $(SRC:%.c=%.o) + $(STRIP) $@ + $(LDID) -S../ent.xml $@ + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< -I. -I../libutil -I../libc/gen + +install-chpass: chpass chpass.1 + $(GINSTALL) -Dm4555 chpass $(DESTDIR)/$(PREFIX)/bin/chpass + ln -sf chpass $(DESTDIR)/$(PREFIX)/bin/chfn + ln -sf chpass $(DESTDIR)/$(PREFIX)/bin/chsh + $(GINSTALL) -Dm644 chpass.1 $(DESTDIR)/$(PREFIX)/share/man/man1/chpass.1 + ln -sf chpass.1 $(DESTDIR)/$(PREFIX)/share/man/man1/chfn.1 + ln -sf chpass.1 $(DESTDIR)/$(PREFIX)/share/man/man1/chsh.1 + +clean: + rm -f chpass $(SRC:%.c=%.o) + +.PHONY: all install install-chpass clean diff --git a/chpass/chpass.c b/chpass/chpass.c index 643b0f3..3b3a41f 100644 --- a/chpass/chpass.c +++ b/chpass/chpass.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <pw_scan.h> #include <libutil.h> +#include <crypt.h> #include "chpass.h" @@ -237,51 +238,26 @@ main(int argc, char *argv[]) password = ""; } - if (old_pw != NULL) - pw->pw_fields |= (old_pw->pw_fields & _PWF_SOURCE); - switch (pw->pw_fields & _PWF_SOURCE) { -#ifdef YP - case _PWF_NIS: - ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host); - if (ypclnt == NULL) { - warnx("ypclnt_new failed"); - exit(1); - } - if (ypclnt_connect(ypclnt) == -1 || - ypclnt_passwd(ypclnt, pw, password) == -1) { - warnx("%s", ypclnt->error); - ypclnt_free(ypclnt); - exit(1); - } - ypclnt_free(ypclnt); - errx(0, "NIS user information updated"); -#endif /* YP */ - case 0: - case _PWF_FILES: - if (pw_init(NULL, NULL)) - err(1, "pw_init()"); - if ((pfd = pw_lock()) == -1) { - pw_fini(); - err(1, "pw_lock()"); - } - if ((tfd = pw_tmp(-1)) == -1) { - pw_fini(); - err(1, "pw_tmp()"); - } - if (pw_copy(pfd, tfd, pw, old_pw) == -1) { - pw_fini(); - err(1, "pw_copy"); - } - if (pw_mkdb(pw->pw_name) == -1) { - pw_fini(); - err(1, "pw_mkdb()"); - } + if (pw_init(NULL, NULL)) + err(1, "pw_init()"); + if ((pfd = pw_lock()) == -1) { + pw_fini(); + err(1, "pw_lock()"); + } + if ((tfd = pw_tmp(-1)) == -1) { + pw_fini(); + err(1, "pw_tmp()"); + } + if (pw_copy(pfd, tfd, pw, old_pw) == -1) { + pw_fini(); + err(1, "pw_copy"); + } + if (pw_mkdb(pw->pw_name) == -1) { pw_fini(); - errx(0, "user information updated"); - break; - default: - errx(1, "unsupported passwd source"); + err(1, "pw_mkdb()"); } + pw_fini(); + errx(0, "user information updated"); } static void |