Репозиторий Sisyphus
Последнее обновление: 12 августа 2022 | Пакетов: 17595 | Посещений: 24760768
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.4/000075500000000000000000000000001067371103500132035ustar00rootroot00000000000000control-0.7.4/control000075500000000000000000000015761067371103500146220ustar00rootroot00000000000000#!/bin/sh

FACILITIES_DIR=/etc/control.d/facilities

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

if [ $# -ge 1 ]; then
FACILITY="$1"
shift

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
fi

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
control-0.7.4/control-dump000064400000000000000000000003231067371103500155470ustar00rootroot00000000000000#!/bin/sh

STATUS_DIR=/var/run/control

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.4/control-dump.8000064400000000000000000000023231067371103500157170ustar00rootroot00000000000000.\"
.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.4/control-restore000064400000000000000000000007301067371103500162670ustar00rootroot00000000000000#!/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.4/control-restore.8000064400000000000000000000000301067371103500164260ustar00rootroot00000000000000.so man8/control-dump.8
control-0.7.4/control.8000064400000000000000000000024131067371103500147540ustar00rootroot00000000000000.\"
.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.4/control.macros000064400000000000000000000005641067371103500160760ustar00rootroot00000000000000# 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.4/control.spec000064400000000000000000000113431067371103500155410ustar00rootroot00000000000000Name: control
Version: 0.7.4
Release: alt1

Summary: A set of scripts to control installed system facilities
License: GPL
Group: System/Base
BuildArch: noarch
Packager: Dmitry V. Levin <ldv@altlinux.org>

Source: %name-%version.tar

Requires: %__subst

%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 -q

%install
mkdir -p %buildroot{%_controldir,%_sbindir,%_man8dir}
install -p -m755 control{,-dump,-restore} %buildroot%_sbindir/
install -p -m755 functions %buildroot%_sysconfdir/control.d/
mkdir -p -m700 %buildroot/var/run/control
install -p -m644 control{,-dump,-restore}.8 %buildroot%_man8dir/
install -pD -m644 control.macros %buildroot%_sysconfdir/rpm/macros.d/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
%config %_sysconfdir/rpm/macros.d/control
%_sbindir/control*
%config %_sysconfdir/control.d
/var/run/control
%_man8dir/*

%changelog
* 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.4/functions000064400000000000000000000075541067371103500151510ustar00rootroot00000000000000#!/bin/sh

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

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

define() # private
{
local arg="$3"
if [ -z "${arg##*[\"\$\`\\]*}" ]; then
arg=$(printf %s "$arg" | sed -e 's/["$`\]/\\&/g')
fi
eval "$1_$2=\"$arg\""
}

define_array() # private
{
local arg="$3"
if [ -z "${arg##*[\"\$\`\\]*}" ]; then
arg=$(printf %s "$arg" | sed -e 's/["$`\]/\\&/g')
fi
array_count n "ARRAY_$1_$2"
eval "$1_$2_$n=\"$arg\"; 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
subst "$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