Added Cyg-Win

This commit is contained in:
Frank Harris 2026-06-06 18:46:40 -04:00
parent 82cbc206eb
commit 413c315806
10586 changed files with 3806249 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,122 @@
#!/bin/sh
# Add a new .gnupg home directory for a list of users -*- sh -*-
#
# Copyright 2004 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PGM=addgnupghome
any_error=0
error () {
echo "$PGM: $*" >&2
any_error=1
}
info () {
echo "$PGM: $*" >&2
}
# Do it for one user
one_user () {
user="$1"
home=$(${cat_passwd} | awk -F: -v n="$user" '$1 == n {print $6}')
if [ -z "$home" ]; then
if ${cat_passwd} | awk -F: -v n="$user" '$1 == n {exit 1}'; then
error "no such user \`$user'"
else
error "no home directory for user \`$user'"
fi
return
fi
if [ ! -d "$home" ]; then
error "home directory \`$home' of user \`$user' does not exist"
return
fi
if [ -d "$home/.gnupg" ]; then
info "skipping user \`$user': \`.gnupg' already exists"
return
fi
info "creating home directory \`$home/.gnupg' for \`$user'"
if ! mkdir "$home/.gnupg" ; then
error "error creating \`$home/.gnupg'"
return
fi
if ! chown $user "$home/.gnupg" ; then
error "error changing ownership of \`$home/.gnupg'"
return
fi
group=$(id -g "$user")
[ -z "$group" ] && group="0"
if [ "$group" -gt 0 ]; then
if ! chgrp $group "$home/.gnupg" ; then
error "error changing group of \`$home/.gnupg'"
return
fi
fi
if ! cd "$home/.gnupg" ; then
error "error cd-ing to \`$home/.gnupg'"
return
fi
for f in $filelist; do
if [ -d /etc/skel/.gnupg/$f ]; then
mkdir $f
else
cp /etc/skel/.gnupg/$f $f
fi
if ! chown $user $f ; then
error "error changing ownership of \`$f'"
return
fi
if [ "$group" -gt 0 ]; then
if ! chgrp $group "$f" ; then
error "error changing group of \`$f'"
return
fi
fi
done
}
if [ -z "$1" ]; then
echo "usage: $PGM userids"
exit 1
fi
# Check whether we can use getent
if getent --help </dev/null >/dev/null 2>&1 ; then
cat_passwd='getent passwd'
else
cat_passwd='cat /etc/passwd'
info "please note that only users from /etc/passwd are checked"
fi
if [ ! -d /etc/skel/.gnupg ]; then
error "skeleton directory \`/etc/skel/.gnupg' does not exist"
exit 1
fi
cd "/etc/skel/.gnupg" || (error "error cd-ing to \`/etc/skel/.gnupg'"; exit 1)
filelist=$(find . \( -type f -o -type d \) '!' -name '*~' '!' -name . -print)
if ! umask 0077 ; then
error "error setting umask"
exit 1
fi
for name in $*; do
one_user $name
done
exit $any_error

Binary file not shown.

View file

