Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37401703
en ru br
Репозитории ALT
S:0.8.0-alt1
5.1: 0.7.4-alt1
4.1: 0.7.4-alt1
4.0: 0.7.4-alt1
+updates:0.7.4-alt1
3.0: 0.7.0-alt1
www.altlinux.org/Changes

Группа :: Система/Основа
Пакет: control

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

control-0.7.6/000075500000000000000000000000001156057037600132145ustar00rootroot00000000000000control-0.7.6/control000075500000000000000000000017531156057037600146300ustar00rootroot00000000000000#!/bin/sh

FACILITIES_DIR=/etc/control.d/facilities

fatal()
{
echo "${0##*/}: $*" >&2
exit 1
}

if [ $# -eq 0 ]; then
ls -1 $FACILITIES_DIR/ |
while read FACILITY; do
case "$FACILITY" in
*.rpm*|*.orig|*~) continue ;;
esac
LIST="`$FACILITIES_DIR/$FACILITY list`"
STATUS="`$FACILITIES_DIR/$FACILITY status`"
[ -n "${FACILITY##_*}" ] || FACILITY="${FACILITY//_//}"
printf "%-15s %-15s (%s)\n" "$FACILITY" "$STATUS" "$LIST"
done
exit
fi

FACILITY="$1"
shift

case "$FACILITY" in
--help)
a= exec man 8 control
exit
;;
--version)
echo @VERSION@
exit
;;
esac

REQUESTED_FACILITY="$FACILITY"
FACILITY="${FACILITY//\//_}"

if [ -x "$FACILITIES_DIR/$FACILITY" ]; then
$FACILITIES_DIR/$FACILITY "$*" || exit 1
case "$*" in
''|help|'help '*|list|status|summary)
exit 0
;;
esac
STATUS="`$FACILITIES_DIR/$FACILITY status`"
if [ "$STATUS" != "$*" ]; then
fatal "$REQUESTED_FACILITY: Requested $*, got $STATUS"
fi
exit 0
else
fatal "No such facility: $FACILITY"
fi
control-0.7.6/control-dump000064400000000000000000000003641156057037600155650ustar00rootroot00000000000000#!/bin/sh

STATUS_DIR=/var/run/control
umask 077
mkdir -p "$STATUS_DIR"

for FACILITY in "$@"; do
FACILITY="${FACILITY//\//_}"

