Compare commits

..

8 Commits
rawhide ... f16

Author SHA1 Message Date
Karel Zak
0d8315b35b 2.20.1-2.3: fix #813315
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-17 15:28:58 +02:00
Michal Luscon
85a6551255 2.20.1-2.2: #747250, #769636, #771607, #747038 2012-01-20 11:39:36 +01:00
Karel Zak
48eb2e3af1 2.20.1-2.1: #748216
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-22 17:06:16 +01:00
Dennis Gilmore
93cde3d361 - Rebuilt for glibc bug#747377 2011-10-26 20:36:16 -05:00
Karel Zak
5da3c25b9b 2.20.1-1: upgrade to the release 2.20.1
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-20 13:11:05 +02:00
Karel Zak
6e643f2ed7 2.20-1: upgrade to stable 2.20
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-29 15:11:29 +02:00
Karel Zak
f70fc8ad51 2.20.0.2: upgrade to -rc2
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-17 11:34:12 +02:00
Karel Zak
de1910078f 2.20-0.1: upgrade to 2.20-rc1
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-02 17:12:49 +02:00
39 changed files with 1824 additions and 1560 deletions

76
.gitignore vendored
View File

@ -14,79 +14,3 @@
/util-linux-2.20-rc2.tar.bz2
/util-linux-2.20.tar.bz2
/util-linux-2.20.1.tar.bz2
/util-linux-2.21-rc2.tar.xz
/util-linux-2.21.tar.xz
/util-linux-2.21.1.tar.xz
/util-linux-2.21.2.tar.xz
/util-linux-2.22-rc2.tar.xz
/util-linux-2.22.tar.xz
/util-linux-2.22.1.tar.xz
/util-linux-2.22.2.tar.xz
/util-linux-2.23-rc1.tar.xz
/util-linux-2.23-rc2.tar.xz
/util-linux-2.23.tar.xz
/util-linux-2.23.1.tar.xz
/util-linux-2.23.2.tar.xz
/util-linux-2.24-rc1.tar.xz
/util-linux-2.24.tar.xz
/util-linux-2.24.1.tar.xz
/util-linux-2.24.2.tar.xz
/util-linux-2.25-rc1.tar.xz
/util-linux-2.25-rc2.tar.xz
/util-linux-2.25.tar.xz
/util-linux-2.25.1-rc1.tar.xz
/util-linux-2.25.1.tar.xz
/util-linux-2.25.2.tar.xz
/util-linux-2.26-rc1.tar.xz
/util-linux-2.26-rc2.tar.xz
/util-linux-2.26.tar.xz
/util-linux-2.26.2.tar.xz
/util-linux-2.27-rc1.tar.xz
/util-linux-2.27-rc2.tar.xz
/util-linux-2.27.tar.xz
/util-linux-2.27.1.tar.xz
/util-linux-2.28-rc1.tar.xz
/util-linux-2.28-rc2.tar.xz
/util-linux-2.28.tar.xz
/util-linux-2.28.1.tar.xz
/util-linux-2.28.2.tar.xz
/util-linux-2.29-rc1.tar.xz
/util-linux-2.29-rc2.tar.xz
/util-linux-2.29.tar.xz
/util-linux-2.29.1.tar.xz
/util-linux-2.29.2.tar.xz
/util-linux-2.30-rc1.tar.xz
/util-linux-2.30.tar.xz
/util-linux-2.30.1.tar.xz
/util-linux-2.30.2.tar.xz
/util-linux-2.31-rc1.tar.xz
/util-linux-2.31-rc2.tar.xz
/util-linux-2.31.tar.xz
/util-linux-2.32-rc1.tar.xz
/util-linux-2.32.tar.xz
/util-linux-2.32.1.tar.xz
/util-linux-2.33-rc2.tar.xz
/util-linux-2.33.1.tar.xz
/util-linux-2.33.2.tar.xz
/util-linux-2.34-rc1.tar.xz
/util-linux-2.34-rc2.tar.xz
/util-linux-2.34.tar.xz
/util-linux-2.35-rc1.tar.xz
/util-linux-2.35-rc1-20-63f8.tar.xz
/util-linux-2.35-rc2.tar.xz
/util-linux-2.35.tar.xz
/util-linux-2.35.1.tar.xz
/util-linux-2.35.2.tar.xz
/util-linux-2.36.tar.xz
/util-linux-2.36.1.tar.xz
/util-linux-2.36.2.tar.xz
/util-linux-2.37-rc2.tar.xz
/util-linux-2.37.tar.xz
/util-linux-2.37.2.tar.xz
/util-linux-2.38-rc1.tar.xz
/util-linux-2.38-rc3.tar.xz
/util-linux-2.38.tar.xz
/util-linux-2.38.1.tar.xz
/util-linux-2.39-rc1.tar.xz
/util-linux-2.39-rc2.tar.xz
/util-linux-2.39-rc3.tar.xz

View File

@ -1,12 +0,0 @@
srpm util-linux
mcd $BUILDDIR/$1
cat <<EOF > config.cache
ax_cv_have_tls=yes
scanf_cv_alloc_modifier=ms
EOF
$SRC/${1}-*/configure $TCONFIGARGS --without-ncurses --without-tinfo \
--prefix=/usr --libexecdir=/usr/lib${SUFFIX} --libdir=/usr/lib${SUFFIX} \
--disable-wall --cache-file=config.cache --without-python --without-systemd
notparallel
make $J V=1
make $J install DESTDIR=${ROOTFS}

View File

@ -1,2 +0,0 @@
0.0 0 0.0
0

View File

@ -1,13 +0,0 @@
diff --git a/include/pathnames.h b/include/pathnames.h
index 3845d4c33..fac3a0783 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -41,7 +41,7 @@
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
#endif
-#define _PATH_MOTDFILE "/usr/share/misc/motd:/run/motd:/etc/motd"
+#define _PATH_MOTDFILE "/usr/share/misc/motd:/run/motd:/run/motd.d:/etc/motd:/etc/motd.d"
#ifndef _PATH_NOLOGIN
# define _PATH_NOLOGIN "/etc/nologin"
#endif

View File

@ -1,12 +0,0 @@
diff -up util-linux-2.36/login-utils/login.c.kzak util-linux-2.36/login-utils/login.c
--- util-linux-2.36/login-utils/login.c.kzak 2020-07-23 14:13:26.777030764 +0200
+++ util-linux-2.36/login-utils/login.c 2020-07-23 14:11:22.793686983 +0200
@@ -585,7 +585,7 @@ static void log_lastlog(struct login_con
sa.sa_handler = SIG_IGN;
sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
- fd = open(_PATH_LASTLOG, O_RDWR, 0);
+ fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0);
if (fd < 0)
goto done;
offset = cxt->pwd->pw_uid * sizeof(ll);

