Compare commits

..

6 commits

Author SHA1 Message Date
Fedora Release Engineering
7248db7686 dist-git conversion 2010-07-29 14:50:15 +00:00
Bill Nottingham
e336b5784d Fix typo that causes a failure to update the common directory. (releng
#2781)
2009-11-26 01:16:36 +00:00
kzak
0e29548e09 - fix #454252 - Problem with who,write and tty permissions
- fix #449738 - Wakeup on RTC alarm does not work anymore [rebase to
    rtcwake(8) from util-linux-ng 2.14.1]
- fix #454354 - FAT filesystem mount option utf8=0 is not documented
2008-08-12 14:03:21 +00:00
kzak
05c92a9c3f - fix #443823 - ionice.1 doesn't to reflect idle class changes in 2.6.25 2008-04-28 10:40:39 +00:00
kzak
a38a974603 - fix audit log injection attack via login 2008-04-22 19:38:16 +00:00
Jesse Keating
9023504857 Initialize branch F-9 for util-linux-ng 2008-04-22 00:17:59 +00:00
29 changed files with 3249 additions and 6 deletions

5
.gitignore vendored
View file

@ -1,5 +1,2 @@
floppy-0.16.tar.bz2
util-linux-ng-2.18.tar.bz2
*~
*.rpm
*.log
util-linux-ng-2.13.1.tar.bz2

View file

@ -1,2 +0,0 @@
util-linux-ng has been renamed to util-linux

View file

@ -0,0 +1,17 @@
diff -up util-linux-ng-2.13.1/mount/mount.8.kzak util-linux-ng-2.13.1/mount/mount.8
--- util-linux-ng-2.13.1/mount/mount.8.kzak 2008-08-12 15:34:29.000000000 +0200
+++ util-linux-ng-2.13.1/mount/mount.8 2008-08-12 15:34:32.000000000 +0200
@@ -1729,9 +1729,10 @@ before trying
.IR name~num.ext .
.TP
.B utf8
-UTF8 is the filesystem safe 8-bit encoding of Unicode that is used
-by the console. It can be be enabled for the filesystem with this option.
-If `uni_xlate' gets set, UTF8 gets disabled.
+UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the
+console. It can be be enabled for the filesystem with this option or disabled
+with utf8=0, utf8=no or utf8=false. If `uni_xlate' gets set, UTF8 gets
+disabled.
.TP
.B shortname=[lower|win95|winnt|mixed]

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);
}

301
rtcwake-rebase-2.14.1.patch Normal file
View file