FILE="$STATUS_DIR/$FACILITY"
rm -f "$FILE"
/usr/sbin/control "$FACILITY" status > "$FILE" || rm -f "$FILE"
done
control-0.7.6/control-dump.8000064400000000000000000000023231156057037600157300ustar00rootroot00000000000000.\"
.TH CONTROL-DUMP 8 "18 April 2003" "Openwall Project"
.ad l
.SH NAME
\fBcontrol-dump\fR, \fBcontrol-restore\fR \- dump or restore state of
installed system facilities
.SH SYNOPSIS
.ad b
.B control-dump
.RI [ FACILITY ...]
.br
.B control-restore
.RI [ FACILITY ...]
.SH DESCRIPTION
.B control-dump
and
.B control-restore
are intended to be used by package pre-install and post-install scripts,
respectively, to dump and restore state of system facilities provided by
those packages.
This allows to keep the desired state of installed system facilities over
package or OS upgrades.
.SH FILES
.ad l
.in +4
.ti -4
.IR /var/run/control/ *
\- shell pattern of saved status files created by
.BR control-dump ,
later used and removed by
.B control-restore
.br
.ti -4
.I /etc/control.d/facilities/
\- installed system facilities' control scripts to be invoked by
.BR control (8)
.br
.ti -4
.I /etc/control.d/functions
\- common shell functions used by the above scripts
.in -4
.ad b
.SH HISTORY
.B control-dump
and
.B control-restore
first appeared in ALT Linux Sisyphus and Openwall GNU/*/Linux 1.0.
.SH AUTHORS
Dmitry V. Levin <ldv@altlinux.org>
.br
Solar Designer <solar@owl.openwall.com>
.SH SEE ALSO
.BR chkconfig (8),
.BR control (8)
control-0.7.6/control-restore000064400000000000000000000007301156057037600163000ustar00rootroot00000000000000#!/bin/sh

STATUS_DIR=/var/run/control

for FACILITY in "$@"; do
FACILITY="${FACILITY//\//_}"

FILE="$STATUS_DIR/$FACILITY"
if [ -s "$FILE" ]; then
STATUS="`cat "$FILE"`"
if [ -n "$STATUS" -a "$STATUS" != unknown ]; then
/usr/sbin/control "$FACILITY" "$STATUS"
else
echo "${0##*/}: Status \"$STATUS\" for \"$FACILITY\" facility cannot be restored" >&2
fi
else
echo "${0##*/}: No status available for \"$FACILITY\" facility" >&2
fi
rm -f "$FILE"
done
control-0.7.6/control-restore.8000064400000000000000000000000301156057037600164370ustar00rootroot00000000000000.so man8/control-dump.8
control-0.7.6/control.8000064400000000000000000000024131156057037600147650ustar00rootroot00000000000000.\"
.TH CONTROL 8 "18 April 2003" "Openwall Project"
.SH NAME
\fBcontrol\fR \- control installed system facilities
.SH SYNOPSIS
.B control
[ \fIFACILITY\fR [\fBhelp\fR|\fBlist\fR|\fBstatus\fR|\fBsummary\fR|\fISTATUS\fR] ]
.SH DESCRIPTION
.B control
provides a common interface to register and control system facilities.
.PP
This is intended primarily for facilities that can potentially be
dangerous to system security, to let you enable, disable, or configure
the facility independently from package installation.
.PP
When run with no arguments,
.B control
lists all available facilities, their current status, and their
supported settings.
.PP
When a
.I FACILITY
name is specified,
.B control
may
print facility
.BR summary ,
.B list
its supported settings or print short
.B help
text for them,
report its current
.B status
(default action),
or switch it to a new
.IR STATUS .
.SH FILES
.ad l
.in +4
.ti -4
.I /etc/control.d/facilities/
\- installed system facilities' control scripts to be invoked by
.B control
.br
.ti -4
.I /etc/control.d/functions
\- common shell functions used by the above scripts
.in -4
.ad b
.SH HISTORY
.B control
first appeared in Openwall GNU/*/Linux 0.1.
.SH AUTHORS
Solar Designer <solar@owl.openwall.com>
.SH SEE ALSO
.BR chkconfig (8),
.BR control-dump (8)
control-0.7.6/control.macros000064400000000000000000000005641156057037600161070ustar00rootroot00000000000000# control(8) macros

%_controldir %_sysconfdir/control.d/facilities

# in %%pre section.
%pre_control() \
if [ $1 -ge 2 ]; then \
/usr/sbin/control-dump %* \
fi \
%nil

# in %%post section.
%post_control(s:) \
if [ $1 -ge 2 ]; then \
/usr/sbin/control-restore %* \
else \
for facility in %*; do \
/usr/sbin/control "$facility" %{-s*}%{!-s:public} \
done \
fi \
%nil
control-0.7.6/control.spec000064400000000000000000000125211156057037600155510ustar00rootroot00000000000000Name: control
Version: 0.7.6
Release: alt1

Summary: A set of scripts to control installed system facilities
License: GPL
Group: System/Base
BuildArch: noarch

Source: %name-%version.tar

# due to sed -i support
Requires: sed >= 1:4.1.1

%define _controldir %_sysconfdir/control.d/facilities

%description
The scripts included in this package provide a common interface to
control system facilities provided by a number of other packages.
This is intended for use primarily by packages which are providing
a facility that can potentially be dangerous to system security,
to let you enable, disable, or configure the facility independently
from package installation.

%prep
%setup

%build
sed -i s/@VERSION@/%version-%release/ control

%install
mkdir -p %buildroot{%_controldir,%_sbindir,%_man8dir,/var/run/control}
install -p -m755 control{,-dump,-restore} %buildroot%_sbindir/
install -p -m755 functions %buildroot%_sysconfdir/control.d/
install -p -m644 control{,-dump,-restore}.8 %buildroot%_man8dir/
install -pD -m644 control.macros %buildroot%_rpmmacrosdir/control

# Generate shell functions provides list.
(
echo '# shell functions provides list'
for f in %buildroot%_sysconfdir/control.d/*; do
[ -f "$f" -a -x "$f" ] || continue
sed -ne 's/^\([A-Za-z][A-Za-z_0-9]*[[:space:]]*\)()$/\1/pg' "$f"
done |LC_COLLATE=C sort -u
) >%buildroot%_controldir/.provides.sh

%files
%_sbindir/control*
%_rpmmacrosdir/control
%config %_sysconfdir/control.d
%attr(0700,root,root) %ghost /var/run/control/
%_man8dir/*

%changelog
* Thu May 05 2011 Dmitry V. Levin <ldv@altlinux.org> 0.7.6-alt1
- control_subst: changed to use "sed -i --follow-symlinks"
instead of plain "sed -i".
- /var/run/control/:
+ changed permissions from 0755 to 0700;
+ packaged as %%ghost;
+ control-dump: changed to create /var/run/control/ (closes: #25575).

* Mon Jun 28 2010 Dmitry V. Levin <ldv@altlinux.org> 0.7.5-alt1
- Added --help and --version options (closes: #16712).
- Optimized functions for speed (legion@).
- Changed code to use "sed -i" instead of "subst".
- Relocated control macro file from /etc/rpm/macros.d/ to
/usr/lib/rpm/macros.d/

* Tue Sep 18 2007 Dmitry V. Levin <ldv@altlinux.org> 0.7.4-alt1
- functions/stat_file: Speed up.

* Sun Apr 22 2007 Dmitry V. Levin <ldv@altlinux.org> 0.7.3-alt1
- control: Changed facility names filter to allow dots in facility
names and disallow rpmi and editor backup files (legion).

* Fri Apr 28 2006 Dmitry V. Levin <ldv@altlinux.org> 0.7.2-alt1
- functions/is_builtin_mode: handle "help *" and "summary".

* Thu Apr 27 2006 Dmitry V. Levin <ldv@altlinux.org> 0.7.1-alt1
- control: New builtin directive: summary.
- control.8: Document help and status directives.
- functions/{new_summary,control_summary}: New functions.
- functions/{control_fmode,control_subst}: Use control_summary.

* Fri May 27 2005 Dmitry V. Levin <ldv@altlinux.org> 0.7.0-alt1
- Optimized functions for speed.

* Thu Mar 31 2005 Dmitry V. Levin <ldv@altlinux.org> 0.6.2-alt1
- functions/new_subst:
+ extended to support several rules for each mode (legion).
- Do not add private functions to the .provides.sh file.

* Thu Nov 11 2004 Dmitry V. Levin <ldv@altlinux.org> 0.6.1.1-alt1
- functions/stat_file: fixed "find -maxdepth" warning.

* Sat Sep 25 2004 Dmitry V. Levin <ldv@altlinux.org> 0.6.1-alt1
- functions/{new_help,control_help}:
new functions for help support.
- functions/control_list:
new function for use by complex facilities.
- functions/control_fmode:
don't change files when the new setting is the same.
- Packaged %_sysconfdir/control.d/.provides.sh file.

* Wed Oct 29 2003 Dmitry V. Levin <ldv@altlinux.org> 0.6-alt2
- functions: use colon instead of dot as user/group name
separator with invocations of chown(1).
- Added rpm macros file (#2972).

* Sat Apr 19 2003 Dmitry V. Levin <ldv@altlinux.org> 0.6-alt1
- Synced with owl-control-0.6:
* Fri Apr 18 2003 Solar Designer <solar@owl.openwall.com> 0.6-owl1
- Avoid *roff commands within .SH NAME to not confuse makewhatis
and apropos(1).

* Sat Apr 12 2003 Dmitry V. Levin <ldv@altlinux.org> 0.5.2-alt1
- control-restore: be more verbose.

* Sun Jan 19 2003 Dmitry V. Levin <ldv@altlinux.org> 0.5.1-alt1
- Refined output for facilities with slashes.

* Wed Jan 08 2003 Dmitry V. Levin <ldv@altlinux.org> 0.5-alt1
- Synced with owl-control-0.5:
* Wed Jan 08 2003 Solar Designer <solar@owl.openwall.com>
- Wrote control(8) and control-dump(8) manual pages.

* Sun Nov 03 2002 Dmitry V. Levin <ldv@altlinux.org> 0.4-alt1
- Synced with owl-control-0.4, including:
+ minor syntax fixes in control, control-dump and control-restore;
+ in control_subst(), don't rewrite files when the new setting is the same.

* Sat Oct 12 2002 Dmitry V. Levin <ldv@altlinux.org> 0.3.1-alt1
- ALT adaptions.
- Added control-dump and control-restore utilities.

* Sun Jul 07 2002 Solar Designer <solar@owl.openwall.com>
- Use grep -q in the provided shell functions.

* Wed Feb 06 2002 Michail Litvak <mci@owl.openwall.com>
- Enforce our new spec file conventions.

* Wed Nov 22 2000 Solar Designer <solar@owl.openwall.com>
- Support extended regexp's in control_subst().

* Fri Aug 11 2000 Solar Designer <solar@owl.openwall.com>
- Various important changes to the provided shell functions.
- Wrote the package description.
- Moved the symlink: /sbin/control is now /usr/sbin/control.

* Thu Aug 10 2000 Solar Designer <solar@owl.openwall.com>
- Initial version.
control-0.7.6/functions000064400000000000000000000072431156057037600151550ustar00rootroot00000000000000#!/bin/sh

echo_error() # private
{
printf %s\\n "${0##*/}: $*" >&2
}