63
nologin.8 Normal file
View File

@ -0,0 +1,63 @@
.\" $OpenBSD: nologin.8,v 1.8 1999/06/04 02:45:19 aaron Exp $
.\" $NetBSD: nologin.8,v 1.3 1995/03/18 14:59:09 cgd Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
.\"
.Dd February 15, 1997
.Dt NOLOGIN 8
.Os
.Sh NAME
.Nm nologin
.Nd politely refuse a login
.Sh SYNOPSIS
.Nm nologin
.Sh DESCRIPTION
.Nm
displays a message that an account is not available and
exits non-zero.
It is intended as a replacement shell field for accounts that
have been disabled.
.Pp
If the file
.Pa /etc/nologin.txt
exists,
.Nm
displays its contents to the user instead of the default message.
.Sh SEE ALSO
.Xr login 1
.Sh HISTORY
The
.Nm
command appeared in
.Bx 4.4 .

58
nologin.c Normal file
View File

@ -0,0 +1,58 @@
/* $OpenBSD: nologin.c,v 1.2 1997/04/04 16:51:37 millert Exp $ */
/*
* Copyright (c) 1997, Jason Downs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
/* Distinctly different from _PATH_NOLOGIN. */
#define _PATH_NOLOGIN_TXT "/etc/nologin.txt"
#define DEFAULT_MESG "This account is currently not available.\n"
/*ARGSUSED*/
int main(argc, argv)
int argc;
char *argv[];
{
int nfd, nrd;
char nbuf[128];
nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
if (nfd < 0) {
write(STDOUT_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG));
exit (1);
}
while ((nrd = read(nfd, nbuf, sizeof(nbuf))) > 0)
write(STDOUT_FILENO, nbuf, nrd);
close (nfd);
exit (1);
}

View File

@ -1 +1,2 @@
SHA512 (util-linux-2.39-rc3.tar.xz) = 8a93d32a5ceb38d50a4b2c8bfa48bcab7ec9b758c89b5a1a4f7fd74558dce37385bd7ea203345148d4389de4ea60ec42058f9d7889a8075d3e616773d085427e
079b37517fd4e002a2e6e992e8b4e361 util-linux-2.20.1.tar.bz2
a02aac97c74259ca1b24972c89147ca4 floppy-0.18.tar.bz2

View File

@ -1,13 +0,0 @@
# Test which run in classic and docker environemnt
- hosts: localhost
tags:
- classic
- container
- atomic
roles:
- role: standard-test-beakerlib
tests:
- various
required_packages:
- util-linux
- util-linux-user

View File

@ -1,64 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/util-linux/various
# Description: This test groups small sanity and regression tests for util-linux
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# 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 version 2.
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/util-linux/Sanity/various
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Miroslav Vadkerti <mvadkert@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: This test groups small sanity and regression tests for util-linux" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: util-linux" >> $(METADATA)
@echo "Requires: util-linux util-linux-user" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL3 -RHEL4 -RHEL5Server -RHEL5Client -RHEL6" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -1,3 +0,0 @@
PURPOSE of /CoreOS/util-linux/various
Description: This test groups small sanity and regression tests for util-linux
Author: Miroslav Vadkerti <mvadkert@redhat.com>

View File