@ -0,0 +1,81 @@
#!/bin/sh
# Apply defaults from /etc/gnupg/gpgconf.conf to all users -*- sh -*-
#
# Copyright 2007 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PGM=applygnupgdefaults
errorfile=
error () {
echo "$PGM: $*" >&2
[ -n "$errorfile" ] && echo "$PGM: $*" >>$errorfile
}
info () {
echo "$PGM: $*" >&2
}
if [ -n "$1" ]; then
echo "usage: $PGM" >&2
exit 1
fi
# Cleanup on exit
cleanup ()
{
[ -n "$errorfile" ] && [ -f "$errorfile" ] && rm "$errorfile"
}
trap cleanup EXIT SIGINT SIGHUP SIGPIPE
errorfile=$(mktemp "/tmp/$PGM.log.XXXXXX")
{ [ -n "$errorfile" ] && [ -f "$errorfile" ]; } || exit 2
# Check whether we can use getent
if getent --help </dev/null >/dev/null 2>&1 ; then
cat_passwd='getent passwd'
else
cat_passwd='cat /etc/passwd'
info "please note that only users from /etc/passwd are processed"
fi
if [ ! -f /etc/gnupg/gpgconf.conf ]; then
error "global configuration file \`/etc/gnupg/gpgconf.conf' does not exist"
exit 1
fi
if [ ! -f /etc/shells ]; then
error "missing file \`/etc/shells'"
exit 1
fi
if [ $(id -u) -ne 0 ]; then
error "needs to be run as root"
exit 1
fi
${cat_passwd} \
| while IFS=: read -r user dmy_a uid dmy_c dmy_d home shell dmy_rest; do
# Process only entries with a valid login shell
grep </etc/shells "^$shell" 2>/dev/null >/dev/null || continue
# and with an pre-existing gnupg home directory
[ -d "$home/.gnupg" ] || continue
# but not root
[ "${uid:-0}" -eq 0 ] && continue
info "running \"gpgconf --apply-defaults\" for $user"
if su -l -s /bin/sh \
-c 'gpgconf --apply-defaults && echo SUCCESS' $user \
| tail -1 | grep ^SUCCESS >/dev/null ; then
:
else
error "failed to update gnupg defaults for $user"
fi
done
[ "$(wc -c <$errorfile)" -gt 0 ] && exit 1
exit 0

View file

