convert.pl revision 87423
187416Sdes#!/usr/bin/perl -w 287416Sdes#- 387416Sdes# Copyright (c) 2001 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: head/etc/pam.d/convert.pl 87423 2001-12-05 21:26:00Z des $ 3687416Sdes# 3787416Sdes 3887416Sdesuse strict; 3987416Sdesuse Fcntl; 4087416Sdesuse vars qw(%SERVICES); 4187416Sdes 4287416SdesMAIN:{ 4387423Sdes my $line; 4487416Sdes my $service; 4587416Sdes my $type; 4687416Sdes local *FILE; 4787416Sdes 4887416Sdes while (<>) { 4987416Sdes chomp(); 5087416Sdes s/\s*$//; 5187423Sdes next unless m/^(\#*)(\w+)\s+(auth|account|session|password)\s+(\S.*)$/; 5287423Sdes $line = $1.$3; 5387423Sdes $line .= "\t" x ((16 - length($line) + 7) / 8); 5487423Sdes $line .= $4; 5587423Sdes push(@{$SERVICES{$2}->{$3}}, $line); 5687416Sdes } 5787416Sdes 5887416Sdes foreach $service (keys(%SERVICES)) { 5987416Sdes sysopen(FILE, $service, O_RDWR|O_CREAT|O_TRUNC) 6087416Sdes or die("$service: $!\n"); 6187416Sdes print(FILE "#\n"); 6287416Sdes print(FILE "# \$FreeBSD\$\n"); 6387416Sdes print(FILE "#\n"); 6487416Sdes print(FILE "# PAM configuration for the \"$service\" service\n"); 6587416Sdes print(FILE "#\n"); 6687416Sdes foreach $type (qw(auth account session password)) { 6787416Sdes next unless exists($SERVICES{$service}->{$type}); 6887416Sdes print(FILE "\n"); 6987416Sdes print(FILE "# $type\n"); 7087416Sdes print(FILE join("\n", @{$SERVICES{$service}->{$type}}, "")); 7187416Sdes } 7287416Sdes close(FILE); 7387416Sdes warn("$service\n"); 7487416Sdes } 7587416Sdes 7687416Sdes exit(0); 7787416Sdes} 78