1
0
forked from pool/util-linux

Accepting request 78456 from Base:System

util-linux-2.20-rc1-hexdump-segfault.patch (bnc#710877) 
util-linux-2.20-rc-fix-dmesg.patch (bnc#710417) 
util-linux-2.20-rc1-agetty-fixes.patch (bnc#711240)

OBS-URL: https://build.opensuse.org/request/show/78456
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/util-linux?expand=0&rev=122
This commit is contained in:
Sascha Peilicke 2011-08-11 07:41:14 +00:00 committed by Git OBS Bridge
parent 982e74dac5
commit 84c19c8697
5 changed files with 447 additions and 0 deletions

View File

@ -0,0 +1,36 @@
From dd8f12f4bc28eaf8e746ae2e4489a4445793d4e3 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Wed, 10 Aug 2011 14:08:55 +0200
Subject: [PATCH] dmesg: avoid mess at the end of dmesg output
Since util-linux commit a7ee94f2204011f26232ed3133514bf6e0d4a62c,
dmesg incorrectly calculates number of bytes that are remaining in the
buffer in get_next_record(). This could, under specific circumstances,
cause printing mess at the end of dmesg output:
> dmesg | tail
[ 1191.478725] Adding 285488k swap on /root/swapfile. Priority:-2 extents:15 across:1186612k
[ 1205.588331] Adding 285488k swap on /root/swapfile. Priority:-2 extents:15 across:1186612k
\xffffffba\xffffffba
Reported-by: Glenn Doig <doiggl@velocitynet.com.au>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=710417
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/dmesg.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
Index: util-linux-2.20-rc1/sys-utils/dmesg.c
===================================================================
--- util-linux-2.20-rc1.orig/sys-utils/dmesg.c
+++ util-linux-2.20-rc1/sys-utils/dmesg.c
@@ -492,6 +492,8 @@ static int get_next_record(struct dmesg_
rec->next_size -= end - rec->next;
rec->next = rec->next_size > 0 ? end + 1 : NULL;
+ if (rec->next_size > 0)
+ rec->next_size--;
return 0;
}

View File

@ -0,0 +1,322 @@
Index: util-linux-2.20-rc1/term-utils/agetty.8
===================================================================
--- util-linux-2.20-rc1.orig/term-utils/agetty.8
+++ util-linux-2.20-rc1/term-utils/agetty.8
@@ -87,9 +87,11 @@ whatever init(8) may have set, and is in
Assume that the tty is 8-bit clean, hence disable parity detection.
.TP
\-a, \-\-autologin \fIusername\fP
-Log the specified user automatically in without asking for a login
-name and password. Check the \-f option from
-\fB/bin/login\fP for this.
+Log the specified user automatically in without asking for a login name and
+password. The \-f \fIusername\fP option is added to the \fB/bin/login\fP
+command line by default. The \-\-login-options option changes this default
+behaviour and then only \\u is replaced by the \fIusername\fP and no other
+option is added to the login command line.
.TP
\-c, \-\-noreset
Don't reset terminal cflags (control modes). See \fItermios(3)\fP for more
@@ -160,9 +162,10 @@ is run as root.
.TP
\-o, \-\-login\-options \fI"login_options"\fP
Options that are passed to the login program. \\u is replaced
-by the login name. Defaults to "-- \\u", which is suitable for
-\fB/bin/login\fP. Please read the SECURITY NOTICE below if
-you want to use this.
+by the login name. The default \fB/bin/login\fP command line
+is "/bin/login -- <username>".
+
+Please read the SECURITY NOTICE below if you want to use this.
.TP
\-p, \-\-login\-pause
Wait for any key before dropping to the login prompt. Can be combined
Index: util-linux-2.20-rc1/term-utils/agetty.c
===================================================================
--- util-linux-2.20-rc1.orig/term-utils/agetty.c
+++ util-linux-2.20-rc1/term-utils/agetty.c
@@ -100,7 +100,7 @@
/* Login prompt. */
#define LOGIN "login: "
-#define ARRAY_SIZE_MAX 16 /* Numbers of args for login beside "-- \\u" */
+#define LOGIN_ARGV_MAX 16 /* Numbers of args for login */
/* Some shorthands for control characters. */
#define CTL(x) (x ^ 0100) /* Assumes ASCII dialect */
@@ -262,9 +262,8 @@ static void log_err(const char *, ...) _
static void log_warn (const char *, ...)
__attribute__((__format__(printf, 1, 2)));
static ssize_t append(char *dest, size_t len, const char *sep, const char *src);
-static void checkname (const char* nm);
-static void replacename (char** arr, const char* nm);
-static void mkarray (char** arr, char* str);
+static void check_username (const char* nm);
+static void login_options_to_argv(char *argv[], int *argc, char *str, char *username);
/* Fake hostname for ut_host specified on command line. */
static char *fakehost;
@@ -278,19 +277,18 @@ FILE *dbf;
int main(int argc, char **argv)
{
- char *logname = NULL; /* login name, given to /bin/login */
- char logcmd[NAME_MAX+1];
- char *logarr[ARRAY_SIZE_MAX + 2]; /* arguments plus "-- \\u" */
+ char *username = NULL; /* login name, given to /bin/login */
struct chardata chardata; /* will be set by get_logname() */
struct termios termios; /* terminal mode bits */
static struct options options = {
.flags = F_ISSUE, /* show /etc/issue (SYSV_STYLE) */
.login = _PATH_LOGIN, /* default login program */
- .logopt = "-- \\u", /* escape for user name */
.tty = "tty1", /* default tty line */
.term = DEFAULT_VCTERM, /* terminal type */
.issue = ISSUE /* default issue file */
};
+ char *login_argv[LOGIN_ARGV_MAX + 1];
+ int login_argc = 0;
struct sigaction sa, sa_hup, sa_quit, sa_int;
sigset_t set;
@@ -315,6 +313,8 @@ int main(int argc, char **argv)
/* Parse command-line arguments. */
parse_args(argc, argv, &options);
+ login_argv[login_argc++] = options.login; /* set login program name */
+
/* Update the utmp file. */
#ifdef SYSV_STYLE
update_utmp(&options);
@@ -379,16 +379,15 @@ int main(int argc, char **argv)
chardata = init_chardata;
if ((options.flags & F_NOPROMPT) == 0) {
if (options.autolog) {
- /* Do the auto login */
+ /* Do the auto login. */
debug("doing auto login\n");
do_prompt(&options, &termios);
printf("%s%s (automatic login)\n", LOGIN, options.autolog);
- logname = options.autolog;
- options.logopt = "-f \\u";
+ username = options.autolog;
} else {
/* Read the login name. */
debug("reading login name\n");
- while ((logname =
+ while ((username =
get_logname(&options, &termios, &chardata)) == 0)
if ((options.flags & F_VCONSOLE) == 0)
next_speed(&options, &termios);
@@ -410,13 +409,25 @@ int main(int argc, char **argv)
sigaction(SIGQUIT, &sa_quit, NULL);
sigaction(SIGINT, &sa_int, NULL);
- *logcmd = '\0';
- append(logcmd, sizeof(logcmd), NULL, options.login);
- append(logcmd, sizeof(logcmd), " ", options.logopt);
-
- checkname(logname);
- mkarray(logarr, logcmd);
- replacename(logarr, logname);
+ if (username)
+ check_username(username);
+
+ if (options.logopt) {
+ /*
+ * The --login-options completely overwrites the default
+ * way how agetty composes login(1) command line.
+ */
+ login_options_to_argv(login_argv, &login_argc,
+ options.logopt, username);
+ } else if (username) {
+ if (options.autolog)
+ login_argv[login_argc++] = "-f";
+ else
+ login_argv[login_argc++] = "--";
+ login_argv[login_argc++] = username;
+ }
+
+ login_argv[login_argc] = NULL; /* last login argv */
if (options.chroot) {
if (chroot(options.chroot) < 0)
@@ -435,8 +446,87 @@ int main(int argc, char **argv)
}
/* Let the login program take care of password validation. */
- execv(options.login, logarr);
- log_err(_("%s: can't exec %s: %m"), options.tty, options.login);
+ execv(options.login, login_argv);
+ log_err(_("%s: can't exec %s: %m"), options.tty, login_argv[0]);
+}
+
+/*
+ * Returns : @str if \u not found
+ * : @username if @str equal to "\u"
+ * : newly allocated string if \u mixed with something other
+ */
+static char *replace_u(char *str, char *username)
+{
+ char *entry = NULL, *p = str;
+ size_t usz = username ? strlen(username) : 0;
+
+ while (*p) {
+ size_t sz;
+ char *tp, *old = entry;
+
+ if (memcmp(p, "\\u", 2)) {
+ p++;
+ continue; /* no \u */
+ }
+ sz = strlen(str);
+
+ if (p == str && sz == 2)
+ /* 'str' contains only '\u' */
+ return username;
+
+ tp = entry = malloc(sz + usz);
+ if (!tp)
+ log_err(_("failed to allocate memory: %m"));
+
+ if (p != str) {
+ /* copy chars befor \u */
+ memcpy(tp, str, p - str);
+ tp += p - str;
+ }
+ if (usz) {
+ /* copy username */
+ memcpy(tp, username, usz);
+ tp += usz;
+ }
+ if (*(p + 2))
+ /* copy chars after \u + \0 */
+ memcpy(tp, p + 2, sz - (p - str) - 1);
+ else
+ *tp = '\0';
+
+ p = tp;
+ str = entry;
+ free(old);
+ }
+
+ return entry ? entry : str;
+}
+
+static void login_options_to_argv(char *argv[], int *argc,
+ char *str, char *username)
+{
+ char *p;
+ int i = *argc;
+
+ while (str && isspace(*str))
+ str++;
+ p = str;
+
+ while (p && *p && i < LOGIN_ARGV_MAX) {
+ if (isspace(*p)) {
+ *p = '\0';
+ while (isspace(*++p))
+ ;
+ if (*p) {
+ argv[i++] = replace_u(str, username);
+ str = p;
+ }
+ } else
+ p++;
+ }
+ if (str && *str && i < LOGIN_ARGV_MAX)
+ argv[i++] = replace_u(str, username);
+ *argc = i;
}
/* Parse command-line arguments. */
@@ -920,7 +1010,7 @@ static void termio_init(struct options *
mode = K_RAW;
switch(mode) {
case K_UNICODE:
- setlocale(LC_CTYPE, "en_US.UTF-8");
+ setlocale(LC_CTYPE, "C.UTF-8");
op->flags |= F_UTF8;
break;
case K_RAW:
@@ -977,7 +1067,14 @@ static void termio_init(struct options *
/* Flush input and output queues, important for modems! */
tcflush(STDIN_FILENO, TCIOFLUSH);
- tp->c_iflag = tp->c_lflag = tp->c_oflag = 0;
+#ifdef IUTF8
+ tp->c_iflag = tp->c_iflag & IUTF8;
+ if (tp->c_iflag & IUTF8)
+ op->flags |= F_UTF8;
+#else
+ tp->c_iflag = 0;
+#endif
+ tp->c_lflag = tp->c_oflag = 0;
if ((op->flags & F_KEEPCFLAGS) == 0)
tp->c_cflag = CS8 | HUPCL | CREAD | (tp->c_cflag & CLOCAL);
@@ -1826,12 +1923,13 @@ static ssize_t append(char *dest, size_t
return dsz + ssz + sz;
}
+
/*
* Do not allow the user to pass an option as a user name
* To be more safe: Use `--' to make sure the rest is
* interpreted as non-options by the program, if it supports it.
*/
-static void checkname(const char* nm)
+static void check_username(const char* nm)
{
const char *p = nm;
if (!nm)
@@ -1848,48 +1946,3 @@ err:
log_err("checkname: %m");
}
-static void replacename(char** arr, const char* nm)
-{
- const char *p;
- char *tmp;
- while ((p = *arr)) {
- const char *p1 = p;
- while (*p1) {
- if (memcmp(p1, "\\u", 2) == 0) {
- tmp = malloc(strlen(p) + strlen(nm));
- if (!tmp)
- log_err(_("failed to allocate memory: %m"));
- if (p1 != p)
- memcpy(tmp, p, (p1 - p));
- *(tmp + (p1 - p)) = 0;
- strcat(tmp, nm);
- strcat(tmp, p1+2);
- *arr = tmp;
- }
- p1++;
- }
- arr++;
- }
-}
-
-static void mkarray(char** arr, char* str)
-{
- char* p = str;
- char* start = p;
- int i = 0;
-
- while (*p && i < ARRAY_SIZE_MAX) {
- if (isspace(*p)) {
- *p = 0;
- while (isspace(*++p))
- ;
- if (*p) {
- arr[i++] = start;
- start = p;
- }
- } else
- p++;
- }
- arr[i++] = start;
- arr[i++] = (char*) 0;
-}

View File

@ -0,0 +1,65 @@
From 474b1ae3ca463acec0c625fb7076bcc746671479 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Wed, 10 Aug 2011 15:23:53 +0200
Subject: [PATCH] hexdump: fix segfault due to uninitialized memory
util-linux commit 85bf44b714ab184907eb448eba389218956d6a51
replaced all calls to emalloc() with xmalloc(), whose semantics
is however different - it does not zero allocated memory. This
made hexdump segfault if MALLOC_PERTURB_ was set.
Reported-by: Kyrill Detinov <lazy.kent@opensuse.org>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=710877
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
text-utils/display.c | 4 ++--
text-utils/parse.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
Index: util-linux-2.20-rc1/text-utils/display.c
===================================================================
--- util-linux-2.20-rc1.orig/text-utils/display.c
+++ util-linux-2.20-rc1/text-utils/display.c
@@ -233,8 +233,8 @@ get(void)
u_char *tmpp;
if (!curp) {
- curp = xmalloc(blocksize);
- savp = xmalloc(blocksize);
+ curp = xcalloc(1, blocksize);
+ savp = xcalloc(1, blocksize);
} else {
tmpp = curp;
curp = savp;
Index: util-linux-2.20-rc1/text-utils/parse.c
===================================================================
--- util-linux-2.20-rc1.orig/text-utils/parse.c
+++ util-linux-2.20-rc1/text-utils/parse.c
@@ -86,7 +86,7 @@ void add(const char *fmt)
const char *savep;
/* Start new linked list of format units. */
- tfs = xmalloc(sizeof(FS));
+ tfs = xcalloc(1, sizeof(FS));
if (!fshead)
fshead = tfs;
else
@@ -102,7 +102,7 @@ void add(const char *fmt)
break;
/* Allocate a new format unit and link it in. */
- tfu = xmalloc(sizeof(FU));
+ tfu = xcalloc(1, sizeof(FU));
*nextfu = tfu;
nextfu = &tfu->nextfu;
tfu->reps = 1;
@@ -219,7 +219,7 @@ void rewrite(FS *fs)
* conversion character gets its own.
*/
for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
- pr = xmalloc(sizeof(PR));
+ pr = xcalloc(1, sizeof(PR));
if (!fu->nextpr)
fu->nextpr = pr;
else

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Wed Aug 10 13:42:33 UTC 2011 - puzel@novell.com
- add util-linux-2.20-rc1-hexdump-segfault.patch (bnc#710877)
-------------------------------------------------------------------
Wed Aug 10 12:20:41 UTC 2011 - puzel@novell.com
- add util-linux-2.20-rc-fix-dmesg.patch (bnc#710417)
-------------------------------------------------------------------
Wed Aug 10 11:06:15 UTC 2011 - puzel@novell.com
- add util-linux-2.20-rc1-agetty-fixes.patch (bnc#711240)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Aug 1 13:44:21 UTC 2011 - puzel@novell.com Mon Aug 1 13:44:21 UTC 2011 - puzel@novell.com

View File

@ -83,6 +83,12 @@ Patch1: util-linux-2.12r-fdisk_remove_bogus_warnings.patch
Patch2: util-linux-2.17.1-mount_losetup_crypto.patch Patch2: util-linux-2.17.1-mount_losetup_crypto.patch
Patch3: util-linux-fix-manpages.patch Patch3: util-linux-fix-manpages.patch
Patch4: util-linux-wall-build-with-pie.patch Patch4: util-linux-wall-build-with-pie.patch
# bnc#711240 - squashed 4 upstream patches
Patch5: util-linux-2.20-rc1-agetty-fixes.patch
# bnc#710471
Patch6: util-linux-2.20-rc-fix-dmesg.patch
# bnc#710877
Patch7: util-linux-2.20-rc1-hexdump-segfault.patch
## ##
## adjtimex ## adjtimex
## ##
@ -185,6 +191,9 @@ Files to develop applications using the libmount library.
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1 %patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
# #
cd adjtimex-* cd adjtimex-*