1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-12-27 00:23:49 +03:00

Compare commits

...

26 Commits

Author SHA1 Message Date
Alasdair Kergon
5e7a308528 Ignore error setting selinux file context if fs doesn't support it. 2004-04-16 12:24:46 +00:00
Alasdair Kergon
7952177786 2.00.12 2004-04-14 20:09:25 +00:00
Alasdair Kergon
9afbe49c84 update 2004-04-14 18:31:35 +00:00
Alasdair Kergon
9f06ba2db3 fix selinux error mesg 2004-04-14 18:10:10 +00:00
Alasdair Kergon
fe55bfddcf lvm.static can be installed in different dir from rest of tools 2004-04-14 18:00:23 +00:00
Alasdair Kergon
c0842e6444 Install example config file by default if there isn't one already. 2004-04-14 17:39:55 +00:00
Alasdair Kergon
3fed20d06a Add power2 2004-04-14 17:33:51 +00:00
Alasdair Kergon
5e8f2e2c04 Fix lvs_in_vg_opened counting. 2004-04-14 17:33:04 +00:00
Alasdair Kergon
e4df99ea84 fix patch that misapplied 2004-04-08 17:21:01 +00:00
Alasdair Kergon
b3276f5f11 Update version 2004-04-08 17:14:00 +00:00
Alasdair Kergon
32667ca256 Option for auto-fallback to LVM1 tools if running 2.4 without device-mapper. 2004-04-08 15:23:23 +00:00
Alasdair Kergon
bed122a170 update for 2.00.10 2004-04-07 18:12:51 +00:00
Alasdair Kergon
14adc9b875 Basic selinux support 2004-04-07 14:08:22 +00:00
Alasdair Kergon
a8778bbc5a Fix status overflow check in kernel patches. 2004-04-07 12:39:59 +00:00
Alasdair Kergon
a54e641f44 fix static selinux build 2004-04-06 20:32:02 +00:00
Alasdair Kergon
5c99efe87a 1.00.13 2004-04-06 18:57:13 +00:00
Alasdair Kergon
7da1d731ff add some selinux support 2004-04-06 18:54:00 +00:00
Alasdair Kergon
af9828e819 Fix sysfs filter to check fs type. 2004-04-06 16:47:59 +00:00
Alasdair Kergon
7a27136142 Update to 2.00.10 2004-04-06 15:17:53 +00:00
Alasdair Kergon
012ad2d423 More build fixes 2004-04-06 15:14:23 +00:00
Alasdair Kergon
ef3bdbf4da Fix dmsetup.static install. 2004-04-06 12:06:55 +00:00
Alasdair Kergon
b3bb698f7b Version 1.00.11 2004-04-05 20:51:42 +00:00
Alasdair Kergon
1ed5d1e4c1 Combine static/dynamic build. 2004-04-05 20:48:14 +00:00
Alasdair Kergon
bdee01a03d Fix shared format1 build. 2004-04-05 16:29:37 +00:00
Alasdair Kergon
458f7376d7 accept argv[0] lvm.static 2004-04-05 16:24:17 +00:00
Alasdair Kergon
cb3a00e027 Move library targets definition into template. 2004-04-05 16:20:50 +00:00
27 changed files with 513 additions and 43 deletions

View File

@@ -16,7 +16,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
SUBDIRS = include man
SUBDIRS = doc include man
ifeq ("@INTL@", "yes")
SUBDIRS += po

View File

@@ -1 +1 @@
2.00.09-cvs (2004-03-31)
2.00.12-cvs (2004-04-14)

View File

