summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2010-06-26 13:30:35 +0100
committerRoger Leigh <rleigh@debian.org>2010-06-26 23:37:24 +0100
commit75f1f2606c5addf9a7a37ff0d930eeedcd49357f (patch)
tree35b80502f24a08c8dc24bffac9d83bad4591befd
parentde8003c2384f1e6e738fd8c5889aba57b2fa9776 (diff)
downloadschroot-75f1f2606c5addf9a7a37ff0d930eeedcd49357f.tar.gz
sbuild: Move verbosity from auth to chroot and session
Add message-verbosity configuration key.
-rw-r--r--TODO4
-rw-r--r--bin/dchroot-dsa/dchroot-dsa-session.cc2
-rw-r--r--bin/dchroot/dchroot-session.cc2
-rw-r--r--bin/schroot/schroot-main-base.cc6
-rw-r--r--contrib/setup.d/09fsck2
-rwxr-xr-xetc/setup.d/00check4
-rwxr-xr-xetc/setup.d/05btrfs14
-rwxr-xr-xetc/setup.d/05file24
-rwxr-xr-xetc/setup.d/05lvm20
-rw-r--r--etc/setup.d/05union4
-rwxr-xr-xetc/setup.d/10mount14
-rwxr-xr-xetc/setup.d/15killprocs8
-rwxr-xr-xetc/setup.d/20copyfiles8
-rwxr-xr-xetc/setup.d/20nssdatabases6
-rwxr-xr-xetc/setup.d/50chrootname2
-rw-r--r--man/schroot-setup.5.in11
-rw-r--r--sbuild/sbuild-auth.cc15
-rw-r--r--sbuild/sbuild-auth.h26
-rw-r--r--sbuild/sbuild-chroot.cc103
-rw-r--r--sbuild/sbuild-chroot.h82
-rw-r--r--sbuild/sbuild-session.cc48
-rw-r--r--sbuild/sbuild-session.h19
-rw-r--r--test/config.ex2/sid3
-rw-r--r--test/sbuild-chroot.cc21
-rw-r--r--test/test-sbuild-chroot.h2
25 files changed, 273 insertions, 177 deletions
diff --git a/TODO b/TODO
index c95a7003..6a77cf4f 100644
--- a/TODO
+++ b/TODO
@@ -71,10 +71,6 @@ fashion. expect might be useful for testing the PAM wrappers.
Similar to debug level, but for normal messages
e.g. quiet/normal/verbose/extra verbose.
-** config file should have a "message" key.
-
- Overridden by --quiet/--verbose options.
-
* Create separate namespaces for chroots and sessions
Note: how to deal with duplicated names in both namespaces for --all?
diff --git a/bin/dchroot-dsa/dchroot-dsa-session.cc b/bin/dchroot-dsa/dchroot-dsa-session.cc
index 7b31479e..8d2cc742 100644
--- a/bin/dchroot-dsa/dchroot-dsa-session.cc
+++ b/bin/dchroot-dsa/dchroot-dsa-session.cc
@@ -134,7 +134,7 @@ session::get_user_command (sbuild::chroot::ptr& session_chroot,
get_auth()->get_user().c_str(),
commandstring.c_str());
- if (get_auth()->get_verbosity() != auth::VERBOSITY_QUIET)
+ if (session_chroot->get_verbosity() != sbuild::chroot::VERBOSITY_QUIET)
{
std::string format_string;
// TRANSLATORS: %1% = chroot name
diff --git a/bin/dchroot/dchroot-session.cc b/bin/dchroot/dchroot-session.cc
index 5ff29056..acd4710a 100644
--- a/bin/dchroot/dchroot-session.cc
+++ b/bin/dchroot/dchroot-session.cc
@@ -122,7 +122,7 @@ session::get_user_command (sbuild::chroot::ptr& session_chroot,
get_auth()->get_user().c_str(),
commandstring.c_str());
- if (get_auth()->get_verbosity() != auth::VERBOSITY_QUIET)
+ if (session_chroot->get_verbosity() != sbuild::chroot::VERBOSITY_QUIET)
{
std::string format_string;
// TRANSLATORS: %1% = chroot name
diff --git a/bin/schroot/schroot-main-base.cc b/bin/schroot/schroot-main-base.cc
index 4f26079d..81927f88 100644
--- a/bin/schroot/schroot-main-base.cc
+++ b/bin/schroot/schroot-main-base.cc
@@ -305,12 +305,10 @@ main_base::run_impl ()
this->session->get_auth()->set_environment(environ);
this->session->set_session_id(this->options->session_name);
this->session->set_force(this->options->session_force);
- sbuild::auth::verbosity verbosity = sbuild::auth::VERBOSITY_NORMAL;
if (this->options->quiet)
- verbosity = sbuild::auth::VERBOSITY_QUIET;
+ this->session->set_verbosity("quiet");
else if (this->options->verbose)
- verbosity = sbuild::auth::VERBOSITY_VERBOSE;
- this->session->get_auth()->set_verbosity(verbosity);
+ this->session->set_verbosity("verbose");
/* Run session. */
this->session->run();
diff --git a/contrib/setup.d/09fsck b/contrib/setup.d/09fsck
index 2d7e5ae4..20030b4d 100644
--- a/contrib/setup.d/09fsck
+++ b/contrib/setup.d/09fsck
@@ -24,7 +24,7 @@ if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
. "$CHROOT_SCRIPT_CONFIG"
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+if [ "$VERBOSE" = "verbose" ]; then
FSCK_VERBOSE="-V"
fi
diff --git a/etc/setup.d/00check b/etc/setup.d/00check
index a73b0c42..a8e23105 100755
--- a/etc/setup.d/00check
+++ b/etc/setup.d/00check
@@ -39,7 +39,7 @@ elif [ $1 = "setup-stop" ] && [ "$(basename "$0")" = "00check" ]; then
exit 0;
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+if [ "$VERBOSE" = "verbose" ]; then
echo "AUTH_USER=$AUTH_USER"
echo "AUTH_RUSER=$AUTH_RUSER"
echo "AUTH_RGROUP=$AUTH_RGROUP"
@@ -49,7 +49,7 @@ if [ "$AUTH_VERBOSITY" = "verbose" ]; then
echo "AUTH_RGID=$AUTH_RGID"
echo "AUTH_HOME=$AUTH_HOME"
echo "AUTH_SHELL=$AUTH_SHELL"
- echo "AUTH_VERBOSITY=$AUTH_VERBOSITY"
+ echo "VERBOSE=$VERBOSE"
echo "MOUNT_DIR=$MOUNT_DIR"
echo "LIBEXEC_DIR=$LIBEXEC_DIR"
echo "PID=$PID"
diff --git a/etc/setup.d/05btrfs b/etc/setup.d/05btrfs
index d2d24acc..40a38993 100755
--- a/etc/setup.d/05btrfs
+++ b/etc/setup.d/05btrfs
@@ -26,19 +26,15 @@ elif [ "$2" = "ok" ]; then
exit 1
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="-v"
-fi
-
if [ "$CHROOT_TYPE" = "btrfs-snapshot" ]; then
if [ $1 = "setup-start" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Creating snapshot $CHROOT_BTRFS_SNAPSHOT_NAME from subvolume $CHROOT_BTRFS_SOURCE_SUBVOLUME"
fi
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
btrfs subvolume snapshot "$CHROOT_BTRFS_SOURCE_SUBVOLUME" \
"$CHROOT_BTRFS_SNAPSHOT_NAME"
else
@@ -50,11 +46,11 @@ if [ "$CHROOT_TYPE" = "btrfs-snapshot" ]; then
if [ -d "$CHROOT_BTRFS_SNAPSHOT_NAME" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Deleting snapshot $CHROOT_BTRFS_SNAPSHOT_NAME"
fi
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
btrfs subvolume delete "$CHROOT_BTRFS_SNAPSHOT_NAME" || true
else
btrfs subvolume delete "$CHROOT_BTRFS_SNAPSHOT_NAME" > /dev/null || true
@@ -63,7 +59,7 @@ if [ "$CHROOT_TYPE" = "btrfs-snapshot" ]; then
else
# The block device no longer exists, or was never created,
# for example on lvcreate failure.
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "$CHROOT_BTRFS_SNAPSHOT_NAME does not exist"
fi
fi
diff --git a/etc/setup.d/05file b/etc/setup.d/05file
index 9654b73c..96315e6c 100755
--- a/etc/setup.d/05file
+++ b/etc/setup.d/05file
@@ -47,11 +47,11 @@ check_filetype()
unpack_file()
{
if [ "$filetype" = "tar" ]; then
- tar $VERBOSE -xf "$CHROOT_FILE"
+ tar $TAR_VERBOSE -xf "$CHROOT_FILE"
elif [ "$filetype" = "tgz" ]; then
- tar $VERBOSE -xzf "$CHROOT_FILE"
+ tar $TAR_VERBOSE -xzf "$CHROOT_FILE"
elif [ "$filetype" = "tbz" ]; then
- tar $VERBOSE -xjf "$CHROOT_FILE"
+ tar $TAR_VERBOSE -xjf "$CHROOT_FILE"
elif [ "$filetype" = "zip" ]; then
unzip $ZIP_VERBOSE "$CHROOT_FILE"
else
@@ -68,11 +68,11 @@ repack_file()
trap "if [ -f \"$NEWFILE\" ]; then rm -f \"$NEWFILE\"; fi" 0
if [ "$filetype" = "tar" ]; then
- tar $VERBOSE -cf "$NEWFILE" .
+ tar $TAR_VERBOSE -cf "$NEWFILE" .
elif [ "$filetype" = "tgz" ]; then
- tar $VERBOSE -czf "$NEWFILE" .
+ tar $TAR_VERBOSE -czf "$NEWFILE" .
elif [ "$filetype" = "tbz" ]; then
- tar $VERBOSE -cjf "$NEWFILE" .
+ tar $TAR_VERBOSE -cjf "$NEWFILE" .
elif [ "$filetype" = "zip" ]; then
zip $ZIP_VERBOSE -r "$NEWFILE" .
else
@@ -87,8 +87,8 @@ repack_file()
trap "" 0
}
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="-v"
+if [ "$VERBOSE" = "verbose" ]; then
+ TAR_VERBOSE="-v"
else
ZIP_VERBOSE="-q"
fi
@@ -101,17 +101,17 @@ if [ "$CHROOT_TYPE" = "file" ]; then
if [ $1 = "setup-start" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "File unpack directory: $UNPACK_LOCATION"
fi
if [ ! -d "$UNPACK_LOCATION" ]; then
mkdir -p "$UNPACK_LOCATION"
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Created file unpack directory: $UNPACK_LOCATION"
fi
fi
cd "$UNPACK_LOCATION"
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Changed CWD to $UNPACK_LOCATION"
fi
@@ -124,7 +124,7 @@ if [ "$CHROOT_TYPE" = "file" ]; then
fi
if [ "$CHROOT_SESSION_PURGE" = "true" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Purging $UNPACK_LOCATION"
fi
if [ -d "$UNPACK_LOCATION" ]; then
diff --git a/etc/setup.d/05lvm b/etc/setup.d/05lvm
index 252ac6d1..c470e33b 100755
--- a/etc/setup.d/05lvm
+++ b/etc/setup.d/05lvm
@@ -26,19 +26,19 @@ elif [ "$2" = "ok" ]; then
exit 1
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="-v"
+if [ "$VERBOSE" = "verbose" ]; then
+ LVM_VERBOSE="-v"
fi
if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
if [ $1 = "setup-start" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- lvcreate $VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
+ if [ "$VERBOSE" = "verbose" ]; then
+ lvcreate $LVM_VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
"$CHROOT_DEVICE" $CHROOT_LVM_SNAPSHOT_OPTIONS
else
- lvcreate $VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
+ lvcreate $LVM_VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
"$CHROOT_DEVICE" $CHROOT_LVM_SNAPSHOT_OPTIONS > /dev/null
fi
@@ -49,22 +49,22 @@ if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
# destroying the device. There is a small race here, but
# the lock can't be dropped once the device has been
# removed.
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Removing device lock for $CHROOT_LVM_SNAPSHOT_DEVICE, owned by pid $PID"
fi
"$LIBEXEC_DIR/schroot-releaselock" \
--device="$CHROOT_LVM_SNAPSHOT_DEVICE" \
--pid=$PID || true
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- lvremove $VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" || true
+ if [ "$VERBOSE" = "verbose" ]; then
+ lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" || true
else
- lvremove $VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" > /dev/null || true
+ lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" > /dev/null || true
fi
else
# The block device no longer exists, or was never created,
# for example on lvcreate failure.
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "$CHROOT_LVM_SNAPSHOT_DEVICE does not exist"
fi
fi
diff --git a/etc/setup.d/05union b/etc/setup.d/05union
index 4413e1b5..6184a281 100644
--- a/etc/setup.d/05union
+++ b/etc/setup.d/05union
@@ -50,7 +50,7 @@ if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then
elif [ $1 = "setup-stop" ]; then
if [ "$CHROOT_SESSION_PURGE" = "true" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Purging $CHROOT_UNION_OVERLAY_DIRECTORY"
fi
if [ -d "${CHROOT_UNION_OVERLAY_DIRECTORY}" ]; then
@@ -59,7 +59,7 @@ if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then
# For safety, use rmdir rather than rm -rf in case
# umount failed.
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Removing $CHROOT_UNION_UNDERLAY_DIRECTORY"
fi
if [ -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then
diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount
index dd9cb6ab..df96abbb 100755
--- a/etc/setup.d/10mount
+++ b/etc/setup.d/10mount
@@ -33,7 +33,7 @@ fi
# $3: mount location
do_mount()
{
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Mounting $2 on $3"
fi
@@ -45,7 +45,7 @@ do_mount()
exit 1
fi
- mount $VERBOSE $1 "$2" "$3"
+ mount $MOUNT_VERBOSE $1 "$2" "$3"
}
# Unmount all filesystems under specified location
@@ -57,7 +57,7 @@ do_umount_all()
if [ "x$mounts" != 'x' ]; then
echo "$mounts" |
while read mountloc; do
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Unmounting $mountloc"
fi
umount "$mountloc" || exit 1
@@ -82,7 +82,7 @@ do_mount_fs_union()
esac
fi
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Using '$CHROOT_UNION_TYPE' for filesystem union"
fi
@@ -90,8 +90,8 @@ do_mount_fs_union()
mount -t "$CHROOT_UNION_TYPE" -o "$CHROOT_UNION_MOUNT_OPTIONS" "$CHROOT_NAME" "$1"
}
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="-v"
+if [ "$VERBOSE" = "verbose" ]; then
+ MOUNT_VERBOSE="-v"
# FSCK_VERBOSE="-V"
fi
@@ -174,7 +174,7 @@ if [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT
if [ -n "$FSTAB" ]; then
if [ -f "$FSTAB" ]; then
- "$LIBEXEC_DIR/schroot-mount" $VERBOSE \
+ "$LIBEXEC_DIR/schroot-mount" $MOUNT_VERBOSE \
-f "$FSTAB" -m "$CHROOT_PATH"
else
echo "fstab file '$FSTAB' does not exist"
diff --git a/etc/setup.d/15killprocs b/etc/setup.d/15killprocs
index 08e0b8d6..cc44e6a9 100755
--- a/etc/setup.d/15killprocs
+++ b/etc/setup.d/15killprocs
@@ -36,14 +36,14 @@ do_kill_all()
exit 0
fi
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Killing processes run inside $1"
fi
ls /proc | egrep '^[[:digit:]]+$' |
while read pid; do
root=$(readlink /proc/"$pid"/root || true)
if [ "$root" = "$1" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
exe=$(readlink /proc/"$pid"/exe || true)
echo "Killing left-over pid $pid (${exe##$1})"
echo " Sending SIGTERM to pid $pid"
@@ -55,13 +55,13 @@ do_kill_all()
max=5
while [ -d /proc/"$pid" ]; do
count=$(( $count + 1 ))
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo " Waiting for pid $pid to shut down... ($count/$max)"
fi
sleep 1
# Wait for $max seconds for process to die before -9'ing it
if [ "$count" -eq "$max" ]; then
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo " Sending SIGKILL to pid $pid"
fi
/bin/kill -KILL "$pid" 2>/dev/null
diff --git a/etc/setup.d/20copyfiles b/etc/setup.d/20copyfiles
index e5de0f6f..430b512c 100755
--- a/etc/setup.d/20copyfiles
+++ b/etc/setup.d/20copyfiles
@@ -26,8 +26,8 @@ elif [ "$2" = "ok" ]; then
exit 1
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="--verbose"
+if [ "$VERBOSE" = "verbose" ]; then
+ CP_VERBOSE="--verbose"
fi
# Copy a file if the source and destination differ
@@ -66,10 +66,10 @@ copy_file()
# Copy only if files are different
if [ "$COPY" = "true" ]; then
if [ -f "$1" ]; then
- cp --preserve=all $VERBOSE "$1" "$2"
+ cp --preserve=all $CP_VERBOSE "$1" "$2"
else
# Copy non-regular file directly
- cp -a $VERBOSE "$1" "$2"
+ cp -a $CP_VERBOSE "$1" "$2"
fi
fi
diff --git a/etc/setup.d/20nssdatabases b/etc/setup.d/20nssdatabases
index 0b99a01f..544e2138 100755
--- a/etc/setup.d/20nssdatabases
+++ b/etc/setup.d/20nssdatabases
@@ -26,16 +26,12 @@ elif [ "$2" = "ok" ]; then
exit 1
fi
-if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- VERBOSE="--verbose"
-fi
-
# Copy NSS database from host to chroot
# $1: database name
# $2: destination file name
dup_nss()
{
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Copying $1 database to $2"
fi
getent "$1" > "$2"
diff --git a/etc/setup.d/50chrootname b/etc/setup.d/50chrootname
index 6b571de0..34533cd8 100755
--- a/etc/setup.d/50chrootname
+++ b/etc/setup.d/50chrootname
@@ -31,7 +31,7 @@ if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
# Strip any UUID or ISO-8601 date and pid from the chroot name
NAME=$(echo "${CHROOT_NAME}" | sed -e 's/-[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]//g' -e 's/-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z-[0-9][0-9]*//g')
- if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+ if [ "$VERBOSE" = "verbose" ]; then
echo "Setting chroot name to ${NAME}"
fi
diff --git a/man/schroot-setup.5.in b/man/schroot-setup.5.in
index 18f74ca2..aa88a946 100644
--- a/man/schroot-setup.5.in
+++ b/man/schroot-setup.5.in
@@ -53,11 +53,6 @@ than once, for example on failure.
AUTH_USER
The username of the user the command in the chroot will run as.
.TP
-AUTH_VERBOSITY
-Set to \[oq]quiet\[cq] if only error messages should be printed,
-\[oq]normal\[cq] if other messages may be printed as well, and
-\[oq]verbose\[cq] if all messages may be printed.
-.TP
HOST
.TP
HOST_OS
@@ -90,6 +85,12 @@ architecture, and may be identical between different architectures.
SESSION_ID
The session identifier.
.TP
+VERBOSE
+Set to \[oq]quiet\[cq] if only error messages should be printed,
+\[oq]normal\[cq] if other messages may be printed as well, and
+\[oq]verbose\[cq] if all messages may be printed. Previously called
+AUTH_VERBOSITY.
+.TP
CHROOT_SESSION_CREATE
Set to \[oq]true\[cq] if a session will be created, otherwise \[oq]false\[cq].
.TP
diff --git a/sbuild/sbuild-auth.cc b/sbuild/sbuild-auth.cc
index ee196384..ed156a8d 100644
--- a/sbuild/sbuild-auth.cc
+++ b/sbuild/sbuild-auth.cc
@@ -81,8 +81,7 @@ auth::auth (std::string const& service_name):
ruid(),
rgid(),
ruser(),
- rgroup(),
- message_verbosity(VERBOSITY_NORMAL)
+ rgroup()
{
this->ruid = getuid();
this->rgid = getgid();
@@ -289,18 +288,6 @@ auth::get_rgroup () const
return this->rgroup;
}
-auth::verbosity
-auth::get_verbosity () const
-{
- return this->message_verbosity;
-}
-
-void
-auth::set_verbosity (auth::verbosity verbosity)
-{
- this->message_verbosity = verbosity;
-}
-
void
auth::start ()
{
diff --git a/sbuild/sbuild-auth.h b/sbuild/sbuild-auth.h
index 4eb877fb..83cb270e 100644
--- a/sbuild/sbuild-auth.h
+++ b/sbuild/sbuild-auth.h
@@ -76,14 +76,6 @@ namespace sbuild
STATUS_FAIL ///< Authentication has failed.
};
- /// Message verbosity
- enum verbosity
- {
- VERBOSITY_QUIET, ///< Only print essential messages.
- VERBOSITY_NORMAL, ///< Print messages (the default).
- VERBOSITY_VERBOSE ///< Print all messages.
- };
-
/// Error codes.
enum error_code
{
@@ -308,22 +300,6 @@ namespace sbuild
get_rgroup () const;
/**
- * Get the message verbosity.
- *
- * Returns the verbosity level.
- */
- verbosity
- get_verbosity () const;
-
- /**
- * Set the message verbosity.
- *
- * @param verbosity the verbosity level.
- */
- void
- set_verbosity (verbosity verbosity);
-
- /**
* Start the PAM system. No other PAM functions may be called before
* calling this function.
*
@@ -467,8 +443,6 @@ namespace sbuild
/// Minimal environment.
environment auth_environment;
#endif // !SBUILD_FEATURE_PAM
- /// The message verbosity.
- verbosity message_verbosity;
};
}
diff --git a/sbuild/sbuild-chroot.cc b/sbuild/sbuild-chroot.cc
index 6dc71d4d..37ef6fa0 100644
--- a/sbuild/sbuild-chroot.cc
+++ b/sbuild/sbuild-chroot.cc
@@ -66,27 +66,28 @@ namespace
*/
emap init_errors[] =
{
- emap(sbuild::chroot::CHROOT_CREATE, N_("Chroot creation failed")),
- emap(sbuild::chroot::CHROOT_DEVICE, N_("Device name not set")),
+ emap(sbuild::chroot::CHROOT_CREATE, N_("Chroot creation failed")),
+ emap(sbuild::chroot::CHROOT_DEVICE, N_("Device name not set")),
// TRANSLATORS: %1% = chroot type name
- emap(sbuild::chroot::CHROOT_TYPE, N_("Unknown chroot type '%1%'")),
- emap(sbuild::chroot::DEVICE_ABS, N_("Device must have an absolute path")),
- emap(sbuild::chroot::DEVICE_LOCK, N_("Failed to lock device")),
- emap(sbuild::chroot::DEVICE_NOTBLOCK, N_("File is not a block device")),
- emap(sbuild::chroot::DEVICE_UNLOCK, N_("Failed to unlock device")),
- emap(sbuild::chroot::DIRECTORY_ABS, N_("Directory must have an absolute path")),
- emap(sbuild::chroot::FACET_INVALID, N_("Attempt to add object which is not a facet")),
- emap(sbuild::chroot::FACET_PRESENT, N_("Attempt to add facet which is already in use")),
- emap(sbuild::chroot::FILE_ABS, N_("File must have an absolute path")),
- emap(sbuild::chroot::FILE_LOCK, N_("Failed to acquire file lock")),
- emap(sbuild::chroot::FILE_NOTREG, N_("File is not a regular file")),
- emap(sbuild::chroot::FILE_OWNER, N_("File is not owned by user root")),
- emap(sbuild::chroot::FILE_PERMS, N_("File has write permissions for others")),
- emap(sbuild::chroot::FILE_UNLOCK, N_("Failed to discard file lock")),
- emap(sbuild::chroot::LOCATION_ABS, N_("Location must have an absolute path")),
+ emap(sbuild::chroot::CHROOT_TYPE, N_("Unknown chroot type '%1%'")),
+ emap(sbuild::chroot::DEVICE_ABS, N_("Device must have an absolute path")),
+ emap(sbuild::chroot::DEVICE_LOCK, N_("Failed to lock device")),
+ emap(sbuild::chroot::DEVICE_NOTBLOCK, N_("File is not a block device")),
+ emap(sbuild::chroot::DEVICE_UNLOCK, N_("Failed to unlock device")),
+ emap(sbuild::chroot::DIRECTORY_ABS, N_("Directory must have an absolute path")),
+ emap(sbuild::chroot::FACET_INVALID, N_("Attempt to add object which is not a facet")),
+ emap(sbuild::chroot::FACET_PRESENT, N_("Attempt to add facet which is already in use")),
+ emap(sbuild::chroot::FILE_ABS, N_("File must have an absolute path")),
+ emap(sbuild::chroot::FILE_LOCK, N_("Failed to acquire file lock")),
+ emap(sbuild::chroot::FILE_NOTREG, N_("File is not a regular file")),
+ emap(sbuild::chroot::FILE_OWNER, N_("File is not owned by user root")),
+ emap(sbuild::chroot::FILE_PERMS, N_("File has write permissions for others")),
+ emap(sbuild::chroot::FILE_UNLOCK, N_("Failed to discard file lock")),
+ emap(sbuild::chroot::LOCATION_ABS, N_("Location must have an absolute path")),
// TRANSLATORS: unlink refers to the C function which removes a file
- emap(sbuild::chroot::SESSION_UNLINK, N_("Failed to unlink session file")),
- emap(sbuild::chroot::SESSION_WRITE, N_("Failed to write session file"))
+ emap(sbuild::chroot::SESSION_UNLINK, N_("Failed to unlink session file")),
+ emap(sbuild::chroot::SESSION_WRITE, N_("Failed to write session file")),
+ emap(sbuild::chroot::VERBOSITY_INVALID, N_("Message verbosity is invalid"))
};
}
@@ -113,6 +114,7 @@ sbuild::chroot::chroot ():
run_setup_scripts(true),
script_config("default/config"),
command_prefix(),
+ message_verbosity(VERBOSITY_NORMAL),
facets()
{
add_facet(sbuild::chroot_facet_personality::create());
@@ -135,6 +137,7 @@ sbuild::chroot::chroot (const chroot& rhs):
run_setup_scripts(rhs.run_setup_scripts),
script_config(rhs.script_config),
command_prefix(rhs.command_prefix),
+ message_verbosity(rhs.message_verbosity),
facets()
{
/// @todo Use internal version of add_facet to add chroot pointer.
@@ -389,6 +392,58 @@ sbuild::chroot::set_command_prefix (string_list const& command_prefix)
this->command_prefix = command_prefix;
}
+chroot::verbosity
+chroot::get_verbosity () const
+{
+ return this->message_verbosity;
+}
+
+const char *
+chroot::get_verbosity_string () const
+{
+ const char *verbosity = 0;
+
+ switch (this->message_verbosity)
+ {
+ case chroot::VERBOSITY_QUIET:
+ verbosity = "quiet";
+ break;
+ case chroot::VERBOSITY_NORMAL:
+ verbosity = "normal";
+ break;
+ case chroot::VERBOSITY_VERBOSE:
+ verbosity = "verbose";
+ break;
+ default:
+ log_debug(DEBUG_CRITICAL) << format("Invalid verbosity level: %1%, falling back to 'normal'")
+ % static_cast<int>(this->message_verbosity)
+ << std::endl;
+ verbosity = "normal";
+ break;
+ }
+
+ return verbosity;
+}
+
+void
+chroot::set_verbosity (chroot::verbosity verbosity)
+{
+ this->message_verbosity = verbosity;
+}
+
+void
+chroot::set_verbosity (std::string const& verbosity)
+{
+ if (verbosity == "quiet")
+ this->message_verbosity = VERBOSITY_QUIET;
+ else if (verbosity == "normal")
+ this->message_verbosity = VERBOSITY_NORMAL;
+ else if (verbosity == "verbose")
+ this->message_verbosity = VERBOSITY_VERBOSE;
+ else
+ throw error(verbosity, VERBOSITY_INVALID);
+}
+
string_list
sbuild::chroot::list_facets () const
{
@@ -535,6 +590,7 @@ sbuild::chroot::get_details (chroot const& chroot,
.add(_("Description"), chroot.get_description())
.add(_("Type"), chroot.get_chroot_type())
.add(_("Priority"), chroot.get_priority())
+ .add(_("Message Verbosity"), chroot.get_verbosity_string())
.add(_("Users"), chroot.get_users())
.add(_("Groups"), chroot.get_groups())
.add(_("Root Users"), chroot.get_root_users())
@@ -644,6 +700,9 @@ sbuild::chroot::get_keyfile (chroot const& chroot,
keyfile, chroot.get_keyfile_name(),
"command-prefix");
+ keyfile::set_object_value(chroot, &chroot::get_verbosity_string,
+ keyfile, chroot.get_keyfile_name(),
+ "message-verbosity");
}
void
@@ -784,4 +843,10 @@ sbuild::chroot::set_keyfile (chroot& chroot,
"command-prefix",
keyfile::PRIORITY_OPTIONAL);
used_keys.push_back("command-prefix");
+
+ keyfile::get_object_value(chroot, &chroot::set_verbosity,
+ keyfile, chroot.get_keyfile_name(),
+ "message-verbosity",
+ keyfile::PRIORITY_OPTIONAL);
+ used_keys.push_back("message-verbosity");
}
diff --git a/sbuild/sbuild-chroot.h b/sbuild/sbuild-chroot.h
index ca6fc857..2788bbde 100644
--- a/sbuild/sbuild-chroot.h
+++ b/sbuild/sbuild-chroot.h
@@ -62,28 +62,37 @@ namespace sbuild
SESSION_PURGE = 1 << 2 ///< The chroot should be purged.
};
+ /// Message verbosity
+ enum verbosity
+ {
+ VERBOSITY_QUIET, ///< Only print essential messages.
+ VERBOSITY_NORMAL, ///< Print messages (the default).
+ VERBOSITY_VERBOSE ///< Print all messages.
+ };
+
/// Error codes.
enum error_code
{
- CHROOT_CREATE, ///< Chroot creation failed.
- CHROOT_DEVICE, ///< Chroot device name not set.
- CHROOT_TYPE, ///< Unknown chroot type.
- DEVICE_ABS, ///< Device must have an absolute path.
- DEVICE_LOCK, ///< Failed to lock device.
- DEVICE_NOTBLOCK, ///< File is not a block device.
- DEVICE_UNLOCK, ///< Failed to unlock device.
- DIRECTORY_ABS, ///< Directory must have an absolute path.
- FACET_INVALID, ///< Attempt to add object which is not a facet.
- FACET_PRESENT, ///< Attempt to add facet which is already in use.
- FILE_ABS, ///< File must have an absolute path.
- FILE_LOCK, ///< Failed to acquire lock.
- FILE_NOTREG, ///< File is not a regular file.
- FILE_OWNER, ///< File is not owned by user root.
- FILE_PERMS, ///< File has write permissions for others.
- FILE_UNLOCK, ///< Failed to discard lock.
- LOCATION_ABS, ///< Location must have an absolute path.
- SESSION_UNLINK, ///< Failed to unlink session file.
- SESSION_WRITE ///< Failed to write session file.
+ CHROOT_CREATE, ///< Chroot creation failed.
+ CHROOT_DEVICE, ///< Chroot device name not set.
+ CHROOT_TYPE, ///< Unknown chroot type.
+ DEVICE_ABS, ///< Device must have an absolute path.
+ DEVICE_LOCK, ///< Failed to lock device.
+ DEVICE_NOTBLOCK, ///< File is not a block device.
+ DEVICE_UNLOCK, ///< Failed to unlock device.
+ DIRECTORY_ABS, ///< Directory must have an absolute path.
+ FACET_INVALID, ///< Attempt to add object which is not a facet.
+ FACET_PRESENT, ///< Attempt to add facet which is already in use.
+ FILE_ABS, ///< File must have an absolute path.
+ FILE_LOCK, ///< Failed to acquire lock.
+ FILE_NOTREG, ///< File is not a regular file.
+ FILE_OWNER, ///< File is not owned by user root.
+ FILE_PERMS, ///< File has write permissions for others.
+ FILE_UNLOCK, ///< Failed to discard lock.
+ LOCATION_ABS, ///< Location must have an absolute path.
+ SESSION_UNLINK, ///< Failed to unlink session file.
+ SESSION_WRITE, ///< Failed to write session file.
+ VERBOSITY_INVALID ///< Message verbosity is invalid.
};
/// Exception type.
@@ -445,6 +454,38 @@ namespace sbuild
set_command_prefix (string_list const& command_prefix);
/**
+ * Get the message verbosity.
+ *
+ * Returns the verbosity level.
+ */
+ verbosity
+ get_verbosity () const;
+
+ /**
+ * Get the message verbosity.
+ *
+ * Returns the verbosity level.
+ */
+ const char *
+ get_verbosity_string () const;
+
+ /**
+ * Set the message verbosity.
+ *
+ * @param verbosity the verbosity level.
+ */
+ void
+ set_verbosity (verbosity verbosity);
+
+ /**
+ * Set the message verbosity.
+ *
+ * @param verbosity the verbosity level.
+ */
+ void
+ set_verbosity (std::string const& verbosity);
+
+ /**
* Get the type of the chroot.
*
* @returns the chroot type.
@@ -731,9 +772,12 @@ namespace sbuild
std::string script_config;
/// Command prefix.
string_list command_prefix;
+ /// The message verbosity.
+ verbosity message_verbosity;
typedef std::tr1::shared_ptr<chroot_facet> facet_ptr;
typedef std::list<facet_ptr> facet_list;
+ /// Contained chroot facets
facet_list facets;
};
diff --git a/sbuild/sbuild-session.cc b/sbuild/sbuild-session.cc
index b0ef1d75..cac37cc3 100644
--- a/sbuild/sbuild-session.cc
+++ b/sbuild/sbuild-session.cc
@@ -1,4 +1,4 @@
-/* Copyright © 2005-2009 Roger Leigh <rleigh@debian.org>
+/* Copyright © 2005-2010 Roger Leigh <rleigh@debian.org>
*
* schroot is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
@@ -271,6 +271,7 @@ session::session (std::string const& service,
saved_sigterm_signal(),
saved_termios(),
termios_ok(false),
+ verbosity(),
cwd(sbuild::getcwd())
{
}
@@ -339,6 +340,18 @@ session::set_session_id (std::string const& session_id)
this->session_id = session_id;
}
+std::string const&
+session::get_verbosity () const
+{
+ return this->verbosity;
+}
+
+void
+session::set_verbosity (std::string const& verbosity)
+{
+ this->verbosity = verbosity;
+}
+
bool
session::get_force () const
{
@@ -619,6 +632,10 @@ session::run_impl ()
chroot::ptr chroot(ch->clone());
assert(chroot);
+ // Override chroot verbosity if needed.
+ if (!this->verbosity.empty())
+ ch->set_verbosity(this->verbosity);
+
/* Create a session using randomly-generated session ID. */
if (ch->get_session_flags() & chroot::SESSION_CREATE)
{
@@ -868,7 +885,7 @@ session::get_login_command (sbuild::chroot::ptr& session_chroot,
shell.c_str());
}
- if (this->authstat->get_verbosity() == auth::VERBOSITY_VERBOSE)
+ if (session_chroot->get_verbosity() == chroot::VERBOSITY_VERBOSE)
{
std::string format_string;
if (this->authstat->get_ruid() == this->authstat->get_uid())
@@ -931,7 +948,7 @@ session::get_user_command (sbuild::chroot::ptr& session_chroot,
syslog(LOG_USER|LOG_NOTICE, "[%s chroot] (%s->%s) Running command: \"%s\"",
session_chroot->get_name().c_str(), this->authstat->get_ruser().c_str(), this->authstat->get_user().c_str(), commandstring.c_str());
- if (this->authstat->get_verbosity() == auth::VERBOSITY_VERBOSE)
+ if (session_chroot->get_verbosity() == chroot::VERBOSITY_VERBOSE)
{
std::string format_string;
if (this->authstat->get_ruid() == this->authstat->get_uid())
@@ -1039,29 +1056,8 @@ session::setup_chroot (sbuild::chroot::ptr& session_chroot,
env.add("AUTH_RGID", this->authstat->get_rgid());
env.add("AUTH_HOME", this->authstat->get_home());
env.add("AUTH_SHELL", this->authstat->get_shell());
- {
- const char *verbosity = 0;
- switch (this->authstat->get_verbosity())
- {
- case auth::VERBOSITY_QUIET:
- verbosity = "quiet";
- break;
- case auth::VERBOSITY_NORMAL:
- verbosity = "normal";
- break;
- case auth::VERBOSITY_VERBOSE:
- verbosity = "verbose";
- break;
- default:
- log_debug(DEBUG_CRITICAL) << format("Invalid verbosity level: %1%, falling back to 'normal'")
- % static_cast<int>(this->authstat->get_verbosity())
- << endl;
- verbosity = "normal";
- break;
- }
- env.add("AUTH_VERBOSITY", verbosity);
- }
+ env.add("VERBOSE", session_chroot->get_verbosity_string());
env.add("MOUNT_DIR", SCHROOT_MOUNT_DIR);
env.add("LIBEXEC_DIR", SCHROOT_LIBEXEC_DIR);
env.add("PID", getpid());
@@ -1075,7 +1071,7 @@ session::setup_chroot (sbuild::chroot::ptr& session_chroot,
run_parts rp(SCHROOT_CONF_SETUP_D,
true, true, 022);
rp.set_reverse(setup_type == chroot::SETUP_STOP);
- rp.set_verbose(this->authstat->get_verbosity() == auth::VERBOSITY_VERBOSE);
+ rp.set_verbose(session_chroot->get_verbosity() == chroot::VERBOSITY_VERBOSE);
log_debug(DEBUG_INFO) << rp << std::endl;
diff --git a/sbuild/sbuild-session.h b/sbuild/sbuild-session.h
index 9179a299..e7c79bed 100644
--- a/sbuild/sbuild-session.h
+++ b/sbuild/sbuild-session.h
@@ -198,6 +198,23 @@ namespace sbuild
set_session_id (std::string const& session_id);
/**
+ * Get the message verbosity.
+ *
+ * @returns the message verbosity.
+ */
+ std::string const&
+ get_verbosity () const;
+
+ /**
+ * Set the message verbosity. This will override the chroot
+ * message verbosity if set.
+ *
+ * @param verbosity the message verbosity.
+ */
+ void
+ set_verbosity (std::string const& verbosity);
+
+ /**
* Get the force status of this session.
*
* @returns true if operation will be forced, otherwise false.
@@ -496,6 +513,8 @@ namespace sbuild
struct termios saved_termios;
/// Are the saved terminal settings valid?
bool termios_ok;
+ /// Message verbosity.
+ std::string verbosity;
protected:
/// Current working directory.
diff --git a/test/config.ex2/sid b/test/config.ex2/sid
index 11ebcd5c..03d271ca 100644
--- a/test/config.ex2/sid
+++ b/test/config.ex2/sid
@@ -6,6 +6,7 @@ priority=3
groups=sbuild,root
root-groups=root,sbuild
aliases=unstable,default
+message-verbosity=quiet
[sid-local]
description=Debian sid (unstable)
@@ -14,4 +15,4 @@ priority=3
groups=sbuild,root
root-groups=root,sbuild
directory=/srv/chroot/sid
-
+message-verbosity=verbose
diff --git a/test/sbuild-chroot.cc b/test/sbuild-chroot.cc
index 8796baa9..850a7aa0 100644
--- a/test/sbuild-chroot.cc
+++ b/test/sbuild-chroot.cc
@@ -114,6 +114,8 @@ class test_chroot : public test_chroot_base<basic_chroot>
CPPUNIT_TEST(test_environment_filter);
CPPUNIT_TEST(test_active);
CPPUNIT_TEST(test_run_setup_scripts);
+ CPPUNIT_TEST(test_verbose);
+ CPPUNIT_TEST_EXCEPTION(test_verbose_error, sbuild::chroot::error);
CPPUNIT_TEST(test_chroot_type);
CPPUNIT_TEST(test_setup_env);
CPPUNIT_TEST(test_setup_keyfile);
@@ -216,6 +218,25 @@ public:
CPPUNIT_ASSERT(chroot->get_run_setup_scripts() == true);
}
+ void test_verbose()
+ {
+ std::tr1::shared_ptr<basic_chroot> c = std::tr1::dynamic_pointer_cast<basic_chroot>(chroot);
+
+ CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::VERBOSITY_QUIET);
+ c->set_verbosity(sbuild::chroot::VERBOSITY_VERBOSE);
+ CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::VERBOSITY_VERBOSE);
+ CPPUNIT_ASSERT(std::string(chroot->get_verbosity_string()) == "verbose");
+ c->set_verbosity("normal");
+ CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::VERBOSITY_NORMAL);
+ CPPUNIT_ASSERT(std::string(chroot->get_verbosity_string()) == "normal");
+ }
+
+ void test_verbose_error()
+ {
+ std::tr1::shared_ptr<basic_chroot> c = std::tr1::dynamic_pointer_cast<basic_chroot>(chroot);
+ c->set_verbosity("invalid");
+ }
+
void test_chroot_type()
{
CPPUNIT_ASSERT(chroot->get_chroot_type() == "test");
diff --git a/test/test-sbuild-chroot.h b/test/test-sbuild-chroot.h
index cedb7c41..99f95892 100644
--- a/test/test-sbuild-chroot.h
+++ b/test/test-sbuild-chroot.h
@@ -149,6 +149,7 @@ public:
chroot->set_root_users(sbuild::split_string("user3,user4", ","));
chroot->set_groups(sbuild::split_string("group1,group2", ","));
chroot->set_root_groups(sbuild::split_string("group3,group4", ","));
+ chroot->set_verbosity("quiet");
sbuild::chroot_facet_personality::ptr pfac
(chroot->get_facet<sbuild::chroot_facet_personality>());
@@ -193,6 +194,7 @@ public:
SBUILD_DEFAULT_ENVIRONMENT_FILTER);
keyfile.set_value(group, "command-prefix", "");
keyfile.set_value(group, "script-config", "default/config");
+ keyfile.set_value(group, "message-verbosity", "quiet");
}
void setup_keyfile_session (sbuild::keyfile& keyfile,