]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
adduser rmuser: Customizable prefix
authorCameron Katri <me@cameronkatri.com>
Wed, 25 Aug 2021 23:10:49 +0000 (19:10 -0400)
committerCameron Katri <me@cameronkatri.com>
Sat, 28 Aug 2021 04:56:53 +0000 (00:56 -0400)
.gitignore
adduser/Makefile
adduser/adduser.sh
adduser/rmuser.sh

index 270dfe12a4b4ac525bfe465956984537bbb09625..68ea20e48f78f59091eb982a4687ce5a0989bbac 100644 (file)
@@ -1,3 +1,5 @@
 *.o
 pw/pw
 chpass/chpass
+adduser/adduser
+adduser/rmuser
index b1755ca2f0f1c3303d7491a0bbf2a452b01b4e2d..5cb44ec01a375ee0889c822feab5c5d8abdd8ee6 100644 (file)
@@ -1,26 +1,37 @@
 PREFIX          ?= /usr
 DESTDIR         ?=
+MEMO_PREFIX     ?=
+MEMO_SUB_PREFIX ?= /usr
 
-all:
-       @echo "Nothing to build"
+all: adduser rmuser
+
+adduser: adduser.sh
+       sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
+               -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
+               $< > $@
+
+rmuser: rmuser.sh
+       sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
+               -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
+               $< > $@
 
 clean:
-       @echo "Nothing to clean"
+       rm -f adduser rmuser
 
 install: install-adduser install-rmuser
 
-install-adduser: adduser.sh adduser.8 adduser.conf.5
+install-adduser: adduser adduser.8 adduser.conf.5
        install -d $(DESTDIR)/$(PREFIX)/sbin \
                $(DESTDIR)/$(PREFIX)/share/man/man5 \
                $(DESTDIR)/$(PREFIX)/share/man/man8
-       install -m755 adduser.sh $(DESTDIR)/$(PREFIX)/sbin/adduser
+       install -m755 adduser $(DESTDIR)/$(PREFIX)/sbin/adduser
        install -m644 adduser.8 $(DESTDIR)/$(PREFIX)/share/man/man8/adduser.8
        install -m644 adduser.conf.5 $(DESTDIR)/$(PREFIX)/share/man/man5/adduser.conf.5
 
-install-rmuser: rmuser.sh rmuser.8
+install-rmuser: rmuser rmuser.8
        install -d $(DESTDIR)/$(PREFIX)/sbin \
                $(DESTDIR)/$(PREFIX)/share/man/man8
-       install -m755 rmuser.sh $(DESTDIR)/$(PREFIX)/sbin/rmuser
+       install -m755 rmuser $(DESTDIR)/$(PREFIX)/sbin/rmuser
        install -m644 rmuser.8 $(DESTDIR)/$(PREFIX)/share/man/man8/rmuser.8
 
 .PHONY: all install install-adduser install-rmuser clean
index b9abd81e9eca9380e63e9cdfa86d907d342cb6e8..3cb11b8bf3a71be39e22e2aaf058428c063a66b7 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@MEMO_PREFIX@/bin/sh
 #
 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
 #
