1# $NetBSD: Makefile,v 1.12 2009/04/22 15:23:09 lukem Exp $ 2# 3 4WARNS?= 1 # XXX: -Wsign-compare -Wcast-qual 5 6.include <bsd.own.mk> 7 8CPPFLAGS+= -DEXTENSIONS -DPW_MKDB_ARGC=2 9 10PROG= user 11SRCS+= user.c main.c 12LINKS+= ${BINDIR}/user ${BINDIR}/useradd 13LINKS+= ${BINDIR}/user ${BINDIR}/userdel 14LINKS+= ${BINDIR}/user ${BINDIR}/usermod 15LINKS+= ${BINDIR}/user ${BINDIR}/group 16LINKS+= ${BINDIR}/user ${BINDIR}/groupadd 17LINKS+= ${BINDIR}/user ${BINDIR}/groupdel 18LINKS+= ${BINDIR}/user ${BINDIR}/groupmod 19LINKS+= ${BINDIR}/user ${BINDIR}/userinfo 20LINKS+= ${BINDIR}/user ${BINDIR}/groupinfo 21LDADD+= -lutil 22DPADD+= ${LIBUTIL} 23MAN= user.8 useradd.8 userdel.8 usermod.8 userinfo.8 usermgmt.conf.5 24MAN+= group.8 groupadd.8 groupdel.8 groupmod.8 groupinfo.8 25MLINKS= useradd.8 adduser.8 26 27# this target checks the built-in default group, and, if it doesn't exist, 28# creates it 29default-group: 30 @ln -fs ${.OBJDIR}/user ${.OBJDIR}/group; \ 31 defgrp=`${.OBJDIR}/user add -D | \ 32 ${TOOL_AWK} '/^group/ { print $$2 }'`; \ 33 if ${.OBJDIR}/group info -e $$defgrp; then \ 34 defgid=`${.OBJDIR}/group info $$defgrp | \ 35 ${TOOL_AWK} '/^gid/ { print $$2 }'`; \ 36 else \ 37 defgid=99; \ 38 while [ $$defgid -gt 0 ]; do \ 39 ${.OBJDIR}/group info -e $$defgid || break; \ 40 defgid=`expr $$defgid - 1`; \ 41 done; \ 42 if [ $$defgid -eq 0 ]; then \ 43 defgid=100; \ 44 while [ $$defgid -lt 60000 ]; do \ 45 ${.OBJDIR}/group info -e $$defgid || break; \ 46 defgid=`expr $$defgid + 1`; \ 47 done; \ 48 if [ $$defgid -eq 60000 ]; then \ 49 echo "No gids left"; \ 50 exit 1; \ 51 fi; \ 52 fi; \ 53 ${.OBJDIR}/group add -g $$defgid $$defgrp; \ 54 fi; \ 55 echo "Default group is $$defgrp ($$defgid):"; \ 56 ${.OBJDIR}/group info $$defgrp 57 58.include <bsd.prog.mk> 59 60test: ${PROG} 61 @echo "No news is good news" 62 @echo "1. Adding new user" 63 @rm -f useradd 64 @ln -s user useradd 65 -./useradd -m -g=uid test1.1 66 @echo "2. Modifying new user" 67 -./${PROG} mod -l test1.2 test1.1 68 @echo "3. Deleting new user" 69 -./${PROG} del -r test1.2 70 @echo "4. Attempting to add an invalid user name - IGNORE ANY ERROR" 71 -./${PROG} add -m test1%1 72 @echo "5. Bad usage - IGNORE ANY ERROR" 73 -./${PROG} add -m 74 @echo "6. Set range defaults" 75 -./${PROG} add -D -r4000..6000 76 -./${PROG} add -D 77 @echo "7. Get user information" 78 -./${PROG} info root 79 @echo "8. Bad user name - IGNORE ANY ERROR" 80 -./${PROG} info test1%1 || echo "User not found" 81 @echo "All tests completed" 82