head	1.4;
access;
symbols
	RELEASE_6_0_0:1.3
	RELEASE_5_4_0:1.3
	RELEASE_4_11_0:1.3
	RELEASE_5_3_0:1.3
	RELEASE_4_10_0:1.3
	RELEASE_5_2_1:1.3
	RELEASE_5_2_0:1.3
	RELEASE_4_9_0:1.3;
locks; strict;
comment	@# @;


1.4
date	2005.09.14.23.14.39;	author pav;	state dead;
branches;
next	1.3;

1.3
date	2003.06.26.18.04.43;	author foxfair;	state Exp;
branches;
next	1.2;

1.2
date	2003.06.26.16.20.12;	author foxfair;	state Exp;
branches;
next	1.1;

1.1
date	2003.06.13.01.09.29;	author foxfair;	state Exp;
branches;
next	;


desc
@@


1.4
log
@- Remove security/pf and security/authpf ports. They were only useful on
  FreeBSD 5.0 - 5.2.1.

Requested by:	mlaier (maintainer) via linimon
@
text
@#!/bin/sh
# an installation script for pf_freebsd copied from Wnn6

check_pw()
{
    if which -s pw; then
	:
    else
	cat <<EOF

This system looks like a pre-2.2 version of FreeBSD.  We see that it
is missing the "pw" utility.  We need this utility.  Please get and
install it, and try again.  You can get the source from:

  ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz

EOF
	exit 1
    fi
}

ask() {
    local question default answer

    question=$1
    default=$2
    if [ -z "${PACKAGE_BUILDING}" ]; then
	read -p "${question} (y/n) [${default}]? " answer
    fi
    if [ x${answer} = x ]; then
	answer=${default}
    fi
    echo ${answer}
}

yesno() {
    local dflt question answer

    question=$1
    dflt=$2
    while :; do
	answer=$(ask "${question}" "${dflt}")
	case "${answer}" in
	[Yy]*)		return 0;;
	[Nn]*)		return 1;;
	esac
	echo "Please answer yes or no."
    done
}

check_service() {
    local name number type comment
    
    name=$1
    number=$2
    type=$3
    comment=$4
    
    FILE="/etc/services"
    # check
    OK=no
    HAS_SERVICE=no
    COUNT=1
    for i in `grep $name $FILE `; do
	if [ $COUNT = 1 ] && [ X"$i" = X"$name" ]; then
	    HAS_SERVICE=yes
	elif [ $COUNT = 2 ] && [ $HAS_SERVICE = yes ] && \
		[ X"$i" = X"$number/$type" ]; then
	    OK=yes
	    break
	fi
	COUNT=`expr ${COUNT} + 1`
    done
    # add an entry for SERVICE to /etc/services
    if [ $OK = no ]; then
	echo "This system has no entry for $name in ${FILE}"
	if yesno "Would you like to add it automatically?" y; then
	    mv ${FILE} ${FILE}.bak
	    (grep -v $name ${FILE}.bak ; \
		echo "$name	$number/$type	# $comment") \
		>> ${FILE}
	    rm ${FILE}.bak
	else
	    echo "Please add '$name $number/$type' into ${FILE}, and try again."
	    return 1
	fi
    fi
    return 0
}

check_group() {
    local name id

    name=$1
    id=$2
    #check
    # We need a command 'pw(8)'
    check_pw
    if pw groupshow $name -q ; then
	return 0
    fi
    if pw groupadd -g $id -n $name -N -q ; then 
    	echo ""
    	echo "You need a group '$name' whose ID number is $id"
    	if yesno "Would you like to create it automatically?" y; then
	    pw groupadd -g $id -n $name
	    return 0
	fi
    fi
    echo ""
    echo "I was not able to add group 'proxy:*:62:' as pw reported:"
    pw groupadd -g $id -n $name -N
    echo "Please correct this and try again!"
    echo ""
    return 1
}

check_user() {
    local name id group

    name=$1
    id=$2
    group=$3
    # check
    id_id=`id -u $id 2> /dev/null`
    id_name=`id -u $name 2> /dev/null`
    if [ X"$id_name" = X$id ];then
	return 0
    elif [ X"$id_id" != X ]; then
cat <<EOF

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This system already has an account whose name is not '$name' and ID
number is $id.

   '`id $id`'

For ftp-proxy in this port or package, ID number of '$name' has to be $id.
Please try again after you delete the account.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
	exit 1
    elif [ X"$id_name" != X ]; then
	cat <<EOF

There is a user '$name' with ID '$id_name'. I'll try to use this account.

EOF
	return 0
    fi

    # add an account '$name' to this system
    echo ""
    echo "You need an account '$name' whose ID number is $id"
    if yesno "Would you like to create it automatically?" y; then
	# We need a command 'pw(8)'
	check_pw
	pw useradd $name -u $id -g $group -h - -d /nonexistent \
		-s /nonexistent -c "Packet Filter pseudo-user" || exit
    else
	echo "Please create it, and try again."
	return 1
    fi
    return 0
}

case $2 in
PRE-INSTALL)

    if ! check_service ftp-proxy 8021 tcp "# ftp-proxy service port"; then
	exit 1
    fi
    if [ "`grep ftp-proxy /etc/inetd.conf`" ]; then
 	echo "Found ftp-proxy entry in inetd.conf ..."
    else
	echo "Adding sample entry for ftp-proxy to /etc/inetd.conf"
	echo "#ftp-proxy stream tcp nowait root ${PKG_PREFIX}/libexec/ftp-proxy ftp-proxy" >> /etc/inetd.conf
    fi
    if ! check_group proxy 62 ; then 
	exit 1
    fi
    groupid=`pw groupshow proxy | awk \
		'{ split ($1,var,":"); print var[3] }' `
    if ! check_user proxy 62 $groupid; then
	exit 1
    fi
    ;;

esac
@


1.3
log
@Use a better comment in system passwd file when we create the user 'proxy'
at first time. No necessary to bump PRTREVISION so only force commit in
Makefile.
@
text
@@


1.2
log
@Approved by:	maintainer
Reformat pkg-install & pkg-message, and add 64-bit platform fix.
Note: pf now register its user as proxy:proxy which uid/gid is 62:62.
@
text
@d159 1
a159 1
		-s /nonexistent -c $name || exit
@


1.1
log
@Add pf 1.0, OpenBSD's pf (packetfilter) as in OpenBSD 3.3 as a loadable
kernel module.

PR:		52121
Submitted by:	Max Laier <max@@love2party.net>
@
text
@d111 1
a111 1
    echo "I was not able to add group 'proxy:*:71:' as pw reported:"
d179 1
a179 1
    if ! check_group proxy 71 ; then 
d184 1
a184 1
    if ! check_user proxy 71 $groupid; then
@