array_count() # private
{
local name="$1"
eval set -- "\$$2"
eval "$name=$#"
}

define() # private
{
eval "$1_$2=\"\$3\""
}

define_array() # private
{
array_count n "ARRAY_$1_$2"
eval "$1_$2_$n=\"\$3\"; ARRAY_$1_$2=\"\$ARRAY_$1_$2 $1_$2_$n\""
}

lookup() # private
{
eval "$1=\"\$$2_$3\""
}

lookup_array() # private
{
eval "$1=\"\$ARRAY_$2_$3\""
}

validate() # private
{
printf %s "$1" | grep -q '^[a-z0-9_]*$'
}

NAME_LIST=
register() # private
{
eval "test -z \"\$REGISTERED_$1\"" || return
define REGISTERED "$1" yes
[ -z "$NAME_LIST" ] && NAME_LIST="$1" || NAME_LIST="$NAME_LIST $1"
}

new_fmode()
{
register "$1"
define NAME_TO_FMODE "$1" "$2"
define NAME_TO_OWNER "$1" "$3:$4"
define FMODE_OWNER_TO_NAME "$2_$3_$4" "$1"
}

new_subst()
{
register "$1"
define_array NAME_TO_REGEX "$1" "$2"
define_array NAME_TO_SUBST "$1" "$3"
}