@ -0,0 +1,257 @@
#! /bin/sh
# Make backups.
# Copyright 2004-2006, 2013, 2019 Free Software Foundation
# This file is part of GNU tar.
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Load library routines
SYSCONFDIR=${SYSCONFDIR-/etc}
. ${LIBDIR-/usr/libexec}/backup.sh
DUMP_LEVEL=0
TIME=
NOW=`now`
usage() {
cat - <<EOF
usage: $PROGNAME [OPTIONS] [WHEN]
Options are:
-l, --level=LEVEL Do backup level LEVEL (default $DUMP_LEVEL).
-f, --force Force backup even if today's log file already
exists.
-v, --verbose[=LEVEL] Set verbosity level. Default 100.
-t, --time=TIME Wait till TIME, then do backup.
Informational options:
-h, --help Display this help message.
-V, --version Display program version.
Optional argument WHEN is for backward compatibility only. It has been
superseded by --time option.
TIME argument can be one of:
now -- do backup immediately.
HH -- do backup at HH hours.
HH:MM -- do backup at HH:MM.
Send bug reports to bug-tar@gnu.org.
EOF
}
# For compatibility with previous versions, deduce the backup level
# from the command name
case "$PROGNAME" in
level-[0-9]) DUMP_LEVEL=`expr $PROGNAME : 'level-\([0-9][0-9]*\)'`;;
esac
for opt
do
if [ -z "$prev" ]; then
option=$opt
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
else
option="${prev}=$opt"
prev=""
optarg=$opt
fi
case $option in
--l=*|--le=*|--lev=*|--leve=*|--level=*)
DUMP_LEVEL=$optarg
;;
-l?*) DUMP_LEVEL=`expr $option : '-l\(.*\)'`;;
-l|--l|--le|--lev|--leve|--level)
prev=--level
;;
--verb=*|--verbo=*|--verbos=*|--verbose=*)
VERBOSE=$optarg
;;
-v|--verb|--verbo|--verbos|--verbose)
VERBOSE=100
;;
-v*) VERBOSE=`expr $option : '-v\(.*\)'`;;
--t=*|--ti=*|--tim=*|--time=*)
TIME=$optarg
;;
-t?*) TIME=`expr $option : '-t\(.*\)'`;;
-t|--t|--ti|--tim|--time)
prev=--time
;;
-V|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "backup (GNU tar) 1.35"
license
exit;;
-h|--h|--he|--hel|--help)
usage
exit;;
-f|--f|--fo|--for|--forc|--force)
FORCE=yes
;;
*) if [ "x$TIME" != "x" ]; then
bailout "Extra argument. Try $PROGNAME --help for more info."
else
TIME=$option
fi;;
esac
done
if [ "x$TIME" = x ]; then
bailout "No backup time specified. Try $PROGNAME --help for more info."
exit 1
fi
init_backup
# Maybe sleep until around specified or default hour.
wait_time $TIME
if [ $DUMP_LEVEL -ne 0 ]; then
PREV_LEVEL=`expr $DUMP_LEVEL - 1`
PREV_DATE=`ls -t ${LOGPATH}/log-*-level-$PREV_LEVEL|
head -n 1|
sed "s,${LOGPATH}/log-\(.*\)-level.*,\1,"`
if [ "x$PREV_DATE" = x ]; then
bailout "Can't determine date of the previous backup"
fi
message 0 "Backup from $PREV_DATE to $NOW"
fi
# start doing things
# Make sure the log file did not already exist. Create it.
if [ "x$FORCE" = "xyes" ]; then
rm ${LOGFILE}
fi
if [ -f "${LOGFILE}" ] ; then
bailout "Log file ${LOGFILE} already exists."
else
touch "${LOGFILE}"
fi
message 1 "Ready for backup."
message 10 "TAR invocation: $TAR_PART1"
message 20 "Variables:"
message 20 "BACKUP_DIRS=$BACKUP_DIRS"
message 20 "BACKUP_FILES=$BACKUP_FILES"
# The bunch of commands below is run in a subshell for which all output is
# piped through 'tee' to the logfile. Doing this, instead of having
# multiple pipelines all over the place, is cleaner and allows access to
# the exit value from various commands more easily.
(
message 1 "preparing tapes"
if ! $MT_BEGIN "${TAPE_FILE}"; then
echo >&2 "$0: tape initialization failed"
exit 1
fi
rm -f "${VOLNO_FILE}"
message 1 "processing backup directories"
set - ${BACKUP_DIRS}
while [ $# -ne 0 ] ; do
date="`date`"
fs="`echo \"${1}\" | sed -e 's/^.*://'`"
fs=`root_fs $fs`
fsname="`echo \"${1}\" | sed -e 's/\//:/g'`"
remotehost="`expr \"${1}\" : '\([^/][^/]*\):.*'`"
if [ -z "$remotehost" ]; then
remotehost=$localhost
fi
echo "Backing up ${1} at ${date}"
message 10 "fs=$fs"
message 10 "fsname=$fsname"
message 10 "remotehost=$remotehost"
if [ $DUMP_LEVEL -eq 0 ]; then
make_level_log ${remotehost}
else
echo "Last `prev_level` dump on this filesystem was on $PREV_DATE"
remote_run "${remotehost}" cp "`level_log_name ${fsname} $PREV_LEVEL`" "`level_log_name temp`"
fi
${DUMP_BEGIN-:} $DUMP_LEVEL $remotehost $fs $fsname
backup_host ${remotehost} \
"--listed=`level_log_name temp`" \
"--label='`print_level` backup of ${fs} on ${remotehost} at ${NOW}'" \
-C ${fs} .
# 'rsh' doesn't exit with the exit status of the remote command. What
# stupid lossage. TODO: think of a reliable workaround.
if [ $? -ne 0 ] ; then
echo "$0: backup of ${1} failed." 1>&2
# I'm assuming that the tar will have written an empty
# file to the tape, otherwise I should do a cat here.
else
flush_level_log ${remotehost} ${fsname}
fi
${MT_STATUS} "$TAPE_FILE"
${DUMP_END-:} $DUMP_LEVEL $remotehost $fs $fsname
echo "sleeping ${SLEEP_TIME} seconds"
sleep ${SLEEP_TIME}
shift
done
# Dump any individual files requested.
if [ "x${BACKUP_FILES}" != "x" ] ; then
message 1 "processing individual files"
date="`date`"
if [ $DUMP_LEVEL -eq 0 ]; then
make_level_log $localhost
else
echo "Last `prev_level` dump on this filesystem was on $PREV_DATE"
remote_run "${localhost}" cp "`level_log_name MISC $PREV_LEVEL`" "`level_log_name temp`"
fi
echo "Backing up miscellaneous files at ${date}"
${DUMP_BEGIN-:} $DUMP_LEVEL $localhost MISC MISC
backup_host $localhost \
"--listed=`level_log_name temp`"\
"--label='`print_level` backup of miscellaneous files at ${NOW}'" \
${BACKUP_FILES}
if [ $? -ne 0 ] ; then
echo "Backup of miscellaneous files failed."
# I'm assuming that the tar will have written an empty
# file to the tape, otherwise I should do a cat here.
else
flush_level_log $localhost MISC
fi
${MT_STATUS} "$TAPE_FILE"
${DUMP_END-:} $DUMP_LEVEL $localhost MISC MISC
else
echo "No miscellaneous files specified"
fi
message 1 "final cleanup"
$MT_REWIND "${TAPE_FILE}"
$MT_OFFLINE "${TAPE_FILE}"
echo "."
) 2>&1 | tee -a "${LOGFILE}"
RC=$?
if test "${ADMINISTRATOR}" != NONE; then
echo "Sending the dump log to ${ADMINISTRATOR}"
mail -s "Results of backup started ${startdate}" ${ADMINISTRATOR} < "${LOGFILE}"
fi
exit $RC
# EOF

Binary file not shown.

View file

@ -0,0 +1,231 @@
#! /bin/sh
# Restore backups.
# Copyright 2004-2023 Free Software Foundation, Inc.
# This file is part of GNU tar.
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Load library routines
SYSCONFDIR=${SYSCONFDIR-/etc}
. ${LIBDIR-/usr/libexec}/backup.sh
usage() {
cat - <<EOF
usage: $PROGNAME [OPTIONS] [PATTERN [PATTERN...]]
Options are:
-a, --all Restore all filesystems.
-l, --level=LEVEL Start restoring from the given backup LEVEL
(default $DUMP_LEVEL).
-v, --verbose[=LEVEL] Set verbosity level. Default 100.
Informational options:
-h, --help Display this help message.
-V, --version Display program version.
Send bug reports to bug-tar@gnu.org.
EOF
}
unset PATTERN
DUMP_LEVEL=0
CMDLINE="$0 $@"
for opt
do
if [ -z "$prev" ]; then
option=$opt
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
else
option="${prev}=$opt"
prev=""
optarg=$opt
fi
case $option in
-a|--a|--al|--all)
RESTORE_ALL=1
;;
--l=*|--le=*|--lev=*|--leve=*|--level=*)
DUMP_LEVEL=$optarg
;;
-l?*) DUMP_LEVEL=`expr $option : '-l\(.*\)'`;;
-l|--l|--le|--lev|--leve|--level)
prev=--level
;;
--verb=*|--verbo=*|--verbos=*|--verbose=*)
VERBOSE=$optarg
;;
-v|--verb|--verbo|--verbos|--verbose)
VERBOSE=100
;;
-v*) VERBOSE=`expr $option : '-v\(.*\)'`;;
-V|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "restore (GNU tar) 1.35"
license
exit;;
-h|--h|--he|--hel|--help)
usage
exit;;
-*) bailout "Unknown option $opt. Try $PROGNAME --help for more info.";;
*) if [ -z "$PATTERN" ]; then
PATTERN=$opt
else
PATTERN="$PATTERN|$opt"
fi
;;
esac
done
if [ -z "$RESTORE_ALL" ]; then
if [ -z "$PATTERN" ]; then
usage
exit;
fi
fi
init_restore
cat > $LOGFILE <<EOF
This file contains any messages produced by $PROGNAME.
It was created by GNU $PROGNAME, from @PACKAGE@ (1.35).
Invocation command line was
\$ $CMDLINE
EOF
restore_fs()
{
fs="`echo \"${1}\" | sed -e 's/^.*://'`"
fs=`root_fs $fs`
fsname="`echo \"${1}\" | sed -e 's/\//:/g'`"
remotehost="`expr \"${1}\" : '\([^/][^/]*\):.*'`"
if [ -z "$remotehost" ]; then
remotehost=$localhost
fi
message 10 "fs=$fs"
message 10 "fsname=$fsname"
message 10 "remotehost=$remotehost"
LOGPAT="`level_log_name ${fsname} '[0-9]'`"
PREFIX="`level_log_name ${fsname} ''`"
message 10 LOGPAT=$LOGPAT
message 10 PREFIX=$PREFIX
LEVELS=`remote_run "${remotehost}" ls $LOGPAT |
sed "s,$PREFIX,," | sort -n`
message 10 "LEVELS=$LEVELS"
echo "Starting restore of ${1} at level $DUMP_LEVEL."
for level in $LEVELS
do
if [ $level -lt $DUMP_LEVEL ]; then
message 10 "Skipping level $level"
continue;
fi
message 10 "Restoring level $level"
DATE=`get_dump_time $level`
FILE="`level_log_name ${fsname} ${level}`"
message 10 "FILE=$FILE"
LABEL="`print_level $level` backup of ${fs} on ${remotehost} at ${DATE}"
${RESTORE_BEGIN-:} $level $remotehost $fs $fsname
backup_host ${remotehost} \
"--listed=\"$FILE\"" \
"--label=\"$LABEL\"" \
-C $fs
${RESTORE_END-:} $level $remotehost $fs $fsname
done
}
restore_files()
{
LOGPAT="`level_log_name MISC '[0-9]'`"
PREFIX="`level_log_name MISC ''`"
message 10 LOGPAT=$LOGPAT
message 10 PREFIX=$PREFIX
LEVELS=`remote_run "${localhost}" ls $LOGPAT | sed "s,$PREFIX,," | sort -n`
message 10 "LEVELS=$LEVELS"
echo "Starting restore of miscellaneous files at level $DUMP_LEVEL."
for level in $LEVELS
do
if [ $level -lt $DUMP_LEVEL ]; then
message 10 "Skipping level $level"
continue;
fi
message 10 "Restoring level $level"
DATE=`get_dump_time $level`
FILE="`level_log_name MISC ${level}`"
message 10 "FILE=$FILE"
LABEL="`print_level $level` backup of miscellaneous files at ${DATE}"
${RESTORE_BEGIN-:} $level $localhost MISC MISC
backup_host ${localhost} \
"--listed=\"$FILE\"" \
"--label=\"$LABEL\"" \
-C ${ROOT_FS-/} $@
${RESTORE_END-:} $level $localhost MISC MISC
done
}
# Operation Overview:
#
# 1. Determine the time of the last backup
# 2. Create list of incremental listings to process
# 3. For each filesystem:
# 3.1. Start at the requested dump level (default 0) and proceed up to
# the last available level:
# 3.1.1 Deduce the volume label
# 3.1.2. Invoke [rsh] tar --listed=FILE --label=LABEL [opts] -xf $TAPE_FILE
# 4. End
(message 1 "Preparing for restore"
message 1 "processing backup directories"
for dir in ${BACKUP_DIRS}
do
message 1 "Processing $dir"
case $dir in
${PATTERN-*}) restore_fs $dir;;
esac
done
if [ "x${BACKUP_FILES}" != "x" ] ; then
message 1 "processing miscellaneous files"
if [ -z "$PATTERN" ]; then
restore_files
else
RESTORE_FILES=""
for file in ${BACKUP_FILES}
do
rel_file=`expr $file : '/\(.*\)'`
case $file in
$PATTERN) if [ -z "$RESTORE_FILES" ]; then
RESTORE_FILES="$rel_file"
else
RESTORE_FILES="$RESTORE_FILES $rel_file"
fi;;
esac
done
[ -z "$RESTORE_FILES" ] || restore_files $RESTORE_FILES
fi
fi) 2>&1 | tee -a "${LOGFILE}"
# EOF

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.