@@ -1,3 +1,26 @@
Version 2.00.13 - 64 Apr 2004
=============================
Ignore error setting selinux file context if fs doesn't support it.
Version 2.00.12 - 14 Apr 2004
=============================
Install a default lvm.conf into /etc/lvm if there isn't one already.
Allow different installation dir for lvm.static (configure --staticdir=)
Fix inverted selinux error check.
Recognise power2 in /proc/devices.
Fix counting in lvs_in_vg_opened. [It ignored devices open more than once.]
Version 2.00.11 - 8 Apr 2004
============================
Set fallback_to_lvm1 in lvm.conf (or configure --enable-lvm1_fallback)
to run lvm1 binaries if running a 2.4 kernel without device-mapper.
Version 2.00.10 - 7 Apr 2004
============================
More fixes for static build.
Add basic selinux support.
Fix sysfs detection.
Version 2.00.09 - 31 Mar 2004
=============================
Update copyright notices for Red Hat.

View File

@@ -1,3 +1,28 @@
Version 1.00.16 - 16 Apr 2004
=============================
Ignore error setting selinux file context if fs doesn't support it.
Version 1.00.15 - 7 Apr 2004
============================
Fix status overflow check in kernel patches.
Version 1.00.14 - 6 Apr 2004
============================
Fix static selinux build.
Version 1.00.13 - 6 Apr 2004
============================
Add some basic selinux support.
Version 1.00.12 - 6 Apr 2004
============================
Fix dmsetup.static install.
Version 1.00.11 - 5 Apr 2004
============================
configure --enable-static_link does static build in addition to dynamic.
Moved Makefile library targets definition into template.
Version 1.00.10 - 2 Apr 2004
============================
Fix DESTDIR handling.

131
configure vendored
View File