@ -1,52 +0,0 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/util-linux/various
# Description: This test groups small sanity and regression tests for util-linux
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# 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 version 2.
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
#. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="util-linux"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlPhaseEnd
rlPhaseStartTest "return code of chfn should be always 1 in case failure"
rlRun "chfn -f a:b" 1
rlRun "chfn -o a:b" 1
rlRun "chfn -p a:b" 1
rlRun "chfn -h a:b" 1
rlRun "chfn -x a:b" 1
rlRun "chfn -f a -o b -p c -h d unknown-user" 1
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,103 @@
diff -up util-linux-2.19/floppy-0.18/floppyfloppy.c.kzak util-linux-2.19/floppy-0.18/floppyfloppy.c
--- util-linux-2.19/floppy-0.18/floppyfloppy.c.kzak 2009-09-24 03:36:33.000000000 +0200
+++ util-linux-2.19/floppy-0.18/floppyfloppy.c 2011-03-07 10:40:42.000000000 +0100
@@ -271,6 +271,33 @@ static RETSIGTYPE sighandler(int signum)
#endif
}
+/* -1=error, 1=true, 0=false */
+static int check_generic(const char *dev, int n)
+{
+ struct floppy_struct param;
+ int fd;
+
+ if ((fd=open(dev, O_RDONLY)) < 0)
+ {
+ perror(dev);
+ return -1;
+ }
+ if (ioctl(fd,FDGETPRM,(long) &param) < 0)
+ {
+ perror(dev);
+ close(fd);
+ return -1;
+ }
+ close(fd);
+
+ if (param.sect==floppy_type[n].sectors &&
+ param.head==floppy_type[n].heads &&
+ param.track==floppy_type[n].tracks)
+ /* generic device uses expected format */
+ return 1;
+
+ return 0;
+}
static int do_format(const char *dev, int fmtnum,
int (*fmt_func)(const char *, int), int flags)
@@ -282,6 +309,7 @@ static int do_format(const char *dev, in
struct format_descr curtrack;
int pct;
struct stat stat_buf;
+ int gen = 0;
int i, j;
char *devname;
@@ -304,23 +332,52 @@ static int do_format(const char *dev, in
strcat(strcpy(devname, dev), floppy_type[fmtnum].dev);
+ if (stat(devname, &stat_buf)==-1 && errno==ENOENT)
+ {
+ /* /dev/fd0xxxxx doesn't exist ...try to use generic device
+ *
+ * Note: we needn't size specific device if the generic device uses
+ * right floppy format (FDGETPRM). -- Karel Zak [30/09/2005]
+ */
+ if ((gen = check_generic(dev, fmtnum))==1) /* true */
+ {
+ fprintf(stderr, _("WARNING: size specific device %s doesn't exist, using generic device: %s\n"),
+ devname, dev);
+ strcpy(devname, dev);
+ }
+ else if (gen==0) /* false */
+ {
+ fprintf(stderr, _("ERROR: size specific device %1$s doesn't exist. Use \"MAKEDEV %1$s\" and try it again.\n"), devname);
+ return (1);
+ }
+ else /* error -- no floppy medium or device? */
+ return(1);
+ }
fd=open(devname, O_WRONLY);
if (fd < 0)
{
perror(devname);
return (1);
}
-
- if (fstat(fd, &stat_buf) ||
- !S_ISBLK(stat_buf.st_mode) ||
- MINOR_DEV(stat_buf.st_rdev) != fmtnum)
+ if (fstat(fd, &stat_buf) < 0)
+ {
+ perror(devname);
+ close(fd);
+ return (1);
+ }
+ if (!S_ISBLK(stat_buf.st_mode))
+ {
+ fprintf(stderr,_("%s: not a block device\n"), devname);
+ close(fd);
+ return (1);
+ }
+ if (gen==0 && MINOR_DEV(stat_buf.st_rdev) != fmtnum)
{
errno=EINVAL;
perror(devname);
close(fd);
return (1);
}
-
if (ioctl(fd, FDGETPRM, &geo) < 0)
{
perror(devname);

View File

@ -0,0 +1,11 @@
diff -up util-linux-2.19/floppy-0.18/superfloppy.c.kzak util-linux-2.19/floppy-0.18/superfloppy.c
--- util-linux-2.19/floppy-0.18/superfloppy.c.kzak 2009-09-23 02:47:26.000000000 +0200
+++ util-linux-2.19/floppy-0.18/superfloppy.c 2011-03-07 10:37:20.000000000 +0100
@@ -13,6 +13,7 @@
#include <popt.h>
#include <locale.h>
#include <libintl.h>
+#include <locale.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

View File

@ -0,0 +1,32 @@
From fa7e0d6d442de9f5940f99fd93f4522602439131 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2011 12:35:26 +0200
Subject: [PATCH] lib: [linux_version.c] accommodate two-component linux
version (e.g. 3.0)
Signed-off-by: Karel Zak <kzak@redhat.com>
---
lib/linux_version.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/linux_version.c b/lib/linux_version.c
index f9fbd8d..ada566a 100644
--- a/lib/linux_version.c
+++ b/lib/linux_version.c
@@ -16,10 +16,10 @@ get_linux_version (void)
return kver;
if (uname (&uts))
kver = 0;
- else if (sscanf (uts.release, "%d.%d.%d", &major, &minor, &teeny) != 3)
- kver = 0;
- else
+ else if (sscanf (uts.release, "%d.%d.%d", &major, &minor, &teeny) == 3)
kver = KERNEL_VERSION (major, minor, teeny);
+ else if (sscanf (uts.release, "%d.%d", &major, &minor) == 2)
+ kver = KERNEL_VERSION (major, minor, 0);
return kver;
}
--
1.7.5.2

View File

@ -0,0 +1,290 @@
From 5c60a0eab5155043f58fa88909d89e0b06cad2f8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 31 May 2011 18:01:36 +0200
Subject: [PATCH] libmount: add mnt_table_is_mounted()
Signed-off-by: Karel Zak <kzak@redhat.com>
---
shlibs/mount/src/libmount.h.in | 3 +
shlibs/mount/src/libmount.sym | 1 +
shlibs/mount/src/tab.c | 210 ++++++++++++++++++++++++++++++++++++++++
shlibs/mount/src/tab_update.c | 2 +-
4 files changed, 215 insertions(+), 1 deletions(-)
diff --git a/shlibs/mount/src/libmount.h.in b/shlibs/mount/src/libmount.h.in
index 3ea2f92..1522208 100644
--- a/shlibs/mount/src/libmount.h.in
+++ b/shlibs/mount/src/libmount.h.in
@@ -308,6 +308,9 @@ extern int mnt_table_find_next_fs(struct libmnt_table *tb,
int (*match_func)(struct libmnt_fs *, void *), void *userdata,
struct libmnt_fs **fs);
+extern int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs);
+
+
/* tab_update.c */
extern struct libmnt_update *mnt_new_update(void);
extern void mnt_free_update(struct libmnt_update *upd);
diff --git a/shlibs/mount/src/libmount.sym b/shlibs/mount/src/libmount.sym
index 0b7c560..a498916 100644
--- a/shlibs/mount/src/libmount.sym
+++ b/shlibs/mount/src/libmount.sym
@@ -195,6 +195,7 @@ global:
mnt_update_is_ready;
mnt_update_set_fs;
mnt_update_table;
+ mnt_table_is_fs_mounted;
local:
*;
};
diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c
index 2a6a235..38a5d5b 100644
--- a/shlibs/mount/src/tab.c
+++ b/shlibs/mount/src/tab.c
@@ -712,6 +712,175 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc
return NULL;
}
+/*
+ * @tb: /proc/self/mountinfo
+ * @fs: filesystem
+ * @mountflags: MS_BIND or 0
+ * @fsroot: fs-root that will be probably used in the mountinfo file
+ * for @fs after mount(2)
+ *
+ * For btrfs subvolumes this function returns NULL, but @fsroot properly set.
+ *
+ * Returns: entry from @tb that will be used as a source for @fs if the @fs is
+ * bindmount.
+ */
+struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
+ struct libmnt_fs *fs,
+ unsigned long mountflags,
+ char **fsroot)
+{
+ char *root = NULL, *mnt = NULL;
+ const char *fstype;
+ struct libmnt_fs *src_fs = NULL;
+
+ assert(tb);
+ assert(fs);
+ assert(fsroot);
+
+ DBG(TAB, mnt_debug("lookup fs-root for %s", mnt_fs_get_source(fs)));
+
+ fstype = mnt_fs_get_fstype(fs);
+
+ if (mountflags & MS_BIND) {
+ const char *src, *src_root;
+
+ DBG(TAB, mnt_debug("fs-root for bind"));
+
+ src = mnt_resolve_spec(mnt_fs_get_source(fs), tb->cache);
+ if (!src)
+ goto err;
+
+ mnt = mnt_get_mountpoint(src);
+ if (!mnt)
+ goto err;
+
+ root = mnt_get_fs_root(src, mnt);
+
+ src_fs = mnt_table_find_target(tb, mnt, MNT_ITER_BACKWARD);
+ if (!src_fs) {
+ DBG(TAB, mnt_debug("not found '%s' in mountinfo -- using default", mnt));
+ goto dflt;
+ }
+
+ /* on btrfs the subvolume is used as fs-root in
+ * /proc/self/mountinfo, so we have to get the original subvolume
+ * name from src_fs and prepend the subvolume name to the
+ * fs-root path
+ */
+ src_root = mnt_fs_get_root(src_fs);
+ if (src_root && !startswith(root, src_root)) {
+ size_t sz = strlen(root) + strlen(src_root) + 1;
+ char *tmp = malloc(sz);
+
+ if (!tmp)
+ goto err;
+ snprintf(tmp, sz, "%s%s", src_root, root);
+ free(root);
+ root = tmp;
+ }
+ }
+
+ /*
+ * btrfs-subvolume mount -- get subvolume name and use it as a root-fs path
+ */
+ else if (fstype && !strcmp(fstype, "btrfs")) {
+ char *vol = NULL, *p;
+ size_t sz, volsz = 0;
+
+ if (mnt_fs_get_option(fs, "subvol", &vol, &volsz))
+ goto dflt;
+
+ DBG(TAB, mnt_debug("setting FS root: btrfs subvol"));
+
+ sz = volsz;
+ if (*vol != '/')
+ sz++;
+ root = malloc(sz + 1);
+ if (!root)
+ goto err;
+ p = root;
+ if (*vol != '/')
+ *p++ = '/';
+ memcpy(p, vol, volsz);
+ *(root + sz) = '\0';
+ }
+dflt:
+ if (!root) {
+ root = strdup("/");
+ if (!root)
+ goto err;
+ }
+ *fsroot = root;
+
+ DBG(TAB, mnt_debug("FS root result: %s", root));
+
+ free(mnt);
+ return src_fs;
+err:
+ free(root);
+ free(mnt);
+ return NULL;
+}
+
+/**
+ * mnt_table_is_mounted:
+ * @tb: /proc/self/mountinfo file
+ * @fstab_fs: /etc/fstab entry
+ *
+ * Checks if the @fstab_fs entry is already in the @tb table. The "swap"
+ * is ignored.
+ *
+ * TODO: check for loopdev (see mount/mount.c is_fstab_entry_mounted().
+ *
+ * Returns: 0 or 1
+ */
+int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
+{
+ char *root = NULL;
+ struct libmnt_fs *src_fs;
+ const char *src, *tgt;
+ int flags = 0, rc = 0;
+
+ assert(tb);
+ assert(fstab_fs);
+
+ if (fstab_fs->flags & MNT_FS_SWAP)
+ return 0;
+
+ if (mnt_fs_get_option(fstab_fs, "bind", NULL, NULL) == 0)
+ flags = MS_BIND;
+
+ src_fs = mnt_table_get_fs_root(tb, fstab_fs, flags, &root);
+ if (src_fs)
+ src = mnt_fs_get_srcpath(src_fs);
+ else
+ src = mnt_resolve_spec(mnt_fs_get_source(fstab_fs), tb->cache);
+
+ tgt = mnt_fs_get_target(fstab_fs);
+
+ if (tgt || src || root) {
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs;
+
+ mnt_reset_iter(&itr, MNT_ITER_FORWARD);
+
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
+ const char *s = mnt_fs_get_srcpath(fs),
+ *t = mnt_fs_get_target(fs),
+ *r = mnt_fs_get_root(fs);
+
+ if (s && t && r && !strcmp(t, tgt) &&
+ !strcmp(s, src) && !strcmp(r, root))
+ break;
+ }
+ if (fs)
+ rc = 1; /* success */
+ }
+
+ free(root);
+ return rc;
+}
+
#ifdef TEST_PROGRAM
static int parser_errcb(struct libmnt_table *tb, const char *filename, int line)
@@ -869,6 +1038,46 @@ done:
return rc;
}
+static int test_is_mounted(struct libmnt_test *ts, int argc, char *argv[])
+{
+ struct libmnt_table *tb = NULL, *fstab = NULL;
+ struct libmnt_fs *fs;
+ struct libmnt_iter *itr = NULL;
+ int rc;
+
+ tb = mnt_new_table_from_file("/proc/self/mountinfo");
+ if (!tb) {
+ fprintf(stderr, "failed to parse mountinfo\n");
+ return -1;
+ }
+
+ fstab = create_table(argv[1]);
+ if (!fstab)
+ goto done;
+
+ itr = mnt_new_iter(MNT_ITER_FORWARD);
+ if (!itr)
+ goto done;
+
+ while(mnt_table_next_fs(fstab, itr, &fs) == 0) {
+ if (mnt_table_is_fs_mounted(tb, fs))
+ printf("%s already mounted on %s\n",
+ mnt_fs_get_source(fs),
+ mnt_fs_get_target(fs));
+ else
+ printf("%s not mounted on %s\n",
+ mnt_fs_get_source(fs),
+ mnt_fs_get_target(fs));
+ }
+
+ rc = 0;
+done:
+ mnt_free_table(tb);
+ mnt_free_table(fstab);
+ mnt_free_iter(itr);
+ return rc;
+}
+
int main(int argc, char *argv[])
{
struct libmnt_test tss[] = {
@@ -877,6 +1086,7 @@ int main(int argc, char *argv[])
{ "--find-backward", test_find_bw, "<file> <source|target> <string>" },
{ "--find-pair", test_find_pair, "<file> <source> <target>" },
{ "--copy-fs", test_copy_fs, "<file> copy root FS from the file" },
+ { "--is-mounted", test_is_mounted, "<fstab> check what from <file> are already mounted" },
{ NULL }
};
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c
index 5abb566..9817f20 100644
--- a/shlibs/mount/src/tab_update.c
+++ b/shlibs/mount/src/tab_update.c
@@ -410,7 +410,7 @@ static int set_fs_root(struct libmnt_fs *result, struct libmnt_fs *fs, unsigned
mnt_fs_set_fstype(result, mnt_fs_get_fstype(src_fs));
/* on btrfs the subvolume is used as fs-root in
- * /proc/self/mountinfo, so we have get the original subvolume
+ * /proc/self/mountinfo, so we have to get the original subvolume
* name from src_fs and prepend the subvolume name to the
* fs-root path
*/
--
1.7.5.2

View File

@ -0,0 +1,105 @@
From 0cac8948216a298deaf5fd30837ed9cc80618f80 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 31 May 2011 18:02:29 +0200
Subject: [PATCH] mount: use libmount to detect already mounted bind mounts
It's pretty tricky to detect that a bind mount from fstab is already
mounted on system without /etc/mtab. Let's use functionality from
libmount.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=701176
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/mount.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/mount/mount.c b/mount/mount.c
index 29963c2..3ba705f 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -212,7 +212,7 @@ static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit,
*opt_encryption, *opt_speed, *opt_comment, *opt_uhelper;
static int is_readonly(const char *node);
-static int mounted (const char *spec0, const char *node0);
+static int mounted (const char *spec0, const char *node0, struct mntentchn *fstab_mc);
static int check_special_mountprog(const char *spec, const char *node,
const char *type, int flags, char *extra_opts, int *status);
@@ -1562,7 +1562,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
/* The "mount -f" checks for for existing record in /etc/mtab (with
* regular non-fake mount this is usually done by kernel)
*/
- if (!(flags & MS_REMOUNT) && fake && mounted (spec, node))
+ if (!(flags & MS_REMOUNT) && fake && mounted (spec, node, NULL))
die(EX_USAGE, _("mount: according to mtab, "
"%s is already mounted on %s\n"),
spec, node);
@@ -2016,13 +2016,46 @@ mount_one (const char *spec, const char *node, const char *types,
return try_mount_one (spec, node, types, opts, freq, pass, 0);
}
+#ifdef HAVE_LIBMOUNT_MOUNT
+static struct libmnt_table *minfo; /* parsed mountinfo file */
+#endif
+
/* Check if an fsname/dir pair was already in the old mtab. */
static int
-mounted (const char *spec0, const char *node0) {
+mounted (const char *spec0, const char *node0, struct mntentchn *fstab_mc) {
struct mntentchn *mc, *mc0;
const char *spec, *node;
int ret = 0;
+#ifdef HAVE_LIBMOUNT_MOUNT
+ /*
+ * Use libmount to check for already mounted bind mounts on systems
+ * without mtab.
+ */
+ if (fstab_mc && fstab_mc->m.mnt_opts &&
+ mtab_is_a_symlink() && strstr(fstab_mc->m.mnt_opts, "bind")) {
+
+ struct libmnt_fs *fs = mnt_new_fs();
+ int rc = fs ? 0 : -1;
+
+ if (!rc)
+ rc = mnt_fs_set_fstype(fs, fstab_mc->m.mnt_type);
+ if (!rc)
+ rc = mnt_fs_set_source(fs, fstab_mc->m.mnt_fsname);
+ if (!rc)
+ rc = mnt_fs_set_target(fs, fstab_mc->m.mnt_dir);
+ if (!rc)
+ rc = mnt_fs_set_options(fs, fstab_mc->m.mnt_opts);
+ if (!rc && !minfo)
+ minfo = mnt_new_table_from_file("/proc/self/mountinfo");
+ if (!rc && minfo)
+ rc = mnt_table_is_fs_mounted(minfo, fs);
+
+ mnt_free_fs(fs);
+ if (rc == 1)
+ return 1;
+ }
+#endif
/* Handle possible UUID= and LABEL= in spec */
spec = spec_to_devname(spec0);
if (!spec)
@@ -2030,6 +2063,7 @@ mounted (const char *spec0, const char *node0) {
node = canonicalize(node0);
+
mc0 = mtab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
if (streq (spec, mc->m.mnt_fsname) &&
@@ -2050,7 +2084,7 @@ is_fstab_entry_mounted(struct mntentchn *mc, int verbose)
{
struct stat st;
- if (mounted(mc->m.mnt_fsname, mc->m.mnt_dir))
+ if (mounted(mc->m.mnt_fsname, mc->m.mnt_dir, mc))
goto yes;
/* extra care for loop devices */
--
1.7.5.2

View File

@ -0,0 +1,33 @@
From aab72640daa7ee2db3d42fc8278ab86e3aef2d71 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 2 Jun 2011 14:53:42 +0200
Subject: [PATCH] mount: canonicalize fstab mnt_dir
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=709681
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/fstab.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/mount/fstab.c b/mount/fstab.c
index 8ce733b..4fa26b4 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -455,7 +455,13 @@ getfs_by_dir (const char *dir) {
cdir = canonicalize(dir);
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
- if (streq(mc->m.mnt_dir, cdir)) {
+ int ok = streq(mc->m.mnt_dir, cdir);
+ if (!ok) {
+ char *dr = canonicalize(mc->m.mnt_dir);
+ ok = dr ? streq(dr, cdir) : 0;
+ free(dr);
+ }
+ if (ok) {
free(cdir);
return mc;
}
--
1.7.5.2

View File

@ -0,0 +1,76 @@
From 067e9b4934372f72b89b2c0442a3d28290834537 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 29 Jun 2011 09:02:50 +0200
Subject: [PATCH] mount: first look for mountpoint
# mount <device|dir>
The current code looks for a device and then for a mountpoint in
/etc/fstab. This is not user friendly solution. People usually use
# mount /dir
to mount any filesystem. It makes more sense to check for mountpoint
and if not found then for device.
This is also important for bind mounts, for example if you have in
your fstab:
/dev/sda1 /mnt/foo auto defaults
/mnt/foo /mnt/bar none bind
then
# mount /mnt/foo
should be interpreted as the first entry and /dev/sda1 should be
mounted.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=716483
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/mount.8 | 11 +++++++++++
mount/mount.c | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/mount/mount.8 b/mount/mount.8
index 8982537..e9a52dd 100644
--- a/mount/mount.8
+++ b/mount/mount.8
@@ -101,6 +101,17 @@ the pathname
refers to the root of the filesystem on
.IR device .
+If only directory or device is given, for example:
+.RS
+
+.br
+.BI "mount /dir"
+.br
+
+.RE
+then mount looks for a mountpoint and if not found then for a device in the
+/etc/fstab file.
+
.B The listing and help.
.RS
Three forms of invocation do not actually mount anything:
diff --git a/mount/mount.c b/mount/mount.c
index 3ba705f..00637f5 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -2347,10 +2347,10 @@ getfs(const char *spec, const char *uuid, const char *label)
else if (label)
mc = getfs_by_label(label);
else {
- mc = getfs_by_spec(spec);
+ mc = getfs_by_dir(spec);
if (!mc)
- mc = getfs_by_dir(spec);
+ mc = getfs_by_spec(spec);
}
if (mc)
return mc;
--
1.7.5.4

View File

@ -0,0 +1,64 @@
diff -up util-linux-2.20-rc1/libblkid/libblkid.3.kzak util-linux-2.20-rc1/libblkid/libblkid.3
--- util-linux-2.20-rc1/libblkid/libblkid.3.kzak 2011-07-26 16:43:07.000000000 +0200
+++ util-linux-2.20-rc1/libblkid/libblkid.3 2011-07-29 21:17:20.883777687 +0200
@@ -28,7 +28,7 @@ partitions and block device topology.
.P
The high-level part of the library keeps information about block devices
in a cache file
-.I /etc/blkid.tab
+.I /etc/blkid/blkid.tab
and is verified to still be valid before being returned to the user
(if the user has read permission on the raw block device, otherwise not).
The cache file also allows unprivileged users (normally anyone other
@@ -69,7 +69,7 @@ symlink does not match with LABEL or UUI
.I CACHE_FILE=<path>
Overrides the standard location of the cache file. This setting can be
overridden by the environment variable BLKID_FILE. Default is
-.I /etc/blkid.tab.
+.I /etc/blkid/blkid.tab.
.TP
.I EVALUATE=<methods>
Defines LABEL and UUID evaluation method(s). Currently, the libblkid library
@@ -87,7 +87,7 @@ from Ted Ts'o. The library was subseque
The low-level probing code was rewritten by Karel Zak.
.SH FILES
.TP 18
-.I /etc/blkid.tab
+.I /etc/blkid/blkid.tab
caches data extracted from each recognized block device
.TP
.I /etc/blkid.conf
diff -up util-linux-2.20-rc1/libblkid/src/blkidP.h.kzak util-linux-2.20-rc1/libblkid/src/blkidP.h
--- util-linux-2.20-rc1/libblkid/src/blkidP.h.kzak 2011-07-20 21:55:23.000000000 +0200
+++ util-linux-2.20-rc1/libblkid/src/blkidP.h 2011-07-29 21:17:52.852169993 +0200
@@ -286,7 +286,7 @@ extern char *blkid_strdup(const char *s)
extern char *blkid_strndup(const char *s, const int length);
extern char *blkid_strconcat(const char *a, const char *b, const char *c);
-#define BLKID_CACHE_FILE "/etc/blkid.tab"
+#define BLKID_CACHE_FILE "/etc/blkid/blkid.tab"
#define BLKID_CONFIG_FILE "/etc/blkid.conf"
#define BLKID_ERR_IO 5
diff -up util-linux-2.20-rc1/misc-utils/blkid.8.kzak util-linux-2.20-rc1/misc-utils/blkid.8
--- util-linux-2.20-rc1/misc-utils/blkid.8.kzak 2011-07-20 21:55:23.000000000 +0200
+++ util-linux-2.20-rc1/misc-utils/blkid.8 2011-07-29 21:15:37.312506693 +0200
@@ -79,7 +79,7 @@ same meaning as "KiB") or decimal (10^N)
Read from
.I cachefile
instead of reading from the default cache file
-.IR /etc/blkid.tab .
+.IR /etc/blkid/blkid.tab .
If you want to start with a clean cache (i.e. don't report devices previously
scanned but not necessarily available at this time), specify
.IR /dev/null .
@@ -242,7 +242,7 @@ Display version number and exit.
Write the device cache to
.I writecachefile
instead of writing it to the default cache file
-.IR /etc/blkid.tab .
+.IR /etc/blkid/blkid.tab .
If you don't want to save the cache at all, specify
.IR /dev/null.
If not specified, it will be the same file as that given with the
diff -up util-linux-2.20-rc1/misc-utils/blkid.c.kzak util-linux-2.20-rc1/misc-utils/blkid.c

View File

@ -0,0 +1,25 @@
diff -up util-linux-2.20-rc1/disk-utils/fdformat.8.orig util-linux-2.20-rc1/disk-utils/fdformat.8
--- util-linux-2.20-rc1/disk-utils/fdformat.8.orig 2011-07-20 21:55:23.000000000 +0200
+++ util-linux-2.20-rc1/disk-utils/fdformat.8 2011-07-29 21:08:57.558601033 +0200
@@ -43,6 +43,11 @@ when a non-standard format is being used
autodetected earlier. In this case, use
.BR setfdprm (8)
to load the disk parameters.
+
+For ATAPI IDE floppy driver (also known as LS-120 drives or "Superdisk"
+drives) you have to use the
+.BR floppy (8).
+
.SH OPTIONS
.TP
\fB\-n\fR, \fB\-\-no\-verify\fR
@@ -58,7 +63,8 @@ Display help and exit.
.BR fd (4),
.BR setfdprm (8),
.BR mkfs (8),
-.BR emkfs (8)
+.BR emkfs (8),
+.BR floppy (8)
.SH AUTHOR
Werner Almesberger (almesber@nessie.cs.id.ethz.ch)
.SH AVAILABILITY

View File

@ -0,0 +1,50 @@
diff -up util-linux-2.20-rc2/sys-utils/ipcs.c.kzak util-linux-2.20-rc2/sys-utils/ipcs.c
--- util-linux-2.20-rc2/sys-utils/ipcs.c.kzak 2011-08-12 11:13:00.000000000 +0200
+++ util-linux-2.20-rc2/sys-utils/ipcs.c 2011-08-17 01:16:23.629928605 +0200
@@ -255,6 +255,28 @@ print_perms (int id, struct ipc_perm *ip
}
+static unsigned long long
+shminfo_from_proc(const char *name, unsigned long def)
+{
+ char path[256];
+ char buf[64];
+ FILE *f;
+ unsigned long long res = def;
+
+ if (!name)
+ return res;
+
+ snprintf(path, sizeof(path), "/proc/sys/kernel/%s", name);
+
+ if (!(f = fopen(path, "r")))
+ return res;
+ if (fgets(buf, sizeof(buf), f))
+ res = atoll(buf);
+ fclose(f);
+ return res;
+}
+
+
void do_shm (char format)
{
int maxid, shmid, id;
@@ -277,12 +299,12 @@ void do_shm (char format)
return;
/* glibc 2.1.3 and all earlier libc's have ints as fields
of struct shminfo; glibc 2.1.91 has unsigned long; ach */
- printf (_("max number of segments = %lu\n"),
- (unsigned long) shminfo.shmmni);
- printf (_("max seg size (kbytes) = %lu\n"),
- (unsigned long) (shminfo.shmmax >> 10));
+ printf (_("max number of segments = %llu\n"),
+ shminfo_from_proc("shmmni", shminfo.shmmni));
+ printf (_("max seg size (kbytes) = %llu\n"),
+ (shminfo_from_proc("shmmax", shminfo.shmmax) >> 10));
printf (_("max total shared memory (kbytes) = %llu\n"),
- getpagesize() / 1024 * (unsigned long long) shminfo.shmall);
+ getpagesize() / 1024 * shminfo_from_proc("shmall", shminfo.shmall));
printf (_("min seg size (bytes) = %lu\n"),
(unsigned long) shminfo.shmmin);
return;

View File

@ -0,0 +1,46 @@
From 86248cd28a27bdd9a437e389966b0415e106802e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 8 Dec 2011 10:20:22 +0100
Subject: [PATCH] logger: fix remote logging
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reported-by: Hervé Quillévéré <herve_quillevere@herveq.tk>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/logger.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index a331f26..c89fca7 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -281,7 +281,7 @@ main(int argc, char **argv) {
}
}
if (p != buf) {
- if (!usock)
+ if (!usock && !udpserver)
syslog(pri, "%s", buf);
else
mysyslog(LogSock, logflags, pri, tag, buf);
@@ -295,13 +295,13 @@ main(int argc, char **argv) {
if (len > 0 && buf[len - 1] == '\n')
buf[len - 1] = '\0';
- if (!usock)
+ if (!usock && !udpserver)
syslog(pri, "%s", buf);
else
mysyslog(LogSock, logflags, pri, tag, buf);
}
}
- if (!usock)
+ if (!usock && !udpserver)
closelog();
else
close(LogSock);
--
1.7.7.5

View File

@ -0,0 +1,51 @@
From 3142564b244b3163446d59f83390f73cea85097b Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 10 Jan 2012 15:43:56 +0100
Subject: [PATCH] mount: add hint that context= has to be quoted
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=747038
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/mount.8 | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/mount/mount.8 b/mount/mount.8
index 2c4f636..00b512e 100644
--- a/mount/mount.8
+++ b/mount/mount.8
@@ -839,7 +839,7 @@ xattrs are supported, you can save time not having to label every file by
assigning the entire disk one security context.
A commonly used option for removable media is
-.BR context=system_u:object_r:removable_t .
+.BR context="system_u:object_r:removable_t" .
Two other options are
.BR fscontext=
@@ -875,8 +875,23 @@ useful for things like stateless linux.
Note that kernel rejects any remount request that includes the context
option even if unchanged from the current context.
+.B Warning that \fIcontext\fP value might contains comma
+and in this case the value has to be properly quoted otherwise
+.BR mount (8)
+will interpret the comma as separator between mount options. Don't forget that
+shell strips off quotes and
+.BR "double quoting is required" ,
+for example:
+.RS
+.RS
+.sp
+mount -t tmpfs none /mnt \-o 'context="system_u:object_r:tmp_t:s0:c127,c456",noexec'
+.sp
+.RE
+
For more details, see
.BR selinux (8)
+.RE
.TP
.B defaults
--
1.7.7.5

View File

@ -0,0 +1,32 @@
diff -up util-linux-2.20.1/libmount/src/context_mount.c.kzak util-linux-2.20.1/libmount/src/context_mount.c
--- util-linux-2.20.1/libmount/src/context_mount.c.kzak 2011-10-18 14:22:27.000000000 +0200
+++ util-linux-2.20.1/libmount/src/context_mount.c 2012-04-17 15:25:14.273287922 +0200
@@ -46,9 +46,10 @@ static int fix_optstr(struct libmnt_cont
fs = cxt->fs;
- /* The propagation flags should not be used together with any other flags */
+ /* The propagation flags should not be used together with any other
+ * flags (except MS_REC and MS_SILENT) */
if (cxt->mountflags & MS_PROPAGATION)
- cxt->mountflags &= MS_PROPAGATION;
+ cxt->mountflags &= (MS_PROPAGATION | MS_REC | MS_SILENT);
if (!mnt_optstr_get_option(fs->user_optstr, "user", &val, &valsz)) {
if (val) {
diff -up util-linux-2.20.1/mount/mount.c.kzak util-linux-2.20.1/mount/mount.c
--- util-linux-2.20.1/mount/mount.c.kzak 2012-04-17 15:24:52.817199995 +0200
+++ util-linux-2.20.1/mount/mount.c 2012-04-17 15:25:14.274287916 +0200
@@ -586,9 +586,10 @@ parse_opts (const char *options, int *fl
*flags |= mounttype;
- /* The propagation flags should not be used together with any other flags */
+ /* The propagation flags should not be used together with any
+ * other flags (except MS_REC and MS_SILENT) */
if (*flags & MS_PROPAGATION)
- *flags &= MS_PROPAGATION;
+ *flags &= (MS_PROPAGATION | MS_REC | MS_SILENT);
}
/* Try to build a canonical options string. */

141
util-linux-2.20-mount.patch Normal file
View File

@ -0,0 +1,141 @@
From a4c0cc75ff9744299f108c259efab1bd30c8007a Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 2 Jan 2012 11:08:17 +0100
Subject: [PATCH] mount: append inverting options for mount.<type>
fstab:
server://foo /mnt/foo nfs user,exec
The mount(8) does not append the option "exec" to /sbin/mount.<type>
helper's command line. This is no problem when executed by non-root
user as it reads the options from fstab only.
.. but when executed by root (UID=0) then the mount.<type> helper
follows the command where the "exec" option is missing. This is bug.
original version (strace output):
execve("/sbin/mount.nfs", ["/sbin/mount.nfs",
"sr.net.home:/mnt/store", "/mnt/store", "-o",
"rw,nosuid,nodev,noauto,user"], [/* 21 vars */]) = 0
fixed version:
execve("/sbin/mount.nfs", ["/sbin/mount.nfs",
"sr.net.home:/mnt/store", "/mnt/store", "-o",
"rw,nosuid,nodev,noauto,user,exec"], [/* 21 vars */]) = 0
^^^^^
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/mount.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/mount/mount.c b/mount/mount.c
index 9b444c4..a18b2df 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -207,6 +207,8 @@ static const struct opt_map opt_map[] = {
static int opt_nofail = 0;
+static int invuser_flags;
+
static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit,
*opt_encryption, *opt_speed, *opt_comment, *opt_uhelper, *opt_helper;
@@ -473,7 +475,7 @@ static int has_context_option(char *opts)
* For the options uid= and gid= replace user or group name by its value.
*/
static inline void
-parse_opt(char *opt, int *mask, char **extra_opts) {
+parse_opt(char *opt, int *mask, int *inv_user, char **extra_opts) {
const struct opt_map *om;
for (om = opt_map; om->opt != NULL; om++)
@@ -482,6 +484,9 @@ parse_opt(char *opt, int *mask, char **extra_opts) {
*mask &= ~om->mask;
else
*mask |= om->mask;
+ if (om->inv && ((*mask & MS_USER) || (*mask & MS_USERS))
+ && (om->mask & MS_SECURE))
+ *inv_user |= om->mask;
if ((om->mask == MS_USER || om->mask == MS_USERS)
&& !om->inv)
*mask |= MS_SECURE;
@@ -566,7 +571,7 @@ parse_opts (const char *options, int *flags, char **extra_opts) {
/* end of option item or last item */
if (*p == '\0' || *(p+1) == '\0') {
if (!parse_string_opt(opt))
- parse_opt(opt, flags, extra_opts);
+ parse_opt(opt, flags, &invuser_flags, extra_opts);
opt = NULL;
}
}
@@ -587,7 +592,9 @@ parse_opts (const char *options, int *flags, char **extra_opts) {
/* Try to build a canonical options string. */
static char *
-fix_opts_string (int flags, const char *extra_opts, const char *user) {
+fix_opts_string (int flags, const char *extra_opts,
+ const char *user, int inv_user)
+{
const struct opt_map *om;
const struct string_opt_map *m;
char *new_opts;
@@ -611,6 +618,16 @@ fix_opts_string (int flags, const char *extra_opts, const char *user) {
if (user)
new_opts = append_opt(new_opts, "user=", user);
+ if (inv_user) {
+ for (om = opt_map; om->opt != NULL; om++) {
+ if (om->mask && om->inv
+ && (inv_user & om->mask) == om->mask) {
+ new_opts = append_opt(new_opts, om->opt, NULL);
+ inv_user &= ~om->mask;
+ }
+ }
+ }
+
return new_opts;
}
@@ -662,7 +679,7 @@ create_mtab (void) {
mnt.mnt_dir = "/";
mnt.mnt_fsname = spec_to_devname(fstab->m.mnt_fsname);
mnt.mnt_type = fstab->m.mnt_type;
- mnt.mnt_opts = fix_opts_string (flags, extra_opts, NULL);
+ mnt.mnt_opts = fix_opts_string (flags, extra_opts, NULL, 0);
mnt.mnt_freq = mnt.mnt_passno = 0;
free(extra_opts);
@@ -787,7 +804,7 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in
if (setuid(getuid()) < 0)
die(EX_FAIL, _("mount: cannot set user id: %s"), strerror(errno));
- oo = fix_opts_string (flags, extra_opts, NULL);
+ oo = fix_opts_string(flags, extra_opts, NULL, invuser_flags);
mountargs[i++] = mountprog; /* 1 */
mountargs[i++] = (char *) spec; /* 2 */
mountargs[i++] = (char *) node; /* 3 */
@@ -1659,7 +1676,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
}
#ifdef HAVE_LIBMOUNT_MOUNT
- mtab_opts = fix_opts_string(flags & ~MS_NOMTAB, extra_opts, user);
+ mtab_opts = fix_opts_string(flags & ~MS_NOMTAB, extra_opts, user, 0);
mtab_flags = flags;
if (fake)
@@ -1703,7 +1720,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
}
if (fake || mnt5_res == 0) {
- char *mo = fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user);
+ char *mo = fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user, 0);
const char *tp = types ? types : "unknown";
/* Mount succeeded, report this (if verbose) and write mtab entry. */
--
1.7.7.5

View File

@ -0,0 +1,25 @@
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -40,6 +40,10 @@
#define MS_MOVE 8192
#endif
+#ifndef MNT_DETACH
+#define MNT_DETACH 0x00000002 /* Just detach from the tree */
+#endif
+
/* remove all files/directories below dirName -- don't cross mountpoints */
static int recursiveRemove(int fd)
{
@@ -131,7 +135,7 @@ static int switchroot(const char *newroot)
if ((stat(newmount, &sb) != 0) || (sb.st_dev != newroot_stat.st_dev)) {
/* mount point seems to be mounted already or stat failed */
- umount(umounts[i]);
+ umount2(umounts[i], MNT_DETACH);
continue;
}
--
1.7.7.5

11
util-linux-60-raw.rules Normal file
View File

@ -0,0 +1,11 @@
# This file and interface are deprecated.
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
#
# Enter raw device bindings here.
#
# An example would be:
# ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
# ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.

View File

@ -1,4 +1,5 @@
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth substack system-auth
auth include postlogin
account required pam_nologin.so
@ -7,6 +8,7 @@ password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session required pam_namespace.so

View File

@ -0,0 +1,10 @@
--- util-linux-2.13-pre6/sys-utils/ctrlaltdel.8.kzak 2006-08-10 12:23:53.000000000 +0200
+++ util-linux-2.13-pre6/sys-utils/ctrlaltdel.8 2006-08-10 12:24:08.000000000 +0200
@@ -32,7 +32,6 @@
.SH FILES
.I /etc/rc.local
.SH "SEE ALSO"
-.BR simpleinit (8),
.BR init (8)
.SH AUTHOR
Peter Orbaek (poe@daimi.aau.dk)

View File

@ -0,0 +1,13 @@
Index: util-linux-ng-2.14.2-rc1/login-utils/login.c
===================================================================
--- util-linux-ng-2.14.2-rc1.orig/login-utils/login.c
+++ util-linux-ng-2.14.2-rc1/login-utils/login.c
@@ -1415,7 +1415,7 @@ dolastlog(int quiet) {
struct lastlog ll;
int fd;
- if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
+ if ((fd = open(_PATH_LASTLOG, O_RDWR|O_CREAT, 0)) >= 0) {
lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);
if (!quiet) {
if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&

View File

@ -1,4 +1,5 @@
#%PAM-1.0
auth required pam_securetty.so
auth substack password-auth
auth include postlogin
account required pam_nologin.so

View File

@ -1,5 +0,0 @@
#%PAM-1.0
auth include runuser
session optional pam_keyinit.so force revoke
-session optional pam_systemd.so
session include runuser

View File

@ -1,5 +0,0 @@
#%PAM-1.0
auth sufficient pam_rootok.so
session optional pam_keyinit.so revoke
session required pam_limits.so
session required pam_unix.so

View File

@ -1,6 +0,0 @@
#%PAM-1.0
auth include su
account include su
password include su
session optional pam_keyinit.so force revoke
session include su

View File

@ -1,14 +0,0 @@
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth substack system-auth
auth include postlogin
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session include postlogin
session optional pam_xauth.so

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
d /run/uuidd 2775 uuidd uuidd

117
uuidd.init Executable file
View File

@ -0,0 +1,117 @@
#!/bin/bash
#
# uuidd uuidd daemon for unique time-based UUID generation
#
# Author: Eric Sandeen <sandeen@redhat.com>
#
# chkconfig: - 60 99
#
# description: uuidd is a helper daemon to guarantee uniqueness of \
# time-based UUIDs when using libuuid.
# processname: uuidd
# pidfile: /var/lib/libuuid/uuidd.pid
#
### BEGIN INIT INFO
# Provides: uuidd
# Required-Start: $time $local_fs
# Required-Stop: $time $local_fs
# Default-Stop: 0 1 6
# Short-Description: UUID daemon
# Description: Daemon which guarantees uniqueness of time-based UUIDS
# when using libuuid.
### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
[ -e /etc/sysconfig/uuidd ] && . /etc/sysconfig/uuidd
DAEMON=uuidd
exec=/usr/sbin/uuidd
prog=uuidd
user=uuidd
lockfile=/var/lock/subsys/$DAEMON
pidfile=/var/run/uuidd/uuidd.pid
check() {
# Check that we're a privileged user
[ $(id -u) -eq 0 ] || exit 4
# Check if daemon binary is executable
[ -x $exec ] || exit 5
}
start () {
check
echo -n $"Starting $prog: "
daemon --user $user --pidfile $pidfile $DAEMON
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop () {
check
echo -n $"Stopping $prog: "
killproc $DAEMON
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $DAEMON
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?