Hello community,
here is the log from the commit of package cryptconfig
checked in at Sat Nov 3 16:14:25 CET 2007.
--------
--- cryptconfig/cryptconfig.changes 2007-06-11 11:35:00.000000000 +0200
+++ /mounts/work_src_done/STABLE/cryptconfig/cryptconfig.changes 2007-11-02 17:22:49.859110000 +0100
@@ -1,0 +2,10 @@
+Fri Nov 2 17:19:19 CET 2007 - crivera@suse.de
+
+- Don't fail if some pam service files don't exist. This fixes
+ 326794.
+- Use loop ioctls instead of the losetup binary.
+- Add memory locking to protect passpharses and key data.
+- Allow for sizes like "1G" and "200M" to be given on the command
+ line.
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ cryptconfig.spec ++++++
--- /var/tmp/diff_new_pack.EH1318/_old 2007-11-03 16:14:05.000000000 +0100
+++ /var/tmp/diff_new_pack.EH1318/_new 2007-11-03 16:14:05.000000000 +0100
@@ -12,11 +12,11 @@
Name: cryptconfig
Version: 0.1.0
-Release: 44
+Release: 79
Group: System/Base
-License: GNU Library General Public License v. 2.0 and 2.1 (LGPL)
+License: GPL v2 or later
Summary: A Utility to Configure Encrypted Home Directories and LUKS Partitions
-Autoreqprov: on
+AutoReqProv: on
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: util-linux cryptsetup pam_mount >= 0.18-32 glib2 >= 2.8 openssl >= 0.9.7
BuildRequires: cryptsetup glib2-devel >= 2.8 intltool openssl-devel >= 0.9.7 pam-devel util-linux
@@ -60,8 +60,14 @@
%{_sbindir}/cryptconfig
%{_sysconfdir}/cryptconfig.conf
%doc %{_mandir}/man8/cryptconfig.8.gz
-
%changelog
+* Fri Nov 02 2007 - crivera@suse.de
+- Don't fail if some pam service files don't exist. This fixes
+ 326794.
+- Use loop ioctls instead of the losetup binary.
+- Add memory locking to protect passpharses and key data.
+- Allow for sizes like "1G" and "200M" to be given on the command
+ line.
* Mon Jun 11 2007 - aj@suse.de
- Change Requires as well.
* Fri Jun 01 2007 - lnussel@suse.de
++++++ cryptconfig-0.1.0.tar.gz ++++++
++++ 23591 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/ChangeLog new/cryptconfig-0.1.0/ChangeLog
--- old/cryptconfig-0.1.0/ChangeLog 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/ChangeLog 2007-11-02 17:15:39.000000000 +0100
@@ -1,3 +1,45 @@
+2007-11-02 Chris Rivera
+
+ * src/cryptconfig-lib.c: Don't fail if
+ the pam service files don't exist. This fixes
+ 326794.
+
+2007-07-09 Chris Rivera
+
+ * src/*: Add memory locking to protect passphrases and
+ decrypted key data.
+
+ * src/cryptconfig-lib.c: Use O_LARGEFILE to open the image.
+
+ * src/cryptconfig.c: Retain the permissions of the key
+ when changing the password.
+
+2007-07-06 Chris Rivera
+
+ * cryptconfig.spec: Update the Requires and BuildRequires.
+
+ * configure.in:
+
+ Remove the check for the losetup binary. Fix the checks for
+ the crypto and pam headers.
+
+ * src/Makefile.am:
+
+ Remove the check for the losetup binary.
+
+ * src/cryptconfig.c:
+
+ Use parse_size () to allow sizes like "1G" or "200M".
+
+ * src/cryptconfig-lib.c:
+
+ Add parse_size().
+ Rename is_pam_mount_setup_for_user() to pam_mount_is_setup_for_user().
+
+ Use LOOP_SET_FD and LOOP_CLR_FD ioctls instead of execing losetup.
+
+ * src/pam_cryptpass.c: simplify get_key_file().
+
2007-03-29 Chris Rivera
* src/cryptconfig-lib.c:
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/compile new/cryptconfig-0.1.0/compile
--- old/cryptconfig-0.1.0/compile 2007-01-11 18:38:37.000000000 +0100
+++ new/cryptconfig-0.1.0/compile 1970-01-01 01:00:00.000000000 +0100
@@ -1,142 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand `-c -o'.
-
-scriptversion=2005-05-14.22
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
-# Written by Tom Tromey .
-#
-# This program 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 2, or (at your option)
-# any later version.
-#
-# This program 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This file is maintained in Automake, please report
-# bugs to or send patches to
-# .
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: compile [--help] [--version] PROGRAM [ARGS]
-
-Wrapper for compilers which do not understand `-c -o'.
-Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
-arguments, and rename the output as expected.
-
-If you are trying to build a whole package this is not the
-right script to run: please start by reading the file `INSTALL'.
-
-Report bugs to .
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "compile $scriptversion"
- exit $?
- ;;
-esac
-
-ofile=
-cfile=
-eat=
-
-for arg
-do
- if test -n "$eat"; then
- eat=
- else
- case $1 in
- -o)
- # configure might choose to run compile as `compile cc -o foo foo.c'.
- # So we strip `-o arg' only if arg is an object.
- eat=1
- case $2 in
- *.o | *.obj)
- ofile=$2
- ;;
- *)
- set x "$@" -o "$2"
- shift
- ;;
- esac
- ;;
- *.c)
- cfile=$1
- set x "$@" "$1"
- shift
- ;;
- *)
- set x "$@" "$1"
- shift
- ;;
- esac
- fi
- shift
-done
-
-if test -z "$ofile" || test -z "$cfile"; then
- # If no `-o' option was seen then we might have been invoked from a
- # pattern rule where we don't need one. That is ok -- this is a
- # normal compilation that the losing compiler can handle. If no
- # `.c' file was seen then we are probably linking. That is also
- # ok.
- exec "$@"
-fi
-
-# Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
-
-# Create the lock directory.
-# Note: use `[/.-]' here to ensure that we don't use the same name
-# that we are using for the .o file. Also, base the name on the expected
-# object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
-while true; do
- if mkdir "$lockdir" >/dev/null 2>&1; then
- break
- fi
- sleep 1
-done
-# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
-
-# Run the compile.
-"$@"
-ret=$?
-
-if test -f "$cofile"; then
- mv "$cofile" "$ofile"
-elif test -f "${cofile}bj"; then
- mv "${cofile}bj" "$ofile"
-fi
-
-rmdir "$lockdir"
-exit $ret
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/config.h.in new/cryptconfig-0.1.0/config.h.in
--- old/cryptconfig-0.1.0/config.h.in 2007-03-30 02:24:51.000000000 +0200
+++ new/cryptconfig-0.1.0/config.h.in 2007-11-02 17:16:22.000000000 +0100
@@ -24,9 +24,6 @@
/* Define if your file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
-/* Define to 1 if you have the `crypto' library (-lcrypto). */
-#undef HAVE_LIBCRYPTO
-
/* Define to 1 if you have the header file. */
#undef HAVE_LINUX_LOOP_H
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/configure.in new/cryptconfig-0.1.0/configure.in
--- old/cryptconfig-0.1.0/configure.in 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/configure.in 2007-07-06 23:03:54.000000000 +0200
@@ -22,14 +22,35 @@
dnl Required headers
dnl
AC_HEADER_STDC
-AC_CHECK_HEADERS(security/pam_modules.h linux/loop.h syslog.h sys/mount.h)
+
+AC_CHECK_HEADERS(syslog.h sys/mount.h,
+ HAVE_GLIBC_HEADERS="yes", HAVE_GLIBC_HEADERS="no")
+if test "x$HAVE_GLIBC_HEADERS" = "xno"; then \
+ AC_ERROR([Missing glibc-devel])
+fi
+
+AC_CHECK_HEADERS(linux/loop.h,
+ HAVE_KERNEL_HEADERS="yes", HAVE_KERNEL_HEADERS="no")
+if test "x$HAVE_KERNEL_HEADERS" = "xno"; then \
+ AC_ERROR([Missing linux-kernel-headers])
+fi
+
+AC_CHECK_HEADERS(security/pam_modules.h,
+ HAVE_PAM_HEADERS="yes", HAVE_PAM_HEADERS="no")
+if test "x$HAVE_PAM_HEADERS" = "xno"; then \
+ AC_ERROR([Missing pam-devel])
+fi
dnl
dnl Check for library funcs
dnl
-AC_CHECK_LIB(crypto, EVP_DecryptInit_ex)
+AC_CHECK_LIB(crypto, EVP_DecryptInit_ex, HAVE_PROPER_CRYPTO="yes")
AC_FUNC_MEMCMP
+if test "x$HAVE_PROPER_CRYPTO" = "x"; then \
+ AC_ERROR([Missing proper EVP crypt functions])
+fi
+
dnl
dnl Translation support
dnl
@@ -60,11 +81,6 @@
AC_MSG_ERROR(mkfs is not installed.)
fi
-AC_PATH_PROG(LOSETUP_BIN_PATH, losetup, [], [$PATH:/sbin:/usr/sbin])
-if ! test -x "$LOSETUP_BIN_PATH"; then
- AC_MSG_ERROR(losetup is not installed.)
-fi
-
AC_PATH_PROG(CRYPTSETUP_BIN_PATH, cryptsetup, [], [$PATH:/sbin:/usr/sbin])
if ! test -x "$CRYPTSETUP_BIN_PATH"; then
AC_MSG_ERROR(cryptsetup is not installed.)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/intltool-extract.in new/cryptconfig-0.1.0/intltool-extract.in
--- old/cryptconfig-0.1.0/intltool-extract.in 2007-03-30 02:24:44.000000000 +0200
+++ new/cryptconfig-0.1.0/intltool-extract.in 2007-11-02 17:15:48.000000000 +0100
@@ -32,7 +32,7 @@
## Release information
my $PROGRAM = "intltool-extract";
my $PACKAGE = "intltool";
-my $VERSION = "0.35.2";
+my $VERSION = "0.35.5";
## Loaded modules
use strict;
@@ -261,8 +261,11 @@
sub type_ini {
### For generic translatable desktop files ###
- while ($input =~ /^_.*=(.*)$/mg) {
- $messages{$1} = [];
+ while ($input =~ /^(#(.+)\n)?^_.*=(.*)$/mg) {
+ if (defined($2)) {
+ $comments{$3} = $2;
+ }
+ $messages{$3} = [];
}
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/intltool-merge.in new/cryptconfig-0.1.0/intltool-merge.in
--- old/cryptconfig-0.1.0/intltool-merge.in 2007-03-30 02:24:44.000000000 +0200
+++ new/cryptconfig-0.1.0/intltool-merge.in 2007-11-02 17:15:48.000000000 +0100
@@ -35,7 +35,7 @@
## Release information
my $PROGRAM = "intltool-merge";
my $PACKAGE = "intltool";
-my $VERSION = "0.35.2";
+my $VERSION = "0.35.5";
## Loaded modules
use strict;
@@ -1017,8 +1017,8 @@
if ($MULTIPLE_OUTPUT) {
for my $lang (sort keys %po_files_by_lang) {
- if ( ! -e $lang ) {
- mkdir $lang or die "Cannot create subdirectory $lang: $!\n";
+ if ( ! -d $lang ) {
+ mkdir $lang or -d $lang or die "Cannot create subdirectory $lang: $!\n";
}
open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
binmode (OUTPUT) if $^O eq 'MSWin32';
@@ -1386,8 +1386,8 @@
}
for my $lang (sort keys %po_files_by_lang) {
- if ( ! -e $lang ) {
- mkdir $lang or die "Cannot create subdirectory $lang: $!\n";
+ if ( ! -d $lang ) {
+ mkdir $lang or -d $lang or die "Cannot create subdirectory $lang: $!\n";
}
open INPUT, "<${FILE}" or die;
open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/intltool-update.in new/cryptconfig-0.1.0/intltool-update.in
--- old/cryptconfig-0.1.0/intltool-update.in 2007-03-30 02:24:44.000000000 +0200
+++ new/cryptconfig-0.1.0/intltool-update.in 2007-11-02 17:15:48.000000000 +0100
@@ -30,7 +30,7 @@
## Release information
my $PROGRAM = "intltool-update";
-my $VERSION = "0.35.2";
+my $VERSION = "0.35.5";
my $PACKAGE = "intltool";
## Loaded modules
@@ -565,14 +565,11 @@
sub GenerateHeaders
{
- my $EXTRACT = "@INTLTOOL_EXTRACT@";
- chomp $EXTRACT;
-
- $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
+ my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
## Generate the .h header files, so we can allow glade and
## xml translation support
- if (! -x "$EXTRACT")
+ if (0)
{
print STDERR "\n *** The intltool-extract script wasn't found!"
."\n *** Without it, intltool-update can not generate files.\n";
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/missing new/cryptconfig-0.1.0/missing
--- old/cryptconfig-0.1.0/missing 2007-01-11 18:38:37.000000000 +0100
+++ new/cryptconfig-0.1.0/missing 2007-09-21 21:04:31.000000000 +0200
@@ -1,9 +1,9 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
-scriptversion=2005-06-08.21
+scriptversion=2006-05-10.23
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard , 1996.
@@ -33,6 +33,8 @@
fi
run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
@@ -44,7 +46,7 @@
msg="missing on your system"
-case "$1" in
+case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
@@ -77,6 +79,7 @@
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
@@ -106,7 +109,7 @@
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
-case "$1" in
+case $1 in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
@@ -135,7 +138,7 @@
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
-case "$1" in
+case $1 in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
@@ -164,7 +167,7 @@
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
- case "$f" in
+ case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
@@ -192,8 +195,8 @@
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
- file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
- test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
@@ -214,25 +217,25 @@
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
- if [ $# -ne 1 ]; then
+ if test $# -ne 1; then
eval LASTARG="\${$#}"
- case "$LASTARG" in
+ case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
- if [ ! -f y.tab.h ]; then
+ if test ! -f y.tab.h; then
echo >y.tab.h
fi
- if [ ! -f y.tab.c ]; then
+ if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
@@ -244,18 +247,18 @@
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
- if [ $# -ne 1 ]; then
+ if test $# -ne 1; then
eval LASTARG="\${$#}"
- case "$LASTARG" in
+ case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
- if [ ! -f lex.yy.c ]; then
+ if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
@@ -267,11 +270,9 @@
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
- fi
- if [ -f "$file" ]; then
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
@@ -289,11 +290,17 @@
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
@@ -317,13 +324,13 @@
fi
firstarg="$1"
if shift; then
- case "$firstarg" in
+ case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
- case "$firstarg" in
+ case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/src/cryptconfig.c new/cryptconfig-0.1.0/src/cryptconfig.c
--- old/cryptconfig-0.1.0/src/cryptconfig.c 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/src/cryptconfig.c 2007-11-02 17:12:48.000000000 +0100
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include "cryptconfig.h"
@@ -70,7 +71,7 @@
gchar *key_data = NULL, *map_dev = NULL, *temp_dir = NULL;
gchar *user_field, *prompt = NULL, *extra_key_file = NULL;
int key_size = KEY_DATA_SIZE;
- long image_size, req_fs_size;
+ gint64 image_size, req_fs_size;
struct passwd *pent;
GOptionEntry entries[] = {
@@ -79,7 +80,8 @@
{ "no-copy", 0, 0, G_OPTION_ARG_NONE, &no_copy, N_("Don't copy user's existing data"), NULL },
{ "random", 0, 0, G_OPTION_ARG_NONE, &random_data, N_("Use random data to fill the image"), NULL },
{ "force", 0, 0, G_OPTION_ARG_NONE, &force, N_("Overwrite existing image and key"), NULL },
- { "remove-data", 0, 0, G_OPTION_ARG_NONE, &unlink_old_home, N_("Remove the old home directory after data is copied"), NULL },
+ { "remove-data", 0, 0, G_OPTION_ARG_NONE, &unlink_old_home, N_("Remove the old home "
+ "directory after data is copied"), NULL },
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace an existing user entry in pam_mount"), NULL },
{ "fs-type", 0, 0, G_OPTION_ARG_STRING, &fs_type, N_("The filesystem type. The default is ext3"), NULL },
{ "image-file", 0, 0, G_OPTION_ARG_STRING, &image_file,
@@ -126,15 +128,14 @@
}
/* validate image size */
- image_size = strtol (argv[3], NULL, 0);
- if (image_size < 0 || image_size == LONG_MIN || image_size == LONG_MAX) {
+ if (!parse_size (argv[3], &image_size)) {
g_printerr (_("Invalid image size\n"));
return FALSE;
}
/* check image size against the min fs size */
if (!check_min_fs_size (fs_type, image_size, &req_fs_size)) {
- g_printerr (_("The image_size must be at least %ld MBs for the "
+ g_printerr (_("The image_size must be at least %lld MBs for the "
"chosen file system.\n"), req_fs_size);
return FALSE;
}
@@ -147,7 +148,7 @@
}
/* make sure pam_mount is not configured for this user already */
- if (is_pam_mount_setup_for_user (user_field)) {
+ if (pam_mount_is_setup_for_user (user_field, NULL, NULL)) {
if (!replace) {
g_printerr (_("pam_mount is already setup for %s. "
"Use --replace to replace the existing entry\n"), user_field);
@@ -180,6 +181,13 @@
goto cleanup;
}
+ /* make sure there's enough space on the disk */
+ if (!check_requested_space (image_dir, image_size)) {
+ g_printerr (_("Not enough space to create %s\n"), image_file);
+ g_free (image_dir);
+ goto cleanup;
+ }
+
g_free (image_dir);
}
@@ -383,6 +391,16 @@
final_ret = TRUE;
cleanup:
+ if (key_data) {
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
+ }
+
+ if (pass) {
+ memset (pass, 0, strlen (pass));
+ munlock (pass, strlen (pass));
+ }
+
/*
* Clean up after ourselves. Some of this stuff might fail,
* but we can't do much about it at this point.
@@ -414,7 +432,7 @@
GError *err = NULL;
GOptionContext *ctx;
gchar *dev, *pass = NULL, *base = NULL, *map_dev = NULL, *fs_type = "ext3";
- gboolean ret, no_verify = FALSE;
+ gboolean ret, no_verify = FALSE, retval = FALSE;
struct stat info;
GOptionEntry entries[] = {
@@ -464,8 +482,7 @@
if (!no_verify) {
char answer[4];
- //FIXME: this is pretty broken
- g_print (_("Are you sure you want to format %s (y/N)? "), dev);
+ g_print ("Are you sure you want to format %s (y/N)? ", dev);
if (read (STDIN_FILENO, answer, 4) == -1)
return FALSE;
@@ -504,14 +521,21 @@
}
g_print (_("Done\n"));
+ retval = TRUE;
+
cleanup:
+ if (pass) {
+ memset (pass, 0, strlen (pass));
+ munlock (pass, strlen (pass));
+ }
+
if (g_file_test (map_dev, G_FILE_TEST_EXISTS))
luks_close (map_dev);
g_free (pass);
g_free (base);
g_free (map_dev);
- return TRUE;
+ return retval;
}
/*
@@ -524,9 +548,9 @@
gchar *image_file, *fs_type = "ext3", *pass_new = NULL;
gchar *loop_device = NULL, *map_name = NULL, *map_dev = NULL;
gchar *key_data = NULL, *pass = NULL, *key_file = NULL, *prompt = NULL;
- gchar *extra_key_file = NULL, *existing_key_file = NULL;
+ gchar *extra_key_file = NULL, *existing_key_file = NULL, *image_dir = NULL;
gboolean ret, random_data = FALSE, no_verify = FALSE, force = FALSE, retval = FALSE;
- long image_size, req_fs_size;
+ gint64 image_size, req_fs_size;
size_t pass_len;
int key_size = KEY_DATA_SIZE;
@@ -560,8 +584,7 @@
image_file = argv[2];
/* validate our image size */
- image_size = strtol (argv[3], NULL, 0);
- if (image_size < 0 || image_size == LONG_MIN || image_size == LONG_MAX) {
+ if (!parse_size (argv[3], &image_size)) {
g_printerr (_("Invalid image size\n"));
return FALSE;
}
@@ -583,11 +606,18 @@
/* check image size against the min fs size */
if (!check_min_fs_size (fs_type, image_size, &req_fs_size)) {
- g_printerr (_("The image_size must be at least %ld MBs for the "
+ g_printerr (_("The image_size must be at least %lld MBs for the "
"chosen file system.\n"), req_fs_size);
return FALSE;
}
+ /* make sure there's enough space on the disk */
+ image_dir = g_path_get_dirname (image_file);
+ if (!check_requested_space (image_dir, image_size)) {
+ g_printerr (_("Not enough space to create %s\n"), image_file);
+ goto cleanup;
+ }
+
/* display the correct prompt */
if (existing_key_file) {
prompt = _("Enter the password for the existing key file ");
@@ -630,7 +660,7 @@
/* we need to generate a new key file */
if (!force && g_file_test (key_file, G_FILE_TEST_EXISTS)) {
g_printerr (_("%s already exists. Use --force to overwrite.\n"), key_file);
- return FALSE;
+ goto cleanup;
}
if (!get_random_key_data (&key_data, key_size)) {
@@ -694,7 +724,7 @@
}
if (!luks_open (pass, pass_len, loop_device, map_name)) {
- g_printerr (_("Failed to format device\n"));
+ g_printerr (_("Failed to open device\n"));
goto cleanup;
}
@@ -707,6 +737,16 @@
retval = TRUE;
cleanup:
+ if (key_data) {
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
+ }
+
+ if (pass_new) {
+ memset (pass_new, 0, strlen (pass_new));
+ munlock (pass_new, strlen (pass_new));
+ }
+
if (g_file_test (map_dev, G_FILE_TEST_EXISTS))
luks_close (map_name);
if (loop_device)
@@ -719,6 +759,7 @@
g_free (map_dev);
g_free (extra_key_file);
g_free (existing_key_file);
+ g_free (image_dir);
return retval;
}
@@ -727,7 +768,7 @@
*/
static gboolean command_enlarge_image (char *cmd, int argc, char *argv[])
{
- long size;
+ gint64 size;
GError *err = NULL;
GOptionContext *ctx;
gchar *loop_device = NULL, *key_file = NULL, *map_device = NULL;
@@ -754,8 +795,7 @@
g_option_context_free (ctx);
/* validate size and image location */
- size = strtol (argv[3], NULL, 0);
- if (size < 0 || size == LONG_MIN || size == LONG_MAX) {
+ if (!parse_size (argv[3], &size)) {
g_printerr (_("Invalid size\n"));
return FALSE;
}
@@ -804,9 +844,10 @@
{
GError *err = NULL;
GOptionContext *ctx;
- gchar *pass_old, *pass_new, *key_data;
- int key_size;
- gboolean ret, no_verify = FALSE;
+ gchar *pass_old = NULL, *pass_new = NULL, *key_data = NULL;
+ int key_size = 0;
+ gboolean ret, no_verify = FALSE, retval = FALSE;
+ struct stat info;
GOptionEntry entries[] = {
{ "no-verify", 0, 0, G_OPTION_ARG_NONE, &no_verify, N_("Don't verify the new password"), NULL },
@@ -829,8 +870,8 @@
g_option_context_free (ctx);
/* make sure the key exists */
- if (!g_file_test (argv[2], G_FILE_TEST_EXISTS)) {
- g_printerr (_("key file '%s' does not exist.\n"), argv[2]);
+ if (stat (argv[2], &info)) {
+ g_printerr (_("Failed to stat '%s': %s\n"), argv[2], strerror (errno));
return FALSE;
}
@@ -843,28 +884,49 @@
g_print ("\n");
if (!get_passphrase (_("Enter the NEW password"), !no_verify, &pass_new)) {
g_printerr (_("Failed to get new password\n"));
- g_free (pass_old);
- return FALSE;
+ goto cleanup;
}
/* decrypt and re-encrypt the key */
g_print ("\n");
if (!decrypt_key (argv[2], pass_old, &key_data, &key_size)) {
g_printerr (_("Failed to decrypt key with old password.\n"));
- g_free (pass_old);
- g_free (pass_new);
- return FALSE;
+ goto cleanup;
}
if (!encrypt_key (argv[2], pass_new, key_data, key_size)) {
g_printerr (_("Failed to encrypt new key\n"));
- g_free (pass_old);
- g_free (pass_new);
- return FALSE;
+ goto cleanup;
+ }
+
+ if (chown (argv[2], info.st_uid, 0) || chmod (argv[2], 0600)) {
+ g_printerr (_("Failed to retain permissions for %s\n"), argv[2]);
+ goto cleanup;
}
+ retval = TRUE;
g_print (_("Done.\n"));
- return TRUE;
+
+cleanup:
+ if (key_data) {
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
+ }
+
+ if (pass_old) {
+ memset (pass_old, 0, strlen (pass_old));
+ munlock (pass_old, strlen (pass_old));
+ }
+
+ if (pass_new) {
+ memset (pass_new, 0, strlen (pass_new));
+ munlock (pass_new, strlen (pass_new));
+ }
+
+ g_free (pass_old);
+ g_free (pass_new);
+ g_free (key_data);
+ return retval;
}
/*
@@ -880,8 +942,10 @@
GOptionEntry entries[] = {
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace an existing user entry in pam_mount"), NULL },
- { "image-file", 0, 0, G_OPTION_ARG_STRING, &image_file, N_("The user's home image file, defaults to /home/$USER.img"), NULL },
- { "key-file", 0, 0, G_OPTION_ARG_STRING, &key_file, N_("The user's image key file, defaults to /home/$USER.key"), NULL },
+ { "image-file", 0, 0, G_OPTION_ARG_STRING, &image_file,
+ N_("The user's home image file, defaults to /home/$USER.img"), NULL },
+ { "key-file", 0, 0, G_OPTION_ARG_STRING, &key_file,
+ N_("The user's image key file, defaults to /home/$USER.key"), NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@@ -908,7 +972,7 @@
}
/* make sure pam_mount is not configured for this user already */
- if (is_pam_mount_setup_for_user (argv[2])) {
+ if (pam_mount_is_setup_for_user (argv[2], NULL, NULL)) {
if (!replace) {
g_printerr (_("pam_mount is already setup for %s. "
"Use --replace to replace the existing entry\n"), argv[2]);
@@ -1079,6 +1143,16 @@
g_print (_("Done.\n"));
cleanup:
+ if (password) {
+ memset (password, 0, strlen (password));
+ munlock (password, strlen (password));
+ }
+
+ if (key_data) {
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
+ }
+
g_free (password);
g_free (key_data);
return retval;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/src/cryptconfig.h new/cryptconfig-0.1.0/src/cryptconfig.h
--- old/cryptconfig-0.1.0/src/cryptconfig.h 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/src/cryptconfig.h 2007-11-02 17:12:48.000000000 +0100
@@ -31,13 +31,13 @@
gboolean encrypt_key (const char *key_file, const char *pass_new,
const char *key_data, int key_size);
-gboolean loop_open (char *image, char **device);
-gboolean loop_close (char *loop_device);
+gboolean loop_open (const char *image, char **device);
+gboolean loop_close (const char *loop_device);
gboolean loop_find_devs_from_image (const char *image,
gchar **map_dev, gchar **loop_dev);
-gboolean create_image_zero (const char *image, int size_in_mb);
-gboolean create_image_random (const char *image, int size_in_mb);
+gboolean create_image_zero (const char *image, guint64 size_in_mb);
+gboolean create_image_random (const char *image, guint64 size_in_mb);
gchar *get_supported_filesystems (void);
gboolean is_mounted (const char *dev);
@@ -45,22 +45,24 @@
gboolean is_filesystem_supported (const char *fs_type);
gboolean create_filesystem (char *device, char *fs_type);
gboolean resize_filesystem (char *device);
-gboolean check_min_fs_size (const char *fs_type, long image_size, long *req_size);
+gboolean check_min_fs_size (const char *fs_type, gint64 image_size, gint64 *req_size);
+gboolean pam_mount_is_setup_for_user (const char * user, char **image, char **key);
gboolean enable_pam_mount (const char *user, const char *image_file, const char *key_file);
-gboolean is_pam_mount_setup_for_user (const char * user);
gboolean disable_pam_mount (const char *user);
gboolean disable_pam_mount_all (void);
gchar *path_to_map_name (const char *path);
gboolean unlock_image (const char *image_file, const char *key_file, char **map_device, char **loop_dev);
gboolean check_disk_space (char *image, char *current_home, guint64 *home_size);
+gboolean check_requested_space (const char *path, guint64 req_size);
gboolean copy_user_data (const char *src, const char *dest);
gboolean get_passphrase (const char *prompt, int verify, gchar **passphrase);
-gboolean enlarge_image (const char *image, int size_to_add_in_mb);
+gboolean enlarge_image (const char *image, guint64 size_to_add_in_mb);
gboolean get_random_key_data (gchar **key_data, size_t key_size);
gboolean temp_mount (char *fs_type, char *device, char **mount_point);
gboolean mount_dev (char *fs_type, char *device, char *mount_point);
gboolean remove_home_directory (struct passwd *pent);
+gboolean parse_size (const char *arg, gint64 *size_in_mb);
#endif
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/src/cryptconfig-lib.c new/cryptconfig-0.1.0/src/cryptconfig-lib.c
--- old/cryptconfig-0.1.0/src/cryptconfig-lib.c 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/src/cryptconfig-lib.c 2007-11-02 17:14:29.000000000 +0100
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#include "cryptconfig.h"
@@ -142,7 +143,7 @@
}
/*
- * Open file, write it's contents to a temp file based on the match_cb,
+ * Open file, write it's contents to a temp file and filter based on the match_cb,
* and then replace file with the temp file. The match_cb should return
* TRUE if the line should be written to the new file and FALSE otherwise.
*/
@@ -390,6 +391,12 @@
int fd;
char buff[BUFF_SIZE];
+ if (!list[i])
+ break;
+
+ if (!g_file_test (list[i], G_FILE_TEST_EXISTS))
+ continue;
+
fd = open (list[i], O_RDWR | O_APPEND);
if (fd == -1) {
g_printerr (_("open: %s\n"), strerror (errno));
@@ -482,6 +489,9 @@
if (!list[i])
break;
+ if (!g_file_test (list[i], G_FILE_TEST_EXISTS))
+ continue;
+
fd = open (list[i], O_RDWR | O_APPEND);
if (fd == -1) {
continue;
@@ -529,7 +539,7 @@
/*
* Parse the pam_mount config to see if pam_mount is setup.
*/
-static gboolean is_pam_mount_setup (void)
+static gboolean pam_mount_is_setup (void)
{
FILE *fs;
char line[BUFF_SIZE];
@@ -553,7 +563,7 @@
/*
* Return TRUE is user has an entry in pam_mount.conf
*/
-gboolean is_pam_mount_setup_for_user (const char * user)
+gboolean pam_mount_is_setup_for_user (const char *user, char **image, char **key)
{
FILE *fs;
char line[BUFF_SIZE];
@@ -568,7 +578,25 @@
while (fgets (line, BUFF_SIZE, fs)) {
if (line[0] != '#' && strstr (line, needle)) {
+ int n = 0;
+ gchar **fields = g_strsplit (line, " ", 0);
+
fclose (fs);
+ for (; fields[n]; n++);
+
+ if (n < 9) {
+ g_strfreev (fields);
+ g_printerr ("invalid line in " PAM_MOUNT_CONF "\n");
+ return FALSE;
+ }
+
+ if (image)
+ *image = g_strdup (fields[4]);
+
+ if (key)
+ *key = g_strchomp (g_strdup (fields[8]));
+
+ g_strfreev (fields);
return TRUE;
}
}
@@ -728,14 +756,14 @@
/*
* Decrypt the encrypted key file using password. The key_data
- * field needs to be freed by the caller.
+ * field needs to be unlocked and freed by the caller.
*/
gboolean decrypt_key (const char *key_file, const char *password,
char **key_data, int *key_data_size)
{
const EVP_CIPHER *cipher = EVP_aes_256_cbc ();
const EVP_MD *md = EVP_md5 ();
- size_t hk_sz, total_size;
+ size_t hk_sz, total_size = 0;
int fd, final_size, kd_size;
gboolean ret = FALSE;
struct stat info;
@@ -781,6 +809,7 @@
kd_size = 0;
total_size = 10 * EVP_MAX_BLOCK_LENGTH;
*key_data = g_malloc (total_size);
+ mlock (*key_data, total_size);
while (1) {
size_t n;
@@ -798,6 +827,7 @@
if (total_size - kd_size < n + EVP_MAX_BLOCK_LENGTH) {
total_size *= 2;
*key_data = g_realloc (*key_data, total_size);
+ mlock (*key_data, total_size);
}
if (!EVP_DecryptUpdate (&ctx, (unsigned char *) *key_data + kd_size,
@@ -811,6 +841,7 @@
if (total_size - kd_size < EVP_MAX_BLOCK_LENGTH) {
total_size *= 2;
*key_data = g_realloc (*key_data, total_size);
+ mlock (*key_data, total_size);
}
/* write out any remaining buffered data */
@@ -822,6 +853,13 @@
ret = TRUE;
error:
+ if (!ret && key_data) {
+ memset (*key_data, 0, total_size);
+ munlock (*key_data, total_size);
+ g_free (*key_data);
+ *key_data = NULL;
+ }
+
close (fd);
EVP_CIPHER_CTX_cleanup (&ctx);
return ret;
@@ -923,27 +961,55 @@
* loop device used. The device string must be freed by
* the caller.
*/
-gboolean loop_open (char *image, char **device)
+gboolean loop_open (const char *image, char **device)
{
- gchar *argv[] = { LOSETUP_BIN_PATH, NULL, image, NULL };
- GError *err;
- gint status;
- gboolean ret;
+ gboolean ret = FALSE;
+ int fd, loop_fd;
+ struct loop_info info;
+ *device = NULL;
if (!loop_get_open_device (device))
return FALSE;
- argv[1] = *device;
- ret = g_spawn_sync (NULL, argv, NULL,
- G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
- NULL, NULL, NULL, NULL, &status, &err);
- if (!ret) {
- g_printerr ("%s\n", err->message);
- g_error_free (err);
+ loop_fd = open (*device, O_RDWR | O_LARGEFILE);
+ if (loop_fd == -1) {
+ g_free (*device);
+ g_printerr ("read: %s\n", strerror (errno));
return FALSE;
}
- return WEXITSTATUS (status) ? FALSE : TRUE;
+ fd = open (image, O_RDWR | O_LARGEFILE);
+ if (fd == -1) {
+ g_free (*device);
+ g_printerr ("read: %s\n", strerror (errno));
+ close (loop_fd);
+ return FALSE;
+ }
+
+ memset(&info, 0, sizeof(info));
+ strncpy(info.lo_name, image, LO_NAME_SIZE);
+ info.lo_name[LO_NAME_SIZE-1] = '\0';
+
+ if (ioctl (loop_fd, LOOP_SET_FD, fd)) {
+ g_printerr ("ioctl: %s\n", strerror (errno));
+ goto cleanup;
+ }
+
+ if (ioctl (loop_fd, LOOP_SET_STATUS, &info)) {
+ g_printerr ("ioctl: %s\n", strerror (errno));
+ ioctl (loop_fd, LOOP_CLR_FD, 0);
+ goto cleanup;
+ }
+
+ ret = TRUE;
+
+cleanup:
+ if (!ret)
+ g_free (*device);
+
+ close (loop_fd);
+ close (fd);
+ return ret;
}
/*
@@ -1007,30 +1073,29 @@
/*
* Free a used loop device.
*/
-gboolean loop_close (char *loop_device)
+gboolean loop_close (const char *loop_device)
{
- gchar *argv[] = { LOSETUP_BIN_PATH, "-d", loop_device, NULL };
- GError *err;
- gint status;
- gboolean ret;
-
- ret = g_spawn_sync (NULL, argv, NULL,
- G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
- NULL, NULL, NULL, NULL, &status, &err);
- if (!ret) {
- g_error_free (err);
+ int loop_fd = open (loop_device, O_RDONLY);
+ if (loop_fd == -1) {
+ perror ("read");
return FALSE;
}
-
- return WEXITSTATUS (status) ? FALSE : TRUE;
+
+ if (ioctl (loop_fd, LOOP_CLR_FD, 0)) {
+ close (loop_fd);
+ return FALSE;
+ }
+
+ close (loop_fd);
+ return TRUE;
}
/*
* Create an image file that's filled with zeros
*/
-gboolean create_image_zero (const char *image, int size_in_mb)
+gboolean create_image_zero (const char *image, guint64 size_in_mb)
{
- long long bytes = (long long) size_in_mb * 1048576;
+ guint64 bytes = size_in_mb * 1048576;
int fd = open (image, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_LARGEFILE, 0600);
if (fd == -1) {
g_printerr ("open: %s\n", strerror (errno));
@@ -1055,9 +1120,9 @@
/*
* Create an image file that's filled with random data
*/
-gboolean create_image_random (const char *image, int size_in_mb)
+gboolean create_image_random (const char *image, guint64 size_in_mb)
{
- long long total = 0, target = (long long) size_in_mb * 1048576;
+ guint64 total = 0, target = size_in_mb * 1048576;
int fd, randfd;
gboolean ret;
char buff[BUFSIZ];
@@ -1156,7 +1221,7 @@
* Make sure the image size is greater than the minimum allowed size
* for the chosen file system.
*/
-gboolean check_min_fs_size (const char *fs_type, long image_size, long *req_size)
+gboolean check_min_fs_size (const char *fs_type, gint64 image_size, gint64 *req_size)
{
int i, len = sizeof(fs_min_sizes)/sizeof(fs_min_sizes[0]);
@@ -1171,6 +1236,32 @@
}
/*
+ * Ensure that we have at least 'size' bytes available on the partition
+ * containing 'path'.
+ */
+gboolean check_requested_space (const char *path, guint64 req_size)
+{
+ guint64 free_space;
+ struct statvfs info;
+ gchar *dir;
+
+ memset (&info, 0, sizeof (info));
+ dir = g_path_get_dirname (path);
+
+ if (statvfs (dir, &info) == -1) {
+ g_printerr ("statvfs: %s\n", strerror (errno));
+ g_free (dir);
+ return FALSE;
+ }
+
+ g_free (dir);
+ free_space = info.f_bavail * (guint64) info.f_bsize;
+ free_space = free_space / 1048576;
+
+ return free_space > req_size ? TRUE : FALSE;
+}
+
+/*
* Ensures that there is enough space to copy a user's current home
* directory to it's encrypted disk image.
*/
@@ -1180,7 +1271,9 @@
struct statvfs info;
gchar *dir;
+ memset (&info, 0, sizeof (info));
dir = g_path_get_dirname (image);
+
if (statvfs (dir, &info) == -1) {
g_printerr ("statvfs: %s\n", strerror (errno));
g_free (dir);
@@ -1313,7 +1406,7 @@
ret = filter_file (PAM_MOUNT_CONF, "pam-mount-conf-XXXXXX",
disable_pam_mount_cb, needle);
- if (ret && !is_pam_mount_setup ())
+ if (ret && !pam_mount_is_setup ())
return restore_pam_session_stacks ();
else
return ret;
@@ -1343,8 +1436,9 @@
/*
* Get a passphrase from standard in. If the verify flag is set then we prompt
- * the user again. The passphrase field needs to be freed by the caller if
- * TRUE is returned. We also turn off echo if STDIN is a terminal.
+ * the user again. We also turn off echo if STDIN is a terminal. The returned
+ * passphrase will also be mlocked. The passpharse field needs to be unlocked
+ * and freed if the call returns TRUE.
*/
gboolean get_passphrase (const char *prompt, gboolean verify, gchar **passphrase)
{
@@ -1379,7 +1473,9 @@
if (tty)
tcsetattr (STDIN_FILENO, TCSAFLUSH, &no_echo);
+ mlock (*passphrase, BUFF_SIZE);
(*passphrase)[BUFF_SIZE - 1] = '\0';
+
for (p = *passphrase; p1_len < BUFF_SIZE - 1; p++, p1_len++) {
n = read (STDIN_FILENO, p, 1);
if (n == -1) {
@@ -1423,6 +1519,8 @@
return TRUE;
error:
+ memset (*passphrase, 0, BUFF_SIZE);
+ munlock (*passphrase, BUFF_SIZE);
g_free (*passphrase);
*passphrase = NULL;
if (tty)
@@ -1434,9 +1532,9 @@
* Enlarge our disk image by seeking past the end of the file and writing
* a zero byte.
*/
-gboolean enlarge_image (const char *image, int size_to_add_in_mb)
+gboolean enlarge_image (const char *image, guint64 size_to_add_in_mb)
{
- off64_t total = (off64_t) size_to_add_in_mb * 1048576;
+ off64_t total = size_to_add_in_mb * 1048576;
int fd = open (image, O_WRONLY | O_LARGEFILE);
if (fd == -1) {
g_printerr ("open: %s\n", strerror (errno));
@@ -1465,8 +1563,8 @@
}
/*
- * Get random data for our new key. key_data needs to freed
- * by the caller.
+ * Get random data for our new key. key_data needs to be
+ * unlocked and freed by the caller.
*/
gboolean get_random_key_data (gchar **key_data, size_t key_size)
{
@@ -1477,8 +1575,10 @@
}
*key_data = g_malloc (key_size);
+ mlock (*key_data, key_size);
if (read (fd, *key_data, key_size) != key_size) {
+ munlock (*key_data, key_size);
g_free (*key_data);
*key_data = NULL;
close (fd);
@@ -1773,6 +1873,16 @@
ret = TRUE;
cleanup:
+ if (key_data) {
+ memset (key_data, 0, key_data_size);
+ munlock (key_data, key_data_size);
+ }
+
+ if (password) {
+ memset (password, 0, strlen (password));
+ munlock (password, strlen (password));
+ }
+
g_free (password);
g_free (map_name);
g_free (map_dev);
@@ -1794,13 +1904,13 @@
if (!g_file_test (extra_key_file, G_FILE_TEST_EXISTS)) {
g_printerr (_("Extra key file does not exist\n"));
- goto cleanup;
+ return FALSE;
}
if (!get_passphrase (_("\nEnter the password for the extra key"),
FALSE, &extra_pass)) {
g_printerr (_("Failed to get extra key password\n"));
- goto cleanup;
+ return FALSE;
}
g_print ("\n");
@@ -1818,6 +1928,16 @@
ret = TRUE;
cleanup:
+ if (extra_key_data) {
+ memset (extra_key_data, 0, extra_key_size);
+ munlock (extra_key_data, extra_key_size);
+ }
+
+ if (extra_pass) {
+ memset (extra_pass, 0, strlen (extra_pass));
+ munlock (extra_pass, strlen (extra_pass));
+ }
+
g_free (extra_pass);
g_free (extra_key_data);
return ret;
@@ -1844,3 +1964,33 @@
return WEXITSTATUS (status) ? FALSE : TRUE;
}
+
+/*
+ * Parse arg and set size to arg in MB.
+ */
+gboolean parse_size (const char *arg, gint64 *size)
+{
+ int m;
+ gint64 s = 0;
+ char unit = '\0';
+
+ m = sscanf (arg, "%lld%c", &s, &unit);
+ if (!m || s <= 0)
+ return FALSE;
+
+ switch (unit) {
+ case '\0':
+ case 'M':
+ *size = s;
+ return TRUE;
+ case 'G':
+ *size = s * 1024;
+ break;
+ case 'K':
+ *size = s / 1024;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/src/Makefile.am new/cryptconfig-0.1.0/src/Makefile.am
--- old/cryptconfig-0.1.0/src/Makefile.am 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/src/Makefile.am 2007-07-06 23:13:43.000000000 +0200
@@ -4,19 +4,18 @@
PROG_CFLAGS = -DDU_BIN_PATH=\"$(DU_BIN_PATH)\" \
-DMKFS_BIN_PATH=\"$(MKFS_BIN_PATH)\" \
- -DLOSETUP_BIN_PATH=\"$(LOSETUP_BIN_PATH)\" \
-DCRYPTSETUP_BIN_PATH=\"$(CRYPTSETUP_BIN_PATH)\" \
-DSYSCONFDIR=\"$(sysconfdir)\"
sbin_PROGRAMS = cryptconfig
cryptconfig_SOURCES = cryptconfig.c cryptconfig.h cryptconfig-lib.c
-cryptconfig_LDFLAGS = $(GLIB_LIBS)
+cryptconfig_LDFLAGS = $(GLIB_LIBS) `pkg-config --libs libcrypto`
cryptconfig_CFLAGS = $(AM_CFLAGS) $(WARNING_FLAGS) $(PROG_CFLAGS) $(GLIB_CFLAGS)
moduledir = @PAM_MODDIR@
module_LTLIBRARIES = pam_cryptpass.la
pam_cryptpass_la_SOURCES = cryptconfig.h cryptconfig-lib.c pam_cryptpass.c
-pam_cryptpass_la_LDFLAGS = -module -avoid-version -lpam $(GLIB_LIBS)
+pam_cryptpass_la_LDFLAGS = -module -avoid-version -lpam $(GLIB_LIBS) `pkg-config --libs libcrypto`
pam_cryptpass_la_CFLAGS = $(AM_CFLAGS) $(WARNING_FLAGS) $(PROG_CFLAGS) $(GLIB_CFLAGS)
CLEANFILES = $(sbin_PROGRAMS) $(module_LT_LIBRARIES)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/cryptconfig-0.1.0/src/pam_cryptpass.c new/cryptconfig-0.1.0/src/pam_cryptpass.c
--- old/cryptconfig-0.1.0/src/pam_cryptpass.c 2007-03-30 02:24:32.000000000 +0200
+++ new/cryptconfig-0.1.0/src/pam_cryptpass.c 2007-07-10 20:56:57.000000000 +0200
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
#define PAM_SM_PASSWORD
#define PAM_SM_SESSION
@@ -45,70 +46,39 @@
#include "cryptconfig.h"
/*
- * Parse pam_mount.conf and set key_file to the key file for user, if it exists.
+ * Set key_file to the key file for user, if it exists.
*/
static int get_key_file (const char *user, char *key_file, size_t kf_len)
{
- FILE *fp;
+ char *key_f = NULL, *image_f = NULL;
struct passwd *pent;
- int key_fd;
struct stat info;
- char line[BUFF_SIZE];
- char needle[BUFF_SIZE];
+ int key_fd, ret = -1;
pent = getpwnam (user);
if (!pent)
return -1;
- needle[BUFF_SIZE - 1] = '\0';
- snprintf (needle, BUFF_SIZE - 1, "volume %s crypt", user);
-
- fp = fopen (PAM_MOUNT_CONF, "r");
- if (!fp)
+ if (!pam_mount_is_setup_for_user (user, &image_f, &key_f))
return -1;
-
- /* parse pam_mount conf */
- while (fgets (line, BUFF_SIZE, fp)) {
- char *p;
- int ws_is_ok = 1;
-
- if (line[0] == '#' || !strstr (line, needle))
- continue;
-
- /* the key file should be the last field */
- for (p = &line[strlen (line) - 1]; p > line; p--) {
- if (*p == '\n' || *p == ' ') {
- if (ws_is_ok) {
- *p = '\0';
- } else {
- break;
- }
- } else {
- ws_is_ok = 0;
- }
- }
- strncpy (key_file, ++p, kf_len - 1);
- key_file[kf_len - 1] = '\0';
-
- /* make sure the key exists and user is the owner */
- key_fd = open (key_file, O_RDONLY | O_NOFOLLOW);
- if (key_fd == -1) {
- fclose (fp);
- return -1;
- }
+ /* make sure the key exists and user is the owner */
+ key_fd = open (key_f, O_RDONLY | O_NOFOLLOW);
+ if (key_fd == -1)
+ goto done;
- if (!fstat (key_fd, &info) && pent->pw_uid == info.st_uid) {
- fclose (fp);
- close (key_fd);
- return 0;
- } else {
- close (key_fd);
- }
+ if (!fstat (key_fd, &info) && pent->pw_uid == info.st_uid) {
+ strncpy (key_file, key_f, kf_len -1);
+ key_file[kf_len - 1] = '\0';
+ ret = 0;
}
+
+ close (key_fd);
- fclose (fp);
- return -1;
+done:
+ g_free (image_f);
+ g_free (key_f);
+ return ret;
}
/*
@@ -163,10 +133,14 @@
ret = encrypt_key (key_file, new_pw, key_data, key_size);
if (ret == FALSE) {
syslog (LOG_ERR, "Failed to encrypt key with new authtok\n");
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
free (key_data);
return PAM_AUTHTOK_ERR;
}
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
free (key_data);
/* change the owner of the fs key to the user */
@@ -280,14 +254,12 @@
if (ret != PAM_SUCCESS)
return PAM_IGNORE;
- /* Don't do anything if the user isn't using encrypted home dirs */
+ /* Don't do anything if the user isn't using an encrypted home dir */
ret = get_key_file(user, key_file, PATH_MAX);
if (ret == -1)
return PAM_IGNORE;
- /*
- * Get the authtok that pam_mount stores in the auth stack.
- */
+ /* Get the authtok that pam_mount stores in the auth stack */
ret = pam_get_data (pamh, "pam_mount_system_authtok", (void *) &pass_curr);
if (ret != PAM_SUCCESS || pass_curr == NULL) {
syslog (LOG_ERR, "Failed to get pam_mount authtok\n");
@@ -308,6 +280,8 @@
return PAM_SESSION_ERR;
}
} else {
+ memset (key_data, 0, key_size);
+ munlock (key_data, key_size);
free (key_data);
return PAM_SUCCESS;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org