ncurses library can be build with terminal related functions
landing in separate libtinfo library. Check for ncurses function
when testing ncurses library existence.
Andrew McGill [Tue, 29 Jul 2008 21:56:05 +0000 (23:56 +0200)]
script: don't flush input when starting script
script currently flushed the input buffer when starting up. This undocumented
behaviour prevents typeahead when starting up (e.g. as part of .profile).
Rather retain queued input. Don't discard queued output either.
Signed-off-by: Andrew McGill <andrew@lunch.za.net>
Karel Zak [Fri, 1 Aug 2008 10:18:03 +0000 (12:18 +0200)]
losetup: looplist_* refactoring, remove scandir()
This patch replaces scandir-based implementation with readdir(). The
readdir(3) is less expensive and more portable (to non-glibc environment).
The patch also replaces sysfs-based solution with simpler /proc/partitions
parsing. The /proc/partitions includes all used loop devices on all systems
(include 2.4). This solution seems faster than scandir(/sys/block/) too.
Summary, the losetup (with this patch) uses three methods to found a
loop device:
a) parse /proc/partitions to found already used loop devices (for
loserup -a)
b) stat(2) for all loop[0-7] devices (default number of loop devices).
This is classic method from util-linux <= 2.13. This method is good
enough for standard Linux machines with default number of loop
devices.
c) scan all /dev or /dev/loop/ for loop devices. This is useful for
crazy people who need more than 8 loop devices.
Matthias Koenig [Mon, 9 Jun 2008 14:38:25 +0000 (16:38 +0200)]
mount: retry on ENOMEDIUM
Due to a change in kernel behaviour when opening CDROM devices,
we need to retry the open/mount call when ENOMEDIUM is returned.
Explanation from Tejun Heo:
Okay, the difference is from the addition of cdrom_get_media_event()
call to both sr_drive_status() and ide_cdrom_drive_status().
Previously, the cdrom driver can't differentiate between tray closed
w/ no media and tray open and always returned tray open, which
triggers close and retry in the open logic which probably have delayed
things enough to get the media recognized.
Now the cdrom driver can discern between tray closed w/o media and
device not ready for other reasons and returns -ENOMEDIUM on the
former. This is all good and dandy but the problem seems that some
drives report no media right after the tray is closed but it hasn't
properly detected the media yet.
It seems the only way to work around the problem is via sensible
retries (e.g. try three times 5 secs apart) and I don't think we can
add that type of retry logic into cdrom open path. Please note that
the previous logic wasn't water proof. Some drives can take longer to
recognize the media is there and could have failed the in-kernel retry
too. Also, reading the media can take quite some time and during that
period the drive reports media present but device not ready. The
driver will retry the command (e.g. READ TOC for open) five times but
all of them can fail w/ EMEDIUMTYPE.
[kzak@redhat.com: - add CRDOM_NOMEDIUM_RETRIES to blkdev.h
- add verbose message to mount.c]
Signed-off-by: Matthias Koenig <mkoenig@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘klogctl’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘type’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘b’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘len’
without belows compat section dmesg just compiles fine against klibc.
as bonus reorder the includes.
Samuel Thibault [Thu, 24 Jul 2008 00:27:14 +0000 (01:27 +0100)]
ldattach: don't compile for non-linux systems
There is just ldattach which doesn't compile because line disciplines are not
implemented that way on the Hurd. Is TIOCSETD any kind of standard? Else I
guess the patch below would be fine.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
no longer use deprecated alias.
clears a useless compile error when compiling against klibc:
mount.c:995: error: `MOUNTED' undeclared (first use in this function)
Karel Zak [Wed, 2 Jul 2008 12:26:51 +0000 (14:26 +0200)]
umount: improve "-d" option for autoclear loops
The new loop auto-destruct feature detaches automatically loop devices
when no longer used. This means they are detached with the umount()
call. But when we call umount with -d, del_loop() is called and fails
because the ioctl() returns ENXIO. We have to check for autoclear
loop devices rather than blindly call del_loop().
Reported-by: Matthias Koenig <mkoenig@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 23 Jun 2008 11:00:00 +0000 (13:00 +0200)]
mount: warn on "file_t" selinux context
Currently if I mount a file system without labels, it works fine, but
later or SELinux will start printing denials and stopping certain
applications from working. It would be nice if the mount command
checked it in selinux mode.
Addresses-Red-Hat-Bugzilla: #390691 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 17 Jun 2008 11:12:12 +0000 (13:12 +0200)]
hwclock: always reads hardware clock
It's a pity that hwclock first tries to read the clock when running
hwclock --systohc --noadjfile --utc
and exits as this fails. I cannot see a reason to read first in that
case.
Old version:
# hwclock --systohc --noadjfile --utc --debug
hwclock from util-linux-ng 2.14
Using /dev interface to clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time
from /dev/rtc to change
...got clock tick
Time read from Hardware Clock: 2008/06/17 11:18:24
Hw clock time : 2008/06/17 11:18:24 = 1213701504 seconds since 1969
Time elapsed since reference time has been 0.904855 seconds.
Delaying further to reach the next full second.
Setting Hardware Clock to 11:18:24 = 1213701504 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
New version:
# hwclock --systohc --noadjfile --utc --debug
hwclock from util-linux-ng 2.14
Using /dev interface to clock.
Assuming hardware clock is kept in UTC time.
Time elapsed since reference time has been 0.572151 seconds.
Delaying further to reach the next full second.
Setting Hardware Clock to 11:18:52 = 1213701532 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Addresses-Debian-Bug: #478663 Signed-off-by: Karel Zak <kzak@redhat.com>
This patch allows "tolerant" behavior, i.e. proceeding even if
priority could not be set. This might be of use in case something
(selinux, old kernel, etc.) does not allow the requested scheduling
priority to be set.
This could be to some extend done as follows:
ionice -c3 command || command
but the downside is that one could not really tell if what failed was
setting priority or command itself, which could result in duplicate
command run.
This patch solves the situation, so that user can do
ionice -t -c3 command
Addresses-Red-Hat-Bugzilla: #443842 Signed-off-by: Lubomir Kundrak <lkundrak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Matthias Koenig [Mon, 2 Jun 2008 14:51:57 +0000 (16:51 +0200)]
hwclock: omit warning about drift if --noadjfile given
Currently, if hwclock is given the --noadjfile option it will
nevertheless display information about the drift rate when invoked with
the --debug option.
Mike Frysinger [Sat, 7 Jun 2008 17:22:45 +0000 (13:22 -0400)]
more: dont use a.out.h
The a.out.h header is not friendly to portable systems (iow, those that
lack a.out support), and since the defines are only used in a cheesy magic,
just use the magic constants. It's not like they're ever going to change.
James Youngman [Wed, 14 May 2008 08:51:40 +0000 (09:51 +0100)]
more: minor fixes to magic()
Read the magic bytes into signed chars instead of vanilla chars in
order to ensure consistent results even on systems whose char type has
no sign. Eliminate spurious parentheses in return statements.
Correct grammatical errors in comments.
Volker Schatz [Tue, 3 Jun 2008 21:52:04 +0000 (23:52 +0200)]
ddate: 11th, 12th and 13th of month
the Discordian date utility ddate gives the 11th, 12th and 13th of the month as
the "11st", "12nd" and "13rd". Unless this is a religious thing, please apply
the patch below.
Karel Zak [Wed, 14 May 2008 14:38:47 +0000 (16:38 +0200)]
mount: remount doesn't care about loop=
The command
# mount -oremount <spec> <dir>
doesn't read fstab or mtab. This is expected behaviour. Unfortunately,
we have to care about the internal loop= option which is generated and
maintained by mount(8)/umount(8). The loop= option has to be persistent.
How to reproduce this bug:
# mount -o loop /home/images/vfat.img /mnt/img; grep vfat /etc/mtab; \
mount -o remount,ro /home/images/vfat.img /mnt/img; grep vfat /etc/mtab;
Karel Zak [Tue, 13 May 2008 12:00:39 +0000 (14:00 +0200)]
setarch: add fallback for linux/personality
setarch.c:248: error: 'ADDR_NO_RANDOMIZE' undeclared (first use in this function)
setarch.c:248: error: (Each undeclared identifier is reported only once
setarch.c:248: error: for each function it appears in.)
setarch.c:251: error: 'FDPIC_FUNCPTRS' undeclared (first use in this function)
setarch.c:257: error: 'ADDR_COMPAT_LAYOUT' undeclared (first use in this function)
setarch.c:260: error: 'READ_IMPLIES_EXEC' undeclared (first use in this function)
Linux gzp1 2.4.36.1-gzp1 #1 SMP Tue Feb 19 10:23:48 CET 2008 i686 GNU/Linux
Reported-By: Gabor Z. Papp <gzp@papp.hu> Signed-off-by: Karel Zak <kzak@redhat.com>
Steve Grubb [Sat, 19 Apr 2008 15:49:02 +0000 (11:49 -0400)]
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.
Steve Grubb [Sat, 19 Apr 2008 15:49:02 +0000 (11:49 -0400)]
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.