@@ -309,7 +309,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/usr
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os MSGFMT JOBS STATIC_LINK LVM1 OWNER GROUP CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LD_DEPS SOFLAG LVM_VERSION DEBUG DEVMAPPER HAVE_LIBDL CMDLIB LOCALEDIR INTL_PACKAGE INTL LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os MSGFMT JOBS STATIC_LINK LVM1 OWNER GROUP CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LD_DEPS LD_FLAGS SOFLAG LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -845,6 +845,8 @@ if test -n "$ac_init_help"; then
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-lvm1_fallback Use this to fall back and use LVM1 binaries if
device-mapper is missing from the kernel
--enable-jobs=NUM Number of jobs to run simultaneously
--enable-static_link Use this to link the tools to their libraries
statically. Default is dynamic linking
@@ -863,6 +865,8 @@ Optional Packages:
--with-lvm1=TYPE LVM1 metadata support: internal/shared/none
TYPE=internal
--with-localedir=DIR Translation files in DIR PREFIX/share/locale
--with-confdir=DIR Configuration files in DIR /etc
--with-staticdir=DIR Static binary in DIR EXEC_PREFIX/sbin
Some influential environment variables:
CC C compiler command
@@ -3885,6 +3889,7 @@ case "$host_os" in
CLDWHOLEARCHIVE="-Wl,-whole-archive"
CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
LD_DEPS=".export.sym"
LD_FLAGS="-Wl,--export-dynamic"
SOFLAG="-shared"
DEVMAPPER=yes
ODIRECT=yes ;;
@@ -3894,6 +3899,7 @@ case "$host_os" in
CLDWHOLEARCHIVE="-all_load"
CLDNOWHOLEARCHIVE=
LD_DEPS=
LD_FLAGS=
SOFLAG="-dynamiclib"
DEVMAPPER=no
ODIRECT=no ;;
@@ -3919,6 +3925,18 @@ else
GROUP="root"
fi;
# Check whether --enable-lvm1_fallback or --disable-lvm1_fallback was given.
if test "${enable_lvm1_fallback+set}" = set; then
enableval="$enable_lvm1_fallback"
LVM1_FALLBACK=$enableval
else
LVM1_FALLBACK=no
fi;
if test x$LVM1_FALLBACK = xyes; then
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
fi
# Check whether --with-lvm1 or --without-lvm1 was given.
if test "${with_lvm1+set}" = set; then
@@ -4582,9 +4600,86 @@ else
fi
if test x$HAVE_LIBDL = xyes; then
if [ "x$HAVE_LIBDL" = xyes -a "xSTATIC_LINK" = xno ]; then
CFLAGS="$CFLAGS -DHAVE_LIBDL"
LIBS="-ldl $LIBS"
else
HAVE_LIBDL=no
fi
if [ "x$LVM1" = xshared -a "x$STATIC_LINK" = xyes ];
then { { echo "$as_me:$LINENO: error: Features cannot be 'shared' when building statically
" >&5
echo "$as_me: error: Features cannot be 'shared' when building statically
" >&2;}
{ (exit 1); exit 1; }; }
exit
fi
echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5
echo $ECHO_N "checking for is_selinux_enabled in -lselinux... $ECHO_C" >&6
if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lselinux $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char is_selinux_enabled ();
int
main ()
{
is_selinux_enabled ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_selinux_is_selinux_enabled=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_selinux_is_selinux_enabled=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5
echo "${ECHO_T}$ac_cv_lib_selinux_is_selinux_enabled" >&6
if test $ac_cv_lib_selinux_is_selinux_enabled = yes; then
HAVE_SELINUX=yes
else
HAVE_SELINUX=no
fi
if test x$HAVE_SELINUX = xyes; then
CFLAGS="$CFLAGS -DHAVE_SELINUX"
LIBS="-lselinux $LIBS"
fi
@@ -4963,6 +5058,25 @@ else
fi;
fi
# Check whether --with-confdir or --without-confdir was given.
if test "${with_confdir+set}" = set; then
withval="$with_confdir"
CONFDIR="$withval"
else
CONFDIR='/etc'
fi;
# Check whether --with-staticdir or --without-staticdir was given.
if test "${with_staticdir+set}" = set; then
withval="$with_staticdir"
STATICDIR="$withval"
else
STATICDIR='${exec_prefix}/sbin'
fi;
if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\""
else
@@ -4991,7 +5105,12 @@ fi
ac_config_files="$ac_config_files Makefile make.tmpl include/Makefile lib/Makefile lib/format1/Makefile man/Makefile po/Makefile tools/Makefile tools/version.h test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile"
ac_config_files="$ac_config_files Makefile make.tmpl doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile man/Makefile po/Makefile tools/Makefile tools/version.h test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -5544,6 +5663,7 @@ do
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"make.tmpl" ) CONFIG_FILES="$CONFIG_FILES make.tmpl" ;;
"doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
"lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
"lib/format1/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/format1/Makefile" ;;
@@ -5678,13 +5798,18 @@ s,@CLDFLAGS@,$CLDFLAGS,;t t
s,@CLDWHOLEARCHIVE@,$CLDWHOLEARCHIVE,;t t
s,@CLDNOWHOLEARCHIVE@,$CLDNOWHOLEARCHIVE,;t t
s,@LD_DEPS@,$LD_DEPS,;t t
s,@LD_FLAGS@,$LD_FLAGS,;t t
s,@SOFLAG@,$SOFLAG,;t t
s,@LVM_VERSION@,$LVM_VERSION,;t t
s,@LVM1_FALLBACK@,$LVM1_FALLBACK,;t t
s,@DEBUG@,$DEBUG,;t t
s,@DEVMAPPER@,$DEVMAPPER,;t t
s,@HAVE_LIBDL@,$HAVE_LIBDL,;t t
s,@HAVE_SELINUX@,$HAVE_SELINUX,;t t
s,@CMDLIB@,$CMDLIB,;t t
s,@LOCALEDIR@,$LOCALEDIR,;t t
s,@CONFDIR@,$CONFDIR,;t t
s,@STATICDIR@,$STATICDIR,;t t
s,@INTL_PACKAGE@,$INTL_PACKAGE,;t t
s,@INTL@,$INTL,;t t
s,@LIBOBJS@,$LIBOBJS,;t t

View File

@@ -55,6 +55,7 @@ case "$host_os" in
CLDWHOLEARCHIVE="-Wl,-whole-archive"
CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
LD_DEPS=".export.sym"
LD_FLAGS="-Wl,--export-dynamic"
SOFLAG="-shared"
DEVMAPPER=yes
ODIRECT=yes ;;
@@ -64,6 +65,7 @@ case "$host_os" in
CLDWHOLEARCHIVE="-all_load"
CLDNOWHOLEARCHIVE=
LD_DEPS=
LD_FLAGS=
SOFLAG="-dynamiclib"
DEVMAPPER=no
ODIRECT=no ;;
@@ -84,6 +86,14 @@ AC_ARG_WITH(group,
[ GROUP="$withval" ],
[ GROUP="root" ])
dnl -- LVM1 tool fallback option
AC_ARG_ENABLE(lvm1_fallback, [ --enable-lvm1_fallback Use this to fall back and use LVM1 binaries if
device-mapper is missing from the kernel], LVM1_FALLBACK=$enableval, LVM1_FALLBACK=no)
if test x$LVM1_FALLBACK = xyes; then
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
fi
dnl -- format1 inclusion type
AC_ARG_WITH(lvm1,
[ --with-lvm1=TYPE LVM1 metadata support: internal/shared/none
@@ -183,9 +193,27 @@ fi
dnl Check for dlopen
AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no)
if test x$HAVE_LIBDL = xyes; then
if [[ "x$HAVE_LIBDL" = xyes -a "xSTATIC_LINK" = xno ]]; then
CFLAGS="$CFLAGS -DHAVE_LIBDL"
LIBS="-ldl $LIBS"
else
HAVE_LIBDL=no
fi
dnl Check for shared/static conflicts
if [[ "x$LVM1" = xshared -a "x$STATIC_LINK" = xyes ]];
then AC_MSG_ERROR(
Features cannot be 'shared' when building statically
)
exit
fi
dnl Check for is_selinux_enabled
AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)
if test x$HAVE_SELINUX = xyes; then
CFLAGS="$CFLAGS -DHAVE_SELINUX"
LIBS="-lselinux $LIBS"
fi
dnl Check for getopt
@@ -230,6 +258,17 @@ if test x$INTL = xyes; then
[ LOCALEDIR='${prefix}/share/locale' ])
fi
AC_ARG_WITH(confdir,
[ --with-confdir=DIR Configuration files in DIR [/etc]],
[ CONFDIR="$withval" ],
[ CONFDIR='/etc' ])
AC_ARG_WITH(staticdir,
[ --with-staticdir=DIR Static binary in DIR [EXEC_PREFIX/sbin]],
[ STATICDIR="$withval" ],
[ STATICDIR='${exec_prefix}/sbin' ])
if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\""
else
@@ -246,15 +285,20 @@ AC_SUBST(CLDFLAGS)
AC_SUBST(CLDWHOLEARCHIVE)
AC_SUBST(CLDNOWHOLEARCHIVE)
AC_SUBST(LD_DEPS)
AC_SUBST(LD_FLAGS)
AC_SUBST(SOFLAG)
AC_SUBST(LIBS)
AC_SUBST(LVM_VERSION)
AC_SUBST(LVM1_FALLBACK)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(HAVE_SELINUX)
AC_SUBST(CMDLIB)
AC_SUBST(MSGFMT)
AC_SUBST(LOCALEDIR)
AC_SUBST(CONFDIR)
AC_SUBST(STATICDIR)
AC_SUBST(INTL_PACKAGE)
AC_SUBST(INTL)
@@ -263,6 +307,7 @@ dnl keep utility scripts running properly
AC_OUTPUT( \
Makefile \
make.tmpl \
doc/Makefile \
include/Makefile \
lib/Makefile \
lib/format1/Makefile \

29
doc/Makefile.in Normal file
View File

@@ -0,0 +1,29 @@
#
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This file is part of the LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
CONFSRC=example.conf
CONFDEST=lvm.conf
include ../make.tmpl
install:
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \
echo "Installing $(CONFSRC) as $(confdir)/$(CONFDEST)"; \
@INSTALL@ -D -o $(OWNER) -g $(GROUP) -m 644 $(CONFSRC) \
$(confdir)/$(CONFDEST); \
fi

View File

@@ -175,6 +175,16 @@ global {
# setting this to 0 should suppress the error messages.
activation = 1
# If we can't communicate with device-mapper, should we try running
# the LVM1 tools?
# This option only applies to 2.4 kernels and is provided to help you
# switch between device-mapper kernels and LVM1 kernels.
# The LVM1 tools need to be installed with .lvm1 suffices
# e.g. vgscan.lvm1 and they will stop working after you start using
# the new lvm2 on-disk metadata format.
# The default value is set when the tools are built.
# fallback_to_lvm1 = 0
# The default metadata format that commands should use - "lvm1" or "lvm2".
# The command line override is -M1 or -M2.
# Defaults to "lvm1" if compiled in, else "lvm2".

View File

@@ -34,6 +34,7 @@
../lib/misc/lib.h
../lib/misc/lvm-file.h
../lib/misc/lvm-string.h
../lib/misc/selinux.h
../lib/misc/sharedlib.h
../lib/regex/matcher.h
../lib/report/report.h

View File

@@ -95,9 +95,13 @@ ifeq ("@HAVE_LIBDL@", "yes")
misc/sharedlib.c
endif
ifeq ("@HAVE_SELINUX@", "yes")
SOURCES += misc/selinux.c
endif
LIB_STATIC = liblvm.a
TARGETS = $(LIB_STATIC)
$(SUBDIRS): $(LIB_STATIC)
include ../make.tmpl

View File

@@ -19,6 +19,7 @@
#include "memlock.h"
#include "display.h"
#include "fs.h"
#include "lvm-file.h"
#include "lvm-string.h"
#include "pool.h"
#include "toolcontext.h"
@@ -31,6 +32,22 @@
#define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args)
int lvm1_present(struct cmd_context *cmd)
{
char path[PATH_MAX];
if (lvm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir)
< 0) {
log_error("LVM1 proc global snprintf failed");
return 0;
}
if (path_exists(path))
return 1;
else
return 0;
}
#ifndef DEVMAPPER_SUPPORT
void set_activation(int act)
{
@@ -523,7 +540,7 @@ int lvs_in_vg_opened(struct volume_group *vg)
list_iterate(lvh, &vg->lvs) {
lv = list_item(lvh, struct lv_list)->lv;
count += (_lv_open_count(lv) == 1);
count += (_lv_open_count(lv) > 0);
}
return count;

View File

@@ -36,6 +36,7 @@ int activation(void);
int driver_version(char *version, size_t size);
int library_version(char *version, size_t size);
int lvm1_present(struct cmd_context *cmd);
int target_present(const char *target_name);

View File

@@ -20,6 +20,10 @@
#include "lvm-file.h"
#include "memlock.h"
#ifdef HAVE_SELINUX
# include "selinux.h"
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
@@ -175,6 +179,13 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
return 0;
}
#ifdef HAVE_SELINUX
if (!set_selinux_context(lv_path)) {
log_sys_error("set_selinux_context", lv_path);
return 0;
}
#endif
return 1;
}