new_help()
{
register "$1"
define HELP_TO "$1" "$2"
}

new_summary()
{
local arg="$1"
if [ -z "${arg##*
*}" ]; then
arg="$(printf %s "$arg" |tr -s '[:space:]' ' ')"
fi
define SUMMARY FOR "$arg"
}

stat_file() # private
{
local PATHNAME="$1"
[ -z "${PATHNAME##/*}" ] || return 1
find "$PATHNAME" -maxdepth 0 -path "$PATHNAME" -printf '%m_%u_%g'
}

control_list()
{
printf %s\\n "$NAME_LIST"
}

control_help()
{
local NAME VALUE SEARCH_LIST

if [ -n "$1" ]; then
SEARCH_LIST="$*"
else
SEARCH_LIST="$NAME_LIST"
fi

for NAME in $SEARCH_LIST; do
printf %s "$NAME: "
lookup VALUE HELP_TO "$NAME"
printf %s\\n "$VALUE"
done
}

control_fmode_status() # private
{
local FILE="$1" STAT NAME=

STAT="$(stat_file "$FILE")"
if validate "$STAT"; then
lookup NAME FMODE_OWNER_TO_NAME "$STAT"
fi
if [ -n "$NAME" ]; then
printf %s\\n "$NAME"
else
echo "unknown"
fi
}

control_fmode()
{
local FILE="$1" REQUEST="$2" FMODE= OWNER=

case "$REQUEST" in
help|'help '*)
control_help "${REQUEST#help}"
;;
list)
control_list
;;
status)
control_fmode_status "$FILE"
;;
summary)
control_summary
;;
*)
if validate "$REQUEST"; then
lookup FMODE NAME_TO_FMODE "$REQUEST"
lookup OWNER NAME_TO_OWNER "$REQUEST"
fi
if [ -z "$FMODE" -o -z "$OWNER" ]; then
echo_error "Invalid mode: $REQUEST"
return 1
fi
if [ "$(control_fmode_status "$FILE")" = "$REQUEST" ]; then
return
fi
chown "$OWNER" "$FILE" && chmod "$FMODE" "$FILE" || return 1
;;
esac
}

control_subst_status() # private
{
local FILE="$1" ARRAY ELEM FOUND NAME REGEX

for NAME in $NAME_LIST; do
FOUND=
lookup_array ARRAY NAME_TO_REGEX "$NAME"
for ELEM in $ARRAY; do
eval "REGEX=\"\$$ELEM\""
[ -n "$REGEX" ] || continue
grep -Eq "$REGEX" "$FILE" &&
FOUND=1 ||
{ FOUND=; break; }
done
if [ -n "$FOUND" ]; then
printf %s\\n "$NAME"
return
fi
done
echo "unknown"
}

control_subst()
{
local FILE="$1" REQUEST="$2" ARRAY= ELEM SUBST=

case "$REQUEST" in
help|'help '*)
control_help "${REQUEST#help}"
;;
list)
control_list
;;
status)
control_subst_status "$FILE"
;;
summary)
control_summary
;;
*)
if validate "$REQUEST"; then
lookup_array ARRAY NAME_TO_SUBST "$REQUEST"
fi
if [ -z "$ARRAY" ]; then
echo_error "Invalid mode: $REQUEST"
return 1
fi
for ELEM in $ARRAY; do
eval "SUBST=\"\$$ELEM\""
if [ -z "$SUBST" ]; then
echo_error "Invalid mode: $REQUEST"
return 1
fi
[ "$(control_subst_status "$FILE")" != "$REQUEST" ] || continue
sed -i --follow-symlinks -e "$SUBST" -- "$FILE" || return 1
done
;;
esac
}

control_summary()
{
printf %s\\n "$SUMMARY_FOR"
}

is_builtin_mode()
{
case "$1" in
''|help|'help '*|list|status|summary)
return 0
;;
esac
return 1
}

[ -n "$*" ] || set - status
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin