- fix #882305 - agetty: unstable /dev/tty* permissions
- fix #885314 - hexdump segfault
- fix #896447 - No newlines in piped "cal" command
- fix libblkid cache usage (upstream patch)
- fix #905008 - uuidd: /usr/sbin/uuidd has incorrect file permissions

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-02-03 16:54:28 +01:00
parent 1bc2448b90
commit 8e3b51d51a
5 changed files with 462 additions and 2 deletions

View File

@ -0,0 +1,45 @@
From 7afbf6f20e1de62fb5595411d998703c95af8965 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 2 Jan 2013 08:23:00 +0100
Subject: [PATCH 1/3] agetty: replace perms 660 to 620
... the default is root:tty 620
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/login.1 | 5 ++++-
term-utils/agetty.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/login-utils/login.1 b/login-utils/login.1
index 092213d..e37e5e6 100644
--- a/login-utils/login.1
+++ b/login-utils/login.1
@@ -184,7 +184,10 @@ login failure. The default value is
(string)
.RS 4
The terminal permissions. The default value is
-.IR 0600 .
+.IR 0600
+or
+.IR 0620
+if tty group is used.
.RE
.PP
.B TTYGROUP
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 7ee252d..17ebfba 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -894,7 +894,7 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
* Linux login(1) will change tty permissions. Use root owner and group
* with permission -rw------- for the period between getty and login.
*/
- if (chown(buf, 0, gid) || chmod(buf, (gid ? 0660 : 0600))) {
+ if (chown(buf, 0, gid) || chmod(buf, (gid ? 0620 : 0600))) {
if (errno == EROFS)
log_warn("%s: %m", buf);
else
--
1.8.1

View File

@ -0,0 +1,139 @@
From c265cc40a8ece740084fbfb3ebd4c1894b3b29b7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Jan 2013 18:48:16 +0100
Subject: [PATCH 3/3] cal: don't mix ncurses output functions and printf()
Fedora 18 (ncurses-libs-5.9-7.20121017, glibc-2.16-28):
$ cal | cat
Actual results:
January 2013 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8
9 10 11 1213 14 15 16 17 18 1920 21 22 23 24 25 2627 28 29 30 31
Not sure where is the problem, but it's too fragile to mix two
output methods in one code.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=896447
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/cal.c | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 60e85df..0e204b9 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -498,7 +498,7 @@ monthly(int day, int month, int year) {
do_monthly(day, month, year, &out);
for (i = 0; i < FMT_ST_LINES; i++) {
my_putstring(out.s[i]);
- putchar('\n');
+ my_putstring("\n");
}
}
@@ -533,8 +533,11 @@ monthly3(int day, int month, int year) {
do_monthly(day, next_month, next_year, &out_next);
width = (julian ? J_WEEK_LEN : WEEK_LEN) -1;
- for (i = 0; i < 2; i++)
- printf("%s %s %s\n", out_prev.s[i], out_curm.s[i], out_next.s[i]);
+ for (i = 0; i < 2; i++) {
+ snprintf(lineout, sizeof(lineout),
+ "%s %s %s\n", out_prev.s[i], out_curm.s[i], out_next.s[i]);
+ my_putstring(lineout);
+ }
for (i = 2; i < FMT_ST_LINES; i++) {
int w1, w2, w3;
w1 = w2 = w3 = width;
@@ -562,7 +565,7 @@ j_yearly(int day, int year) {
snprintf(lineout, sizeof(lineout), "%d", year);
center(lineout, J_WEEK_LEN*2 + J_HEAD_SEP - 1, 0);
- printf("\n\n");
+ my_putstring("\n\n");
for (i = 0; i < 12; i++)
day_array(day, i + 1, year, days[i]);
@@ -571,8 +574,10 @@ j_yearly(int day, int year) {
for (month = 0; month < 12; month += 2) {
center(full_month[month], J_WEEK_LEN-1, J_HEAD_SEP+1);
center(full_month[month + 1], J_WEEK_LEN-1, 0);
- printf("\n%s%*s %s\n", j_day_headings, J_HEAD_SEP, "",
- j_day_headings);
+ snprintf(lineout, sizeof(lineout),
+ "\n%s%*s %s\n", j_day_headings, J_HEAD_SEP, "",
+ j_day_headings);
+ my_putstring(lineout);
for (row = 0; row < 6; row++) {
p = lineout;
for (which_cal = 0; which_cal < 2; which_cal++) {
@@ -584,10 +589,10 @@ j_yearly(int day, int year) {
*p = '\0';
trim_trailing_spaces(lineout);
my_putstring(lineout);
- putchar('\n');
+ my_putstring("\n");
}
}
- printf("\n");
+ my_putstring("\n");
}
void
@@ -598,7 +603,7 @@ yearly(int day, int year) {
snprintf(lineout, sizeof(lineout), "%d", year);
center(lineout, WEEK_LEN*3 + HEAD_SEP*2 - 1, 0);
- printf("\n\n");
+ my_putstring("\n\n");
for (i = 0; i < 12; i++)
day_array(day, i + 1, year, days[i]);
@@ -608,8 +613,10 @@ yearly(int day, int year) {
center(full_month[month], WEEK_LEN-1, HEAD_SEP+1);
center(full_month[month + 1], WEEK_LEN-1, HEAD_SEP+1);
center(full_month[month + 2], WEEK_LEN-1, 0);
- printf("\n%s%*s %s%*s %s\n", day_headings, HEAD_SEP,
- "", day_headings, HEAD_SEP, "", day_headings);
+ snprintf(lineout, sizeof(lineout),
+ "\n%s%*s %s%*s %s\n", day_headings, HEAD_SEP,
+ "", day_headings, HEAD_SEP, "", day_headings);
+ my_putstring(lineout);
for (row = 0; row < 6; row++) {
p = lineout;
for (which_cal = 0; which_cal < 3; which_cal++) {
@@ -621,10 +628,10 @@ yearly(int day, int year) {
*p = '\0';
trim_trailing_spaces(lineout);
my_putstring(lineout);
- putchar('\n');
+ my_putstring("\n");
}
}
- putchar('\n');
+ my_putstring("\n");
}
/*
@@ -773,10 +780,14 @@ void
center(const char *str, size_t len, int separate)
{
char lineout[FMT_ST_CHARS];
+
center_str(str, lineout, ARRAY_SIZE(lineout), len);
- fputs(lineout, stdout);
- if (separate)
- printf("%*s", separate, "");
+ my_putstring(lineout);
+
+ if (separate) {
+ snprintf(lineout, sizeof(lineout), "%*s", separate, "");
+ my_putstring(lineout);
+ }
}
static void __attribute__ ((__noreturn__)) usage(FILE * out)
--
1.8.1

View File

@ -0,0 +1,95 @@
From 85c24fe2b11cd136d43bbffd983014a3f967c25e Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@redhat.com>
Date: Fri, 21 Dec 2012 13:04:04 +0100
Subject: [PATCH 2/3] hexdump: do not segfault when iterating over an empty
format string
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
---
tests/commands.sh | 1 +
tests/expected/hexdump/empty-format | 1 +
tests/ts/hexdump/empty-format | 26 ++++++++++++++++++++++++++
text-utils/parse.c | 16 +++++++++-------
4 files changed, 37 insertions(+), 7 deletions(-)
create mode 100644 tests/expected/hexdump/empty-format
create mode 100755 tests/ts/hexdump/empty-format
diff --git a/tests/commands.sh b/tests/commands.sh
index db1d4ac..3672095 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -62,3 +62,4 @@ TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"$top_builddir/findmnt"}
TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"}
+TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"$top_builddir/hexdump"}
diff --git a/tests/expected/hexdump/empty-format b/tests/expected/hexdump/empty-format
new file mode 100644
index 0000000..9d60796
--- /dev/null
+++ b/tests/expected/hexdump/empty-format
@@ -0,0 +1 @@
+11
\ No newline at end of file
diff --git a/tests/ts/hexdump/empty-format b/tests/ts/hexdump/empty-format
new file mode 100755
index 0000000..4a3e528
--- /dev/null
+++ b/tests/ts/hexdump/empty-format
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file 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 of the License, or
+# (at your option) any later version.
+#
+# This file 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.
+#
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="format-strings"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+INPUT=$(printf \\1)
+$TS_CMD_HEXDUMP -n1 -ve '2 "" "%x"' <<< $INPUT 2>&1 >> $TS_OUTPUT
+
+$TS_CMD_HEXDUMP -n1 -ve '4 "%x"' -e '2 ""' <<< $INPUT 2>&1 >> $TS_OUTPUT
+
+ts_finalize
diff --git a/text-utils/parse.c b/text-utils/parse.c
index 5f1e2bd..bd96961 100644
--- a/text-utils/parse.c
+++ b/text-utils/parse.c
@@ -421,13 +421,15 @@ isint2: switch(fu->bcnt) {
!(fu->flags&F_SETREP) && fu->bcnt)
fu->reps += (blocksize - fs->bcnt) / fu->bcnt;
if (fu->reps > 1) {
- for (pr = fu->nextpr;; pr = pr->nextpr)
- if (!pr->nextpr)
- break;
- for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
- p2 = isspace((unsigned char)*p1) ? p1 : NULL;
- if (p2)
- pr->nospace = p2;
+ if (fu->nextpr) {
+ for (pr = fu->nextpr; ; pr = pr->nextpr)
+ if (!pr->nextpr)
+ break;
+ for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
+ p2 = isspace((unsigned char)*p1) ? p1 : NULL;
+ if (p2)
+ pr->nospace = p2;
+ }
}
}
}
--
1.8.1

View File

@ -0,0 +1,165 @@
From 2270b1ad90b394950f4fe215eb2fc1042020cef0 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 1 Feb 2013 15:59:58 +0100
Subject: [PATCH] libblkid: remove optimization from verify( funrtion
Now libblkid (the cache based part) tries to probe for the cached
filesystem firstly. This optimization is broken, because:
* new another superblock could be on the device and the original
is already obsolete
* we still need to probe for partitions and raids
* the code was too fragile
The patch also suggests lsblk --fs in blkid.8 for end users. lsblk
read information from used db.
Reported-by: Andreas Hofmeister <andi@collax.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/verify.c | 76 ++++++++-------------------------------------------
misc-utils/blkid.8 | 11 ++++++++
2 files changed, 22 insertions(+), 65 deletions(-)
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index 4bab4de..0f48c48 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -43,26 +43,6 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev)
blkid_set_tag(dev, name, data, len);
}
}
-
- /*
- * remove obsolete tags
- */
- if (!nvals || !blkid_probe_has_value(pr, "LABEL"))
- blkid_set_tag(dev, "LABEL", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "UUID"))
- blkid_set_tag(dev, "UUID", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "PART_ENTRY_UUID"))
- blkid_set_tag(dev, "PARTUUID", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "PART_ENTRY_NAME"))
- blkid_set_tag(dev, "PARTLABEL", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "TYPE"))
- blkid_set_tag(dev, "TYPE", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "SEC_TYPE"))
- blkid_set_tag(dev, "SEC_TYPE", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "EXT_JOURNAL")) /* extN */
- blkid_set_tag(dev, "EXT_JOURNAL", NULL, 0);
- if (!nvals || !blkid_probe_has_value(pr, "MOUNT")) /* ocfs */
- blkid_set_tag(dev, "MOUNT", NULL, 0);
}
/*
@@ -76,9 +56,10 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev)
*/
blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
{
+ blkid_tag_iterate iter;
+ const char *type, *value;
struct stat st;
time_t diff, now;
- char *fltr[2];
int fd;
if (!dev)
@@ -155,64 +136,29 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
return NULL;
}
- blkid_probe_enable_superblocks(cache->probe, TRUE);
+ /* remove old cache info */
+ iter = blkid_tag_iterate_begin(dev);
+ while (blkid_tag_next(iter, &type, &value) == 0)
+ blkid_set_tag(dev, type, NULL, 0);
+ blkid_tag_iterate_end(iter);
+ /* enable superblocks probing */
+ blkid_probe_enable_superblocks(cache->probe, TRUE);
blkid_probe_set_superblocks_flags(cache->probe,
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE);
- /*
- * If we already know the type, then try that first.
- */
- if (dev->bid_type) {
- blkid_tag_iterate iter;
- const char *type, *value;
-
- fltr[0] = dev->bid_type;
- fltr[1] = NULL;
-
- blkid_probe_filter_superblocks_type(cache->probe,
- BLKID_FLTR_ONLYIN, fltr);
-
- if (blkid_do_probe(cache->probe) == 0) {
- /*
- * Cool, we found FS type, let's also read PART{UUID,LABEL}
- */
- blkid_probe_enable_superblocks(cache->probe, FALSE);
- blkid_probe_enable_partitions(cache->probe, TRUE);
- blkid_probe_set_partitions_flags(cache->probe, BLKID_PARTS_ENTRY_DETAILS);
- if (blkid_do_probe(cache->probe) == 0)
- goto found_type;
- }
-
- blkid_probe_enable_superblocks(cache->probe, TRUE);
- blkid_probe_invert_superblocks_filter(cache->probe);
-
- /*
- * Zap the device filesystem information and try again
- */
- DBG(DEBUG_PROBE,
- printf("previous fs type %s not valid, "
- "trying full probe\n", dev->bid_type));
- iter = blkid_tag_iterate_begin(dev);
- while (blkid_tag_next(iter, &type, &value) == 0)
- blkid_set_tag(dev, type, 0, 0);
- blkid_tag_iterate_end(iter);
- }
-
+ /* enable partitions probing */
blkid_probe_enable_partitions(cache->probe, TRUE);
blkid_probe_set_partitions_flags(cache->probe, BLKID_PARTS_ENTRY_DETAILS);
- /*
- * Probe for all types.
- */
+ /* probe */
if (blkid_do_safeprobe(cache->probe)) {
/* found nothing or error */
blkid_free_dev(dev);
dev = NULL;
}
-found_type:
if (dev) {
#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
struct timeval tv;
diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8
index 2ba1ab4..eb8d716 100644
--- a/misc-utils/blkid.8
+++ b/misc-utils/blkid.8
@@ -64,6 +64,17 @@ library. It can determine the type of content (e.g. filesystem or swap)
that a block device holds, and also attributes (tokens, NAME=value pairs)
from the content metadata (e.g. LABEL or UUID fields).
.PP
+Note that
+.B blkid
+reads information directly from devices and for non-root users
+it returns cached unverified information. It's better to use
+.B lsblk --fs
+to get user-friendly overview about filesystems and devices.
+.BR lsblk (8)
+is also easy to use in scripts.
+.B blkid
+is mostly designed for system services and to test libblkid functionality.
+.PP
.B blkid
has two main forms of operation: either searching for a device with a
specific NAME=value pair, or displaying NAME=value pairs for one or
--
1.8.1

View File

@ -2,7 +2,7 @@
Summary: A collection of basic system utilities
Name: util-linux
Version: 2.22.2
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base
URL: http://en.wikipedia.org/wiki/Util-linux
@ -98,6 +98,14 @@ Patch4: util-linux-2.21-ipcs-32bit.patch
### Upstream patches (2.23 or 2.22.x)
# 889888 - wipefs does not completely wipe btrfs volume
Patch100: libblkid-add-support-for-btrfs-backup-superblock.patch
# 882305 - agetty: unstable /dev/tty* permissions
Patch101: agetty-replace-perms-660-to-620.patch
# 885314 - hexdump segfault
Patch102: hexdump-do-not-segfault-when-iterating-over-an-empty.patch
# 896447 - No newlines in piped "cal" command
Patch103: cal-don-t-mix-ncurses-output-functions-and-printf.patch
# upstream patch
Patch104: libblkid-remove-optimization-from-verify-function.patch
### Upstream patches from master branch (will be v2.23) for su(1) and new
### runuser(1) implementation. This is required for the recent coreutils where
@ -128,6 +136,7 @@ Summary: Device mounting library
Group: Development/Libraries
License: LGPLv2+
Requires: libblkid = %{version}-%{release}
Requires: libuuid = %{version}-%{release}
Conflicts: filesystem < 3
%description -n libmount
@ -710,7 +719,7 @@ fi
%defattr(-,root,root)
%doc Documentation/licenses/COPYING.GPLv2
%{_mandir}/man8/uuidd.8*
%attr(-, uuidd, uuidd) %{_sbindir}/uuidd
%{_sbindir}/uuidd
%{_unitdir}/*
%dir %attr(2775, uuidd, uuidd) /var/lib/libuuid
%dir %attr(2775, uuidd, uuidd) /run/uuidd
@ -769,6 +778,13 @@ fi
%changelog
* Sun Feb 3 2013 Karel Zak <kzak@redhat.com> 2.22.2-3
- fix #882305 - agetty: unstable /dev/tty* permissions
- fix #885314 - hexdump segfault
- fix #896447 - No newlines in piped "cal" command
- fix libblkid cache usage (upstream patch)
- fix #905008 - uuidd: /usr/sbin/uuidd has incorrect file permissions
* Tue Jan 15 2013 Karel Zak <kzak@redhat.com> 2.22.2-2
- fix #889888 - wipefs does not completely wipe btrfs volume