Karel Zak [Wed, 12 Dec 2012 09:36:32 +0000 (10:36 +0100)]
chfn: clean up exit status
The old version in some cases (but not always) returns -1 (255) on
error. It seems better to cleanup the code and don't return internal
return codes by exit().
Bernhard Voelker [Fri, 30 Nov 2012 16:12:12 +0000 (17:12 +0100)]
libmount: avoid endless loop in mnt_get_kernel_cmdline_option
The above function infloops when the name to search for can only
be found at the beginning of /proc/cmdline but doesn't match,
e.g. when searching for "ro" in "root=/dev/sda1 quiet vga=0x31a".
* libmount/src/utils.c (mnt_get_kernel_cmdline_option): Replace
while by for loop to ensure the pointer p is incremented.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
Karel Zak [Tue, 4 Dec 2012 10:58:13 +0000 (11:58 +0100)]
libblkid: cleanup nonnull attribute usage
- don't mix __attribute__((nonnull)) and "if (!argument) return" for
the same function. The "if ()" check will be *silently* optimized
out by gcc.
- use __attribute__((nonnull)) for functions where is impossible to
return error code. For example "is" and "has" functions or functions
where we return unsigned types and zero is a valid value.
Karel Zak [Mon, 3 Dec 2012 14:32:16 +0000 (15:32 +0100)]
fdisk: remove global variable sector_offset
- add cxt->first_lba as replacement to sector_offset
- add label->reset_alignment() to overwrite the default alignment setting
- add fdisk_reset_alignment() to setup grain, first LBA offset, etc.
Davidlohr Bueso [Mon, 26 Nov 2012 04:25:49 +0000 (20:25 -0800)]
fdisk: api: move disklabel type to cxt
Get rid of it as a global variable as it belongs in the context.
To compare a disklabel on the device, the fdisk_dev_is_disklabel()
function is introduced. Also, to avoid naming issues, the fdisk_labeltype
members where renamed to FDISK_DISKLABEL_<type>.
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>