Karel Zak [Mon, 26 Nov 2012 13:30:22 +0000 (14:30 +0100)]
mount: sanitize paths from non-root users
$ mount /root/.ssh/../../dev/sda2
mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot
this is too promiscuous. It seems better to ignore on command line
specified paths which are not resolve-able for non-root users.
Fixed version:
$ mount /root/.ssh/../../dev/sda2
mount: /root/.ssh/../../dev/sda2: Permission denied
$ mount /dev/sda2
mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot
Note that this bug has no relation to mount(2) permissions evaluation
in suid mode. The way how non-root user specifies paths on command
line is completely irrelevant for comparison with fstab entries.
Karel Zak [Mon, 5 Nov 2012 15:48:12 +0000 (16:48 +0100)]
ipcs: clean up do_shm()
- don't expect maxid as argument in ipc_shm_get_info()
- if there is @id argument then use it everywhere in ipc_shm_get_info()
- don't call shmctl() if not necessary in do_shm()
Sami Kerola [Sun, 21 Oct 2012 16:39:36 +0000 (17:39 +0100)]
ipcs: add /proc and /sys path definitions
The necessary proc and sysfs files are tested to be present. When
information files are missing the ipcs will use obsolted system calls,
and data structures, as fallback.
Karel Zak [Thu, 22 Nov 2012 13:26:41 +0000 (14:26 +0100)]
lib/ttyutils: create .c file
Well, now all tty stuff are incline functions in include/ttyutils.h.
It's seems more elegant to create regular lib/ttyutils.c for libcommon
and write test program.
Karel Zak [Thu, 22 Nov 2012 10:14:02 +0000 (11:14 +0100)]
agetty: add --{erase,kill}-chars options
We need way to disable the default kill and erase agetty chars to make
the getty usable for Active Directory users with '@' in username.
It seems that the most extendible solution is to add options that
allow to complete control additional erase/kill chars. If you specify
empty strings then the chars are disabled at all.
Note that this patch is backwardly compatible.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=870854 Signed-off-by: Karel Zak <kzak@redhat.com>
Commit c550f728f724360f99aae0fdb45b0589d9a347e0 added O_EXCL when
opening the thing to erase. This broke the wipefs utility when used
on anything which isn't an unmounted filesystem. eg. If you use it on
a block device containing partitions, then it won't work because the
kernel recognizes the partitions and so thinks the device is in use.
This change adds the --force option which, when used, undoes the above
flag change. However you still have to use --force most of the time
when erasing something that isn't a plain unmounted filesystem.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Karel Zak [Thu, 15 Nov 2012 15:44:07 +0000 (16:44 +0100)]
umount: (recursive) don't call umount(2) for already unmounted targets
In the umount --recursive we follow entries from mountinfo, but the
entries maybe already obsolete. Especially if the hierarchy of the
mountpoints contains shared subtrees and umount(2) for one entry may
generate umount for some other entry too.
Toshi Kani [Tue, 23 Oct 2012 19:49:46 +0000 (13:49 -0600)]
lscpu: Fix issue found on CPU hot-remove
read_basicinfo() relies on sysfs cpu directories
"/sys/devices/system/cpu/cpu%d" with assumption that cpu
logical number %d is always sequentially assigned for all
CPUs. However, this assumption is not correct with CPU
hot-remove operation since it removes a target sysfs cpu
directory after it is ejected. As a result, lscpu may not
recognize all CPUs.
The issue can be easily reproduced on KVM or VirtualBox,
which supports CPU eject operation, as follows.
1) The system has 4 CPUs
$ lscpu -a -e
CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
0 0 0 0 0:0:0 yes
1 0 1 1 1:1:1 yes
2 0 2 2 2:2:2 yes
3 0 3 3 3:3:3 yes
3) lscpu no longer recognizes cpu3 after cpu2 is ejected
$ lscpu -a -e
CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
0 0 0 0 0:0:0 yes
1 0 1 1 1:1:1 yes
The following changes are made to address this issue.
- Use maxcpus to allocate and parse bitmaps.
- Set desc->ncpu from cpu/present, which includes both on-line
and off-line CPUs.
- Add is_cpu_present() to check if a CPU is present. Ejected
CPUs are not present.
[kzak@redhat.com: - read also /sys/devices/system/cpu/possible mask to
determine maximal number of CPUs,
- err() if possible mask is not found in /sys]
Signed-off-by: Toshi Kani <toshi.kani@hp.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 9 Nov 2012 11:52:33 +0000 (12:52 +0100)]
lib/consoles: try another methods before go to fallback
The current code goes immediately to the fallback section if any
detection method fails. It seems better to try another methods before
the fallback solution.
The reason, as Daniel it reported, was that the script will close stderr
twice, once as timing file and atexit() in function close_stdout(). This
commit fixes the problem.
Reported-by: Daniel Narvaez <dwnarvaez@gmail.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Davidlohr Bueso [Sat, 27 Oct 2012 17:23:47 +0000 (19:23 +0200)]
gpt: create empty disklabels
This patch enables creating a new, empty, GPT disklabel from either
an empty disk or one that already has a disklabel. For this
purpose, a 'g' option is added to the main menu and is visible to all
labels. Here's an example for a scsi_debug device (/dev/sdb):
...
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x20a614c8.
3696: fdisk: CONTEXT: zeroize in-memory first sector buffer
Command (m for help): g
3696: fdisk: LABEL: changing to gpt label
3696: fdisk: CONTEXT: zeroize in-memory first sector buffer
3696: fdisk: LABEL: created new empty GPT disklabel (GUID: D4EA0706-F011-46DC-B7DE-6A72C7090AF8)
Command (m for help): w
The partition table has been altered!
...
Acked-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Davidlohr Bueso [Sat, 27 Oct 2012 17:23:36 +0000 (19:23 +0200)]
fdisk: gpt: write entire first sector
We were writing only 1 byte in LBA0, and GPT requires dealing with an entire
sector. This bug wasn't affecting when dealing with already existing devices
with GPT as we weren't writing an important part of the first sector, thus
leaving it unchanged. Also use write_all() wrapper from all-io.h
Acked-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Davidlohr Bueso <dave@gnu.org>