@ -0,0 +1,301 @@
diff -up util-linux-ng-2.13.1/sys-utils/rtcwake.8.kzak util-linux-ng-2.13.1/sys-utils/rtcwake.8
--- util-linux-ng-2.13.1/sys-utils/rtcwake.8.kzak 2008-08-12 15:26:02.000000000 +0200
+++ util-linux-ng-2.13.1/sys-utils/rtcwake.8 2008-08-12 15:26:02.000000000 +0200
@@ -76,15 +76,20 @@ is the time in seconds since 1970-01-01,
Use standby state \fImode\fP. Valid values are \fIstandby\fP,
\fImem\fP, \fIdisk\fP and \fIon\fP (no suspend). The default is
\fIstandby\fP.
+.SH NOTES
+Some PC systems can't currently exit sleep states such as \fImem\fP
+using only the kernel code accessed by this driver.
+They need help from userspace code to make the framebuffer work again.
.SH HISTORY
-The program first appeared as kernel commit message for Linux 2.6 in the GIT
+The program was posted several times on LKML and other lists
+before appearing in kernel commit message for Linux 2.6 in the GIT
commit 87ac84f42a7a580d0dd72ae31d6a5eb4bfe04c6d.
.SH AVAILABILITY
The rtcwake command is part of the util-linux-ng package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
.SH AUTHOR
-The program was written by David Brownell <david-b@pacbell.net> and improved by
-Bernhard Walle <bwalle@suse.de>.
+The program was written by David Brownell <dbrownell@users.sourceforge.net>
+and improved by Bernhard Walle <bwalle@suse.de>.
.SH COPYRIGHT
This is free software. You may redistribute copies of it under the terms
of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
diff -up util-linux-ng-2.13.1/sys-utils/rtcwake.c.kzak util-linux-ng-2.13.1/sys-utils/rtcwake.c
--- util-linux-ng-2.13.1/sys-utils/rtcwake.c.kzak 2008-08-12 15:17:56.000000000 +0200
+++ util-linux-ng-2.13.1/sys-utils/rtcwake.c 2008-08-12 15:25:35.000000000 +0200
@@ -16,11 +16,13 @@
* The best way to set the system's RTC is so that it holds the current
* time in UTC. Use the "-l" flag to tell this program that the system
* RTC uses a local timezone instead (maybe you dual-boot MS-Windows).
+ * That flag should not be needed on systems with adjtime support.
*/
#include <stdio.h>
#include <getopt.h>
#include <fcntl.h>
+#include <libgen.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -46,10 +48,10 @@ static char *progname;
#define VERSION_STRING "rtcwake from " PACKAGE_STRING
#define RTC_PATH "/sys/class/rtc/%s/device/power/wakeup"
-#define SYS_POWER_SATE_PATH "/sys/power/state"
+#define SYS_POWER_STATE_PATH "/sys/power/state"
#define ADJTIME_PATH "/etc/adjtime"
#define DEFAULT_DEVICE "/dev/rtc0"
-#define DEFAULT_MODE "suspend"
+#define DEFAULT_MODE "standby"
enum ClockMode {
CM_AUTO,
@@ -89,7 +91,7 @@ static void usage(int retval)
exit(retval);
}
-static int may_wakeup(const char *devname)
+static int is_wakeup_enabled(const char *devname)
{
char buf[128], *s;
FILE *f;
@@ -136,12 +138,12 @@ static int get_basetimes(int fd)
*/
if (ioctl(fd, RTC_RD_TIME, &rtc) < 0) {
perror(_("read rtc time"));
- return 0;
+ return -1;
}
sys_time = time(0);
if (sys_time == (time_t)-1) {
perror(_("read system time"));
- return 0;
+ return -1;
}
/* convert rtc_time to normal arithmetic-friendly form,
@@ -159,22 +161,26 @@ static int get_basetimes(int fd)
if (rtc_time == (time_t)-1) {
perror(_("convert rtc time"));
- return 0;
+ return -1;
}
if (verbose) {
- if (clock_mode == CM_LOCAL) {
- printf("\ttzone = %ld\n", timezone);
- printf("\ttzname = %s\n", tzname[daylight]);
- gmtime_r(&rtc_time, &tm);
- }
- printf("\tsystime = %ld, (UTC) %s\n",
+ /* Unless the system uses UTC, either delta or tzone
+ * reflects a seconds offset from UTC. The value can
+ * help sort out problems like bugs in your C library.
+ */
+ printf("\tdelta = %ld\n", sys_time - rtc_time);
+ printf("\ttzone = %ld\n", timezone);
+
+ printf("\ttzname = %s\n", tzname[daylight]);
+ gmtime_r(&rtc_time, &tm);
+ printf("\tsystime = %ld, (UTC) %s",
(long) sys_time, asctime(gmtime(&sys_time)));
- printf("\trtctime = %ld, (UTC) %s\n",
+ printf("\trtctime = %ld, (UTC) %s",
(long) rtc_time, asctime(&tm));
}
- return 1;
+ return 0;
}
static int setup_alarm(int fd, time_t *wakeup)
@@ -182,7 +188,17 @@ static int setup_alarm(int fd, time_t *w
struct tm *tm;
struct rtc_wkalrm wake;
- tm = gmtime(wakeup);
+ /* The wakeup time is in POSIX time (more or less UTC).
+ * Ideally RTCs use that same time; but PCs can't do that
+ * if they need to boot MS-Windows. Messy...
+ *
+ * When clock_mode == CM_UTC this process's timezone is UTC,
+ * so we'll pass a UTC date to the RTC.
+ *
+ * Else clock_mode == CM_LOCAL so the time given to the RTC
+ * will instead use the local time zone.
+ */
+ tm = localtime(wakeup);
wake.time.tm_sec = tm->tm_sec;
wake.time.tm_min = tm->tm_min;
@@ -190,41 +206,41 @@ static int setup_alarm(int fd, time_t *w
wake.time.tm_mday = tm->tm_mday;
wake.time.tm_mon = tm->tm_mon;
wake.time.tm_year = tm->tm_year;
- wake.time.tm_wday = tm->tm_wday;
- wake.time.tm_yday = tm->tm_yday;
- wake.time.tm_isdst = tm->tm_isdst;
-
- /* many rtc alarms only support up to 24 hours from 'now' ... */
- if ((rtc_time + (24 * 60 * 60)) > *wakeup) {
- if (ioctl(fd, RTC_ALM_SET, &wake.time) < 0) {
- perror(_("set rtc alarm"));
- return 0;
- }
- if (ioctl(fd, RTC_AIE_ON, 0) < 0) {
- perror(_("enable rtc alarm"));
- return 0;
- }
-
- /* ... so use the "more than 24 hours" request only if we must */
- } else {
- /* avoid an extra AIE_ON call */
- wake.enabled = 1;
-
- if (ioctl(fd, RTC_WKALM_SET, &wake) < 0) {
+ /* wday, yday, and isdst fields are unused by Linux */
+ wake.time.tm_wday = -1;
+ wake.time.tm_yday = -1;
+ wake.time.tm_isdst = -1;
+
+ wake.enabled = 1;
+ /* First try the preferred RTC_WKALM_SET */
+ if (ioctl(fd, RTC_WKALM_SET, &wake) < 0) {
+ wake.enabled = 0;
+ /* Fall back on the non-preferred way of setting wakeups; only
+ * works for alarms < 24 hours from now */
+ if ((rtc_time + (24 * 60 * 60)) > *wakeup) {
+ if (ioctl(fd, RTC_ALM_SET, &wake.time) < 0) {
+ perror(_("set rtc alarm"));
+ return -1;
+ }
+ if (ioctl(fd, RTC_AIE_ON, 0) < 0) {
+ perror(_("enable rtc alarm"));
+ return -1;
+ }
+ } else {
perror(_("set rtc wake alarm"));
- return 0;
+ return -1;
}
}
- return 1;
+ return 0;
}
static void suspend_system(const char *suspend)
{
- FILE *f = fopen(SYS_POWER_SATE_PATH, "w");
+ FILE *f = fopen(SYS_POWER_STATE_PATH, "w");
if (!f) {
- perror(SYS_POWER_SATE_PATH);
+ perror(SYS_POWER_STATE_PATH);
return;
}
@@ -243,24 +259,24 @@ static int read_clock_mode(void)
fp = fopen(ADJTIME_PATH, "r");
if (!fp)
- return 0;
+ return -1;
/* skip first line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
/* skip second line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
/* read third line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
if (strncmp(linebuf, "UTC", 3) == 0)
@@ -270,7 +286,7 @@ static int read_clock_mode(void)
fclose(fp);
- return 1;
+ return 0;
}
int main(int argc, char **argv)
@@ -321,8 +337,9 @@ int main(int argc, char **argv)
suspend = strdup(optarg);
break;
}
- fprintf(stderr, _("%s: unrecognized suspend state '%s'\n"),
- progname, optarg);
+ fprintf(stderr,
+ _("%s: unrecognized suspend state '%s'\n"),
+ progname, optarg);
usage(EXIT_FAILURE);
/* alarm time, seconds-to-sleep (relative) */
@@ -372,14 +389,14 @@ int main(int argc, char **argv)
}
if (clock_mode == CM_AUTO) {
- if (!read_clock_mode()) {
+ if (read_clock_mode() < 0) {
printf(_("%s: assuming RTC uses UTC ...\n"), progname);
clock_mode = CM_UTC;
}
- if (verbose)
- printf(_("Using %s time\n"),
- clock_mode == CM_UTC ? "UTC" : _("local"));
}
+ if (verbose)
+ printf(clock_mode == CM_UTC ? _("Using UTC time.\n") :
+ _("Using local time.\n"));
if (!alarm && !seconds) {
fprintf(stderr, _("%s: must provide wake time\n"), progname);
@@ -402,7 +419,7 @@ int main(int argc, char **argv)
devname = new_devname;
}
- if (strcmp(suspend, "on") != 0 && !may_wakeup(devname)) {
+ if (strcmp(suspend, "on") != 0 && !is_wakeup_enabled(devname)) {
fprintf(stderr, _("%s: %s not enabled for wakeup events\n"),
progname, devname);
exit(EXIT_FAILURE);
@@ -416,15 +433,16 @@ int main(int argc, char **argv)
}
/* relative or absolute alarm time, normalized to time_t */
- if (!get_basetimes(fd))
+ if (get_basetimes(fd) < 0)
exit(EXIT_FAILURE);
if (verbose)
printf(_("alarm %ld, sys_time %ld, rtc_time %ld, seconds %u\n"),
alarm, sys_time, rtc_time, seconds);
if (alarm) {
if (alarm < sys_time) {
- fprintf(stderr, _("%s: time doesn't go backward to %s\n"),
- progname, ctime(&alarm));
+ fprintf(stderr,
+ _("%s: time doesn't go backward to %s\n"),
+ progname, ctime(&alarm));
exit(EXIT_FAILURE);
}
alarm += sys_time - rtc_time;

2
sources Normal file
View file

@ -0,0 +1,2 @@
7eeb9a6f7a258174bf0fa80f1370788d floppy-0.16.tar.bz2
424badc1832e4b5291a2ec04e9e244f4 util-linux-ng-2.13.1.tar.bz2

View file

@ -0,0 +1,105 @@
diff -up util-linux-ng-2.13/disk-utils/blockdev.c.kzak util-linux-ng-2.13/disk-utils/blockdev.c
--- util-linux-ng-2.13/disk-utils/blockdev.c.kzak 2007-09-04 15:43:33.000000000 +0200
+++ util-linux-ng-2.13/disk-utils/blockdev.c 2007-10-31 11:14:32.000000000 +0100
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
+#include <linux/blkpg.h>
#include "nls.h"
@@ -32,6 +33,14 @@
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
#endif
+#ifndef BLKPG
+#define BLKPG _IO(0x12,105)
+#define BLKPG_DEL_PARTITION 2
+#define BLKPG_DEVNAMELTH 64
+#define BLKPG_VOLNAMELTH 64
+
+#endif
+
/* Maybe <linux/hdreg.h> could be included */
#ifndef HDIO_GETGEO
#define HDIO_GETGEO 0x0301
@@ -104,6 +113,10 @@ struct bdc {
{ "--rereadpt", "BLKRRPART", BLKRRPART, ARGNONE, 0, NULL,
N_("reread partition table") },
#endif
+#ifdef BLKPG
+ { "--rmpart", "BLKPG", BLKPG, ARGINTAP, 0, "PARTNO", N_("disable partition") },
+ { "--rmparts", "BLKPG", BLKPG, ARGNONE, 0, NULL, N_("disable all partitions") },
+#endif
};
#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
@@ -163,6 +176,40 @@ getsize(int fd, long long *sectors) {
return 0;
}
+#ifdef BLKPG
+static int
+disable_partition(int fd, int partno) {
+ struct blkpg_partition part = {
+ .pno = partno,
+ .start = 0,
+ .length = 0,
+ .devname[0] = 0,
+ .volname[0] = 0,
+ };
+ struct blkpg_ioctl_arg io = {
+ .op = BLKPG_DEL_PARTITION,
+ .datalen = sizeof(part),
+ .data = &part,
+ .flags = 0,
+ };
+ int res;
+
+ res = ioctl(fd, BLKPG, &io);
+ if (res < 0)
+ return 0;
+ return 1;
+}
+
+static int
+disable_partitions(int fd) {
+ int p, res = 0;
+
+ for (p = 1; p <= 256; p++)
+ res += disable_partition(fd, p);
+ return res ? 0 : -1;
+}
+#endif
+
void do_commands(int fd, char **argv, int d);
void report_header(void);
void report_device(char *device, int quiet);
@@ -280,6 +327,12 @@ do_commands(int fd, char **argv, int d)
switch(bdcms[j].argtype) {
default:
case ARGNONE:
+#ifdef BLKPG
+ if (bdcms[j].ioc == BLKPG) {
+ res = disable_partitions(fd);
+ break;
+ }
+#endif
res = ioctl(fd, bdcms[j].ioc, 0);
break;
case ARGINTA:
@@ -297,6 +350,13 @@ do_commands(int fd, char **argv, int d)
bdcms[j].name);
usage();
}
+#ifdef BLKPG
+ if (bdcms[j].ioc == BLKPG) {
+ iarg = atoi(argv[++i]);
+ res = disable_partition(fd, iarg) ? 0 : -1;
+ break;
+ }
+#endif
iarg = atoi(argv[++i]);
res = ioctl(fd, bdcms[j].ioc, &iarg);
break;

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,23 @@
--- util-linux-ng-2.13-rc3/disk-utils/fdformat.8.xxx 2007-07-03 01:56:04.000000000 +0200
+++ util-linux-ng-2.13-rc3/disk-utils/fdformat.8 2007-08-13 12:07:58.000000000 +0200
@@ -45,6 +45,10 @@
.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
.B \-n
@@ -54,7 +58,8 @@
.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,11 @@
--- util-linux-ng-2.13-rc3/fdisk/fdisk.c.kzak 2007-07-16 23:15:33.000000000 +0200
+++ util-linux-ng-2.13-rc3/fdisk/fdisk.c 2007-08-13 12:15:42.000000000 +0200
@@ -2588,7 +2588,7 @@
*/
sector_size = atoi(optarg);
if (sector_size != 512 && sector_size != 1024 &&
- sector_size != 2048)
+ sector_size != 2048 && sector_size != 4096)
fatal(usage);
sector_offset = 2;
user_set_sector_size = 1;

View file

@ -0,0 +1,102 @@
--- util-linux-2.12p/floppy-0.16/floppyfloppy.c.generic 2001-02-13 01:15:38.000000000 +0100
+++ util-linux-2.12p/floppy-0.16/floppyfloppy.c 2005-09-30 15:38:08.000000000 +0200
@@ -264,6 +264,33 @@
#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)
@@ -275,6 +302,7 @@
struct format_descr curtrack;
int pct;
struct stat stat_buf;
+ int gen = 0;
int i, j;
char *devname;
@@ -297,23 +325,52 @@
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,10 @@
--- util-linux-ng-2.13-rc3/floppy-0.16/superfloppy.c.kzak 2001-07-14 05:26:16.000000000 +0200
+++ util-linux-ng-2.13-rc3/floppy-0.16/superfloppy.c 2007-08-13 13:14:53.000000000 +0200
@@ -12,6 +12,7 @@
#include <errno.h>
#include <popt.h>
#include <libintl.h>
+#include <locale.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

View file

@ -0,0 +1,33 @@
From 776452cbfcfc2dfe81088e29ae13a681bee64e75 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 Apr 2008 12:23:40 +0200
Subject: [PATCH] ionice: update man page to reflect IDLE class change in 2.6.25
The idle class is safe for non-root users since 2.6.25.
http://lwn.net/Articles/266256/
Addresses-Red-Hat-Bugzilla: #443823
Signed-off-by: Karel Zak <kzak@redhat.com>
---
schedutils/ionice.1 | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/schedutils/ionice.1 b/schedutils/ionice.1
index 8203a5e..93aabe8 100644
--- a/schedutils/ionice.1
+++ b/schedutils/ionice.1
@@ -13,8 +13,9 @@ this writing, Linux supports 3 scheduling classes:
A program running with idle io priority will only get disk time when no other
program has asked for disk io for a defined grace period. The impact of idle
io processes on normal system activity should be zero. This scheduling
-class does not take a priority argument. This scheduling class is not
-permitted for an ordinary (i.e., non-root) user.
+class does not take a priority argument. Presently, this scheduling class
+is permitted for an ordinary user (since kernel 2.6.25).
+
\fBBest effort\fR.
This is the default scheduling class for any process that hasn't asked for
--
1.5.4.1

View file

@ -0,0 +1,56 @@
--- util-linux-ng-2.13-rc3/sys-utils/ipcs.c.kzak 2007-04-25 14:43:38.000000000 +0200
+++ util-linux-ng-2.13-rc3/sys-utils/ipcs.c 2007-08-13 12:21:15.000000000 +0200
@@ -253,6 +253,26 @@
printf(" %-10d\n", ipcp->gid);
}
+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)
{
@@ -268,7 +288,7 @@
printf (_("kernel not configured for shared memory\n"));
return;
}
-
+
switch (format) {
case LIMITS:
printf (_("------ Shared Memory Limits --------\n"));
@@ -276,12 +296,12 @@
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"),
- sysconf(_SC_PAGESIZE) / 1024 * (unsigned long long) shminfo.shmall);
+ sysconf(_SC_PAGESIZE) / 1024 * shminfo_from_proc("shmall", shminfo.shmall));
printf (_("min seg size (bytes) = %lu\n"),
(unsigned long) shminfo.shmmin);
return;

View file

@ -0,0 +1,51 @@
From 8ccf0b253ac0f4f58d64bc9674de18bff5a88782 Mon Sep 17 00:00:00 2001
From: Steve Grubb <sgrubb@redhat.com>
Date: Sat, 19 Apr 2008 11:49:02 -0400
Subject: [PATCH] login: audit log injection attack via login
A while back I found a couple audit log injection attacks which became
CVE-2007-3102. I forgot to look at login to see if its vulnerable and Mirek
found that it is. To verify the problem, type:
root addr=xyz.com
for the account name while logging in. It will look like root logged in with
an address of xyz.com.
Signed-off-by: Steve Grubb <sgrubb@redhat.com>
---
login-utils/login.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/login-utils/login.c b/login-utils/login.c
index aad2779..2301213 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -324,7 +324,6 @@ static void
logaudit(const char *tty, const char *username, const char *hostname,
struct passwd *pwd, int status)
{
- char buf[64];
int audit_fd;
audit_fd = audit_open();
@@ -332,13 +331,10 @@ logaudit(const char *tty, const char *username, const char *hostname,
return;
if (!pwd && username)
pwd = getpwnam(username);
- if (pwd)
- snprintf(buf, sizeof(buf), "uid=%d", pwd->pw_uid);
- else
- snprintf(buf, sizeof(buf), "acct=%s", username ? username : "(unknown)");
- audit_log_user_message(audit_fd, AUDIT_USER_LOGIN,
- buf, hostname, NULL, tty, status);
+ audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
+ NULL, "login", username ? username : "(unknown)",
+ pwd ? pwd->pw_uid : -1, hostname, NULL, tty, status);
close(audit_fd);
}
--
1.5.4.1

View file

@ -0,0 +1,11 @@
--- util-linux-ng-2.13-rc3/login-utils/login.c.xxx 2007-08-13 12:11:14.000000000 +0200
+++ util-linux-ng-2.13-rc3/login-utils/login.c 2007-08-13 12:12:24.000000000 +0200
@@ -1402,7 +1402,7 @@
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

@ -0,0 +1,11 @@
--- util-linux-ng-2.13-rc3/login-utils/login.c.kzak 2007-06-29 01:13:51.000000000 +0200
+++ util-linux-ng-2.13-rc3/login-utils/login.c 2007-08-13 11:32:10.000000000 +0200
@@ -546,7 +546,7 @@
* Therefore, we are safe not setting it to anything
*/
- retcode = pam_start("login",username, &conv, &pamh);
+ retcode = pam_start(hflag?"remote":"login",username, &conv, &pamh);
if(retcode != PAM_SUCCESS) {
fprintf(stderr, _("login: PAM Failure, aborting: %s\n"),
pam_strerror(pamh, retcode));

View file

@ -0,0 +1,73 @@
diff -up util-linux-ng-2.13.1/disk-utils/mkswap.c.uuid util-linux-ng-2.13.1/disk-utils/mkswap.c
--- util-linux-ng-2.13.1/disk-utils/mkswap.c.uuid 2008-01-16 10:31:41.000000000 +0100
+++ util-linux-ng-2.13.1/disk-utils/mkswap.c 2008-04-02 16:07:47.000000000 +0200
@@ -351,7 +351,7 @@ bit_test_and_clear (unsigned long *addr,
static void
usage(void) {
fprintf(stderr,
- _("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] /dev/name [blocks]\n"),
+ _("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] [-U UUID] /dev/name [blocks]\n"),
program_name);
exit(1);
}
@@ -502,6 +502,7 @@ main(int argc, char ** argv) {
char *opt_label = NULL;
unsigned char *uuid = NULL;
#ifdef HAVE_LIBUUID
+ unsigned char *opt_uuid = NULL;
uuid_t uuid_dat;
#endif
@@ -546,6 +547,16 @@ main(int argc, char ** argv) {
case 'v':
version = atoi(argv[i]+2);
break;
+ case 'U':
+#ifdef HAVE_LIBUUID
+ opt_uuid = argv[i]+2;
+ if (!*opt_uuid && i+1 < argc)
+ opt_uuid = argv[++i];
+#else
+ fprintf(stderr, _("%1$s: warning: ignore -U (UUIDs are unsupported by %1$s)\n"),
+ program_name);
+#endif
+ break;
default:
usage();
}
@@ -558,7 +569,11 @@ main(int argc, char ** argv) {
}
#ifdef HAVE_LIBUUID
- uuid_generate(uuid_dat);
+ if(opt_uuid) {
+ if (uuid_parse(opt_uuid, uuid_dat) != 0)
+ die(_("error: UUID parsing failed"));
+ } else
+ uuid_generate(uuid_dat);
uuid = uuid_dat;
#endif
diff -up util-linux-ng-2.13.1/disk-utils/mkswap.8.uuid util-linux-ng-2.13.1/disk-utils/mkswap.8
--- util-linux-ng-2.13.1/disk-utils/mkswap.8.uuid 2007-08-27 15:00:34.000000000 +0200
+++ util-linux-ng-2.13.1/disk-utils/mkswap.8 2008-04-02 16:07:47.000000000 +0200
@@ -7,7 +7,7 @@
.SH NAME
mkswap \- set up a Linux swap area
.SH SYNOPSIS
-.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] " device " [" size "]"
+.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] [\-U " uuid "] " device " [" size "]"
.SH DESCRIPTION
.B mkswap
sets up a Linux swap area on a device or in a file.
@@ -156,6 +156,10 @@ when creating the swapspace.
Version 0 (-v0) swap space format is no longer supported in 2.5+ kernels.
+.TP
+.B \-U uuid
+Specify the uuid to use. The default is to generate UUIDs.
+
.SH "SEE ALSO"
.BR fdisk (8),
.BR swapon (8)

View file

@ -0,0 +1,11 @@
--- util-linux-ng-2.13-rc3/mount/mount.c.xxx 2007-08-07 01:20:15.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/mount.c 2007-08-13 11:58:45.000000000 +0200
@@ -182,6 +182,8 @@
{ "norelatime", 0, 1, MS_RELATIME }, /* Update access time without regard
to mtime/ctime */
#endif
+ { "kudzu", 0, 0, MS_COMMENT }, /* Silently remove this option (backwards compat use only - deprecated) */
+ { "managed", 0, 0, MS_COMMENT }, /* Silently remove this option */
{ NULL, 0, 0, 0 }
};

View file

@ -0,0 +1,138 @@
--- util-linux-ng-2.13-rc3/mount/umount.c.xxx 2007-05-30 10:18:12.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/umount.c 2007-08-13 12:02:07.000000000 +0200
@@ -434,7 +434,7 @@
umount_file (char *arg) {
struct mntentchn *mc, *fs;
const char *file, *options;
- int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
+ int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group, fstab_has_pamconsole;
int ok;
if (!*arg) { /* "" would be expanded to `pwd` */
@@ -521,13 +521,16 @@
fstab_has_users = contains(options, "users");
fstab_has_owner = contains(options, "owner");
fstab_has_group = contains(options, "group");
+ fstab_has_pamconsole = contains(options, "pamconsole");
ok = 0;
if (fstab_has_users)
ok = 1;
if (!ok && (fstab_has_user || fstab_has_owner ||
- fstab_has_group)) {
+ fstab_has_group || fstab_has_pamconsole)) {
+ char pamconsole_file_name[256];
+ struct stat sb;
char *user = getusername();
options = mc->m.mnt_opts;
@@ -537,6 +540,14 @@
if (user && mtab_user && streq (user, mtab_user))
ok = 1;
+
+ /*pam_console user check*/
+ if (user && fstab_has_pamconsole) {
+ snprintf (pamconsole_file_name, sizeof (pamconsole_file_name), "/var/run/console/%s", user);
+ if (stat (pamconsole_file_name, &sb) == 0) {
+ ok = 1;
+ }
+ }
}
if (!ok)
die (2, _("umount: only %s can unmount %s from %s"),
--- util-linux-ng-2.13-rc3/mount/fstab.5.xxx 2007-07-03 01:56:04.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/fstab.5 2007-08-13 12:02:07.000000000 +0200
@@ -156,10 +156,10 @@
.BR nfs (5).
Common for all types of file system are the options ``noauto''
(do not mount when "mount -a" is given, e.g., at boot time), ``user''
-(allow a user to mount), and ``owner''
-(allow device owner to mount), and ``comment''
+(allow a user to mount), ``owner''
+(allow device owner to mount), ``pamconsole'' (allow a user at the console to mount), and ``comment''
(e.g., for use by fstab-maintaining programs).
-The ``owner'' and ``comment'' options are Linux-specific.
+The ``owner'', ``pamconsole'' and ``comment'' options are Linux-specific.
For more details, see
.BR mount (8).
--- util-linux-ng-2.13-rc3/mount/mount.c.xxx 2007-08-13 12:00:15.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/mount.c 2007-08-13 12:05:15.000000000 +0200
@@ -108,14 +108,15 @@
#define MS_USER 0x20000000
#define MS_OWNER 0x10000000
#define MS_GROUP 0x08000000
+#define MS_PAMCONSOLE 0x04000000
#define MS_COMMENT 0x02000000
#define MS_LOOP 0x00010000
/* Options that we keep the mount system call from seeing. */
-#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP)
+#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP|MS_PAMCONSOLE)
/* Options that we keep from appearing in the options field in the mtab. */
-#define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USERS|MS_USER)
+#define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USERS|MS_USER|MS_PAMCONSOLE)
#define MS_PROPAGATION (MS_SHARED|MS_SLAVE|MS_UNBINDABLE|MS_PRIVATE)
@@ -155,6 +156,8 @@
{ "comment", 0, 0, MS_COMMENT}, /* fstab comment only (kudzu,_netdev)*/
/* add new options here */
+ { "pamconsole", 0, 0, MS_PAMCONSOLE }, /* Allow users at console to mount */
+ { "nopamconsole", 0, 1, MS_PAMCONSOLE }, /* Console user has no special privs */
#ifdef MS_NOSUB
{ "sub", 0, 1, MS_NOSUB }, /* allow submounts */
{ "nosub", 0, 0, MS_NOSUB }, /* don't allow submounts */
@@ -379,7 +382,7 @@
*mask &= ~om->mask;
else
*mask |= om->mask;
- if ((om->mask == MS_USER || om->mask == MS_USERS)
+ if ((om->mask == MS_USER || om->mask == MS_USERS || om->mask == MS_PAMCONSOLE)
&& !om->inv)
*mask |= MS_SECURE;
if ((om->mask == MS_OWNER || om->mask == MS_GROUP)
@@ -807,7 +810,29 @@
}
}
- /* James Kehl <mkehl@gil.com.au> came with a similar patch:
+ /* Red Hat patch: allow users at console to mount when fstab
+ contains the console option. This option should not be used
+ in a high security environment but is useful to give console
+ users the possibility of using locally attached devices
+ such as USB keychains and USB harddisks where it is now suitable
+ to give the console owner write access to the device node */
+ if (*flags & MS_PAMCONSOLE) {
+ char *username;
+ char pamconsole_file_name[256];
+ struct stat sb;
+
+ username = getusername ();
+
+ if (username != NULL) {
+ snprintf (pamconsole_file_name, sizeof (pamconsole_file_name),
+ "/var/run/console/%s", username);
+ if (stat (pamconsole_file_name, &sb) == 0) {
+ *flags |= MS_USER;
+ }
+ }
+ }
+
+ /* James Kehl <mkehl@gil.com.au> came with a similar patch:
allow an arbitrary user to mount when he is the owner of
the mount-point and has write-access to the device.
This is even less secure. Let me skip it for the time being;
@@ -823,7 +848,7 @@
*user = getusername();
}
- *flags &= ~(MS_OWNER | MS_GROUP);
+ *flags &= ~(MS_OWNER | MS_GROUP | MS_PAMCONSOLE);
}
static int

View file

@ -0,0 +1,71 @@
--- util-linux-ng-2.13-rc3/mount/fstab.c.kzak 2007-07-31 12:39:42.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/fstab.c 2007-08-13 12:24:40.000000000 +0200
@@ -264,6 +264,27 @@
return (ct == 1);
}
+/*
+ * Given the loop file LOOPFILE, and the mount point DIR, check that
+ * same file is already mounted on same directory
+ *
+ * Don't forget there's
+ * /path/loopfile /path/dir loop=/dev/loop0
+ * in mtab for loop devices.
+ */
+int
+is_mounted_same_loopfile(const char *loopfile, const char *dir) {
+ struct mntentchn *mc, *mc0;
+ int ct = 0;
+
+ mc0 = mtab_head();
+ for (mc = mc0->prev; mc && mc != mc0; mc = mc->prev)
+ if (streq(mc->m.mnt_fsname, loopfile) &&
+ streq(mc->m.mnt_dir, dir))
+ ct++;
+ return (ct == 1);
+}
+
/* Given the name FILE, try to find the option "loop=FILE" in mtab. */
struct mntentchn *
getmntoptfile (const char *file) {
--- util-linux-ng-2.13-rc3/mount/fstab.h.kzak 2007-05-30 10:18:12.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/fstab.h 2007-08-13 12:24:40.000000000 +0200
@@ -5,6 +5,7 @@
int mtab_is_writable(void);
int mtab_does_not_exist(void);
int is_mounted_once(const char *name);
+int is_mounted_same_loopfile(const char *loopfile, const char *dir);
struct mntentchn {
struct mntentchn *nxt, *prev;
--- util-linux-ng-2.13-rc3/mount/mount.c.kzak 2007-08-13 12:23:13.000000000 +0200
+++ util-linux-ng-2.13-rc3/mount/mount.c 2007-08-13 12:29:01.000000000 +0200
@@ -853,7 +853,7 @@
static int
loop_check(const char **spec, const char **type, int *flags,
- int *loop, const char **loopdev, const char **loopfile) {
+ int *loop, const char **loopdev, const char **loopfile, const char *dir) {
int looptype;
unsigned long long offset;
@@ -894,6 +894,10 @@
offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
+ if (is_mounted_same_loopfile(*loopfile, dir)) {
+ error(_("mount: %s already mounted on %s"), *loopfile, dir);
+ return EX_FAIL;
+ }
do {
if (!*loopdev || !**loopdev)
*loopdev = find_unused_loop_device();
@@ -1079,7 +1083,7 @@
* stale assignments of files to loop devices. Nasty when used for
* encryption.
*/
- res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
+ res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile, node);
if (res)
goto out;
}

View file

@ -0,0 +1,106 @@
diff -up util-linux-ng-2.13.1/mount/swapon.c.reinit util-linux-ng-2.13.1/mount/swapon.c
--- util-linux-ng-2.13.1/mount/swapon.c.reinit 2008-01-16 10:31:41.000000000 +0100
+++ util-linux-ng-2.13.1/mount/swapon.c 2008-04-02 16:00:24.000000000 +0200
@@ -10,6 +10,9 @@
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <fcntl.h>
#include "xmalloc.h"
#include "swap_constants.h"
#include "nls.h"
@@ -17,6 +20,8 @@
#include "realpath.h"
#include "mount_paths.h"
+#define PATH_MKSWAP "/sbin/mkswap"
+
#ifdef HAVE_SYS_SWAP_H
# include <sys/swap.h>
#endif
@@ -158,6 +163,64 @@ display_summary(void)
}
static int
+swap_is_suspend(const char *device) {
+ const char *type = fsprobe_get_fstype_by_devname(device);
+
+ return (type && strcmp(type, "swsuspend") == 0) ? 1 : 0;
+}
+
+/* calls mkswap */
+static int
+swap_reinitialize(const char *device) {
+ const char *label = fsprobe_get_label_by_devname(device);
+ const char *uuid = fsprobe_get_uuid_by_devname(device);
+ pid_t pid;
+ int status, ret;
+ char *cmd[7];
+ int idx=0;
+
+ switch((pid=fork())) {
+ case -1: /* fork error */
+ fprintf(stderr, _("%s: cannot fork: %s\n"),
+ progname, strerror(errno));
+ return -1;
+
+ case 0: /* child */
+ cmd[idx++] = PATH_MKSWAP;
+ if (label && *label) {
+ cmd[idx++] = "-L";
+ cmd[idx++] = (char *) label;
+ }
+ if (uuid && *uuid) {
+ cmd[idx++] = "-U";
+ cmd[idx++] = (char *) uuid;
+ }
+ cmd[idx++] = (char *) device;
+ cmd[idx++] = NULL;
+ execv(cmd[0], cmd);
+ perror("execv");
+ exit(1); /* error */
+
+ default: /* parent */
+ do {
+ if ((ret = waitpid(pid, &status, 0)) < 0
+ && errno == EINTR)
+ continue;
+ else if (ret < 0) {
+ fprintf(stderr, _("%s: waitpid: %s\n"),
+ progname, strerror(errno));
+ return -1;
+ }
+ } while (0);
+
+ /* mkswap returns: 0=suss, 1=error */
+ if (WIFEXITED(status) && WEXITSTATUS(status)==0)
+ return 0; /* ok */
+ }
+ return -1; /* error */
+}
+
+static int
do_swapon(const char *orig_special, int prio, int canonic) {
int status;
struct stat st;
@@ -179,6 +242,18 @@ do_swapon(const char *orig_special, int
return -1;
}
+ /* We have to reinitialize swap with old (=useless) software suspend
+ * data. The problem is that if we don't do it, then we get data
+ * corruption the next time an attempt at unsuspending is made.
+ */
+ if (swap_is_suspend(special)) {
+ fprintf(stdout, _("%s: %s: software suspend data detected. "
+ "Reinitializing the swap.\n"),
+ progname, special);
+ if (swap_reinitialize(special) < 0)
+ return -1;
+ }
+
/* people generally dislike this warning - now it is printed
only when `verbose' is set */
if (verbose) {

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

@ -0,0 +1,6 @@
#%PAM-1.0
auth sufficient pam_rootok.so
auth include system-auth
account include system-auth
password include system-auth
session include system-auth

16
util-linux-ng-login.pamd Normal file
View file

@ -0,0 +1,16 @@
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
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
session optional pam_keyinit.so force revoke
session include system-auth
session optional pam_ck_connector.so

15
util-linux-ng-remote.pamd Normal file
View file

@ -0,0 +1,15 @@
#%PAM-1.0
auth required pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
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
session optional pam_keyinit.so force revoke
session include system-auth

1859
util-linux-ng.spec Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,78 @@
From ced94242e11e2ac121c9dae5c707bac5b47e501a Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 7 Jul 2008 15:22:22 +0200
Subject: [PATCH] write: doesn't check for tty group
write(1) selects a wrong tty, because there is not a proper
check of tty group ownership:
$ write kzak
write: kzak is logged in more than once; writing to tty7
write: /dev/tty7: Permission denied
$ ls -la /dev/tty7
crw--w---- 1 root root 4, 7 2008-07-04 00:32 /dev/tty7
^^^^
$ ls -la /usr/bin/write
-rwxr-sr-x 1 root tty 11864 2008-04-02 16:24 /usr/bin/write
^ ^^^
We have to check for tty group owner, because we don't have
permissions to write to arbitrary tty.
Fixed version:
$ write kzak
write: kzak is logged in more than once; writing to pts/6
^^^^
Message from test@nb on pts/7 at 15:22 ...
^C
$ ls -la /dev/pts/6
crw--w---- 1 kzak tty 136, 6 2008-07-07 15:35 /dev/pts/6
^^^
Addresses-Red-Hat-Bugzilla: #454252
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/write.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/misc-utils/write.c b/misc-utils/write.c
index 46b8f0a..276fe96 100644
--- a/misc-utils/write.c
+++ b/misc-utils/write.c
@@ -72,6 +72,8 @@ static void done(int);
int term_chk(char *, int *, time_t *, int);
int utmp_chk(char *, char *);
+static gid_t myegid;
+
int
main(int argc, char **argv) {
time_t atime;
@@ -83,6 +85,8 @@ main(int argc, char **argv) {
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ myegid = getegid();
+
/* check that sender has write enabled */
if (isatty(fileno(stdin)))
myttyfd = fileno(stdin);
@@ -267,7 +271,9 @@ int term_chk(char *tty, int *msgsokP, time_t *atimeP, int showerror)
"write: %s: %s\n", path, strerror(errno));
return(1);
}
- *msgsokP = (s.st_mode & (S_IWRITE >> 3)) != 0; /* group write bit */
+
+ /* group write bit and group ownership */
+ *msgsokP = (s.st_mode & (S_IWRITE >> 3)) && myegid == s.st_gid;
*atimeP = s.st_atime;
return(0);
}
--
1.5.5.1