View File

@@ -450,6 +450,11 @@ static int _init_hostname(struct cmd_context *cmd)
return 0;
}
if (!(cmd->kernel_vsn = pool_strdup(cmd->libmem, uts.release))) {
log_error("_init_hostname: pool_strdup kernel_vsn failed");
return 0;
}
return 1;
}

View File

@@ -58,6 +58,7 @@ struct cmd_context {
struct list formats; /* Available formats */
const char *hostname;
const char *kernel_vsn;
char *cmd_line;
struct command *command;

View File

@@ -35,6 +35,12 @@
#define DEFAULT_UMASK 0077
#ifdef LVM1_FALLBACK
# define DEFAULT_FALLBACK_TO_LVM1 1
#else
# define DEFAULT_FALLBACK_TO_LVM1 0
#endif
#ifdef LVM1_SUPPORT
# define DEFAULT_FORMAT "lvm1"
#else

View File

@@ -26,7 +26,7 @@ static int _locate_sysfs_blocks(const char *proc, char *path, size_t len)
char proc_mounts[PATH_MAX];
int r = 0;
FILE *fp;
char *split[2], buffer[PATH_MAX + 16];
char *split[4], buffer[PATH_MAX + 16];
if (!*proc) {
log_verbose("No proc filesystem found: skipping sysfs filter");
@@ -45,8 +45,8 @@ static int _locate_sysfs_blocks(const char *proc, char *path, size_t len)
}
while (fgets(buffer, sizeof(buffer), fp)) {
if (split_words(buffer, 2, split) == 2 &&
!strcmp(split[0], "sysfs")) {
if (split_words(buffer, 4, split) == 4 &&
!strcmp(split[2], "sysfs")) {
if (lvm_snprintf(path, len, "%s/%s", split[1],
"block") >= 0) {
r = 1;

View File

@@ -53,6 +53,7 @@ static const device_info_t device_info[] = {
{"ubd", 16}, /* User-mode virtual block device */
{"ataraid", 16}, /* ATA Raid */
{"drbd", 16}, /* Distributed Replicated Block Device */
{"power2", 16}, /* EMC Powerpath */
{NULL, 0}
};

View File

@@ -25,7 +25,7 @@ SOURCES =\
lvm1-label.c \
vg_number.c
TARGETS = liblvm2format1.so
LIB_SHARED = liblvm2format1.so
include ../../make.tmpl

42
lib/misc/selinux.c Normal file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "selinux.h"
#include <selinux/selinux.h>
int set_selinux_context(const char *path)
{
security_context_t scontext;
log_very_verbose("Setting SELinux context for %s", path);
if (is_selinux_enabled() <= 0)
return 0;
if (matchpathcon(path, 0, &scontext) < 0) {
log_sys_error("matchpathcon", path);
return 0;
}
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
log_sys_error("lsetfilecon", path);
free(scontext);
return 0;
}
free(scontext);
return 1;
}

20
lib/misc/selinux.h Normal file
View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_SELINUX_H
#define _LVM_SELINUX_H
int set_selinux_context(const char * path);
#endif

View File

@@ -24,17 +24,15 @@ INCLUDES = -I$(interface)
LIB_STATIC = $(interface)/libdevmapper.a
LIB_SHARED = $(interface)/libdevmapper.so
TARGETS = $(LIB_STATIC) $(LIB_SHARED)
include ../make.tmpl
.PHONY: install_dynamic install_static \
install_@interface@ install_@interface@_static
install_fs install_ioctl install_ioctl_static
INSTALL_TYPE = install_dynamic
ifeq ("@STATIC_LINK@", "yes")
INSTALL_TYPE = install_static
else
INSTALL_TYPE = install_dynamic
INSTALL_TYPE += install_static
endif
install: $(INSTALL_TYPE)

View File

@@ -29,6 +29,10 @@
#include <linux/dm-ioctl.h>
#include <linux/kdev_t.h>
#ifdef HAVE_SELINUX
# include <selinux/selinux.h>
#endif
#define DEV_DIR "/dev/"
static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
@@ -197,6 +201,31 @@ int dm_task_add_target(struct dm_task *dmt, uint64_t start, uint64_t size,
return 1;
}
#ifdef HAVE_SELINUX
static int _set_selinux_context(const char *path)
{
security_context_t scontext;
log_debug("Setting SELinux context for %s", path);
if (is_selinux_enabled() <= 0)
return 0;
if (matchpathcon(path, 0, &scontext) < 0) {
log_error("%s: matchpathcon failed: %s", path, strerror(errno));
return 0;
}
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
free(scontext);
return 0;
}
free(scontext);
return 1;
}
#endif
static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor)
{
char path[PATH_MAX];
@@ -226,6 +255,10 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor)
log_error("Unable to make device node for '%s'", dev_name);
return 0;
}
#ifdef HAVE_SELINUX
if (!_set_selinux_context(path))
return 0;
#endif
return 1;
}

