187416Sdes#!/usr/bin/perl -w 287416Sdes#- 389289Sdes# Copyright (c) 2001,2002 Networks Associates Technologies, Inc. 487416Sdes# All rights reserved. 587416Sdes# 687416Sdes# This software was developed for the FreeBSD Project by ThinkSec AS and 787416Sdes# NAI Labs, the Security Research Division of Network Associates, Inc. 887416Sdes# under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 987416Sdes# DARPA CHATS research program. 1087416Sdes# 1187416Sdes# Redistribution and use in source and binary forms, with or without 1287416Sdes# modification, are permitted provided that the following conditions 1387416Sdes# are met: 1487416Sdes# 1. Redistributions of source code must retain the above copyright 1587416Sdes# notice, this list of conditions and the following disclaimer. 1687416Sdes# 2. Redistributions in binary form must reproduce the above copyright 1787416Sdes# notice, this list of conditions and the following disclaimer in the 1887416Sdes# documentation and/or other materials provided with the distribution. 1987416Sdes# 3. The name of the author may not be used to endorse or promote 2087416Sdes# products derived from this software without specific prior written 2187416Sdes# permission. 2287416Sdes# 2387416Sdes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2487416Sdes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2587416Sdes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2687416Sdes# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2787416Sdes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2887416Sdes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2987416Sdes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3087416Sdes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3187416Sdes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3287416Sdes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3387416Sdes# SUCH DAMAGE. 3487416Sdes# 3587416Sdes# $FreeBSD$ 3687416Sdes# 3787416Sdes 3887416Sdesuse strict; 3987416Sdesuse Fcntl; 4087416Sdesuse vars qw(%SERVICES); 4187416Sdes 4287416SdesMAIN:{ 4387423Sdes my $line; 4487416Sdes my $service; 4589285Sdes my $version; 4687416Sdes my $type; 4787416Sdes local *FILE; 48130151Sschweikh 4987416Sdes while (<>) { 5087416Sdes chomp(); 5187416Sdes s/\s*$//; 5287423Sdes next unless m/^(\#*)(\w+)\s+(auth|account|session|password)\s+(\S.*)$/; 5387423Sdes $line = $1.$3; 5487423Sdes $line .= "\t" x ((16 - length($line) + 7) / 8); 5587423Sdes $line .= $4; 5687423Sdes push(@{$SERVICES{$2}->{$3}}, $line); 5787416Sdes } 5887416Sdes 5987416Sdes foreach $service (keys(%SERVICES)) { 6089298Sdes $version = '$' . 'FreeBSD' . '$'; 6189285Sdes if (sysopen(FILE, $service, O_RDONLY)) { 6289285Sdes while (<FILE>) { 6389298Sdes next unless (m/(\$[F]reeBSD.*?\$)/); 6489285Sdes $version = $1; 6589285Sdes last; 6689285Sdes } 6789285Sdes close(FILE); 6889285Sdes } 6987416Sdes sysopen(FILE, $service, O_RDWR|O_CREAT|O_TRUNC) 7087416Sdes or die("$service: $!\n"); 7187416Sdes print(FILE "#\n"); 7289285Sdes print(FILE "# $version\n"); 7387416Sdes print(FILE "#\n"); 7487416Sdes print(FILE "# PAM configuration for the \"$service\" service\n"); 7587416Sdes print(FILE "#\n"); 7687416Sdes foreach $type (qw(auth account session password)) { 7787416Sdes next unless exists($SERVICES{$service}->{$type}); 7887416Sdes print(FILE "\n"); 7987416Sdes print(FILE "# $type\n"); 8087416Sdes print(FILE join("\n", @{$SERVICES{$service}->{$type}}, "")); 8187416Sdes } 8287416Sdes close(FILE); 8387416Sdes warn("$service\n"); 8487416Sdes } 85130151Sschweikh 8687416Sdes exit(0); 8787416Sdes} 88