@@ -319,8 +319,8 @@ add_user() {
                        #
                        _dir="`dirname $msgfile`"
                        _file="`basename $msgfile`"
-                       _perms=`/usr/bin/find $_dir -name $_file -perm +07022 -prune`
-                       _owner=`/usr/bin/find $_dir -name $_file -user 0 -prune`
+                       _perms=`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/find $_dir -name $_file -perm +07022 -prune`
+                       _owner=`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/find $_dir -name $_file -user 0 -prune`
                        if [ -z "$_owner" -o -n "$_perms" ]; then
                                err "The message file ($msgfile) may be writeable only by root."
                                return 1
@@ -837,17 +837,17 @@ input_interactive() {
 
 #### END SUBROUTINE DEFINITION ####
 
-THISCMD=`/usr/bin/basename $0`
-DEFAULTSHELL=/bin/sh
-ADDUSERCONF="${ADDUSERCONF:-/etc/adduser.conf}"
-PWCMD="${PWCMD:-/usr/sbin/pw}"
+THISCMD=`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/basename $0`
+DEFAULTSHELL=@PREFIX@/bin/sh
+ADDUSERCONF="${ADDUSERCONF:-@MEMO_PREFIX@/etc/adduser.conf}"
+PWCMD="${PWCMD:-@MEMO_PREFIX@@MEMO_SUB_PREFIX@/sbin/pw}"
 MAILCMD="${MAILCMD:-mail}"
-ETCSHELLS="${ETCSHELLS:-/etc/shells}"
-NOHOME="/nonexistent"
+ETCSHELLS="${ETCSHELLS:-@MEMO_PREFIX@/etc/shells}"
+NOHOME="@MEMO_PREFIX@/var/lib/empty"
 NOLOGIN="nologin"
-NOLOGIN_PATH="/usr/sbin/nologin"
-GREPCMD="/usr/bin/grep"
-DATECMD="/bin/date"
+NOLOGIN_PATH="@MEMO_PREFIX@@MEMO_SUB_PREFIX@/sbin/nologin"
+GREPCMD="@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/grep"
+DATECMD="@MEMO_PREFIX@/bin/date"
 
 # Set default values
 #
@@ -861,13 +861,13 @@ uhome=
 uhomeperm=
 upass=
 ushell=
-udotdir=/usr/share/skel
+udotdir=@MEMO_PREFIX@@MEMO_SUB_PREFIX@/share/skel
 ugroups=
 uexpire=
 upwexpire=
 shells="`valid_shells`"
 passwdtype="yes"
-msgfile=/etc/adduser.msg
+msgfile=@MEMO_PREFIX@/etc/adduser.msg
 msgflag=
 quietflag=
 configflag=
@@ -877,7 +877,7 @@ disableflag=
 Dflag=
 Sflag=
 readconfig="yes"
-homeprefix="/var"
+homeprefix="@MEMO_PREFIX@/var"
 randompass=
 fileline=
 savedpwtype=
@@ -891,7 +891,7 @@ defaultHomePerm=
 # measure as much as it is a useful method of reminding the user to
 # 'su -' before he/she wastes time entering data that won't be saved.
 #
-procowner=${procowner:-`/usr/bin/id -u`}
+procowner=${procowner:-`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/id -u`}
 if [ "$procowner" != "0" ]; then
        err 'you must be the super-user (uid 0) to use this utility.'
        exit 1
index e2308d01b1d14196d43286a380c0dc3bc6967398..92522160f3ad43552a338da94b5f11f7ae869db6 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@MEMO_PREFIX@/bin/sh
 #
 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
 #
 # $FreeBSD$
 #
 
-ATJOBDIR="/var/at/jobs"
-CRONJOBDIR="/var/cron/tabs"
-MAILSPOOL="/var/mail"
+ATJOBDIR="@MEMO_PREFIX@/var/at/jobs"
+CRONJOBDIR="@MEMO_PREFIX@/var/cron/tabs"
+MAILSPOOL="@MEMO_PREFIX@/var/mail"
 SIGKILL="-KILL"
-TEMPDIRS="/tmp /var/tmp"
-THISCMD=`/usr/bin/basename $0`
-PWCMD="${PWCMD:-/usr/sbin/pw}"
+TEMPDIRS="@MEMO_PREFIX@/tmp @MEMO_PREFIX@/var/tmp"
+THISCMD=`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/basename $0`
+PWCMD="${PWCMD:-@MEMO_PREFIX@@MEMO_PREFIX@/sbin/pw}"
 
 # err msg
 #      Display $msg on stderr.
@@ -230,7 +230,7 @@ userlist=
 yflag=
 vflag=
 
-procowner=`/usr/bin/id -u`
+procowner=`@MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/id -u`
 if [ "$procowner" != "0" ]; then
        err 'you must be root (0) to use this utility.'
        exit 1