View File

@@ -29,18 +29,21 @@ CLDFLAGS += @CLDFLAGS@
CLDWHOLEARCHIVE += @CLDWHOLEARCHIVE@
CLDNOWHOLEARCHIVE += @CLDNOWHOLEARCHIVE@
LD_DEPS += @LD_DEPS@
LD_FLAGS += @LD_FLAGS@
SOFLAG += @SOFLAG@
# Setup directory variables
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(DESTDIR)@bindir@
confdir = $(DESTDIR)@CONFDIR@/lvm
includedir = $(DESTDIR)@includedir@
libdir = $(DESTDIR)@libdir@
sbindir = $(DESTDIR)@sbindir@
infodir = $(DESTDIR)@infodir@
mandir = $(DESTDIR)@mandir@
localedir = $(DESTDIR)@LOCALEDIR@
staticdir = $(DESTDIR)@STATICDIR@
# setup misc variables
# define the ownership variables for the binaries and man pages
@@ -71,10 +74,6 @@ endif
LD_FLAGS += -L$(top_srcdir)/lib -L$(libdir)
ifeq ("@STATIC_LINK@", "yes")
LD_FLAGS += -static
endif
#CFLAGS += -DDEBUG_POOL
#CFLAGS += -DBOUNDS_CHECK
@@ -109,6 +108,8 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean)
.PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
.PHONY: $(SUBDIRS.pofile)
TARGETS += $(LIB_SHARED) $(LIB_STATIC)
all: $(SUBDIRS) $(TARGETS)
install: all $(SUBDIRS.install)
@@ -137,16 +138,14 @@ $(TARGETS): $(OBJECTS)
%.o: %.c
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
%.pot: %.c
%.pot: %.c Makefile
$(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
$(CFLAGS) $< > $@
%.pot: Makefile
%.so: %.o
$(CC) -c $(INCLUDES) $(CFLAGS) %< -o $@
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
%.so: $(OBJECTS) $(LD_DEPS)
$(LIB_SHARED): $(OBJECTS) $(LD_DEPS)
$(CC) $(SOFLAG) -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
$(CLDFLAGS) $(OBJECTS) -o $@

View File

@@ -16,7 +16,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
SOURCES=\
SOURCES =\
archiver.c \
dumpconfig.c \
lvchange.c \
@@ -57,20 +57,26 @@ SOURCES=\
vgscan.c \
vgsplit.c
TARGETS=\
TARGETS =\
.commands \
lvm
LVMLIBS=-llvm
INSTALL_TARGETS = install_tools_dynamic
INSTALL_CMDLIB_TARGETS = install_cmdlib_dynamic
INSTALL_TARGETS=\
install_lvm_tools
ifeq ("@STATIC_LINK@", "yes")
TARGETS += lvm.static
INSTALL_TARGETS += install_tools_static
INSTALL_CMDLIB_TARGETS += install_cmdlib_static
endif
CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a
LVMLIBS = -llvm
CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a lvm lvm.static
ifeq ("@CMDLIB@", "yes")
TARGETS += liblvm2cmd.so
INSTALL_TARGETS += install_cmdlib
INSTALL_TARGETS += $(INSTALL_CMDLIB_TARGETS)
endif
ifeq ("@DEVMAPPER@", "yes")
@@ -80,7 +86,11 @@ endif
include ../make.tmpl
lvm: $(OBJECTS) lvm.o $(top_srcdir)/lib/liblvm.a
$(CC) -o lvm $(OBJECTS) lvm.o $(LD_FLAGS) $(LVMLIBS) $(LIBS)
$(CC) -o $@ $(OBJECTS) lvm.o $(LD_FLAGS) $(LVMLIBS) $(LIBS) -rdynamic
lvm.static: $(OBJECTS) lvm.o $(top_srcdir)/lib/liblvm.a
$(CC) -o $@ $(OBJECTS) lvm.o -static $(LD_FLAGS) $(LVMLIBS) $(LIBS) \
-rdynamic
liblvm2cmd.a: $(top_srcdir)/lib/liblvm.a $(OBJECTS)
cat $(top_srcdir)/lib/liblvm.a > $@
@@ -94,16 +104,24 @@ liblvm2cmd.so: liblvm2cmd.a $(LD_DEPS)
$(CC) -E -P cmdnames.h 2> /dev/null | \
egrep -v '^ *(|#.*|dumpconfig|help|pvdata|version) *$$' > .commands
.PHONY: install_lvm_tools install_cmdlib
.PHONY: install_cmdlib_dynamic install_cmdlib_static \
install_tools_dynamic install_tools_static
install_cmdlib: $(TARGETS)
install_cmdlib_dynamic: liblvm2cmd.so
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) liblvm2cmd.so \
$(libdir)/liblvm2cmd.so.$(LIB_VERSION)
$(LN_S) -f liblvm2cmd.so.$(LIB_VERSION) $(libdir)/liblvm2cmd.so
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 444 lvm2cmd.h \
$(includedir)/lvm2cmd.h
install_lvm_tools: $(TARGETS)
install_cmdlib_static: liblvm2cmd.a
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) liblvm2cmd.a \
$(libdir)/liblvm2cmd.a.$(LIB_VERSION)
$(LN_S) -f liblvm2cmd.a.$(LIB_VERSION) $(libdir)/liblvm2cmd.a
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 444 lvm2cmd.h \
$(includedir)/lvm2cmd.h
install_tools_dynamic: lvm .commands
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm \
$(sbindir)/lvm
@echo Creating symbolic links for individual commands in $(sbindir)
@@ -114,5 +132,9 @@ install_lvm_tools: $(TARGETS)
done; \
)
install_tools_static: lvm.static
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm.static \
$(staticdir)/lvm.static
install: $(INSTALL_TARGETS)

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
@@ -1054,7 +1054,7 @@ static char *_list_args(const char *text, int state)
char c;
if (!(c = (the_args +
com->valid_args[match_no++])->short_arg))
continue;
continue;
sprintf(s, "-%c", c);
if (!strncmp(text, s, len))
@@ -1285,6 +1285,42 @@ void lvm2_exit(void *handle)
#endif
/*
* Determine whether we should fall back and exec the equivalent LVM1 tool
*/
static int _lvm1_fallback(struct cmd_context *cmd)
{
char vsn[80];
int dm_present;
if (!find_config_int(cmd->cft->root, "global/fallback_to_lvm1",
DEFAULT_FALLBACK_TO_LVM1) ||
strncmp(cmd->kernel_vsn, "2.4.", 4))
return 0;
log_suppress(1);
dm_present = driver_version(vsn, sizeof(vsn));
log_suppress(0);
if (dm_present || !lvm1_present(cmd))
return 0;
return 1;
}
static void _exec_lvm1_command(struct cmd_context *cmd, int argc, char **argv)
{
char path[PATH_MAX];
if (lvm_snprintf(path, sizeof(path), "%s.lvm1", argv[0]) < 0) {
log_error("Failed to create LVM1 tool pathname");
return;
}
execvp(path, argv);
log_sys_error("execvp", path);
}
int lvm2_main(int argc, char **argv)
{
char *namebase, *base;
@@ -1299,12 +1335,27 @@ int lvm2_main(int argc, char **argv)
base = basename(namebase);
while (*base == '/')
base++;
if (strcmp(base, "lvm"))
if (strcmp(base, "lvm") && strcmp(base, "lvm.static"))
alias = 1;
free(namebase);
_register_commands();
if (_lvm1_fallback(cmd)) {
/* Attempt to run equivalent LVM1 tool instead */
if (!alias) {
argv++;
argc--;
alias = 0;
}
if (!argc) {
log_error("Falling back to LVM1 tools, but no "
"command specified.");
return ECMD_FAILED;
}
_exec_lvm1_command(cmd, argc, argv);
return ECMD_FAILED;
}
#ifdef READLINE_SUPPORT
if (!alias && argc == 1) {
ret = _shell(cmd);