Compare commits
155 commits
master
...
stable/v2.
Author | SHA1 | Date | |
---|---|---|---|
|
12f5423fc2 | ||
|
0eb9b50878 | ||
|
c6fe19815a | ||
|
39a81981ac | ||
|
86f89da80e | ||
|
331a1e6e10 | ||
|
d4178c526b | ||
|
5ac78f94e6 | ||
|
018a10907f | ||
|
f3db9bd609 | ||
|
f59c8fd38d | ||
|
9ffaa85be1 | ||
|
a2ec89ca4b | ||
|
c10d72868e | ||
|
1a59c9fa15 | ||
|
ede5254afa | ||
|
d0aeb4d2c0 | ||
|
75882dea1a | ||
|
6dde514b2a | ||
|
19238be16d | ||
|
a5c6ab54e6 | ||
|
f6dd7b20cd | ||
|
ebd4749115 | ||
|
692167ff5e | ||
|
8ab700b933 | ||
|
5cc21d91fc | ||
|
bca77acb03 | ||
|
3c466f7c35 | ||
|
54cb0dd60c | ||
|
4763080701 | ||
|
4f2406545c | ||
|
31bb588663 | ||
|
86d5de52d4 | ||
|
9d761e8325 | ||
|
6e8af4695e | ||
|
b5a4d57a5c | ||
|
bb894a4493 | ||
|
bb954f7658 | ||
|
7169c01223 | ||
|
6bf2c99b2e | ||
|
debce7468d | ||
|
2349d4c090 | ||
|
e5694e94b5 | ||
|
5ba2c4317c | ||
|
4fcd20534f | ||
|
d1a5e99e8a | ||
|
f626170062 | ||
|
a3d73c246f | ||
|
650fca1a06 | ||
|
22a2bce042 | ||
|
937fe5d9c5 | ||
|
1bb08cfc01 | ||
|
4bea4821ab | ||
|
18492b47b7 | ||
|
db4d80fcef | ||
|
d501259161 | ||
|
ee3d6b0d4a | ||
|
9c3b9269d9 | ||
|
6a7194ea23 | ||
|
71b98c36d4 | ||
|
8da7e26cbc | ||
|
375afc17f4 | ||
|
19dd7a1e30 | ||
|
be39647ac4 | ||
|
9ada40d3cc | ||
|
5ca73c6eef | ||
|
6269a5fc0d | ||
|
89379c88db | ||
|
0be381be44 | ||
|
54da548e02 | ||
|
2db4c7f0b3 | ||
|
45f40a1ed8 | ||
|
28941d202a | ||
|
97b7dcf32e | ||
|
cd969e8908 | ||
|
c0617de5a4 | ||
|
cb75cf88b8 | ||
|
9ee95fa26a | ||
|
878307e960 | ||
|
e4aad0a9c4 | ||
|
0ea3e2f0ed | ||
|
ee021a5f9e | ||
|
a9768580a4 | ||
|
cbfbbc44c4 | ||
|
22cecf786f | ||
|
aeba558136 | ||
|
9411b6ccf8 | ||
|
c357816caa | ||
|
7a50f117a4 | ||
|
21ef212a58 | ||
|
b2db509d13 | ||
|
8803c8d4ab | ||
|
096487c616 | ||
|
8335261c3d | ||
|
b6cd420e03 | ||
|
62aa386c4f | ||
|
0729593862 | ||
|
736b6ab7fd | ||
|
864578ded7 | ||
|
b0f8d63e63 | ||
|
86328e78ea | ||
|
155b79d38e | ||
|
b342240e84 | ||
|
a000aad7a6 | ||
|
ab26415a03 | ||
|
42a9c18706 | ||
|
59bb9ab136 | ||
|
703ec6fc66 | ||
|
7b18166aa3 | ||
|
b2bd06d9ca | ||
|
856ec50de5 | ||
|
7bee16f27f | ||
|
609468bc9b | ||
|
bda3f658e0 | ||
|
292161888c | ||
|
b22ecdd840 | ||
|
2f40ad0608 | ||
|
7e787030bf | ||
|
5fc0e55af1 | ||
|
ed03caf2c6 | ||
|
421c6766ea | ||
|
b81a870767 | ||
|
c22bb73d3a | ||
|
33eec71c1a | ||
|
cff7e7d84b | ||
|
f113d46a50 | ||
|
9461ae9b90 | ||
|
aec0e37683 | ||
|
37bb1b07e0 | ||
|
da0c591015 | ||
|
ee0653123c | ||
|
3aef5dcad5 | ||
|
3871a969ed | ||
|
612913cda5 | ||
|
b1e37433bb | ||
|
4b9d512c6f | ||
|
296f21699d | ||
|
a8deea07a7 | ||
|
994b3295c2 | ||
|
bcb6ccf819 | ||
|
5f0cf2484f | ||
|
a7f7d3474a | ||
|
d72c79d495 | ||
|
a27ff267f0 | ||
|
d3363ef6d7 | ||
|
4f42dc779e | ||
|
97660cb42a | ||
|
250fc0bc9b | ||
|
af5527f45e | ||
|
66099fe11c | ||
|
fb87dcc80e | ||
|
9bf924165b | ||
|
bef5ab005e | ||
|
fce7b9501c | ||
|
e0c46c2d4e |
179 changed files with 72546 additions and 49609 deletions
16
AUTHORS
16
AUTHORS
|
@ -111,6 +111,7 @@ CONTRIBUTORS:
|
||||||
Alexey Gladkov <gladkov.alexey@gmail.com>
|
Alexey Gladkov <gladkov.alexey@gmail.com>
|
||||||
Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
|
Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
|
||||||
Alex Ivanov <yourbestfriend@openmailbox.org>
|
Alex Ivanov <yourbestfriend@openmailbox.org>
|
||||||
|
Alex Xu <351006+Hello71@users.noreply.github.com>
|
||||||
Allon Mureinik <amureini@redhat.com>
|
Allon Mureinik <amureini@redhat.com>
|
||||||
Alon Bar-Lev <alon.barlev@gmail.com>
|
Alon Bar-Lev <alon.barlev@gmail.com>
|
||||||
Alvaro M. Echevarria
|
Alvaro M. Echevarria
|
||||||
|
@ -198,6 +199,8 @@ CONTRIBUTORS:
|
||||||
Chris MacGregor <chrismacgregor@google.com>
|
Chris MacGregor <chrismacgregor@google.com>
|
||||||
Chris Metcalf <cmetcalf@mellanox.com>
|
Chris Metcalf <cmetcalf@mellanox.com>
|
||||||
Chris Morin <chris.morin2@gmail.com>
|
Chris Morin <chris.morin2@gmail.com>
|
||||||
|
Christian Bartolomäus <use_v6@aglaz.de>
|
||||||
|
Christian Finnberg <christian@finnberg.net>
|
||||||
Christian Hesse <mail@eworm.de>
|
Christian Hesse <mail@eworm.de>
|
||||||
Christian von Roques <roques@juliet.ka.sub.org>
|
Christian von Roques <roques@juliet.ka.sub.org>
|
||||||
Christian Wiese <chris@opensde.org>
|
Christian Wiese <chris@opensde.org>
|
||||||
|
@ -272,6 +275,7 @@ CONTRIBUTORS:
|
||||||
Elliott Mitchell <ehem+util-linux@drgnwing.com>
|
Elliott Mitchell <ehem+util-linux@drgnwing.com>
|
||||||
Eric Biggers <ebiggers@google.com>
|
Eric Biggers <ebiggers@google.com>
|
||||||
Eric Desrochers <eric.desrochers@canonical.com>
|
Eric Desrochers <eric.desrochers@canonical.com>
|
||||||
|
Érico Nogueira <erico.erc@gmail.com>
|
||||||
Érico Rolim <erico.erc@gmail.com>
|
Érico Rolim <erico.erc@gmail.com>
|
||||||
Eric Rannaud <e@nanocritical.com>
|
Eric Rannaud <e@nanocritical.com>
|
||||||
Eric Rasmussen <ear@usfirst.org>
|
Eric Rasmussen <ear@usfirst.org>
|
||||||
|
@ -323,6 +327,7 @@ CONTRIBUTORS:
|
||||||
Gaël PORTAY <gael.portay@collabora.com>
|
Gaël PORTAY <gael.portay@collabora.com>
|
||||||
Gao Xiang <hsiangkao@redhat.com>
|
Gao Xiang <hsiangkao@redhat.com>
|
||||||
Georg Schiesser <georg.schiesser@opentech.at>
|
Georg Schiesser <georg.schiesser@opentech.at>
|
||||||
|
Georgy Yakovlev <gyakovlev@gentoo.org>
|
||||||
Gerald Schaefer <gerald.schaefer@de.ibm.com>
|
Gerald Schaefer <gerald.schaefer@de.ibm.com>
|
||||||
Gerhard Schneider <gs@ilfb.tuwien.ac.at>
|
Gerhard Schneider <gs@ilfb.tuwien.ac.at>
|
||||||
Gero Treuner <gero@70t.de>
|
Gero Treuner <gero@70t.de>
|
||||||
|
@ -440,6 +445,7 @@ CONTRIBUTORS:
|
||||||
Jörg Jenderek <joerg.jen.der.ek@gmx.net>
|
Jörg Jenderek <joerg.jen.der.ek@gmx.net>
|
||||||
Joseph Parmelee <jparmele@wildbear.com>
|
Joseph Parmelee <jparmele@wildbear.com>
|
||||||
Josep Puigdemont <josep.puigdemont@gmail.com>
|
Josep Puigdemont <josep.puigdemont@gmail.com>
|
||||||
|
Jose Riha <jose1711@gmail.com>
|
||||||
Josh Triplett <josh@joshtriplett.org>
|
Josh Triplett <josh@joshtriplett.org>
|
||||||
Joshua Hudson <joshudson@gmail.com>
|
Joshua Hudson <joshudson@gmail.com>
|
||||||
Joshua Watt <jpewhacker@gmail.com>
|
Joshua Watt <jpewhacker@gmail.com>
|
||||||
|
@ -488,6 +494,7 @@ CONTRIBUTORS:
|
||||||
Li Zefan <lizf@cn.fujitsu.com>
|
Li Zefan <lizf@cn.fujitsu.com>
|
||||||
Lubomir Kundrak <lkundrak@redhat.com>
|
Lubomir Kundrak <lkundrak@redhat.com>
|
||||||
Lubomir Rintel <lkundrak@v3.sk>
|
Lubomir Rintel <lkundrak@v3.sk>
|
||||||
|
Luca Boccassi <bluca@debian.org>
|
||||||
Luca Boccassi <luca.boccassi@microsoft.com>
|
Luca Boccassi <luca.boccassi@microsoft.com>
|
||||||
Luca BRUNO <luca.bruno@coreos.com>
|
Luca BRUNO <luca.bruno@coreos.com>
|
||||||
Luca Ceresoli <luca@lucaceresoli.net>
|
Luca Ceresoli <luca@lucaceresoli.net>
|
||||||
|
@ -584,6 +591,7 @@ CONTRIBUTORS:
|
||||||
nick black <dankamongmen@gmail.com>
|
nick black <dankamongmen@gmail.com>
|
||||||
nick black <nick.black@sprezzatech.com>
|
nick black <nick.black@sprezzatech.com>
|
||||||
Nick Holloway <Nick.Holloway@pyrites.org.uk>
|
Nick Holloway <Nick.Holloway@pyrites.org.uk>
|
||||||
|
Nicolai Dagestad <nicolai@dagestad.fr>
|
||||||
Nicolai Langfeldt <janl@math.uio.no>
|
Nicolai Langfeldt <janl@math.uio.no>
|
||||||
Nicolas Boichat <nicolas@boichat.ch>
|
Nicolas Boichat <nicolas@boichat.ch>
|
||||||
Nicolas Provost <nprovost@quadriv.com>
|
Nicolas Provost <nprovost@quadriv.com>
|
||||||
|
@ -605,6 +613,7 @@ CONTRIBUTORS:
|
||||||
osexp2000 <osexp2000@gmail.com>
|
osexp2000 <osexp2000@gmail.com>
|
||||||
Pádraig Brady <P@draigBrady.com>
|
Pádraig Brady <P@draigBrady.com>
|
||||||
Pali Rohár <pali.rohar@gmail.com>
|
Pali Rohár <pali.rohar@gmail.com>
|
||||||
|
panchenbo <panchenbo@uniontech.com>
|
||||||
Pascal Terjan <pterjan@mandriva.com>
|
Pascal Terjan <pterjan@mandriva.com>
|
||||||
Patrice Dumas <pertusus@free.fr>
|
Patrice Dumas <pertusus@free.fr>
|
||||||
Patrick Plagwitz <patrick.plagwitz@fau.de>
|
Patrick Plagwitz <patrick.plagwitz@fau.de>
|
||||||
|
@ -647,6 +656,7 @@ CONTRIBUTORS:
|
||||||
Pierre Labastie <pierre.labastie@neuf.fr>
|
Pierre Labastie <pierre.labastie@neuf.fr>
|
||||||
Pietro Castelli
|
Pietro Castelli
|
||||||
Pino Toscano <toscano.pino@tiscali.it>
|
Pino Toscano <toscano.pino@tiscali.it>
|
||||||
|
Platon Pronko <platon7pronko@gmail.com>
|
||||||
Po-Yu Chuang <ratbert@faraday-tech.com>
|
Po-Yu Chuang <ratbert@faraday-tech.com>
|
||||||
Prarit Bhargava <prarit@redhat.com>
|
Prarit Bhargava <prarit@redhat.com>
|
||||||
Qais Yousef <qais.yousef@arm.com>
|
Qais Yousef <qais.yousef@arm.com>
|
||||||
|
@ -666,6 +676,7 @@ CONTRIBUTORS:
|
||||||
Randy Dunlap <randy.dunlap@oracle.com>
|
Randy Dunlap <randy.dunlap@oracle.com>
|
||||||
Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
|
Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
|
||||||
Rasmus Villemoes <rasmus.villemoes@prevas.dk>
|
Rasmus Villemoes <rasmus.villemoes@prevas.dk>
|
||||||
|
ratijas <me@ratijas.tk>
|
||||||
Raul Gutierrez Segales <rgs@itevenworks.net>
|
Raul Gutierrez Segales <rgs@itevenworks.net>
|
||||||
Ray Wang <wanglei1123@gmail.com>
|
Ray Wang <wanglei1123@gmail.com>
|
||||||
Rian Hunter <rian@alum.mit.edu>
|
Rian Hunter <rian@alum.mit.edu>
|
||||||
|
@ -696,6 +707,7 @@ CONTRIBUTORS:
|
||||||
Ron Sommeling <sommel@sci.kun.nl>
|
Ron Sommeling <sommel@sci.kun.nl>
|
||||||
Rosen Penev <rosenp@gmail.com>
|
Rosen Penev <rosenp@gmail.com>
|
||||||
Ross Biro <biro@yggdrasil.com>
|
Ross Biro <biro@yggdrasil.com>
|
||||||
|
Ross Burton <ross.burton@arm.com>
|
||||||
Rostislav Skudnov <rostislav@tuxera.com>
|
Rostislav Skudnov <rostislav@tuxera.com>
|
||||||
Roy Peled <the.roy.peled@gmail.com>
|
Roy Peled <the.roy.peled@gmail.com>
|
||||||
Ruediger Meier <ruediger.meier@ga-group.nl>
|
Ruediger Meier <ruediger.meier@ga-group.nl>
|
||||||
|
@ -706,6 +718,7 @@ CONTRIBUTORS:
|
||||||
Sami Kerola <kerolasa@iki.fi>
|
Sami Kerola <kerolasa@iki.fi>
|
||||||
Sami Liedes <sami.liedes@iki.fi>
|
Sami Liedes <sami.liedes@iki.fi>
|
||||||
Sami Loone <sami@loone.fi>
|
Sami Loone <sami@loone.fi>
|
||||||
|
Samir Benmendil <me@rmz.io>
|
||||||
Sam Morris <sam@robots.org.uk>
|
Sam Morris <sam@robots.org.uk>
|
||||||
Samuel Dionne-Riel <samuel@dionne-riel.com>
|
Samuel Dionne-Riel <samuel@dionne-riel.com>
|
||||||
Samuel Ortiz <sameo@linux.intel.com>
|
Samuel Ortiz <sameo@linux.intel.com>
|
||||||
|
@ -777,6 +790,7 @@ CONTRIBUTORS:
|
||||||
Terry Burton <tez@terryburton.co.uk>
|
Terry Burton <tez@terryburton.co.uk>
|
||||||
Thayne McCombs <thayne@lucidchart.com>
|
Thayne McCombs <thayne@lucidchart.com>
|
||||||
Theodore Ts'o <tytso@mit.edu>
|
Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Thiébaud Weksteen <tweek@google.com>
|
||||||
Thierry Reding <thierry.reding@avionic-design.de>
|
Thierry Reding <thierry.reding@avionic-design.de>
|
||||||
Thierry Vignaud <thierry.vignaud@gmail.com>
|
Thierry Vignaud <thierry.vignaud@gmail.com>
|
||||||
Thomas Abraham <tabraham@suse.com>
|
Thomas Abraham <tabraham@suse.com>
|
||||||
|
@ -794,6 +808,7 @@ CONTRIBUTORS:
|
||||||
Timo Juhani Lindfors <timo.lindfors@iki.fi>
|
Timo Juhani Lindfors <timo.lindfors@iki.fi>
|
||||||
Timo Warns <Warns@Pre-Sense.DE>
|
Timo Warns <Warns@Pre-Sense.DE>
|
||||||
Tim Waugh <twaugh@redhat.com>
|
Tim Waugh <twaugh@redhat.com>
|
||||||
|
Tj <hacker@iam.tj>
|
||||||
Tobias Klauser <tklauser@distanz.ch>
|
Tobias Klauser <tklauser@distanz.ch>
|
||||||
Tobias Stoeckmann <tobias@stoeckmann.org>
|
Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||||
Todd Lewis <utoddl@email.unc.edu>
|
Todd Lewis <utoddl@email.unc.edu>
|
||||||
|
@ -807,6 +822,7 @@ CONTRIBUTORS:
|
||||||
Tom Prince <tom.prince@ualberta.net>
|
Tom Prince <tom.prince@ualberta.net>
|
||||||
Toni Uhlig <matzeton@googlemail.com>
|
Toni Uhlig <matzeton@googlemail.com>
|
||||||
Tony Asleson <tasleson@redhat.com>
|
Tony Asleson <tasleson@redhat.com>
|
||||||
|
Topi Miettinen <toiwoton@gmail.com>
|
||||||
Torsten Hilbrich <torsten.hilbrich@secunet.com>
|
Torsten Hilbrich <torsten.hilbrich@secunet.com>
|
||||||
Toshi Kani <toshi.kani@hp.com>
|
Toshi Kani <toshi.kani@hp.com>
|
||||||
Trần Ngọc Quân <vnwildman@gmail.com>
|
Trần Ngọc Quân <vnwildman@gmail.com>
|
||||||
|
|
181
Documentation/releases/v2.37.1-ReleaseNotes
Normal file
181
Documentation/releases/v2.37.1-ReleaseNotes
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
util-linux 2.37.1 Release Notes
|
||||||
|
===============================
|
||||||
|
|
||||||
|
agetty:
|
||||||
|
- do not use atol() [Karel Zak]
|
||||||
|
blockdev:
|
||||||
|
- improve arguments parsing (remove atoi) [Karel Zak]
|
||||||
|
build-sys:
|
||||||
|
- Update configure.ac [Alex Xu]
|
||||||
|
- add generated man-pages to distribution tarball [Karel Zak]
|
||||||
|
- display cryptsetup status after ./configure [Luca Boccassi]
|
||||||
|
- fix {release-version} man pages [Karel Zak]
|
||||||
|
- install hardlink bash-completion [Karel Zak]
|
||||||
|
- make re-use of generated man-pages more robust [Karel Zak]
|
||||||
|
- use $LIBS rather than LDFLAGS [Karel Zak]
|
||||||
|
cfdisk:
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
- optimize mountpoint detection for PARTUUID [Karel Zak]
|
||||||
|
dmesg:
|
||||||
|
- fix indentation in man page [Platon Pronko]
|
||||||
|
- fix possible memory leak [coverity scan] [Karel Zak]
|
||||||
|
- remove condition [lgtm scan] [Karel Zak]
|
||||||
|
docs:
|
||||||
|
- add uclampset to AUTHORS file [Karel Zak]
|
||||||
|
- fix typo in v2.37-ReleaseNotes [Karel Zak]
|
||||||
|
- update AUTHORS file [Karel Zak]
|
||||||
|
eject:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
fdisk:
|
||||||
|
- do not print error message when partition reordering is not needed [Pali Rohár]
|
||||||
|
- move reorder diag messages to fdisk_reorder_partitions() [Pali Rohár]
|
||||||
|
findmnt:
|
||||||
|
- (verify) fix cache related memory leaks on --nocanonicalize [coverity scan] [Karel Zak]
|
||||||
|
- (verify) fix memory leak [asan] [Karel Zak]
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
fsck:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
fsck.cramfs:
|
||||||
|
- use open+fstat rather than stat+open [Karel Zak]
|
||||||
|
fstrim:
|
||||||
|
- clean return code on --quiet-unsupported [Karel Zak]
|
||||||
|
hardlink:
|
||||||
|
- remove pcre2posix.h support [Karel Zak]
|
||||||
|
hexdump:
|
||||||
|
- correctly display signed single byte integers [Samir Benmendil]
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
hwclock:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- close adjtime on write error [coverity scan] [Karel Zak]
|
||||||
|
- fix ul_path_scanf() use [Karel Zak]
|
||||||
|
include/c:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
- add drop_permissions(), consolidate UID/GID reset [Karel Zak]
|
||||||
|
include/path:
|
||||||
|
- add __format__attribute [Karel Zak]
|
||||||
|
include/strutils:
|
||||||
|
- cleanup strto..() functions [Karel Zak]
|
||||||
|
- consolidate string to number conversion [Karel Zak]
|
||||||
|
- fix __format__attribute [Karel Zak]
|
||||||
|
- fix heap-buffer-overflow in normalize_whitespace() [Karel Zak]
|
||||||
|
include/strv:
|
||||||
|
- fix format attributes [Karel Zak]
|
||||||
|
ipcs:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
kill:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
ldattach:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
lib/loopdev:
|
||||||
|
- perform retry on EAGAIN [Karel Zak]
|
||||||
|
lib/path:
|
||||||
|
- (test) fix ul_new_path() use [Karel Zak]
|
||||||
|
- fix possible leak when use ul_path_read_string() [coverity scan] [Karel Zak]
|
||||||
|
- improve ul_path_readlink() to be more robust [Karel Zak]
|
||||||
|
libblkid:
|
||||||
|
- Add hyphens to UUID string representation in Stratis superblock parsing [John Baublitz]
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- vfat Fix reading FAT16 boot label and serial id [Pali Rohár]
|
||||||
|
- vfat Fix reading FAT32 boot label [Pali Rohár]
|
||||||
|
libfdisk:
|
||||||
|
- add and fix __format__ attributes [Karel Zak]
|
||||||
|
libmount:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
libsmartcols:
|
||||||
|
- fix bare array on JSON output [Karel Zak]
|
||||||
|
libuuid:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
logger:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
login:
|
||||||
|
- add callback for close_range() [Karel Zak]
|
||||||
|
- fix close_range() use [Karel Zak]
|
||||||
|
- remove obsolete and confusing comment [Karel Zak]
|
||||||
|
lsblk:
|
||||||
|
- fix formatting in -e option [ratijas]
|
||||||
|
- normalize space in SERIAL and MODEL [Karel Zak]
|
||||||
|
- use ID_MODEL_ENC is possible [Karel Zak]
|
||||||
|
lscpu:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
- don't use DMI if executed with --sysroot [Karel Zak]
|
||||||
|
- fix build on powerpc [Georgy Yakovlev]
|
||||||
|
lslocks:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
lslogins:
|
||||||
|
- ask for supplementary groups only once [asan] [Karel Zak]
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
- consolidate and optimize utmp files use [Karel Zak]
|
||||||
|
- fix memory leak [asan] [Karel Zak]
|
||||||
|
- use sd_journal_get_data() in proper way [Karel Zak]
|
||||||
|
lsmem:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
meson:
|
||||||
|
- fix crypt_activate_by_signed_key detection [Luca Boccassi]
|
||||||
|
- fix dlopen support for cryptsetup [Luca Boccassi]
|
||||||
|
misc:
|
||||||
|
- improve string to number conversions [Karel Zak]
|
||||||
|
mkfs.cramfs:
|
||||||
|
- add comment to explain readlink() use [Karel Zak]
|
||||||
|
mkswap:
|
||||||
|
- fix holes detection (infinite loop and/or stack-buffer-underflow) [Karel Zak]
|
||||||
|
more:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
- fix null-pointer dereference [Karel Zak]
|
||||||
|
- fix setuid/setgid order [Karel Zak]
|
||||||
|
mount:
|
||||||
|
- fix roothash signature extension in manpage [Luca Boccassi]
|
||||||
|
- man-page; add all overlayfs options [Tj]
|
||||||
|
- mount.8 fix overlayfs nfs_export= indention [Karel Zak]
|
||||||
|
mount.8.adoc:
|
||||||
|
- Remove context options exclusion [Thiébaud Weksteen]
|
||||||
|
- document SELinux use of nosuid mount flag [Topi Miettinen]
|
||||||
|
namei:
|
||||||
|
- simplify code [Karel Zak]
|
||||||
|
newgrp:
|
||||||
|
- fix memory leak [coverity scan] [Karel Zak]
|
||||||
|
pg:
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
po:
|
||||||
|
- merge changes [Karel Zak]
|
||||||
|
- update es.po (from translationproject.org) [Antonio Ceballos Roa]
|
||||||
|
- update pt_BR.po (from translationproject.org) [Rafael Fontenelle]
|
||||||
|
- update sr.po (from translationproject.org) [Мирослав Николић]
|
||||||
|
readprofile:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
||||||
|
rename:
|
||||||
|
- use readlink() in more robust way [Karel Zak]
|
||||||
|
rfkill:
|
||||||
|
- Set scols table name to make the json output valid [Nicolai Dagestad]
|
||||||
|
script:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
sulogin:
|
||||||
|
- add missing ifdefs [Karel Zak]
|
||||||
|
- use explicit_bzero() for buffer with password [Karel Zak]
|
||||||
|
swapon:
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
test/eject:
|
||||||
|
- guard asan LD_PRELOAD with use-system-commands check [Ross Burton]
|
||||||
|
tests:
|
||||||
|
- check correct log file for errors in blkdiscard test [Ross Burton]
|
||||||
|
- don't hardcode /bin/kill in the kill tests [Ross Burton]
|
||||||
|
- fix lsns test on kernels without USER namespaces [Anatoly Pugachev]
|
||||||
|
- mark ul/ul as a known failure [Ross Burton]
|
||||||
|
- skip if scsi_debug model file is not accessible [Karel Zak]
|
||||||
|
- update sfdisk reorder test [Karel Zak]
|
||||||
|
tools:
|
||||||
|
- report and use LDFLAGS in tools/config-gen [Karel Zak]
|
||||||
|
uclampset:
|
||||||
|
- Fix left over optind++ [Qais Yousef]
|
||||||
|
utmpdump:
|
||||||
|
- do not use atoi() [Karel Zak]
|
||||||
|
verity:
|
||||||
|
- fix verity.roothashsig only working as last parameter [Luca Boccassi]
|
||||||
|
wall:
|
||||||
|
- add __format__ attribute [Karel Zak]
|
||||||
|
wipefs:
|
||||||
|
- check errno after strto..() [Karel Zak]
|
41
Documentation/releases/v2.37.2-ReleaseNotes
Normal file
41
Documentation/releases/v2.37.2-ReleaseNotes
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
util-linux 2.37.2 Release Notes
|
||||||
|
===============================
|
||||||
|
|
||||||
|
blockdev:
|
||||||
|
- allow for larger values for start sector [Thomas Abraham]
|
||||||
|
- use snprintf() rather than sprintf() [Karel Zak]
|
||||||
|
docs:
|
||||||
|
- fix info about LIBSMARTCOLS_DEBUG_PADDING [Karel Zak]
|
||||||
|
- update AUTHORS file [Karel Zak]
|
||||||
|
lib/pwdutils:
|
||||||
|
- don't use getlogin(3). [Érico Nogueira]
|
||||||
|
- use assert to check correct usage. [Érico Nogueira]
|
||||||
|
libfdisk:
|
||||||
|
- (dos) don't ignore MBR+FAT use-case [Karel Zak]
|
||||||
|
- (dos) support partition and MBR overlap [Karel Zak]
|
||||||
|
libmount:
|
||||||
|
- don't use setgroups at all() [Karel Zak]
|
||||||
|
- fix setgroups() use [Karel Zak]
|
||||||
|
logger:
|
||||||
|
- use xgetlogin from pwdutils. [Érico Nogueira]
|
||||||
|
losetup:
|
||||||
|
- use LOOP_CONFIGURE in a more robust way [Karel Zak]
|
||||||
|
lscpu:
|
||||||
|
- Add Phytium FT-2000+ & S2500 support [panchenbo]
|
||||||
|
- Add Phytium aarch64 cpupart [panchenbo]
|
||||||
|
- fix NULL dereference [Karel Zak]
|
||||||
|
- fix compilation against librtas [Karel Zak]
|
||||||
|
mount:
|
||||||
|
- mount.8 don't consider additional mounts as experimental [Karel Zak]
|
||||||
|
po:
|
||||||
|
- add sk.po (from translationproject.org) [Jose Riha]
|
||||||
|
- merge changes [Karel Zak]
|
||||||
|
- update pl.po (from translationproject.org) [Jakub Bogusz]
|
||||||
|
prlimit:
|
||||||
|
- fix compiler warning [-Wmaybe-uninitialized] [Karel Zak]
|
||||||
|
sulogin:
|
||||||
|
- fix getpasswd() [Karel Zak]
|
||||||
|
sys-utils/ipcutils:
|
||||||
|
- be careful when call calloc() for uint64 nmembs [Karel Zak]
|
||||||
|
wall:
|
||||||
|
- use xgetlogin. [Érico Nogueira]
|
13
Documentation/releases/v2.37.3-ReleaseNotes
Normal file
13
Documentation/releases/v2.37.3-ReleaseNotes
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
util-linux 2.37.3 Release Notes
|
||||||
|
===============================
|
||||||
|
|
||||||
|
This release fixes two security mount(8) and umount(8) issues:
|
||||||
|
|
||||||
|
CVE-2021-3996
|
||||||
|
Improper UID check in libmount allows an unprivileged user to unmount FUSE
|
||||||
|
filesystems of users with similar UID.
|
||||||
|
|
||||||
|
CVE-2021-3995
|
||||||
|
This issue is related to parsing the /proc/self/mountinfo file allows an
|
||||||
|
unprivileged user to unmount other user's filesystems that are either
|
||||||
|
world-writable themselves or mounted in a world-writable directory.
|
15
Documentation/releases/v2.37.4-ReleaseNotes
Normal file
15
Documentation/releases/v2.37.4-ReleaseNotes
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
util-linux 2.37.4 Release Notes
|
||||||
|
===============================
|
||||||
|
|
||||||
|
This release fixes security issue in chsh(1) and chfn(8):
|
||||||
|
|
||||||
|
CVE-2022-0563
|
||||||
|
|
||||||
|
The readline library uses INPUTRC= environment variable to get a path
|
||||||
|
to the library config file. When the library cannot parse the
|
||||||
|
specified file, it prints an error message containing data from the
|
||||||
|
file.
|
||||||
|
|
||||||
|
Unfortunately, the library does not use secure_getenv() (or a similar
|
||||||
|
concept), or sanitize the config file path to avoid vulnerabilities that
|
||||||
|
could occur if set-user-ID or set-group-ID programs.
|
29
Makefile.am
29
Makefile.am
|
@ -195,16 +195,16 @@ $(PATHFILES): Makefile
|
||||||
@ mv $@.tmp $@
|
@ mv $@.tmp $@
|
||||||
|
|
||||||
|
|
||||||
CLEANFILES += $(MANPAGES) $(MANLINKS)
|
|
||||||
EXTRA_DIST += $(ADOCFILES_COMMON)
|
|
||||||
|
|
||||||
if ENABLE_ASCIIDOC
|
if ENABLE_ASCIIDOC
|
||||||
|
EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
|
||||||
man_MANS += $(MANPAGES) $(MANLINKS)
|
man_MANS += $(MANPAGES) $(MANLINKS)
|
||||||
|
|
||||||
$(MANPAGES): $(ADOCFILES_COMMON) Makefile
|
$(MANPAGES): $(ADOCFILES_COMMON)
|
||||||
|
|
||||||
asciidoc_man_cmd = $(ASCIIDOCTOR) \
|
asciidoc_man_cmd = $(ASCIIDOCTOR) \
|
||||||
-b manpage \
|
-b manpage \
|
||||||
|
-a 'release-version=$(VERSION)' \
|
||||||
|
-a 'package-docdir=$(docdir)' \
|
||||||
-a 'VERSION=$(VERSION)' \
|
-a 'VERSION=$(VERSION)' \
|
||||||
-a 'ADJTIME_PATH=$(ADJTIME_PATH)'
|
-a 'ADJTIME_PATH=$(ADJTIME_PATH)'
|
||||||
|
|
||||||
|
@ -218,14 +218,33 @@ SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
|
||||||
$(MANLINKS): $(MANPAGES)
|
$(MANLINKS): $(MANPAGES)
|
||||||
gen-man: $(man_MANS)
|
gen-man: $(man_MANS)
|
||||||
|
|
||||||
|
# Standard "make" follows BUILD_* macros from ./configure, and in this case, it
|
||||||
|
# ignores man pages for disabled tools, but for distribution tarball, we need
|
||||||
|
# to generate all man-pages (to avoid dependence on asciidoc). [kzak Jan-2022]
|
||||||
|
gen-man-dist:
|
||||||
|
@list=`find -name *.adoc -not -path "*/man-common/*" -not -path "*/po-man/*" | sed -e 's/\.adoc//g'`; \
|
||||||
|
missing=`for p in $$list; do test -f $$p || echo $$p; done`; \
|
||||||
|
if test -n "$$missing"; then \
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) $$missing; \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
|
||||||
|
# !ENABLE_ASCIIDOC
|
||||||
else
|
else
|
||||||
|
|
||||||
|
if HAVE_MANPAGES
|
||||||
|
EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
|
||||||
|
man_MANS += $(MANPAGES) $(MANLINKS)
|
||||||
|
endif
|
||||||
|
|
||||||
gen-man:
|
gen-man:
|
||||||
|
gen-man-dist:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
# Arrange so that .tarball-version appears only in the distribution
|
# Arrange so that .tarball-version appears only in the distribution
|
||||||
# tarball, and never in a checked-out repository.
|
# tarball, and never in a checked-out repository.
|
||||||
dist-hook:
|
dist-hook: gen-man-dist
|
||||||
echo $(VERSION) > $(distdir)/.tarball-version
|
echo $(VERSION) > $(distdir)/.tarball-version
|
||||||
# Set ChangeLog tag reference.
|
# Set ChangeLog tag reference.
|
||||||
sed -i "s!log!log?h=v$(VERSION)!" $(distdir)/ChangeLog
|
sed -i "s!log!log?h=v$(VERSION)!" $(distdir)/ChangeLog
|
||||||
|
|
16
NEWS
16
NEWS
|
@ -1,3 +1,19 @@
|
||||||
|
util-linux 2.37.4: Feb 14 2022
|
||||||
|
* see Documentation/releases/v2.37.4-ReleaseNotes or the complete changelog at
|
||||||
|
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.4-ChangeLog
|
||||||
|
|
||||||
|
util-linux 2.37.3: Jan 25 2022
|
||||||
|
* see Documentation/releases/v2.37.3-ReleaseNotes or the complete changelog at
|
||||||
|
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.3-ChangeLog
|
||||||
|
|
||||||
|
util-linux 2.37.2: Aug 16 2021
|
||||||
|
* see Documentation/releases/v2.37.2-ReleaseNotes or the complete changelog at
|
||||||
|
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.2-ChangeLog
|
||||||
|
|
||||||
|
util-linux 2.37.1: Jul 22 2021
|
||||||
|
* see Documentation/releases/v2.37.1-ReleaseNotes or the complete changelog at
|
||||||
|
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.1-ChangeLog
|
||||||
|
|
||||||
util-linux 2.37: Jun 1 2021
|
util-linux 2.37: Jun 1 2021
|
||||||
* see Documentation/releases/v2.37-ReleaseNotes or the complete changelog at
|
* see Documentation/releases/v2.37-ReleaseNotes or the complete changelog at
|
||||||
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37-ChangeLog
|
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37-ChangeLog
|
||||||
|
|
|
@ -329,5 +329,8 @@ endif
|
||||||
if BUILD_UL
|
if BUILD_UL
|
||||||
dist_bashcompletion_DATA += bash-completion/ul
|
dist_bashcompletion_DATA += bash-completion/ul
|
||||||
endif
|
endif
|
||||||
|
if BUILD_HARDLINK
|
||||||
|
dist_bashcompletion_DATA += bash-completion/hardlink
|
||||||
|
endif
|
||||||
|
|
||||||
endif # BUILD_BASH_COMPLETION
|
endif # BUILD_BASH_COMPLETION
|
||||||
|
|
28
configure.ac
28
configure.ac
|
@ -29,7 +29,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{
|
||||||
|
|
||||||
dnl libblkid version
|
dnl libblkid version
|
||||||
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
|
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
|
||||||
LIBBLKID_DATE="01-Jun-2021"
|
LIBBLKID_DATE="14-Feb-2022"
|
||||||
LIBBLKID_LT_MAJOR=1
|
LIBBLKID_LT_MAJOR=1
|
||||||
LIBBLKID_LT_MINOR=1
|
LIBBLKID_LT_MINOR=1
|
||||||
LIBBLKID_LT_MICRO=0
|
LIBBLKID_LT_MICRO=0
|
||||||
|
@ -742,6 +742,13 @@ UL_BUILD_INIT([asciidoc])
|
||||||
UL_REQUIRES_PROGRAM([asciidoc], [ASCIIDOCTOR], [asciidoctor], [man pages])
|
UL_REQUIRES_PROGRAM([asciidoc], [ASCIIDOCTOR], [asciidoctor], [man pages])
|
||||||
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$build_asciidoc" = xyes])
|
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$build_asciidoc" = xyes])
|
||||||
|
|
||||||
|
have_manpages=no
|
||||||
|
AS_IF([test -f "$srcdir/sys-utils/mount.8"], [
|
||||||
|
AC_MSG_NOTICE([re-use already generated man-pages.])
|
||||||
|
have_manpages=yes]
|
||||||
|
)
|
||||||
|
AM_CONDITIONAL([HAVE_MANPAGES], [test "x$have_manpages" = xyes])
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([poman],
|
AC_ARG_ENABLE([poman],
|
||||||
AS_HELP_STRING([--enable-poman], [generate translated man pages]),
|
AS_HELP_STRING([--enable-poman], [generate translated man pages]),
|
||||||
|
@ -836,8 +843,8 @@ char *c = crypt("abc","pw");
|
||||||
have_libcrypt=no
|
have_libcrypt=no
|
||||||
have_crypt=yes
|
have_crypt=yes
|
||||||
],[
|
],[
|
||||||
LIBS="$LIBS -lcrypt"
|
UL_SET_LIBS([-lcrypt])
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||||
#ifdef HAVE_CRYPT_H
|
#ifdef HAVE_CRYPT_H
|
||||||
#include <crypt.h>
|
#include <crypt.h>
|
||||||
#else
|
#else
|
||||||
|
@ -847,12 +854,12 @@ char *c = crypt("abc","pw");
|
||||||
]], [[
|
]], [[
|
||||||
char *c = crypt("abc","pw");
|
char *c = crypt("abc","pw");
|
||||||
]])],[
|
]])],[
|
||||||
AC_DEFINE([HAVE_LIBCRYPT], [1], [Do we need -lcrypt?])
|
|
||||||
have_libcrypt=yes
|
have_libcrypt=yes
|
||||||
have_crypt=yes
|
have_crypt=yes
|
||||||
],[
|
],[
|
||||||
AC_MSG_WARN([crypt() is not available])
|
AC_MSG_WARN([crypt() is not available])
|
||||||
])
|
])
|
||||||
|
UL_RESTORE_LIBS
|
||||||
])
|
])
|
||||||
AM_CONDITIONAL([HAVE_LIBCRYPT], [test "x$have_libcrypt" = xyes])
|
AM_CONDITIONAL([HAVE_LIBCRYPT], [test "x$have_libcrypt" = xyes])
|
||||||
|
|
||||||
|
@ -874,10 +881,10 @@ AS_IF([test "x$with_selinux" = xno], [
|
||||||
UL_PKG_STATIC([SELINUX_LIBS_STATIC], [libselinux])
|
UL_PKG_STATIC([SELINUX_LIBS_STATIC], [libselinux])
|
||||||
AM_CONDITIONAL([HAVE_SELINUX], [true])
|
AM_CONDITIONAL([HAVE_SELINUX], [true])
|
||||||
|
|
||||||
UL_SET_FLAGS([], [], [$SELINUX_LIBS])
|
UL_SET_LIBS([$SELINUX_LIBS])
|
||||||
# This function is missing in old libselinux 1.xx versions
|
# This function is missing in old libselinux 1.xx versions
|
||||||
AC_CHECK_FUNCS([security_get_initial_context])
|
AC_CHECK_FUNCS([security_get_initial_context])
|
||||||
UL_RESTORE_FLAGS
|
UL_RESTORE_LIBS
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
AC_SUBST([SELINUX_LIBS])
|
AC_SUBST([SELINUX_LIBS])
|
||||||
|
@ -1452,14 +1459,6 @@ UL_REQUIRES_HAVE([setpriv], [linux_capability_h], [linux/capability.h header fil
|
||||||
UL_REQUIRES_HAVE([setpriv], [cap_ng], [libcap-ng library])
|
UL_REQUIRES_HAVE([setpriv], [cap_ng], [libcap-ng library])
|
||||||
AM_CONDITIONAL([BUILD_SETPRIV], [test "x$build_setpriv" = xyes])
|
AM_CONDITIONAL([BUILD_SETPRIV], [test "x$build_setpriv" = xyes])
|
||||||
|
|
||||||
PKG_CHECK_MODULES([PCRE2_POSIX], [libpcre2-posix],
|
|
||||||
[have_pcre2_posix=yes],
|
|
||||||
[have_pcre2_posix=no])
|
|
||||||
AS_IF([test "x$have_pcre2_posix" = xyes ], [
|
|
||||||
AC_DEFINE([HAVE_PCRE2_POSIX], [1], [Define if libpcre2-posix is available])
|
|
||||||
])
|
|
||||||
AM_CONDITIONAL([HAVE_PCRE2_POSIX], [test "x$have_pcre2_posix" = xyes])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([hardlink],
|
AC_ARG_ENABLE([hardlink],
|
||||||
AS_HELP_STRING([--disable-hardlink], [do not build hardlink]),
|
AS_HELP_STRING([--disable-hardlink], [do not build hardlink]),
|
||||||
[], [UL_DEFAULT_ENABLE([hardlink], [check])]
|
[], [UL_DEFAULT_ENABLE([hardlink], [check])]
|
||||||
|
@ -2681,6 +2680,7 @@ AC_MSG_RESULT([
|
||||||
libeconf support: ${have_econf}
|
libeconf support: ${have_econf}
|
||||||
Btrfs support: ${have_btrfs}
|
Btrfs support: ${have_btrfs}
|
||||||
Wide-char support: ${build_widechar}
|
Wide-char support: ${build_widechar}
|
||||||
|
libcryptsetup support: ${have_cryptsetup}
|
||||||
|
|
||||||
Manual pages: ${build_asciidoc}
|
Manual pages: ${build_asciidoc}
|
||||||
Manual pages translated: ${build_poman}
|
Manual pages translated: ${build_poman}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "blkdev.h"
|
#include "blkdev.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
#include "closestream.h"
|
#include "closestream.h"
|
||||||
|
#include "strutils.h"
|
||||||
#include "sysfs.h"
|
#include "sysfs.h"
|
||||||
|
|
||||||
struct bdc {
|
struct bdc {
|
||||||
|
@ -351,7 +352,7 @@ static void do_commands(int fd, char **argv, int d)
|
||||||
bdcms[j].name);
|
bdcms[j].name);
|
||||||
errtryhelp(EXIT_FAILURE);
|
errtryhelp(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
iarg = atoi(argv[++i]);
|
iarg = strtos32_or_err(argv[++i], _("failed to parse command argument"));
|
||||||
} else
|
} else
|
||||||
iarg = bdcms[j].argval;
|
iarg = bdcms[j].argval;
|
||||||
|
|
||||||
|
@ -441,7 +442,7 @@ static void report_all_devices(void)
|
||||||
&ma, &mi, &sz, ptname) != 4)
|
&ma, &mi, &sz, ptname) != 4)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprintf(device, "/dev/%s", ptname);
|
snprintf(device, sizeof(device), "/dev/%s", ptname);
|
||||||
report_device(device, 1);
|
report_device(device, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +456,7 @@ static void report_device(char *device, int quiet)
|
||||||
long ra;
|
long ra;
|
||||||
unsigned long long bytes;
|
unsigned long long bytes;
|
||||||
uint64_t start = 0;
|
uint64_t start = 0;
|
||||||
char start_str[11] = { "\0" };
|
char start_str[16] = { "\0" };
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
fd = open(device, O_RDONLY | O_NONBLOCK);
|
fd = open(device, O_RDONLY | O_NONBLOCK);
|
||||||
|
@ -477,13 +478,13 @@ static void report_device(char *device, int quiet)
|
||||||
disk != st.st_rdev) {
|
disk != st.st_rdev) {
|
||||||
|
|
||||||
if (ul_path_read_u64(pc, &start, "start") != 0)
|
if (ul_path_read_u64(pc, &start, "start") != 0)
|
||||||
/* TRANSLATORS: Start sector not available. Max. 10 letters. */
|
/* TRANSLATORS: Start sector not available. Max. 15 letters. */
|
||||||
sprintf(start_str, "%10s", _("N/A"));
|
snprintf(start_str, sizeof(start_str), "%15s", _("N/A"));
|
||||||
}
|
}
|
||||||
ul_unref_path(pc);
|
ul_unref_path(pc);
|
||||||
}
|
}
|
||||||
if (!*start_str)
|
if (!*start_str)
|
||||||
sprintf(start_str, "%10ju", start);
|
snprintf(start_str, sizeof(start_str), "%15ju", start);
|
||||||
|
|
||||||
if (ioctl(fd, BLKROGET, &ro) == 0 &&
|
if (ioctl(fd, BLKROGET, &ro) == 0 &&
|
||||||
ioctl(fd, BLKRAGET, &ra) == 0 &&
|
ioctl(fd, BLKRAGET, &ra) == 0 &&
|
||||||
|
|
|
@ -141,9 +141,14 @@ static void menu_refresh_size(struct cfdisk *cf);
|
||||||
|
|
||||||
static int ui_end(void);
|
static int ui_end(void);
|
||||||
static int ui_refresh(struct cfdisk *cf);
|
static int ui_refresh(struct cfdisk *cf);
|
||||||
static void ui_warnx(const char *fmt, ...);
|
|
||||||
static void ui_warn(const char *fmt, ...);
|
static void ui_warnx(const char *fmt, ...)
|
||||||
static void ui_info(const char *fmt, ...);
|
__attribute__((__format__ (__printf__, 1, 2)));
|
||||||
|
static void ui_warn(const char *fmt, ...)
|
||||||
|
__attribute__((__format__ (__printf__, 1, 2)));
|
||||||
|
static void ui_info(const char *fmt, ...)
|
||||||
|
__attribute__((__format__ (__printf__, 1, 2)));
|
||||||
|
|
||||||
static void ui_draw_menu(struct cfdisk *cf);
|
static void ui_draw_menu(struct cfdisk *cf);
|
||||||
static int ui_menu_move(struct cfdisk *cf, int key);
|
static int ui_menu_move(struct cfdisk *cf, int key);
|
||||||
static void ui_menu_resize(struct cfdisk *cf);
|
static void ui_menu_resize(struct cfdisk *cf);
|
||||||
|
@ -630,13 +635,13 @@ static int ask_callback(struct fdisk_context *cxt __attribute__((__unused__)),
|
||||||
|
|
||||||
switch(fdisk_ask_get_type(ask)) {
|
switch(fdisk_ask_get_type(ask)) {
|
||||||
case FDISK_ASKTYPE_INFO:
|
case FDISK_ASKTYPE_INFO:
|
||||||
ui_info(fdisk_ask_print_get_mesg(ask));
|
ui_info("%s", fdisk_ask_print_get_mesg(ask));
|
||||||
break;
|
break;
|
||||||
case FDISK_ASKTYPE_WARNX:
|
case FDISK_ASKTYPE_WARNX:
|
||||||
ui_warnx(fdisk_ask_print_get_mesg(ask));
|
ui_warnx("%s", fdisk_ask_print_get_mesg(ask));
|
||||||
break;
|
break;
|
||||||
case FDISK_ASKTYPE_WARN:
|
case FDISK_ASKTYPE_WARN:
|
||||||
ui_warn(fdisk_ask_print_get_mesg(ask));
|
ui_warn("%s", fdisk_ask_print_get_mesg(ask));
|
||||||
break;
|
break;
|
||||||
case FDISK_ASKTYPE_MENU:
|
case FDISK_ASKTYPE_MENU:
|
||||||
ask_menu(ask, (struct cfdisk *) data);
|
ask_menu(ask, (struct cfdisk *) data);
|
||||||
|
@ -668,7 +673,8 @@ static int ui_end(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap)
|
static void __attribute__((__format__ (__printf__, 3, 0)))
|
||||||
|
ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
size_t width;
|
size_t width;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
@ -698,7 +704,8 @@ static void ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_center(size_t line, const char *fmt, ...)
|
static void __attribute__((__format__ (__printf__, 2, 3)))
|
||||||
|
ui_center(size_t line, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -706,7 +713,8 @@ static void ui_center(size_t line, const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_warnx(const char *fmt, ...)
|
static void __attribute__((__format__ (__printf__, 1, 2)))
|
||||||
|
ui_warnx(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -721,7 +729,8 @@ static void ui_warnx(const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_warn(const char *fmt, ...)
|
static void __attribute__((__format__ (__printf__, 1, 2)))
|
||||||
|
ui_warn(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char *fmt_m;
|
char *fmt_m;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -747,7 +756,9 @@ static void ui_clean_warn(void)
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __attribute__((__noreturn__)) ui_err(int rc, const char *fmt, ...)
|
static int __attribute__((__noreturn__))
|
||||||
|
__attribute__((__format__ (__printf__, 2, 3)))
|
||||||
|
ui_err(int rc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
ui_end();
|
ui_end();
|
||||||
|
@ -761,7 +772,9 @@ static int __attribute__((__noreturn__)) ui_err(int rc, const char *fmt, ...)
|
||||||
exit(rc);
|
exit(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __attribute__((__noreturn__)) ui_errx(int rc, const char *fmt, ...)
|
static int __attribute__((__noreturn__))
|
||||||
|
__attribute__((__format__ (__printf__, 2, 3)))
|
||||||
|
ui_errx(int rc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
ui_end();
|
ui_end();
|
||||||
|
@ -775,7 +788,8 @@ static int __attribute__((__noreturn__)) ui_errx(int rc, const char *fmt, ...)
|
||||||
exit(rc);
|
exit(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_info(const char *fmt, ...)
|
static void __attribute__((__format__ (__printf__, 1, 2)))
|
||||||
|
ui_info(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -796,7 +810,8 @@ static void ui_clean_info(void)
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_hint(const char *fmt, ...)
|
static void __attribute__((__format__ (__printf__, 1, 2)))
|
||||||
|
ui_hint(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -1130,7 +1145,7 @@ static void ui_draw_menuitem(struct cfdisk *cf,
|
||||||
if (cf->menu->idx == idx) {
|
if (cf->menu->idx == idx) {
|
||||||
standend();
|
standend();
|
||||||
if (d->desc)
|
if (d->desc)
|
||||||
ui_hint(_(d->desc));
|
ui_hint("%s", _(d->desc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,6 +1322,34 @@ static char *get_mountpoint(struct cfdisk *cf, const char *tagname, const char *
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBMOUNT */
|
#endif /* HAVE_LIBMOUNT */
|
||||||
|
|
||||||
|
static inline int iszero(const char *str)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
for (p = str; p && *p == '0'; p++);
|
||||||
|
|
||||||
|
return !p || *p == '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static int has_uuid(struct fdisk_table *tb, const char *uuid)
|
||||||
|
{
|
||||||
|
struct fdisk_partition *pa;
|
||||||
|
struct fdisk_iter *itr;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (!tb || !uuid || fdisk_table_is_empty(tb))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
itr = fdisk_new_iter(FDISK_ITER_FORWARD);
|
||||||
|
while (rc == 0 && fdisk_table_next_partition(tb, itr, &pa) == 0) {
|
||||||
|
const char *x = fdisk_partition_get_uuid(pa);
|
||||||
|
if (x)
|
||||||
|
rc = strcmp(x, uuid) == 0;
|
||||||
|
}
|
||||||
|
fdisk_free_iter(itr);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static void extra_prepare_data(struct cfdisk *cf)
|
static void extra_prepare_data(struct cfdisk *cf)
|
||||||
{
|
{
|
||||||
struct fdisk_partition *pa = get_current_partition(cf);
|
struct fdisk_partition *pa = get_current_partition(cf);
|
||||||
|
@ -1326,7 +1369,14 @@ static void extra_prepare_data(struct cfdisk *cf)
|
||||||
|
|
||||||
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_UUID, &data) && data) {
|
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_UUID, &data) && data) {
|
||||||
extra_insert_pair(l, _("Partition UUID:"), data);
|
extra_insert_pair(l, _("Partition UUID:"), data);
|
||||||
if (!mountpoint)
|
|
||||||
|
/* Search for mountpoint by PARTUUID= means that we need to
|
||||||
|
* check fstab and convert PARTUUID to the device name. This is
|
||||||
|
* unnecessary and overkill for newly created partitions. Let's
|
||||||
|
* check if the UUID already exist in the old layout, otherwise
|
||||||
|
* ignore it.
|
||||||
|
*/
|
||||||
|
if (!mountpoint && has_uuid(cf->original_layout, data))
|
||||||
mountpoint = get_mountpoint(cf, "PARTUUID", data);
|
mountpoint = get_mountpoint(cf, "PARTUUID", data);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
@ -1350,19 +1400,19 @@ static void extra_prepare_data(struct cfdisk *cf)
|
||||||
|
|
||||||
/* for numeric data, only show non-zero rows */
|
/* for numeric data, only show non-zero rows */
|
||||||
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_BSIZE, &data) && data) {
|
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_BSIZE, &data) && data) {
|
||||||
if (atoi(data))
|
if (!iszero(data))
|
||||||
extra_insert_pair(l, "BSIZE:", data);
|
extra_insert_pair(l, "BSIZE:", data);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_CPG, &data) && data) {
|
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_CPG, &data) && data) {
|
||||||
if (atoi(data))
|
if (!iszero(data))
|
||||||
extra_insert_pair(l, "CPG:", data);
|
extra_insert_pair(l, "CPG:", data);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_FSIZE, &data) && data) {
|
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_FSIZE, &data) && data) {
|
||||||
if (atoi(data))
|
if (!iszero(data))
|
||||||
extra_insert_pair(l, "FSIZE:", data);
|
extra_insert_pair(l, "FSIZE:", data);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
@ -1778,7 +1828,7 @@ static ssize_t ui_get_string(const char *prompt,
|
||||||
mbs_edit_goto(edit, MBS_EDIT_END);
|
mbs_edit_goto(edit, MBS_EDIT_END);
|
||||||
|
|
||||||
if (hint)
|
if (hint)
|
||||||
ui_hint(hint);
|
ui_hint("%s", hint);
|
||||||
else
|
else
|
||||||
ui_clean_hint();
|
ui_clean_hint();
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,10 @@ void list_disk_geometry(struct fdisk_context *cxt)
|
||||||
fdisk_info(cxt, _("Disk model: %s"), fdisk_get_devmodel(cxt));
|
fdisk_info(cxt, _("Disk model: %s"), fdisk_get_devmodel(cxt));
|
||||||
|
|
||||||
if (lb && (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt)))
|
if (lb && (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt)))
|
||||||
fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
|
fdisk_info(cxt, _("Geometry: %d heads, %ju sectors/track, %ju cylinders"),
|
||||||
fdisk_get_geom_heads(cxt),
|
fdisk_get_geom_heads(cxt),
|
||||||
fdisk_get_geom_sectors(cxt),
|
(uintmax_t) fdisk_get_geom_sectors(cxt),
|
||||||
fdisk_get_geom_cylinders(cxt));
|
(uintmax_t) fdisk_get_geom_cylinders(cxt));
|
||||||
|
|
||||||
fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"),
|
fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"),
|
||||||
fdisk_get_unit(cxt, FDISK_PLURAL),
|
fdisk_get_unit(cxt, FDISK_PLURAL),
|
||||||
|
@ -182,7 +182,7 @@ void list_disklabel(struct fdisk_context *cxt)
|
||||||
|
|
||||||
/* print */
|
/* print */
|
||||||
if (!scols_table_is_empty(out)) {
|
if (!scols_table_is_empty(out)) {
|
||||||
fdisk_info(cxt, ""); /* just line break */
|
fdisk_info(cxt, "%s", ""); /* just line break */
|
||||||
scols_print_table(out);
|
scols_print_table(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,14 +193,14 @@ void list_disklabel(struct fdisk_context *cxt)
|
||||||
continue;
|
continue;
|
||||||
if (!fdisk_lba_is_phy_aligned(cxt, fdisk_partition_get_start(pa))) {
|
if (!fdisk_lba_is_phy_aligned(cxt, fdisk_partition_get_start(pa))) {
|
||||||
if (!post)
|
if (!post)
|
||||||
fdisk_info(cxt, ""); /* line break */
|
fdisk_info(cxt, "%s", ""); /* line break */
|
||||||
fdisk_warnx(cxt, _("Partition %zu does not start on physical sector boundary."),
|
fdisk_warnx(cxt, _("Partition %zu does not start on physical sector boundary."),
|
||||||
fdisk_partition_get_partno(pa) + 1);
|
fdisk_partition_get_partno(pa) + 1);
|
||||||
post++;
|
post++;
|
||||||
}
|
}
|
||||||
if (fdisk_partition_has_wipe(cxt, pa)) {
|
if (fdisk_partition_has_wipe(cxt, pa)) {
|
||||||
if (!post)
|
if (!post)
|
||||||
fdisk_info(cxt, ""); /* line break */
|
fdisk_info(cxt, "%s", ""); /* line break */
|
||||||
|
|
||||||
fdisk_info(cxt, _("Filesystem/RAID signature on partition %zu will be wiped."),
|
fdisk_info(cxt, _("Filesystem/RAID signature on partition %zu will be wiped."),
|
||||||
fdisk_partition_get_partno(pa) + 1);
|
fdisk_partition_get_partno(pa) + 1);
|
||||||
|
@ -210,7 +210,7 @@ void list_disklabel(struct fdisk_context *cxt)
|
||||||
|
|
||||||
if (fdisk_table_wrong_order(tb)) {
|
if (fdisk_table_wrong_order(tb)) {
|
||||||
if (!post)
|
if (!post)
|
||||||
fdisk_info(cxt, ""); /* line break */
|
fdisk_info(cxt, "%s", ""); /* line break */
|
||||||
fdisk_info(cxt, _("Partition table entries are not in disk order."));
|
fdisk_info(cxt, _("Partition table entries are not in disk order."));
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
@ -308,7 +308,7 @@ void list_freespace(struct fdisk_context *cxt)
|
||||||
|
|
||||||
/* print */
|
/* print */
|
||||||
if (!scols_table_is_empty(out)) {
|
if (!scols_table_is_empty(out)) {
|
||||||
fdisk_info(cxt, ""); /* line break */
|
fdisk_info(cxt, "%s", ""); /* line break */
|
||||||
scols_print_table(out);
|
scols_print_table(out);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -636,10 +636,6 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
rc = fdisk_reorder_partitions(cxt);
|
rc = fdisk_reorder_partitions(cxt);
|
||||||
if (rc)
|
|
||||||
fdisk_warnx(cxt, _("Failed to fix partitions order."));
|
|
||||||
else
|
|
||||||
fdisk_info(cxt, _("Partitions order fixed."));
|
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
rc = fdisk_enable_details(cxt, 0);
|
rc = fdisk_enable_details(cxt, 0);
|
||||||
|
|
|
@ -209,7 +209,7 @@ enables libblkid debug output.
|
||||||
enables libsmartcols debug output.
|
enables libsmartcols debug output.
|
||||||
|
|
||||||
*LIBSMARTCOLS_DEBUG_PADDING*=on::
|
*LIBSMARTCOLS_DEBUG_PADDING*=on::
|
||||||
use visible padding characters. Requires enabled *LIBSMARTCOLS_DEBUG*.
|
use visible padding characters.
|
||||||
|
|
||||||
*LOCK_BLOCK_DEVICE*=<mode>::
|
*LOCK_BLOCK_DEVICE*=<mode>::
|
||||||
use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details.
|
use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details.
|
||||||
|
|
|
@ -16,7 +16,7 @@ fsck - check and repair a Linux filesystem
|
||||||
|
|
||||||
== SYNOPSIS
|
== SYNOPSIS
|
||||||
|
|
||||||
*fsck* [*-lsAVRTMNP*] [*-r* [_fd_]] [*-C* [_fd_] [*-t* _fstype_] [_filesystem_...] [*--*] [_fs-specific-options_]
|
*fsck* [*-lsAVRTMNP*] [*-r* [_fd_]] [*-C* [_fd_]] [*-t* _fstype_] [_filesystem_...] [*--*] [_fs-specific-options_]
|
||||||
|
|
||||||
== DESCRIPTION
|
== DESCRIPTION
|
||||||
|
|
||||||
|
|
|
@ -169,8 +169,9 @@ static int string_to_int(const char *s)
|
||||||
long l;
|
long l;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
l = strtol(s, &p, 0);
|
l = strtol(s, &p, 0);
|
||||||
if (*p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
|
if (errno || *p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (int) l;
|
return (int) l;
|
||||||
|
@ -1603,8 +1604,8 @@ static void parse_argv(int argc, char *argv[])
|
||||||
|
|
||||||
if (getenv("FSCK_FORCE_ALL_PARALLEL"))
|
if (getenv("FSCK_FORCE_ALL_PARALLEL"))
|
||||||
force_all_parallel++;
|
force_all_parallel++;
|
||||||
if ((tmp = getenv("FSCK_MAX_INST")))
|
if (ul_strtos32(getenv("FSCK_MAX_INST"), &max_running, 10) != 0)
|
||||||
max_running = atoi(tmp);
|
max_running = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
@ -152,14 +152,15 @@ static void test_super(int *start, size_t * length)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
/* find the physical size of the file or block device */
|
|
||||||
if (stat(filename, &st) < 0)
|
|
||||||
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
|
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
err(FSCK_EX_ERROR, _("cannot open %s"), filename);
|
err(FSCK_EX_ERROR, _("cannot open %s"), filename);
|
||||||
|
|
||||||
|
/* find the physical size of the file or block device */
|
||||||
|
if (fstat(fd, &st) < 0)
|
||||||
|
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
|
||||||
|
|
||||||
if (S_ISBLK(st.st_mode)) {
|
if (S_ISBLK(st.st_mode)) {
|
||||||
unsigned long long bytes;
|
unsigned long long bytes;
|
||||||
if (blkdev_get_size(fd, &bytes))
|
if (blkdev_get_size(fd, &bytes))
|
||||||
|
|
|
@ -157,6 +157,8 @@ do_mmap(char *path, unsigned int size, unsigned int mode){
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (S_ISLNK(mode)) {
|
if (S_ISLNK(mode)) {
|
||||||
|
/* The link buffer is unnecessary to terminate by null as it's
|
||||||
|
* always used as buffer rather than a string */
|
||||||
start = xmalloc(size);
|
start = xmalloc(size);
|
||||||
if (readlink(path, start, size) < 0) {
|
if (readlink(path, start, size) < 0) {
|
||||||
warn(_("readlink failed: %s"), path);
|
warn(_("readlink failed: %s"), path);
|
||||||
|
|
|
@ -267,6 +267,8 @@ static void check_extents(struct mkswap_control *ctl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
n = fiemap->fm_mapped_extents;
|
n = fiemap->fm_mapped_extents;
|
||||||
|
if (n == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
struct fiemap_extent *e = &fiemap->fm_extents[i];
|
struct fiemap_extent *e = &fiemap->fm_extents[i];
|
||||||
|
|
|
@ -29,7 +29,7 @@ sfdisk - display or manipulate a disk partition table
|
||||||
|
|
||||||
*sfdisk* [options] _device_ [*-N* _partition-number_]
|
*sfdisk* [options] _device_ [*-N* _partition-number_]
|
||||||
|
|
||||||
*sfdisk* [options] _command_]
|
*sfdisk* [options] _command_
|
||||||
|
|
||||||
== DESCRIPTION
|
== DESCRIPTION
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
|
||||||
typescript = mk_backup_filename_tpl(sf->move_typescript, devname, ".move");
|
typescript = mk_backup_filename_tpl(sf->move_typescript, devname, ".move");
|
||||||
|
|
||||||
if (!sf->quiet) {
|
if (!sf->quiet) {
|
||||||
fdisk_info(sf->cxt,"");
|
fdisk_info(sf->cxt, "%s", "");
|
||||||
color_scheme_enable("header", UL_COLOR_BOLD);
|
color_scheme_enable("header", UL_COLOR_BOLD);
|
||||||
fdisk_info(sf->cxt, sf->noact ? _("Data move: (--no-act)") : _("Data move:"));
|
fdisk_info(sf->cxt, sf->noact ? _("Data move: (--no-act)") : _("Data move:"));
|
||||||
color_disable();
|
color_disable();
|
||||||
|
@ -1926,7 +1926,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
|
||||||
rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
|
rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
errno = -rc;
|
errno = -rc;
|
||||||
fdisk_warn(sf->cxt, _("Failed to add #%d partition"), next_partno + 1);
|
fdisk_warn(sf->cxt, _("Failed to add #%zu partition"), next_partno + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
include/c.h
22
include/c.h
|
@ -16,6 +16,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <grp.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -217,7 +219,7 @@ prog_inv_sh_nm_from_file(char *f, char stripext)
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_ERR_H
|
#ifndef HAVE_ERR_H
|
||||||
static inline void
|
static inline void __attribute__ ((__format__ (__printf__, 4, 5)))
|
||||||
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
|
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: ", program_invocation_short_name);
|
fprintf(stderr, "%s: ", program_invocation_short_name);
|
||||||
|
@ -335,6 +337,24 @@ static inline size_t get_hostname_max(void)
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int drop_permissions(void)
|
||||||
|
{
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
/* drop GID */
|
||||||
|
if (setgid(getgid()) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* drop UID */
|
||||||
|
if (setuid(getuid()) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
return errno ? -errno : -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The usleep function was marked obsolete in POSIX.1-2001 and was removed
|
* The usleep function was marked obsolete in POSIX.1-2001 and was removed
|
||||||
* in POSIX.1-2008. It was replaced with nanosleep() that provides more
|
* in POSIX.1-2008. It was replaced with nanosleep() that provides more
|
||||||
|
|
|
@ -82,18 +82,16 @@ static inline struct dirent *xreaddir(DIR *dp)
|
||||||
# if defined(SYS_close_range)
|
# if defined(SYS_close_range)
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# ifndef HAVE_CLOSE_RANGE
|
# ifndef HAVE_CLOSE_RANGE
|
||||||
static inline int close_range(unsigned int first, unsigned int last)
|
static inline int close_range(unsigned int first, unsigned int last, int flags)
|
||||||
{
|
{
|
||||||
return syscall(SYS_close_range, first, last);
|
return syscall(SYS_close_range, first, last, flags);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# define HAVE_CLOSE_RANGE 1
|
# define HAVE_CLOSE_RANGE 1
|
||||||
# endif /* SYS_close_range */
|
# endif /* SYS_close_range */
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
#ifndef HAVE_CLOSE_RANGE
|
|
||||||
extern void ul_close_all_fds(unsigned int first, unsigned int last);
|
extern void ul_close_all_fds(unsigned int first, unsigned int last);
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UL_COPY_READ_ERROR (-1)
|
#define UL_COPY_READ_ERROR (-1)
|
||||||
#define UL_COPY_WRITE_ERROR (-2)
|
#define UL_COPY_WRITE_ERROR (-2)
|
||||||
|
|
|
@ -23,7 +23,8 @@ struct path_cxt {
|
||||||
int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
|
int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct path_cxt *ul_new_path(const char *dir, ...);
|
struct path_cxt *ul_new_path(const char *dir, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
void ul_unref_path(struct path_cxt *pc);
|
void ul_unref_path(struct path_cxt *pc);
|
||||||
void ul_ref_path(struct path_cxt *pc);
|
void ul_ref_path(struct path_cxt *pc);
|
||||||
|
|
||||||
|
@ -55,15 +56,18 @@ int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
|
||||||
int ul_path_open(struct path_cxt *pc, int flags, const char *path);
|
int ul_path_open(struct path_cxt *pc, int flags, const char *path);
|
||||||
int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
|
int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap);
|
int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap)
|
||||||
|
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||||
|
|
||||||
FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
|
FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
|
||||||
FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
|
FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap);
|
FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap)
|
||||||
|
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||||
|
|
||||||
DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
|
DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
|
||||||
DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap);
|
DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||||
DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
|
DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
|
@ -72,7 +76,8 @@ ssize_t ul_path_readlinkf(struct path_cxt *pc, char *buf, size_t bufsiz, const c
|
||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
|
int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
|
||||||
int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap);
|
int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap)
|
||||||
|
__attribute__ ((__format__ (__printf__, 4, 0)));
|
||||||
int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
|
int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
|
@ -84,8 +89,10 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char
|
||||||
int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
|
int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...);
|
int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__scanf__, 3, 4)));
|
||||||
int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
|
int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 0)))
|
||||||
__attribute__ ((__format__ (__scanf__, 4, 5)));
|
__attribute__ ((__format__ (__scanf__, 4, 5)));
|
||||||
|
|
||||||
int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);
|
int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);
|
||||||
|
|
|
@ -19,17 +19,25 @@ extern int parse_size(const char *str, uintmax_t *res, int *power);
|
||||||
extern int strtosize(const char *str, uintmax_t *res);
|
extern int strtosize(const char *str, uintmax_t *res);
|
||||||
extern uintmax_t strtosize_or_err(const char *str, const char *errmesg);
|
extern uintmax_t strtosize_or_err(const char *str, const char *errmesg);
|
||||||
|
|
||||||
extern int16_t strtos16_or_err(const char *str, const char *errmesg);
|
extern int ul_strtos64(const char *str, int64_t *num, int base);
|
||||||
extern uint16_t strtou16_or_err(const char *str, const char *errmesg);
|
extern int ul_strtou64(const char *str, uint64_t *num, int base);
|
||||||
extern uint16_t strtox16_or_err(const char *str, const char *errmesg);
|
extern int ul_strtos32(const char *str, int32_t *num, int base);
|
||||||
|
extern int ul_strtou32(const char *str, uint32_t *num, int base);
|
||||||
|
|
||||||
extern int32_t strtos32_or_err(const char *str, const char *errmesg);
|
extern int64_t str2num_or_err(const char *str, int base, const char *errmesg, int64_t low, int64_t up);
|
||||||
extern uint32_t strtou32_or_err(const char *str, const char *errmesg);
|
extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up);
|
||||||
extern uint32_t strtox32_or_err(const char *str, const char *errmesg);
|
|
||||||
|
|
||||||
extern int64_t strtos64_or_err(const char *str, const char *errmesg);
|
#define strtos64_or_err(_s, _e) str2num_or_err(_s, 10, _e, 0, 0)
|
||||||
extern uint64_t strtou64_or_err(const char *str, const char *errmesg);
|
#define strtou64_or_err(_s, _e) str2unum_or_err(_s, 10, _e, 0)
|
||||||
extern uint64_t strtox64_or_err(const char *str, const char *errmesg);
|
#define strtox64_or_err(_s, _e) str2unum_or_err(_s, 16, _e, 0)
|
||||||
|
|
||||||
|
#define strtos32_or_err(_s, _e) (int32_t) str2num_or_err(_s, 10, _e, INT32_MIN, INT32_MAX)
|
||||||
|
#define strtou32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 10, _e, UINT32_MAX)
|
||||||
|
#define strtox32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 16, _e, UINT32_MAX)
|
||||||
|
|
||||||
|
#define strtos16_or_err(_s, _e) (int16_t) str2num_or_err(_s, 10, _e, INT16_MIN, INT16_MAX)
|
||||||
|
#define strtou16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 10, _e, UINT16_MAX)
|
||||||
|
#define strtox16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 16, _e, UINT16_MAX)
|
||||||
|
|
||||||
extern double strtod_or_err(const char *str, const char *errmesg);
|
extern double strtod_or_err(const char *str, const char *errmesg);
|
||||||
extern long double strtold_or_err(const char *str, const char *errmesg);
|
extern long double strtold_or_err(const char *str, const char *errmesg);
|
||||||
|
@ -98,8 +106,8 @@ static inline char *mem2strcpy(char *dest, const void *src, size_t n, size_t nma
|
||||||
if (n + 1 > nmax)
|
if (n + 1 > nmax)
|
||||||
n = nmax - 1;
|
n = nmax - 1;
|
||||||
|
|
||||||
|
memset(dest, '\0', nmax);
|
||||||
memcpy(dest, src, n);
|
memcpy(dest, src, n);
|
||||||
dest[nmax-1] = '\0';
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +342,7 @@ static inline size_t normalize_whitespace(unsigned char *str)
|
||||||
else
|
else
|
||||||
str[x++] = str[i++];
|
str[x++] = str[i++];
|
||||||
}
|
}
|
||||||
if (nsp) /* tailing space */
|
if (nsp && x > 0) /* tailing space */
|
||||||
x--;
|
x--;
|
||||||
str[x] = '\0';
|
str[x] = '\0';
|
||||||
return x;
|
return x;
|
||||||
|
@ -362,7 +370,7 @@ static inline void strrem(char *s, int rem)
|
||||||
extern char *strnappend(const char *s, const char *suffix, size_t b);
|
extern char *strnappend(const char *s, const char *suffix, size_t b);
|
||||||
extern char *strappend(const char *s, const char *suffix);
|
extern char *strappend(const char *s, const char *suffix);
|
||||||
extern char *strfappend(const char *s, const char *format, ...)
|
extern char *strfappend(const char *s, const char *format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
extern const char *split(const char **state, size_t *l, const char *separator, int quoted);
|
extern const char *split(const char **state, size_t *l, const char *separator, int quoted);
|
||||||
|
|
||||||
extern int skip_fline(FILE *fp);
|
extern int skip_fline(FILE *fp);
|
||||||
|
|
|
@ -13,9 +13,12 @@ unsigned strv_length(char * const *l);
|
||||||
int strv_extend_strv(char ***a, char **b);
|
int strv_extend_strv(char ***a, char **b);
|
||||||
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
|
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
|
||||||
int strv_extend(char ***l, const char *value);
|
int strv_extend(char ***l, const char *value);
|
||||||
int strv_extendv(char ***l, const char *format, va_list ap);
|
|
||||||
int strv_extendf(char ***l, const char *format, ...)
|
int strv_extendv(char ***l, const char *format, va_list ap)
|
||||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||||
|
int strv_extendf(char ***l, const char *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
int strv_push(char ***l, char *value);
|
int strv_push(char ***l, char *value);
|
||||||
int strv_push_prepend(char ***l, char *value);
|
int strv_push_prepend(char ***l, char *value);
|
||||||
int strv_consume(char ***l, char *value);
|
int strv_consume(char ***l, char *value);
|
||||||
|
|
|
@ -170,8 +170,7 @@ char *canonicalize_path_restricted(const char *path)
|
||||||
pipes[0] = -1;
|
pipes[0] = -1;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
/* drop permissions */
|
if (drop_permissions() != 0)
|
||||||
if (setgid(getgid()) < 0 || setuid(getuid()) < 0)
|
|
||||||
canonical = NULL; /* failed */
|
canonical = NULL; /* failed */
|
||||||
else {
|
else {
|
||||||
char *dmname = NULL;
|
char *dmname = NULL;
|
||||||
|
|
|
@ -129,7 +129,6 @@ unsigned int get_fd_tabsize(void)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_CLOSE_RANGE
|
|
||||||
void ul_close_all_fds(unsigned int first, unsigned int last)
|
void ul_close_all_fds(unsigned int first, unsigned int last)
|
||||||
{
|
{
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
|
@ -166,7 +165,6 @@ void ul_close_all_fds(unsigned int first, unsigned int last)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TEST_PROGRAM_FILEUTILS
|
#ifdef TEST_PROGRAM_FILEUTILS
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -189,10 +187,10 @@ int main(int argc, char *argv[])
|
||||||
ignore_result( dup(STDIN_FILENO) );
|
ignore_result( dup(STDIN_FILENO) );
|
||||||
|
|
||||||
# ifdef HAVE_CLOSE_RANGE
|
# ifdef HAVE_CLOSE_RANGE
|
||||||
close_range(STDERR_FILENO + 1, ~0U);
|
if (close_range(STDERR_FILENO + 1, ~0U, 0) < 0)
|
||||||
# else
|
|
||||||
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
|
|
||||||
# endif
|
# endif
|
||||||
|
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
|
||||||
|
|
||||||
} else if (strcmp(argv[1], "--copy-file") == 0) {
|
} else if (strcmp(argv[1], "--copy-file") == 0) {
|
||||||
int ret = ul_copy_file(STDIN_FILENO, STDOUT_FILENO);
|
int ret = ul_copy_file(STDIN_FILENO, STDOUT_FILENO);
|
||||||
if (ret == UL_COPY_READ_ERROR)
|
if (ret == UL_COPY_READ_ERROR)
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
|
||||||
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
|
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
if (errno != EINVAL) {
|
if (errno != EINVAL && errno != ENOTTY) {
|
||||||
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
|
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
23
lib/path.c
23
lib/path.c
|
@ -542,14 +542,14 @@ DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
|
||||||
ssize_t ul_path_readlink(struct path_cxt *pc, char *buf, size_t bufsiz, const char *path)
|
ssize_t ul_path_readlink(struct path_cxt *pc, char *buf, size_t bufsiz, const char *path)
|
||||||
{
|
{
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
ssize_t ssz;
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
const char *p = get_absdir(pc);
|
const char *p = get_absdir(pc);
|
||||||
if (!p)
|
if (!p)
|
||||||
return -errno;
|
return -errno;
|
||||||
return readlink(p, buf, bufsiz);
|
ssz = readlink(p, buf, bufsiz - 1);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
dirfd = ul_path_get_dirfd(pc);
|
dirfd = ul_path_get_dirfd(pc);
|
||||||
if (dirfd < 0)
|
if (dirfd < 0)
|
||||||
return dirfd;
|
return dirfd;
|
||||||
|
@ -557,7 +557,12 @@ ssize_t ul_path_readlink(struct path_cxt *pc, char *buf, size_t bufsiz, const ch
|
||||||
if (*path == '/')
|
if (*path == '/')
|
||||||
path++;
|
path++;
|
||||||
|
|
||||||
return readlinkat(dirfd, path, buf, bufsiz);
|
ssz = readlinkat(dirfd, path, buf, bufsiz - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssz >= 0)
|
||||||
|
buf[ssz] = '\0';
|
||||||
|
return ssz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -617,7 +622,7 @@ int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path,
|
||||||
* Returns newly allocated buffer with data from file. Maximal size is BUFSIZ
|
* Returns newly allocated buffer with data from file. Maximal size is BUFSIZ
|
||||||
* (send patch if you need something bigger;-)
|
* (send patch if you need something bigger;-)
|
||||||
*
|
*
|
||||||
* Returns size of the string!
|
* Returns size of the string without \0, nothing is allocated if returns <= 0.
|
||||||
*/
|
*/
|
||||||
int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
|
int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
|
||||||
{
|
{
|
||||||
|
@ -635,6 +640,8 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
|
||||||
/* Remove tailing newline (usual in sysfs) */
|
/* Remove tailing newline (usual in sysfs) */
|
||||||
if (rc > 0 && *(buf + rc - 1) == '\n')
|
if (rc > 0 && *(buf + rc - 1) == '\n')
|
||||||
--rc;
|
--rc;
|
||||||
|
if (rc == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
buf[rc] = '\0';
|
buf[rc] = '\0';
|
||||||
*str = strdup(buf);
|
*str = strdup(buf);
|
||||||
|
@ -1099,7 +1106,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
ul_path_init_debug();
|
ul_path_init_debug();
|
||||||
|
|
||||||
pc = ul_new_path(dir);
|
pc = ul_new_path("%s", dir);
|
||||||
if (!pc)
|
if (!pc)
|
||||||
err(EXIT_FAILURE, "failed to initialize path context");
|
err(EXIT_FAILURE, "failed to initialize path context");
|
||||||
if (prefix)
|
if (prefix)
|
||||||
|
@ -1191,11 +1198,11 @@ int main(int argc, char *argv[])
|
||||||
errx(EXIT_FAILURE, "<file> not defined");
|
errx(EXIT_FAILURE, "<file> not defined");
|
||||||
file = argv[optind++];
|
file = argv[optind++];
|
||||||
|
|
||||||
if (ul_path_read_string(pc, &res, file) < 0)
|
if (ul_path_read_string(pc, &res, file) <= 0)
|
||||||
err(EXIT_FAILURE, "read string failed");
|
err(EXIT_FAILURE, "read string failed");
|
||||||
printf("read: %s: %s\n", file, res);
|
printf("read: %s: %s\n", file, res);
|
||||||
|
|
||||||
if (ul_path_readf_string(pc, &res, "%s", file) < 0)
|
if (ul_path_readf_string(pc, &res, "%s", file) <= 0)
|
||||||
err(EXIT_FAILURE, "readf string failed");
|
err(EXIT_FAILURE, "readf string failed");
|
||||||
printf("readf: %s: %s\n", file, res);
|
printf("readf: %s: %s\n", file, res);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* it what you wish.
|
* it what you wish.
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "pwdutils.h"
|
#include "pwdutils.h"
|
||||||
|
@ -17,8 +18,8 @@ struct passwd *xgetpwnam(const char *username, char **pwdbuf)
|
||||||
struct passwd *pwd = NULL, *res = NULL;
|
struct passwd *pwd = NULL, *res = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!pwdbuf || !username)
|
assert(pwdbuf);
|
||||||
return NULL;
|
assert(username);
|
||||||
|
|
||||||
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
|
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
|
||||||
pwd = xcalloc(1, sizeof(struct passwd));
|
pwd = xcalloc(1, sizeof(struct passwd));
|
||||||
|
@ -49,8 +50,8 @@ struct group *xgetgrnam(const char *groupname, char **grpbuf)
|
||||||
struct group *grp = NULL, *res = NULL;
|
struct group *grp = NULL, *res = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!grpbuf || !groupname)
|
assert(grpbuf);
|
||||||
return NULL;
|
assert(groupname);
|
||||||
|
|
||||||
*grpbuf = xmalloc(UL_GETPW_BUFSIZ);
|
*grpbuf = xmalloc(UL_GETPW_BUFSIZ);
|
||||||
grp = xcalloc(1, sizeof(struct group));
|
grp = xcalloc(1, sizeof(struct group));
|
||||||
|
@ -77,8 +78,7 @@ struct passwd *xgetpwuid(uid_t uid, char **pwdbuf)
|
||||||
struct passwd *pwd = NULL, *res = NULL;
|
struct passwd *pwd = NULL, *res = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!pwdbuf)
|
assert(pwdbuf);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
|
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
|
||||||
pwd = xcalloc(1, sizeof(struct passwd));
|
pwd = xcalloc(1, sizeof(struct passwd));
|
||||||
|
@ -104,11 +104,6 @@ char *xgetlogin(void)
|
||||||
{
|
{
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
uid_t ruid;
|
uid_t ruid;
|
||||||
char *user;
|
|
||||||
|
|
||||||
user = getlogin();
|
|
||||||
if (user)
|
|
||||||
return xstrdup(user);
|
|
||||||
|
|
||||||
/* GNU Hurd implementation has an extension where a process can exist in a
|
/* GNU Hurd implementation has an extension where a process can exist in a
|
||||||
* non-conforming environment, and thus be outside the realms of POSIX
|
* non-conforming environment, and thus be outside the realms of POSIX
|
||||||
|
@ -117,6 +112,9 @@ char *xgetlogin(void)
|
||||||
* environment.
|
* environment.
|
||||||
*
|
*
|
||||||
* http://austingroupbugs.net/view.php?id=511
|
* http://austingroupbugs.net/view.php?id=511
|
||||||
|
*
|
||||||
|
* The same implementation is useful for other systems, since getlogin(3)
|
||||||
|
* shouldn't be used as actual identification.
|
||||||
*/
|
*/
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ruid = getuid();
|
ruid = getuid();
|
||||||
|
|
213
lib/strutils.c
213
lib/strutils.c
|
@ -319,123 +319,114 @@ char *strndup(const char *s, size_t n)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint32_t _strtou32_or_err(const char *str, const char *errmesg, int base);
|
/*
|
||||||
static uint64_t _strtou64_or_err(const char *str, const char *errmesg, int base);
|
* convert strings to numbers; returns <0 on error, and 0 on success
|
||||||
|
*/
|
||||||
int16_t strtos16_or_err(const char *str, const char *errmesg)
|
int ul_strtos64(const char *str, int64_t *num, int base)
|
||||||
{
|
{
|
||||||
int32_t num = strtos32_or_err(str, errmesg);
|
|
||||||
|
|
||||||
if (num < INT16_MIN || num > INT16_MAX) {
|
|
||||||
errno = ERANGE;
|
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t _strtou16_or_err(const char *str, const char *errmesg, int base)
|
|
||||||
{
|
|
||||||
uint32_t num = _strtou32_or_err(str, errmesg, base);
|
|
||||||
|
|
||||||
if (num > UINT16_MAX) {
|
|
||||||
errno = ERANGE;
|
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t strtou16_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
return _strtou16_or_err(str, errmesg, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t strtox16_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
return _strtou16_or_err(str, errmesg, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t strtos32_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
int64_t num = strtos64_or_err(str, errmesg);
|
|
||||||
|
|
||||||
if (num < INT32_MIN || num > INT32_MAX) {
|
|
||||||
errno = ERANGE;
|
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t _strtou32_or_err(const char *str, const char *errmesg, int base)
|
|
||||||
{
|
|
||||||
uint64_t num = _strtou64_or_err(str, errmesg, base);
|
|
||||||
|
|
||||||
if (num > UINT32_MAX) {
|
|
||||||
errno = ERANGE;
|
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t strtou32_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
return _strtou32_or_err(str, errmesg, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t strtox32_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
return _strtou32_or_err(str, errmesg, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t strtos64_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
int64_t num;
|
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (str == NULL || *str == '\0')
|
if (str == NULL || *str == '\0')
|
||||||
goto err;
|
return -EINVAL;
|
||||||
num = strtoimax(str, &end, 10);
|
*num = (int64_t) strtoimax(str, &end, base);
|
||||||
|
|
||||||
if (errno || str == end || (end && *end))
|
if (errno || str == end || (end && *end))
|
||||||
goto err;
|
return -EINVAL;
|
||||||
|
return 0;
|
||||||
return num;
|
|
||||||
err:
|
|
||||||
if (errno == ERANGE)
|
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
|
|
||||||
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t _strtou64_or_err(const char *str, const char *errmesg, int base)
|
int ul_strtou64(const char *str, uint64_t *num, int base)
|
||||||
{
|
{
|
||||||
uintmax_t num;
|
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
int64_t tmp;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (str == NULL || *str == '\0')
|
if (str == NULL || *str == '\0')
|
||||||
goto err;
|
return -EINVAL;
|
||||||
num = strtoumax(str, &end, base);
|
|
||||||
|
/* we need to ignore negative numbers, note that for invalid negative
|
||||||
|
* number strtoimax() returns negative number too, so we do not
|
||||||
|
* need to check errno here */
|
||||||
|
tmp = (int64_t) strtoimax(str, &end, base);
|
||||||
|
if (tmp < 0)
|
||||||
|
errno = ERANGE;
|
||||||
|
else {
|
||||||
|
errno = 0;
|
||||||
|
*num = strtoumax(str, &end, base);
|
||||||
|
}
|
||||||
|
|
||||||
if (errno || str == end || (end && *end))
|
if (errno || str == end || (end && *end))
|
||||||
goto err;
|
return -EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return num;
|
int ul_strtos32(const char *str, int32_t *num, int base)
|
||||||
err:
|
{
|
||||||
|
int64_t tmp;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ul_strtos64(str, &tmp, base);
|
||||||
|
if (rc == 0 && (tmp < INT32_MIN || tmp > INT32_MAX))
|
||||||
|
rc = -(errno = ERANGE);
|
||||||
|
if (rc == 0)
|
||||||
|
*num = (int32_t) tmp;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ul_strtou32(const char *str, uint32_t *num, int base)
|
||||||
|
{
|
||||||
|
uint64_t tmp;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ul_strtou64(str, &tmp, base);
|
||||||
|
if (rc == 0 && tmp > UINT32_MAX)
|
||||||
|
rc = -(errno = ERANGE);
|
||||||
|
if (rc == 0)
|
||||||
|
*num = (uint32_t) tmp;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Covert strings to numbers in defined range and print message on error.
|
||||||
|
*
|
||||||
|
* These functions are used when we read input from users (getopt() etc.). It's
|
||||||
|
* better to consolidate the code and keep it all based on 64-bit numbers then
|
||||||
|
* implement it for 32 and 16-bit numbers too.
|
||||||
|
*/
|
||||||
|
int64_t str2num_or_err(const char *str, int base, const char *errmesg,
|
||||||
|
int64_t low, int64_t up)
|
||||||
|
{
|
||||||
|
int64_t num = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ul_strtos64(str, &num, base);
|
||||||
|
if (rc == 0 && ((low && num < low) || (up && num > up)))
|
||||||
|
rc = -(errno = ERANGE);
|
||||||
|
|
||||||
|
if (rc) {
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
||||||
|
|
||||||
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
||||||
}
|
}
|
||||||
|
return num;
|
||||||
uint64_t strtou64_or_err(const char *str, const char *errmesg)
|
|
||||||
{
|
|
||||||
return _strtou64_or_err(str, errmesg, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t strtox64_or_err(const char *str, const char *errmesg)
|
uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up)
|
||||||
{
|
{
|
||||||
return _strtou64_or_err(str, errmesg, 16);
|
uint64_t num = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ul_strtou64(str, &num, base);
|
||||||
|
if (rc == 0 && (up && num > up))
|
||||||
|
rc = -(errno = ERANGE);
|
||||||
|
|
||||||
|
if (rc) {
|
||||||
|
if (errno == ERANGE)
|
||||||
|
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
||||||
|
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
double strtod_or_err(const char *str, const char *errmesg)
|
double strtod_or_err(const char *str, const char *errmesg)
|
||||||
|
@ -1192,29 +1183,49 @@ static int test_strutils_normalize(int argc, char *argv[])
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc == 3 && strcmp(argv[1], "--size") == 0)
|
if (argc == 3 && strcmp(argv[1], "--size") == 0) {
|
||||||
return test_strutils_sizes(argc - 1, argv + 1);
|
return test_strutils_sizes(argc - 1, argv + 1);
|
||||||
|
|
||||||
if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0)
|
} else if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0) {
|
||||||
return test_strutils_cmp_paths(argc - 1, argv + 1);
|
return test_strutils_cmp_paths(argc - 1, argv + 1);
|
||||||
|
|
||||||
if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0)
|
} else if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0) {
|
||||||
return test_strdup_to_member(argc - 1, argv + 1);
|
return test_strdup_to_member(argc - 1, argv + 1);
|
||||||
|
|
||||||
if (argc == 4 && strcmp(argv[1], "--stralnumcmp") == 0) {
|
} else if (argc == 4 && strcmp(argv[1], "--stralnumcmp") == 0) {
|
||||||
printf("%s\n", ul_stralnumcmp(argv[2], argv[3]) == 0 ?
|
printf("%s\n", ul_stralnumcmp(argv[2], argv[3]) == 0 ?
|
||||||
"match" : "dismatch");
|
"match" : "dismatch");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--normalize") == 0) {
|
||||||
} else if (argc == 3 && strcmp(argv[1], "--normalize") == 0)
|
|
||||||
return test_strutils_normalize(argc - 1, argv + 1);
|
return test_strutils_normalize(argc - 1, argv + 1);
|
||||||
|
|
||||||
else {
|
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtos64") == 0) {
|
||||||
|
printf("'%s'-->%jd\n", argv[2], strtos64_or_err(argv[2], "strtos64 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtou64") == 0) {
|
||||||
|
printf("'%s'-->%ju\n", argv[2], strtou64_or_err(argv[2], "strtou64 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtos32") == 0) {
|
||||||
|
printf("'%s'-->%d\n", argv[2], strtos32_or_err(argv[2], "strtos32 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtou32") == 0) {
|
||||||
|
printf("'%s'-->%u\n", argv[2], strtou32_or_err(argv[2], "strtou32 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtos16") == 0) {
|
||||||
|
printf("'%s'-->%hd\n", argv[2], strtos16_or_err(argv[2], "strtos16 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (argc == 3 && strcmp(argv[1], "--strtou16") == 0) {
|
||||||
|
printf("'%s'-->%hu\n", argv[2], strtou16_or_err(argv[2], "strtou16 failed"));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
} else {
|
||||||
fprintf(stderr, "usage: %1$s --size <number>[suffix]\n"
|
fprintf(stderr, "usage: %1$s --size <number>[suffix]\n"
|
||||||
" %1$s --cmp-paths <path> <path>\n"
|
" %1$s --cmp-paths <path> <path>\n"
|
||||||
" %1$s --strdup-member <str> <str>\n"
|
" %1$s --strdup-member <str> <str>\n"
|
||||||
" %1$s --stralnumcmp <str> <str>\n"
|
" %1$s --stralnumcmp <str> <str>\n"
|
||||||
" %1$s --normalize <str>\n",
|
" %1$s --normalize <str>\n"
|
||||||
|
" %1$s --strto{s,u}{16,32,64} <str>\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
11
lib/sysfs.c
11
lib/sysfs.c
|
@ -182,10 +182,9 @@ char *sysfs_blkdev_get_name(struct path_cxt *pc, char *buf, size_t bufsiz)
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
|
|
||||||
/* read /sys/dev/block/<maj:min> link */
|
/* read /sys/dev/block/<maj:min> link */
|
||||||
sz = ul_path_readlink(pc, link, sizeof(link) - 1, NULL);
|
sz = ul_path_readlink(pc, link, sizeof(link), NULL);
|
||||||
if (sz < 0)
|
if (sz < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
link[sz] = '\0';
|
|
||||||
|
|
||||||
name = strrchr(link, '/');
|
name = strrchr(link, '/');
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -393,7 +392,7 @@ char *sysfs_blkdev_get_devchain(struct path_cxt *pc, char *buf, size_t bufsz)
|
||||||
if (sz <= 0 || sz + sizeof(_PATH_SYS_DEVBLOCK "/") > bufsz)
|
if (sz <= 0 || sz + sizeof(_PATH_SYS_DEVBLOCK "/") > bufsz)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buf[sz++] = '\0';
|
sz++;
|
||||||
prefix = ul_path_get_prefix(pc);
|
prefix = ul_path_get_prefix(pc);
|
||||||
if (prefix)
|
if (prefix)
|
||||||
psz = strlen(prefix);
|
psz = strlen(prefix);
|
||||||
|
@ -567,10 +566,9 @@ int sysfs_blkdev_get_wholedisk( struct path_cxt *pc,
|
||||||
char *name;
|
char *name;
|
||||||
ssize_t linklen;
|
ssize_t linklen;
|
||||||
|
|
||||||
linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath) - 1, NULL);
|
linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath), NULL);
|
||||||
if (linklen < 0)
|
if (linklen < 0)
|
||||||
goto err;
|
goto err;
|
||||||
linkpath[linklen] = '\0';
|
|
||||||
|
|
||||||
stripoff_last_component(linkpath); /* dirname */
|
stripoff_last_component(linkpath); /* dirname */
|
||||||
name = stripoff_last_component(linkpath); /* basename */
|
name = stripoff_last_component(linkpath); /* basename */
|
||||||
|
@ -678,11 +676,10 @@ int sysfs_blkdev_scsi_get_hctl(struct path_cxt *pc, int *h, int *c, int *t, int
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
blk->hctl_error = 1;
|
blk->hctl_error = 1;
|
||||||
len = ul_path_readlink(pc, buf, sizeof(buf) - 1, "device");
|
len = ul_path_readlink(pc, buf, sizeof(buf), "device");
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
buf[len] = '\0';
|
|
||||||
hctl = strrchr(buf, '/');
|
hctl = strrchr(buf, '/');
|
||||||
if (!hctl)
|
if (!hctl)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1040,8 +1040,9 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
|
||||||
if (prefix && strncasecmp(prefix, "part", 4) == 0) {
|
if (prefix && strncasecmp(prefix, "part", 4) == 0) {
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
partno = strtol(prefix + 4, &end, 10);
|
partno = strtol(prefix + 4, &end, 10);
|
||||||
if (prefix == end || (end && *end))
|
if (errno || prefix == end || (end && *end))
|
||||||
partno = 0;
|
partno = 0;
|
||||||
else
|
else
|
||||||
rc = 0; /* success */
|
rc = 0; /* success */
|
||||||
|
|
|
@ -1272,7 +1272,11 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
|
||||||
if (rc || len == 0 || off == NULL)
|
if (rc || len == 0 || off == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
magoff = strtoumax(off, NULL, 10);
|
magoff = strtoumax(off, NULL, 10);
|
||||||
|
if (errno)
|
||||||
|
return 0;
|
||||||
|
|
||||||
offset = magoff + pr->off;
|
offset = magoff + pr->off;
|
||||||
fd = blkid_probe_get_fd(pr);
|
fd = blkid_probe_get_fd(pr);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
|
|
@ -297,16 +297,25 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
|
||||||
|
|
||||||
DBG(READ, ul_debug("tag: %s=\"%s\"", name, value));
|
DBG(READ, ul_debug("tag: %s=\"%s\"", name, value));
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
/* Some tags are stored directly in the device struct */
|
/* Some tags are stored directly in the device struct */
|
||||||
if (!strcmp(name, "DEVNO"))
|
if (!strcmp(name, "DEVNO")) {
|
||||||
dev->bid_devno = strtoull(value, NULL, 0);
|
dev->bid_devno = strtoull(value, NULL, 0);
|
||||||
else if (!strcmp(name, "PRI"))
|
if (errno)
|
||||||
|
return -errno;
|
||||||
|
} else if (!strcmp(name, "PRI")) {
|
||||||
dev->bid_pri = strtol(value, NULL, 0);
|
dev->bid_pri = strtol(value, NULL, 0);
|
||||||
else if (!strcmp(name, "TIME")) {
|
if (errno)
|
||||||
|
return -errno;
|
||||||
|
} else if (!strcmp(name, "TIME")) {
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
||||||
dev->bid_time = strtoull(value, &end, 0);
|
dev->bid_time = strtoull(value, &end, 0);
|
||||||
if (end && *end == '.')
|
if (errno == 0 && end && *end == '.')
|
||||||
dev->bid_utime = strtoull(end + 1, NULL, 0);
|
dev->bid_utime = strtoull(end + 1, NULL, 0);
|
||||||
|
if (errno)
|
||||||
|
return -errno;
|
||||||
} else
|
} else
|
||||||
ret = blkid_set_tag(dev, name, value, strlen(value));
|
ret = blkid_set_tag(dev, name, value, strlen(value));
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,18 @@
|
||||||
#include "superblocks.h"
|
#include "superblocks.h"
|
||||||
#include "crc32c.h"
|
#include "crc32c.h"
|
||||||
|
|
||||||
|
/* Macro to avoid error in struct declaration. */
|
||||||
|
#define STRATIS_UUID_LEN 32
|
||||||
|
/* Contains 4 hyphens and trailing null byte. */
|
||||||
|
const int STRATIS_UUID_STR_LEN = 37;
|
||||||
|
|
||||||
struct stratis_sb {
|
struct stratis_sb {
|
||||||
uint32_t crc32;
|
uint32_t crc32;
|
||||||
uint8_t magic[16];
|
uint8_t magic[16];
|
||||||
uint64_t sectors;
|
uint64_t sectors;
|
||||||
uint8_t reserved[4];
|
uint8_t reserved[4];
|
||||||
uint8_t pool_uuid[32];
|
uint8_t pool_uuid[STRATIS_UUID_LEN];
|
||||||
uint8_t dev_uuid[32];
|
uint8_t dev_uuid[STRATIS_UUID_LEN];
|
||||||
uint64_t mda_size;
|
uint64_t mda_size;
|
||||||
uint64_t reserved_size;
|
uint64_t reserved_size;
|
||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
|
@ -57,11 +62,29 @@ static int stratis_valid_sb(uint8_t *p)
|
||||||
return crc == le32_to_cpu(stratis->crc32);
|
return crc == le32_to_cpu(stratis->crc32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format UUID string representation to include hyphens given that Stratis stores
|
||||||
|
* UUIDs without hyphens in the superblock to keep the UUID length a power of 2.
|
||||||
|
*/
|
||||||
|
static void stratis_format_uuid(const unsigned char *src_uuid,
|
||||||
|
unsigned char *dst_uuid)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < STRATIS_UUID_LEN; i++) {
|
||||||
|
*dst_uuid++ = *src_uuid++;
|
||||||
|
if (i == 7 || i == 11 || i == 15 || i == 19)
|
||||||
|
*dst_uuid ++ = '-';
|
||||||
|
}
|
||||||
|
*dst_uuid = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
static int probe_stratis(blkid_probe pr,
|
static int probe_stratis(blkid_probe pr,
|
||||||
const struct blkid_idmag *mag __attribute__((__unused__)))
|
const struct blkid_idmag *mag __attribute__((__unused__)))
|
||||||
{
|
{
|
||||||
const struct stratis_sb *stratis = NULL;
|
const struct stratis_sb *stratis = NULL;
|
||||||
uint8_t *buf = blkid_probe_get_buffer(pr, 0, SB_AREA_SIZE);
|
uint8_t *buf = blkid_probe_get_buffer(pr, 0, SB_AREA_SIZE);
|
||||||
|
unsigned char uuid[STRATIS_UUID_STR_LEN];
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return errno ? -errno : 1;
|
return errno ? -errno : 1;
|
||||||
|
@ -76,17 +99,16 @@ static int probe_stratis(blkid_probe pr,
|
||||||
(buf + SECOND_COPY_OFFSET);
|
(buf + SECOND_COPY_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
blkid_probe_strncpy_uuid(pr, stratis->dev_uuid,
|
stratis_format_uuid(stratis->dev_uuid, uuid);
|
||||||
sizeof(stratis->dev_uuid));
|
blkid_probe_strncpy_uuid(pr, uuid, sizeof(uuid));
|
||||||
blkid_probe_set_value(pr, "POOL_UUID",
|
|
||||||
stratis->pool_uuid,
|
stratis_format_uuid(stratis->pool_uuid, uuid);
|
||||||
sizeof(stratis->pool_uuid));
|
blkid_probe_set_value(pr, "POOL_UUID", uuid, sizeof(uuid));
|
||||||
|
|
||||||
blkid_probe_sprintf_value(pr, "BLOCKDEV_SECTORS", "%" PRIu64,
|
blkid_probe_sprintf_value(pr, "BLOCKDEV_SECTORS", "%" PRIu64,
|
||||||
le64_to_cpu(stratis->sectors));
|
le64_to_cpu(stratis->sectors));
|
||||||
blkid_probe_sprintf_value(pr, "BLOCKDEV_INITTIME", "%" PRIu64,
|
blkid_probe_sprintf_value(pr, "BLOCKDEV_INITTIME", "%" PRIu64,
|
||||||
le64_to_cpu(stratis->initialization_time));
|
le64_to_cpu(stratis->initialization_time));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ struct vfat_super_block {
|
||||||
/* 30*/ uint16_t vs_fsinfo_sector;
|
/* 30*/ uint16_t vs_fsinfo_sector;
|
||||||
/* 32*/ uint16_t vs_backup_boot;
|
/* 32*/ uint16_t vs_backup_boot;
|
||||||
/* 34*/ uint16_t vs_reserved2[6];
|
/* 34*/ uint16_t vs_reserved2[6];
|
||||||
/* 40*/ unsigned char vs_unknown[3];
|
/* 40*/ unsigned char vs_drive_number;
|
||||||
|
/* 41*/ unsigned char vs_boot_flags;
|
||||||
|
/* 42*/ unsigned char vs_ext_boot_sign; /* 0x28 - without vs_label/vs_magic; 0x29 - with */
|
||||||
/* 43*/ unsigned char vs_serno[4];
|
/* 43*/ unsigned char vs_serno[4];
|
||||||
/* 47*/ unsigned char vs_label[11];
|
/* 47*/ unsigned char vs_label[11];
|
||||||
/* 52*/ unsigned char vs_magic[8];
|
/* 52*/ unsigned char vs_magic[8];
|
||||||
|
@ -53,6 +55,7 @@ struct vfat_super_block {
|
||||||
|
|
||||||
/* Yucky misaligned values */
|
/* Yucky misaligned values */
|
||||||
struct msdos_super_block {
|
struct msdos_super_block {
|
||||||
|
/* DOS 2.0 BPB */
|
||||||
/* 00*/ unsigned char ms_ignored[3];
|
/* 00*/ unsigned char ms_ignored[3];
|
||||||
/* 03*/ unsigned char ms_sysid[8];
|
/* 03*/ unsigned char ms_sysid[8];
|
||||||
/* 0b*/ unsigned char ms_sector_size[2];
|
/* 0b*/ unsigned char ms_sector_size[2];
|
||||||
|
@ -63,16 +66,21 @@ struct msdos_super_block {
|
||||||
/* 13*/ unsigned char ms_sectors[2]; /* =0 iff V3 or later */
|
/* 13*/ unsigned char ms_sectors[2]; /* =0 iff V3 or later */
|
||||||
/* 15*/ unsigned char ms_media;
|
/* 15*/ unsigned char ms_media;
|
||||||
/* 16*/ uint16_t ms_fat_length; /* Sectors per FAT */
|
/* 16*/ uint16_t ms_fat_length; /* Sectors per FAT */
|
||||||
|
/* DOS 3.0 BPB */
|
||||||
/* 18*/ uint16_t ms_secs_track;
|
/* 18*/ uint16_t ms_secs_track;
|
||||||
/* 1a*/ uint16_t ms_heads;
|
/* 1a*/ uint16_t ms_heads;
|
||||||
/* 1c*/ uint32_t ms_hidden;
|
/* 1c*/ uint32_t ms_hidden;
|
||||||
/* V3 BPB */
|
/* DOS 3.31 BPB */
|
||||||
/* 20*/ uint32_t ms_total_sect; /* iff ms_sectors == 0 */
|
/* 20*/ uint32_t ms_total_sect; /* iff ms_sectors == 0 */
|
||||||
/* V4 BPB */
|
/* DOS 3.4 EBPB */
|
||||||
/* 24*/ unsigned char ms_unknown[3]; /* Phys drive no., resvd, V4 sig (0x29) */
|
/* 24*/ unsigned char ms_drive_number;
|
||||||
|
/* 25*/ unsigned char ms_boot_flags;
|
||||||
|
/* 26*/ unsigned char ms_ext_boot_sign; /* 0x28 - DOS 3.4 EBPB; 0x29 - DOS 4.0 EBPB */
|
||||||
/* 27*/ unsigned char ms_serno[4];
|
/* 27*/ unsigned char ms_serno[4];
|
||||||
|
/* DOS 4.0 EBPB */
|
||||||
/* 2b*/ unsigned char ms_label[11];
|
/* 2b*/ unsigned char ms_label[11];
|
||||||
/* 36*/ unsigned char ms_magic[8];
|
/* 36*/ unsigned char ms_magic[8];
|
||||||
|
/* padding */
|
||||||
/* 3e*/ unsigned char ms_dummy2[0x1fe - 0x3e];
|
/* 3e*/ unsigned char ms_dummy2[0x1fe - 0x3e];
|
||||||
/*1fe*/ unsigned char ms_pmagic[2];
|
/*1fe*/ unsigned char ms_pmagic[2];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
@ -324,7 +332,10 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
|
||||||
vol_label = vol_label_buf;
|
vol_label = vol_label_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ms->ms_ext_boot_sign == 0x29)
|
||||||
boot_label = ms->ms_label;
|
boot_label = ms->ms_label;
|
||||||
|
|
||||||
|
if (ms->ms_ext_boot_sign == 0x28 || ms->ms_ext_boot_sign == 0x29)
|
||||||
vol_serno = ms->ms_serno;
|
vol_serno = ms->ms_serno;
|
||||||
|
|
||||||
blkid_probe_set_value(pr, "SEC_TYPE", (unsigned char *) "msdos",
|
blkid_probe_set_value(pr, "SEC_TYPE", (unsigned char *) "msdos",
|
||||||
|
@ -378,7 +389,9 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
|
||||||
|
|
||||||
version = "FAT32";
|
version = "FAT32";
|
||||||
|
|
||||||
|
if (vs->vs_ext_boot_sign == 0x29)
|
||||||
boot_label = vs->vs_label;
|
boot_label = vs->vs_label;
|
||||||
|
|
||||||
vol_serno = vs->vs_serno;
|
vol_serno = vs->vs_serno;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -73,10 +73,7 @@ static int probe_dm_tp(blkid_probe pr,
|
||||||
if (dmpipe[1] != STDOUT_FILENO)
|
if (dmpipe[1] != STDOUT_FILENO)
|
||||||
dup2(dmpipe[1], STDOUT_FILENO);
|
dup2(dmpipe[1], STDOUT_FILENO);
|
||||||
|
|
||||||
/* The libblkid library could linked with setuid programs */
|
if (drop_permissions() != 0)
|
||||||
if (setgid(getgid()) < 0)
|
|
||||||
exit(1);
|
|
||||||
if (setuid(getuid()) < 0)
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
snprintf(maj, sizeof(maj), "%d", major(devno));
|
snprintf(maj, sizeof(maj), "%d", major(devno));
|
||||||
|
|
|
@ -82,10 +82,7 @@ static int probe_lvm_tp(blkid_probe pr,
|
||||||
if (lvpipe[1] != STDOUT_FILENO)
|
if (lvpipe[1] != STDOUT_FILENO)
|
||||||
dup2(lvpipe[1], STDOUT_FILENO);
|
dup2(lvpipe[1], STDOUT_FILENO);
|
||||||
|
|
||||||
/* The libblkid library could linked with setuid programs */
|
if (drop_permissions() != 0)
|
||||||
if (setgid(getgid()) < 0)
|
|
||||||
exit(1);
|
|
||||||
if (setuid(getuid()) < 0)
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
lvargv[0] = cmd;
|
lvargv[0] = cmd;
|
||||||
|
|
|
@ -834,12 +834,6 @@ static int dos_probe_label(struct fdisk_context *cxt)
|
||||||
if (!mbr_is_valid_magic(cxt->firstsector))
|
if (!mbr_is_valid_magic(cxt->firstsector))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* ignore disks with FAT */
|
|
||||||
if (cxt->collision &&
|
|
||||||
(strcmp(cxt->collision, "vfat") == 0 ||
|
|
||||||
strcmp(cxt->collision, "ntfs") == 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dos_init(cxt);
|
dos_init(cxt);
|
||||||
|
|
||||||
get_partition_table_geometry(cxt, &h, &s);
|
get_partition_table_geometry(cxt, &h, &s);
|
||||||
|
@ -1257,7 +1251,8 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
|
||||||
if (start >= temp + fdisk_get_units_per_sector(cxt)
|
if (start >= temp + fdisk_get_units_per_sector(cxt)
|
||||||
&& read) {
|
&& read) {
|
||||||
if (!pa || !pa->start_follow_default)
|
if (!pa || !pa->start_follow_default)
|
||||||
fdisk_info(cxt, _("Sector %llu is already allocated."), temp);
|
fdisk_info(cxt, _("Sector %ju is already allocated."),
|
||||||
|
(uintmax_t) temp);
|
||||||
temp = start;
|
temp = start;
|
||||||
read = 0;
|
read = 0;
|
||||||
if (pa && fdisk_partition_has_start(pa))
|
if (pa && fdisk_partition_has_start(pa))
|
||||||
|
@ -1513,12 +1508,13 @@ static void check(struct fdisk_context *cxt, size_t n,
|
||||||
"maximum %d"), n, h + 1, cxt->geom.heads);
|
"maximum %d"), n, h + 1, cxt->geom.heads);
|
||||||
if (real_s >= cxt->geom.sectors)
|
if (real_s >= cxt->geom.sectors)
|
||||||
fdisk_warnx(cxt, _("Partition %zu: sector %d greater than "
|
fdisk_warnx(cxt, _("Partition %zu: sector %d greater than "
|
||||||
"maximum %llu"), n, s, cxt->geom.sectors);
|
"maximum %ju"), n, s,
|
||||||
|
(uintmax_t) cxt->geom.sectors);
|
||||||
if (real_c >= cxt->geom.cylinders)
|
if (real_c >= cxt->geom.cylinders)
|
||||||
fdisk_warnx(cxt, _("Partition %zu: cylinder %d greater than "
|
fdisk_warnx(cxt, _("Partition %zu: cylinder %d greater than "
|
||||||
"maximum %llu"),
|
"maximum %ju"),
|
||||||
n, real_c + 1,
|
n, real_c + 1,
|
||||||
cxt->geom.cylinders);
|
(uintmax_t) cxt->geom.cylinders);
|
||||||
|
|
||||||
if (cxt->geom.cylinders <= 1024 && start != total)
|
if (cxt->geom.cylinders <= 1024 && start != total)
|
||||||
fdisk_warnx(cxt, _("Partition %zu: previous sectors %u "
|
fdisk_warnx(cxt, _("Partition %zu: previous sectors %u "
|
||||||
|
@ -1704,11 +1700,11 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
|
||||||
if (!nerrors) {
|
if (!nerrors) {
|
||||||
fdisk_info(cxt, _("No errors detected."));
|
fdisk_info(cxt, _("No errors detected."));
|
||||||
if (total > n_sectors)
|
if (total > n_sectors)
|
||||||
fdisk_info(cxt, _("Total allocated sectors %llu greater "
|
fdisk_info(cxt, _("Total allocated sectors %ju greater "
|
||||||
"than the maximum %llu."), total, n_sectors);
|
"than the maximum %ju."), (uintmax_t) total, (uintmax_t) n_sectors);
|
||||||
else if (total < n_sectors)
|
else if (total < n_sectors)
|
||||||
fdisk_info(cxt, _("Remaining %lld unallocated %ld-byte "
|
fdisk_info(cxt, _("Remaining %ju unallocated %ld-byte "
|
||||||
"sectors."), n_sectors - total, cxt->sector_size);
|
"sectors."), (uintmax_t) n_sectors - total, cxt->sector_size);
|
||||||
} else
|
} else
|
||||||
fdisk_warnx(cxt,
|
fdisk_warnx(cxt,
|
||||||
P_("%d error detected.", "%d errors detected.", nerrors),
|
P_("%d error detected.", "%d errors detected.", nerrors),
|
||||||
|
@ -1873,10 +1869,10 @@ static int dos_add_partition(struct fdisk_context *cxt,
|
||||||
msg = _("All space for primary partitions is in use.");
|
msg = _("All space for primary partitions is in use.");
|
||||||
|
|
||||||
if (pa && fdisk_partition_has_start(pa)) {
|
if (pa && fdisk_partition_has_start(pa)) {
|
||||||
fdisk_warnx(cxt, msg);
|
fdisk_warnx(cxt, "%s", msg);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
fdisk_info(cxt, msg);
|
fdisk_info(cxt, "%s", msg);
|
||||||
}
|
}
|
||||||
DBG(LABEL, ul_debug("DOS: trying logical"));
|
DBG(LABEL, ul_debug("DOS: trying logical"));
|
||||||
rc = add_logical(cxt, pa, &res);
|
rc = add_logical(cxt, pa, &res);
|
||||||
|
@ -2440,10 +2436,8 @@ static int dos_reorder(struct fdisk_context *cxt)
|
||||||
struct pte *pei, *pek;
|
struct pte *pei, *pek;
|
||||||
size_t i,k;
|
size_t i,k;
|
||||||
|
|
||||||
if (!wrong_p_order(cxt, NULL)) {
|
if (!wrong_p_order(cxt, NULL))
|
||||||
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
while ((i = wrong_p_order(cxt, &k)) != 0 && i < 4) {
|
while ((i = wrong_p_order(cxt, &k)) != 0 && i < 4) {
|
||||||
/* partition i should have come earlier, move it */
|
/* partition i should have come earlier, move it */
|
||||||
|
@ -2500,10 +2494,11 @@ int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the default start is at the second sector of the disk or at the
|
/* The safe start is at the second sector, but some use-cases require
|
||||||
* second sector of the extended partition
|
* to have MBR within the first partition , so default to the first
|
||||||
|
* sector of the disk or at the second sector of the extended partition
|
||||||
*/
|
*/
|
||||||
free_start = pe->offset ? pe->offset + 1 : 1;
|
free_start = pe->offset ? pe->offset + 1 : 0;
|
||||||
|
|
||||||
curr_start = get_abs_partition_start(pe);
|
curr_start = get_abs_partition_start(pe);
|
||||||
|
|
||||||
|
@ -2543,6 +2538,11 @@ int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i)
|
||||||
dos_partition_set_start(p, new);
|
dos_partition_set_start(p, new);
|
||||||
|
|
||||||
partition_set_changed(cxt, i, 1);
|
partition_set_changed(cxt, i, 1);
|
||||||
|
|
||||||
|
if (new == 0)
|
||||||
|
fdisk_info(cxt, _("The new beginning of the partition overlaps the disk "
|
||||||
|
"label area. Be very careful when using the partition. "
|
||||||
|
"You can lose all your partitions on the disk."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
#define EFI_PMBR_OSTYPE 0xEE
|
#define EFI_PMBR_OSTYPE 0xEE
|
||||||
#define MSDOS_MBR_SIGNATURE 0xAA55
|
#define MSDOS_MBR_SIGNATURE 0xAA55
|
||||||
#define GPT_PART_NAME_LEN (72 / sizeof(uint16_t))
|
#define GPT_PART_NAME_LEN (72 / sizeof(uint16_t))
|
||||||
#define GPT_NPARTITIONS FDISK_GPT_NPARTITIONS_DEFAULT
|
#define GPT_NPARTITIONS ((size_t) FDISK_GPT_NPARTITIONS_DEFAULT)
|
||||||
|
|
||||||
/* Globally unique identifier */
|
/* Globally unique identifier */
|
||||||
struct gpt_guid {
|
struct gpt_guid {
|
||||||
|
@ -951,7 +952,7 @@ static int valid_pmbr(struct fdisk_context *cxt)
|
||||||
|
|
||||||
fdisk_warnx(cxt, _("GPT PMBR size mismatch (%"PRIu64" != %"PRIu64") "
|
fdisk_warnx(cxt, _("GPT PMBR size mismatch (%"PRIu64" != %"PRIu64") "
|
||||||
"will be corrected by write."),
|
"will be corrected by write."),
|
||||||
sz_lba, cxt->total_sectors - 1ULL);
|
sz_lba, cxt->total_sectors - (uint64_t) 1);
|
||||||
|
|
||||||
/* Note that gpt_write_pmbr() overwrites PMBR, but we want to keep it valid already
|
/* Note that gpt_write_pmbr() overwrites PMBR, but we want to keep it valid already
|
||||||
* in memory too to disable warnings when valid_pmbr() called next time */
|
* in memory too to disable warnings when valid_pmbr() called next time */
|
||||||
|
@ -2677,7 +2678,7 @@ static int gpt_create_disklabel(struct fdisk_context *cxt)
|
||||||
fdisk_info(cxt, _("Created a new GPT disklabel (GUID: %s)."), str);
|
fdisk_info(cxt, _("Created a new GPT disklabel (GUID: %s)."), str);
|
||||||
|
|
||||||
if (gpt_get_nentries(gpt) < GPT_NPARTITIONS)
|
if (gpt_get_nentries(gpt) < GPT_NPARTITIONS)
|
||||||
fdisk_info(cxt, _("The maximal number of partitions is %d (default is %d)."),
|
fdisk_info(cxt, _("The maximal number of partitions is %zu (default is %zu)."),
|
||||||
gpt_get_nentries(gpt), GPT_NPARTITIONS);
|
gpt_get_nentries(gpt), GPT_NPARTITIONS);
|
||||||
done:
|
done:
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -2758,7 +2759,7 @@ static int gpt_check_table_overlap(struct fdisk_context *cxt,
|
||||||
}
|
}
|
||||||
if (gpt_partition_end(e) > last_usable) {
|
if (gpt_partition_end(e) > last_usable) {
|
||||||
fdisk_warnx(cxt, _("Partition #%zu out of range (maximal end is %"PRIu64" sectors)"),
|
fdisk_warnx(cxt, _("Partition #%zu out of range (maximal end is %"PRIu64" sectors)"),
|
||||||
i + 1, last_usable - 1ULL);
|
i + 1, last_usable - (uint64_t) 1);
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2806,7 +2807,7 @@ int fdisk_gpt_set_npartitions(struct fdisk_context *cxt, uint32_t nents)
|
||||||
fdisk_warnx(cxt, _("The partition entry size is zero."));
|
fdisk_warnx(cxt, _("The partition entry size is zero."));
|
||||||
else
|
else
|
||||||
fdisk_warnx(cxt, _("The number of the partition has to be smaller than %zu."),
|
fdisk_warnx(cxt, _("The number of the partition has to be smaller than %zu."),
|
||||||
UINT32_MAX / entry_size);
|
(size_t) UINT32_MAX / entry_size);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2858,7 +2859,7 @@ int fdisk_gpt_set_npartitions(struct fdisk_context *cxt, uint32_t nents)
|
||||||
/* update library info */
|
/* update library info */
|
||||||
cxt->label->nparts_max = gpt_get_nentries(gpt);
|
cxt->label->nparts_max = gpt_get_nentries(gpt);
|
||||||
|
|
||||||
fdisk_info(cxt, _("Partition table length changed from %"PRIu32" to %"PRIu64"."),
|
fdisk_info(cxt, _("Partition table length changed from %"PRIu32" to %"PRIu32"."),
|
||||||
old_nents, nents);
|
old_nents, nents);
|
||||||
|
|
||||||
fdisk_label_set_changed(cxt->label, 1);
|
fdisk_label_set_changed(cxt->label, 1);
|
||||||
|
@ -3096,10 +3097,8 @@ static int gpt_reorder(struct fdisk_context *cxt)
|
||||||
(const void *) gpt_get_entry(gpt, i),
|
(const void *) gpt_get_entry(gpt, i),
|
||||||
(const void *) gpt_get_entry(gpt, i + 1)) > 0;
|
(const void *) gpt_get_entry(gpt, i + 1)) > 0;
|
||||||
|
|
||||||
if (!mess) {
|
if (!mess)
|
||||||
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
qsort(gpt->ents, nparts, sizeof(struct gpt_entry),
|
qsort(gpt->ents, nparts, sizeof(struct gpt_entry),
|
||||||
gpt_entry_cmp_start);
|
gpt_entry_cmp_start);
|
||||||
|
|
|
@ -583,12 +583,28 @@ int fdisk_toggle_partition_flag(struct fdisk_context *cxt,
|
||||||
*/
|
*/
|
||||||
int fdisk_reorder_partitions(struct fdisk_context *cxt)
|
int fdisk_reorder_partitions(struct fdisk_context *cxt)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (!cxt || !cxt->label)
|
if (!cxt || !cxt->label)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!cxt->label->op->reorder)
|
if (!cxt->label->op->reorder)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
return cxt->label->op->reorder(cxt);
|
rc = cxt->label->op->reorder(cxt);
|
||||||
|
|
||||||
|
switch (rc) {
|
||||||
|
case 0:
|
||||||
|
fdisk_info(cxt, _("Partitions order fixed."));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fdisk_warnx(cxt, _("Failed to fix partitions order."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -875,9 +875,12 @@ size_t fdisk_ask_menu_get_nitems(struct fdisk_ask *ask);
|
||||||
int fdisk_ask_print_get_errno(struct fdisk_ask *ask);
|
int fdisk_ask_print_get_errno(struct fdisk_ask *ask);
|
||||||
const char *fdisk_ask_print_get_mesg(struct fdisk_ask *ask);
|
const char *fdisk_ask_print_get_mesg(struct fdisk_ask *ask);
|
||||||
|
|
||||||
int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...);
|
int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...)
|
||||||
int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...);
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...);
|
int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
/* utils.h */
|
/* utils.h */
|
||||||
extern char *fdisk_partname(const char *dev, size_t partno);
|
extern char *fdisk_partname(const char *dev, size_t partno);
|
||||||
|
|
|
@ -987,9 +987,10 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
|
||||||
/* otherwise print error and use truncated version */
|
/* otherwise print error and use truncated version */
|
||||||
fdisk_warnx(cxt,
|
fdisk_warnx(cxt,
|
||||||
_("BLKGETSIZE ioctl failed on %s. "
|
_("BLKGETSIZE ioctl failed on %s. "
|
||||||
"Using geometry cylinder value of %llu. "
|
"Using geometry cylinder value of %ju. "
|
||||||
"This value may be truncated for devices "
|
"This value may be truncated for devices "
|
||||||
"> 33.8 GB."), cxt->dev_path, cxt->geom.cylinders);
|
"> 33.8 GB."), cxt->dev_path,
|
||||||
|
(uintmax_t) cxt->geom.cylinders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,10 +83,10 @@ static void set_partition(struct fdisk_context *cxt, size_t i,
|
||||||
fdisk_label_get_parttype_from_code(cxt->label, sysid);
|
fdisk_label_get_parttype_from_code(cxt->label, sysid);
|
||||||
|
|
||||||
if (start / (cxt->geom.heads * cxt->geom.sectors) > UINT32_MAX)
|
if (start / (cxt->geom.heads * cxt->geom.sectors) > UINT32_MAX)
|
||||||
fdisk_warnx(cxt, _("%#zu: start cylinder overflows Sun label limits"), i+1);
|
fdisk_warnx(cxt, _("#%zu: start cylinder overflows Sun label limits"), i+1);
|
||||||
|
|
||||||
if (stop - start > UINT32_MAX)
|
if (stop - start > UINT32_MAX)
|
||||||
fdisk_warnx(cxt, _("%#zu: number of sectors overflow Sun label limits"), i+1);
|
fdisk_warnx(cxt, _("#%zu: number of sectors overflow Sun label limits"), i+1);
|
||||||
|
|
||||||
sunlabel->vtoc.infos[i].id = cpu_to_be16(sysid);
|
sunlabel->vtoc.infos[i].id = cpu_to_be16(sysid);
|
||||||
sunlabel->vtoc.infos[i].flags = cpu_to_be16(0);
|
sunlabel->vtoc.infos[i].flags = cpu_to_be16(0);
|
||||||
|
@ -246,10 +246,10 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
|
||||||
} else {
|
} else {
|
||||||
fdisk_warnx(cxt,
|
fdisk_warnx(cxt,
|
||||||
_("BLKGETSIZE ioctl failed on %s. "
|
_("BLKGETSIZE ioctl failed on %s. "
|
||||||
"Using geometry cylinder value of %llu. "
|
"Using geometry cylinder value of %ju. "
|
||||||
"This value may be truncated for devices "
|
"This value may be truncated for devices "
|
||||||
"> 33.8 GB."),
|
"> 33.8 GB."),
|
||||||
cxt->dev_path, cxt->geom.cylinders);
|
cxt->dev_path, (uintmax_t) cxt->geom.cylinders);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ask_geom(cxt);
|
ask_geom(cxt);
|
||||||
|
|
|
@ -81,7 +81,7 @@ lib_mount = library(
|
||||||
link_with : [lib_common,
|
link_with : [lib_common,
|
||||||
lib_blkid],
|
lib_blkid],
|
||||||
dependencies : [lib_selinux,
|
dependencies : [lib_selinux,
|
||||||
lib_cryptsetup,
|
get_option('cryptsetup-dlopen').enabled() ? lib_dl : lib_cryptsetup,
|
||||||
realtime_libs],
|
realtime_libs],
|
||||||
install : build_libmount)
|
install : build_libmount)
|
||||||
|
|
||||||
|
|
|
@ -220,9 +220,12 @@ PyMODINIT_FUNC initpylibmount(void)
|
||||||
if (!(pylibmount_debug_mask & PYMNT_DEBUG_INIT)) {
|
if (!(pylibmount_debug_mask & PYMNT_DEBUG_INIT)) {
|
||||||
char *str = getenv("PYLIBMOUNT_DEBUG");
|
char *str = getenv("PYLIBMOUNT_DEBUG");
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
pylibmount_debug_mask = 0;
|
pylibmount_debug_mask = 0;
|
||||||
if (str)
|
if (str)
|
||||||
pylibmount_debug_mask = strtoul(str, NULL, 0);
|
pylibmount_debug_mask = strtoul(str, NULL, 0);
|
||||||
|
if (errno)
|
||||||
|
pylibmount_debug_mask = 0;
|
||||||
|
|
||||||
pylibmount_debug_mask |= PYMNT_DEBUG_INIT;
|
pylibmount_debug_mask |= PYMNT_DEBUG_INIT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2702,7 +2702,7 @@ int mnt_context_strerror(struct libmnt_context *cxt __attribute__((__unused__)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, char *fmt, ...)
|
int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
|
|
|
@ -645,10 +645,7 @@ static int exec_helper(struct libmnt_context *cxt)
|
||||||
const char *args[14], *type;
|
const char *args[14], *type;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (setgid(getgid()) < 0)
|
if (drop_permissions() != 0)
|
||||||
_exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
if (setuid(getuid()) < 0)
|
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (!mnt_context_switch_origin_ns(cxt))
|
if (!mnt_context_switch_origin_ns(cxt))
|
||||||
|
|
|
@ -453,10 +453,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
|
||||||
struct libmnt_ns *ns_old;
|
struct libmnt_ns *ns_old;
|
||||||
const char *type = mnt_fs_get_fstype(cxt->fs);
|
const char *type = mnt_fs_get_fstype(cxt->fs);
|
||||||
const char *optstr;
|
const char *optstr;
|
||||||
char *user_id = NULL;
|
uid_t uid, entry_uid;
|
||||||
size_t sz;
|
|
||||||
uid_t uid;
|
|
||||||
char uidstr[sizeof(stringify_value(ULONG_MAX))];
|
|
||||||
|
|
||||||
*errsv = 0;
|
*errsv = 0;
|
||||||
|
|
||||||
|
@ -473,11 +470,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
|
||||||
optstr = mnt_fs_get_fs_options(cxt->fs);
|
optstr = mnt_fs_get_fs_options(cxt->fs);
|
||||||
if (!optstr)
|
if (!optstr)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (mnt_optstr_get_uid(optstr, "user_id", &entry_uid) != 0)
|
||||||
if (mnt_optstr_get_option(optstr, "user_id", &user_id, &sz) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sz == 0 || user_id == NULL)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* get current user */
|
/* get current user */
|
||||||
|
@ -494,8 +487,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(uidstr, sizeof(uidstr), "%lu", (unsigned long) uid);
|
return uid == entry_uid;
|
||||||
return strncmp(user_id, uidstr, sz) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -696,10 +688,7 @@ static int exec_helper(struct libmnt_context *cxt)
|
||||||
const char *args[12], *type;
|
const char *args[12], *type;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (setgid(getgid()) < 0)
|
if (drop_permissions() != 0)
|
||||||
_exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
if (setuid(getuid()) < 0)
|
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (!mnt_context_switch_origin_ns(cxt))
|
if (!mnt_context_switch_origin_ns(cxt))
|
||||||
|
|
|
@ -61,8 +61,9 @@ static size_t crypt_hex_to_bytes(const char *hex, char **result)
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
memcpy(buf, &hex[i * 2], 2);
|
memcpy(buf, &hex[i * 2], 2);
|
||||||
|
errno = 0;
|
||||||
bytes[i] = strtoul(buf, &endp, 16);
|
bytes[i] = strtoul(buf, &endp, 16);
|
||||||
if (endp != &buf[2]) {
|
if (errno || endp != &buf[2]) {
|
||||||
free(bytes);
|
free(bytes);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,8 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
|
||||||
const char *backing_file, *optstr;
|
const char *backing_file, *optstr;
|
||||||
char *val = NULL, *key = NULL, *root_hash_binary = NULL, *mapper_device = NULL,
|
char *val = NULL, *key = NULL, *root_hash_binary = NULL, *mapper_device = NULL,
|
||||||
*mapper_device_full = NULL, *backing_file_basename = NULL, *root_hash = NULL,
|
*mapper_device_full = NULL, *backing_file_basename = NULL, *root_hash = NULL,
|
||||||
*hash_device = NULL, *root_hash_file = NULL, *fec_device = NULL, *hash_sig = NULL;
|
*hash_device = NULL, *root_hash_file = NULL, *fec_device = NULL, *hash_sig = NULL,
|
||||||
|
*root_hash_sig_file = NULL;
|
||||||
size_t len, hash_size, hash_sig_size = 0, keysize = 0;
|
size_t len, hash_size, hash_sig_size = 0, keysize = 0;
|
||||||
struct crypt_params_verity crypt_params = {};
|
struct crypt_params_verity crypt_params = {};
|
||||||
struct crypt_device *crypt_dev = NULL;
|
struct crypt_device *crypt_dev = NULL;
|
||||||
|
@ -217,7 +219,10 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
|
||||||
*/
|
*/
|
||||||
if (rc == 0 && (cxt->user_mountflags & MNT_MS_ROOT_HASH_SIG) &&
|
if (rc == 0 && (cxt->user_mountflags & MNT_MS_ROOT_HASH_SIG) &&
|
||||||
mnt_optstr_get_option(optstr, "verity.roothashsig", &val, &len) == 0 && val) {
|
mnt_optstr_get_option(optstr, "verity.roothashsig", &val, &len) == 0 && val) {
|
||||||
rc = ul_path_stat(NULL, &hash_sig_st, val);
|
root_hash_sig_file = strndup(val, len);
|
||||||
|
rc = root_hash_sig_file ? 0 : -ENOMEM;
|
||||||
|
if (rc == 0)
|
||||||
|
rc = ul_path_stat(NULL, &hash_sig_st, root_hash_sig_file);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
rc = !S_ISREG(hash_sig_st.st_mode) || !hash_sig_st.st_size ? -EINVAL : 0;
|
rc = !S_ISREG(hash_sig_st.st_mode) || !hash_sig_st.st_size ? -EINVAL : 0;
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
|
@ -226,7 +231,7 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
|
||||||
rc = hash_sig ? 0 : -ENOMEM;
|
rc = hash_sig ? 0 : -ENOMEM;
|
||||||
}
|
}
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
rc = ul_path_read(NULL, hash_sig, hash_sig_size, val);
|
rc = ul_path_read(NULL, hash_sig, hash_sig_size, root_hash_sig_file);
|
||||||
rc = rc < (int)hash_sig_size ? -1 : 0;
|
rc = rc < (int)hash_sig_size ? -1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,6 +415,7 @@ done:
|
||||||
free(hash_device);
|
free(hash_device);
|
||||||
free(root_hash);
|
free(root_hash);
|
||||||
free(root_hash_file);
|
free(root_hash_file);
|
||||||
|
free(root_hash_sig_file);
|
||||||
free(fec_device);
|
free(fec_device);
|
||||||
free(hash_sig);
|
free(hash_sig);
|
||||||
free(key);
|
free(key);
|
||||||
|
|
|
@ -399,6 +399,7 @@ extern const struct libmnt_optmap *mnt_optmap_get_entry(
|
||||||
const struct libmnt_optmap **mapent);
|
const struct libmnt_optmap **mapent);
|
||||||
|
|
||||||
/* optstr.c */
|
/* optstr.c */
|
||||||
|
extern int mnt_optstr_get_uid(const char *optstr, const char *name, uid_t *uid);
|
||||||
extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end);
|
extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end);
|
||||||
extern int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next);
|
extern int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next);
|
||||||
extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next);
|
extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next);
|
||||||
|
@ -454,7 +455,8 @@ extern int mnt_context_set_tabfilter(struct libmnt_context *cxt,
|
||||||
int (*fltr)(struct libmnt_fs *, void *),
|
int (*fltr)(struct libmnt_fs *, void *),
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
extern int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, char *fmt, ...);
|
extern int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, const char *fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
extern int mnt_context_get_mount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);
|
extern int mnt_context_get_mount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);
|
||||||
extern int mnt_context_get_umount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);
|
extern int mnt_context_get_umount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);
|
||||||
|
|
||||||
|
|
|
@ -1076,6 +1076,48 @@ int mnt_optstr_fix_user(char **optstr)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts value from @optstr addressed by @name to uid.
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, 1 if not found, <0 on error
|
||||||
|
*/
|
||||||
|
int mnt_optstr_get_uid(const char *optstr, const char *name, uid_t *uid)
|
||||||
|
{
|
||||||
|
char *value = NULL;
|
||||||
|
size_t valsz = 0;
|
||||||
|
char buf[sizeof(stringify_value(UINT64_MAX))];
|
||||||
|
int rc;
|
||||||
|
uint64_t num;
|
||||||
|
|
||||||
|
assert(optstr);
|
||||||
|
assert(name);
|
||||||
|
assert(uid);
|
||||||
|
|
||||||
|
rc = mnt_optstr_get_option(optstr, name, &value, &valsz);
|
||||||
|
if (rc != 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (valsz > sizeof(buf) - 1) {
|
||||||
|
rc = -ERANGE;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
mem2strcpy(buf, value, valsz, sizeof(buf));
|
||||||
|
|
||||||
|
rc = ul_strtou64(buf, &num, 10);
|
||||||
|
if (rc != 0)
|
||||||
|
goto fail;
|
||||||
|
if (num > ULONG_MAX || (uid_t) num != num) {
|
||||||
|
rc = -ERANGE;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
*uid = (uid_t) num;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
DBG(UTILS, ul_debug("failed to convert '%s'= to number [rc=%d]", name, rc));
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mnt_match_options:
|
* mnt_match_options:
|
||||||
* @optstr: options string
|
* @optstr: options string
|
||||||
|
|
|
@ -50,11 +50,12 @@ static const char *next_s32(const char *s, int *num, int *rc)
|
||||||
if (!s || !*s)
|
if (!s || !*s)
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
*rc = -EINVAL;
|
*rc = -EINVAL;
|
||||||
*num = strtol(s, &end, 10);
|
*num = strtol(s, &end, 10);
|
||||||
if (end == NULL || s == end)
|
if (end == NULL || s == end)
|
||||||
return s;
|
return s;
|
||||||
if (*end == ' ' || *end == '\t' || *end == '\0')
|
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
|
||||||
*rc = 0;
|
*rc = 0;
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@ -66,11 +67,12 @@ static const char *next_u64(const char *s, uint64_t *num, int *rc)
|
||||||
if (!s || !*s)
|
if (!s || !*s)
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
*rc = -EINVAL;
|
*rc = -EINVAL;
|
||||||
*num = (uint64_t) strtoumax(s, &end, 10);
|
*num = (uint64_t) strtoumax(s, &end, 10);
|
||||||
if (end == NULL || s == end)
|
if (end == NULL || s == end)
|
||||||
return s;
|
return s;
|
||||||
if (*end == ' ' || *end == '\t' || *end == '\0')
|
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
|
||||||
*rc = 0;
|
*rc = 0;
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@ -225,11 +227,6 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, const char *s)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove "\040(deleted)" suffix */
|
|
||||||
p = (char *) endswith(fs->target, PATH_DELETED_SUFFIX);
|
|
||||||
if (p && *p)
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
s = skip_separator(s);
|
s = skip_separator(s);
|
||||||
|
|
||||||
/* (6) vfs options (fs-independent) */
|
/* (6) vfs options (fs-independent) */
|
||||||
|
|
|
@ -119,7 +119,7 @@ static int do_print_table(struct libscols_table *tb, int *is_empty)
|
||||||
if (scols_table_is_json(tb)) {
|
if (scols_table_is_json(tb)) {
|
||||||
ul_jsonwrt_init(&tb->json, tb->out, 0);
|
ul_jsonwrt_init(&tb->json, tb->out, 0);
|
||||||
ul_jsonwrt_root_open(&tb->json);
|
ul_jsonwrt_root_open(&tb->json);
|
||||||
ul_jsonwrt_array_open(&tb->json, tb->name);
|
ul_jsonwrt_array_open(&tb->json, tb->name ? tb->name : "");
|
||||||
ul_jsonwrt_array_close(&tb->json);
|
ul_jsonwrt_array_close(&tb->json);
|
||||||
ul_jsonwrt_root_close(&tb->json);
|
ul_jsonwrt_root_close(&tb->json);
|
||||||
} else if (is_empty)
|
} else if (is_empty)
|
||||||
|
@ -134,7 +134,7 @@ static int do_print_table(struct libscols_table *tb, int *is_empty)
|
||||||
|
|
||||||
if (scols_table_is_json(tb)) {
|
if (scols_table_is_json(tb)) {
|
||||||
ul_jsonwrt_root_open(&tb->json);
|
ul_jsonwrt_root_open(&tb->json);
|
||||||
ul_jsonwrt_array_open(&tb->json, tb->name);
|
ul_jsonwrt_array_open(&tb->json, tb->name ? tb->name : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb->format == SCOLS_FMT_HUMAN)
|
if (tb->format == SCOLS_FMT_HUMAN)
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void check_padding_debug(struct libscols_table *tb)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
assert(libsmartcols_debug_mask); /* debug has to be enabled! */
|
assert(libsmartcols_debug_mask); /* debug has to be already initialized! */
|
||||||
|
|
||||||
str = getenv("LIBSMARTCOLS_DEBUG_PADDING");
|
str = getenv("LIBSMARTCOLS_DEBUG_PADDING");
|
||||||
if (!str || (strcmp(str, "on") != 0 && strcmp(str, "1") != 0))
|
if (!str || (strcmp(str, "on") != 0 && strcmp(str, "1") != 0))
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "c.h"
|
||||||
#include "uuidP.h"
|
#include "uuidP.h"
|
||||||
|
|
||||||
int uuid_parse(const char *in, uuid_t uu)
|
int uuid_parse(const char *in, uuid_t uu)
|
||||||
|
@ -70,16 +71,28 @@ int uuid_parse_range(const char *in_start, const char *in_end, uuid_t uu)
|
||||||
if (!isxdigit(*cp))
|
if (!isxdigit(*cp))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
uuid.time_low = strtoul(in_start, NULL, 16);
|
uuid.time_low = strtoul(in_start, NULL, 16);
|
||||||
|
|
||||||
|
if (!errno)
|
||||||
uuid.time_mid = strtoul(in_start+9, NULL, 16);
|
uuid.time_mid = strtoul(in_start+9, NULL, 16);
|
||||||
|
if (!errno)
|
||||||
uuid.time_hi_and_version = strtoul(in_start+14, NULL, 16);
|
uuid.time_hi_and_version = strtoul(in_start+14, NULL, 16);
|
||||||
|
if (!errno)
|
||||||
uuid.clock_seq = strtoul(in_start+19, NULL, 16);
|
uuid.clock_seq = strtoul(in_start+19, NULL, 16);
|
||||||
|
if (errno)
|
||||||
|
return -1;
|
||||||
|
|
||||||
cp = in_start+24;
|
cp = in_start+24;
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
for (i=0; i < 6; i++) {
|
for (i=0; i < 6; i++) {
|
||||||
buf[0] = *cp++;
|
buf[0] = *cp++;
|
||||||
buf[1] = *cp++;
|
buf[1] = *cp++;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
uuid.node[i] = strtoul(buf, NULL, 16);
|
uuid.node[i] = strtoul(buf, NULL, 16);
|
||||||
|
if (errno)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid_pack(&uuid, uu);
|
uuid_pack(&uuid, uu);
|
||||||
|
|
|
@ -109,7 +109,7 @@ chfn_chsh_sources = \
|
||||||
login-utils/ch-common.c
|
login-utils/ch-common.c
|
||||||
chfn_chsh_cflags = $(SUID_CFLAGS) $(AM_CFLAGS)
|
chfn_chsh_cflags = $(SUID_CFLAGS) $(AM_CFLAGS)
|
||||||
chfn_chsh_ldflags = $(SUID_LDFLAGS) $(AM_LDFLAGS)
|
chfn_chsh_ldflags = $(SUID_LDFLAGS) $(AM_LDFLAGS)
|
||||||
chfn_chsh_ldadd = libcommon.la $(READLINE_LIBS)
|
chfn_chsh_ldadd = libcommon.la
|
||||||
|
|
||||||
if CHFN_CHSH_PASSWORD
|
if CHFN_CHSH_PASSWORD
|
||||||
chfn_chsh_ldadd += -lpam
|
chfn_chsh_ldadd += -lpam
|
||||||
|
|
|
@ -56,11 +56,6 @@
|
||||||
# include "auth.h"
|
# include "auth.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
# define _FUNCTION_DEF
|
|
||||||
# include <readline/readline.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct finfo {
|
struct finfo {
|
||||||
char *full_name;
|
char *full_name;
|
||||||
char *office;
|
char *office;
|
||||||
|
@ -228,23 +223,18 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question,
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *buf;
|
char *buf;
|
||||||
#ifndef HAVE_LIBREADLINE
|
|
||||||
size_t dummy = 0;
|
size_t dummy = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!def_val)
|
if (!def_val)
|
||||||
def_val = "";
|
def_val = "";
|
||||||
while (true) {
|
while (true) {
|
||||||
printf("%s [%s]:", question, def_val);
|
printf("%s [%s]:", question, def_val);
|
||||||
__fpurge(stdin);
|
__fpurge(stdin);
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
rl_bind_key('\t', rl_insert);
|
|
||||||
if ((buf = readline(" ")) == NULL)
|
|
||||||
#else
|
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
|
|
||||||
if (getline(&buf, &dummy, stdin) < 0)
|
if (getline(&buf, &dummy, stdin) < 0)
|
||||||
#endif
|
|
||||||
errx(EXIT_FAILURE, _("Aborted."));
|
errx(EXIT_FAILURE, _("Aborted."));
|
||||||
|
|
||||||
/* remove white spaces from string end */
|
/* remove white spaces from string end */
|
||||||
ltrim_whitespace((unsigned char *) buf);
|
ltrim_whitespace((unsigned char *) buf);
|
||||||
len = rtrim_whitespace((unsigned char *) buf);
|
len = rtrim_whitespace((unsigned char *) buf);
|
||||||
|
|
|
@ -58,11 +58,6 @@
|
||||||
# include "auth.h"
|
# include "auth.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
# define _FUNCTION_DEF
|
|
||||||
# include <readline/readline.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct sinfo {
|
struct sinfo {
|
||||||
char *username;
|
char *username;
|
||||||
char *shell;
|
char *shell;
|
||||||
|
@ -121,33 +116,6 @@ static void print_shells(void)
|
||||||
endusershell();
|
endusershell();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
static char *shell_name_generator(const char *text, int state)
|
|
||||||
{
|
|
||||||
static size_t len;
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
setusershell();
|
|
||||||
len = strlen(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((s = getusershell())) {
|
|
||||||
if (strncmp(s, text, len) == 0)
|
|
||||||
return xstrdup(s);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char **shell_name_completion(const char *text,
|
|
||||||
int start __attribute__((__unused__)),
|
|
||||||
int end __attribute__((__unused__)))
|
|
||||||
{
|
|
||||||
rl_attempted_completion_over = 1;
|
|
||||||
return rl_completion_matches(text, shell_name_generator);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parse_argv () --
|
* parse_argv () --
|
||||||
* parse the command line arguments, and fill in "pinfo" with any
|
* parse the command line arguments, and fill in "pinfo" with any
|
||||||
|
@ -198,21 +166,16 @@ static char *ask_new_shell(char *question, char *oldshell)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *ans = NULL;
|
char *ans = NULL;
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
rl_attempted_completion_function = shell_name_completion;
|
|
||||||
#else
|
|
||||||
size_t dummy = 0;
|
size_t dummy = 0;
|
||||||
#endif
|
|
||||||
if (!oldshell)
|
if (!oldshell)
|
||||||
oldshell = "";
|
oldshell = "";
|
||||||
printf("%s [%s]:", question, oldshell);
|
printf("%s [%s]:", question, oldshell);
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
if ((ans = readline(" ")) == NULL)
|
|
||||||
#else
|
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
|
|
||||||
if (getline(&ans, &dummy, stdin) < 0)
|
if (getline(&ans, &dummy, stdin) < 0)
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* remove the newline at the end of ans. */
|
/* remove the newline at the end of ans. */
|
||||||
ltrim_whitespace((unsigned char *) ans);
|
ltrim_whitespace((unsigned char *) ans);
|
||||||
len = rtrim_whitespace((unsigned char *) ans);
|
len = rtrim_whitespace((unsigned char *) ans);
|
||||||
|
|
|
@ -1012,7 +1012,6 @@ static void loginpam_acct(struct login_context *cxt)
|
||||||
loginpam_err(pamh, rc);
|
loginpam_err(pamh, rc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the user information out of the password file for future use.
|
|
||||||
* First get the username that we are actually using, though.
|
* First get the username that we are actually using, though.
|
||||||
*/
|
*/
|
||||||
rc = loginpam_get_username(pamh, &cxt->username);
|
rc = loginpam_get_username(pamh, &cxt->username);
|
||||||
|
@ -1358,10 +1357,9 @@ static void initialize(int argc, char **argv, struct login_context *cxt)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef HAVE_CLOSE_RANGE
|
#ifdef HAVE_CLOSE_RANGE
|
||||||
close_range(STDERR_FILENO + 1, ~0U);
|
if (close_range(STDERR_FILENO + 1, ~0U, 0) < 0)
|
||||||
#else
|
|
||||||
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
|
|
||||||
#endif
|
#endif
|
||||||
|
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -474,55 +474,52 @@ static struct utmpx *get_last_btmp(struct lslogins_control *ctl, const char *use
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_utmp(char const *file, size_t *nents, struct utmpx **res)
|
static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **records)
|
||||||
{
|
{
|
||||||
size_t n_read = 0, n_alloc = 0;
|
size_t i, imax = 0;
|
||||||
struct utmpx *utmp = NULL, *u;
|
struct utmpx *ary = NULL;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if (utmpxname(file) < 0)
|
*nrecords = 0;
|
||||||
|
*records = NULL;
|
||||||
|
|
||||||
|
if (utmpxname(path) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
setutxent();
|
/* optimize allocation according to file size, the realloc() below is
|
||||||
|
* just fallback only */
|
||||||
|
if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) {
|
||||||
|
imax = st.st_size / sizeof(struct utmpx);
|
||||||
|
ary = xmalloc(imax * sizeof(struct utmpx));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; ; i++) {
|
||||||
|
struct utmpx *u;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
u = getutxent();
|
||||||
|
if (!u) {
|
||||||
|
if (errno)
|
||||||
|
goto fail;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == imax)
|
||||||
|
ary = xrealloc(ary, (imax *= 2) * sizeof(struct utmpx));
|
||||||
|
ary[i] = *u;
|
||||||
|
}
|
||||||
|
|
||||||
while ((u = getutxent()) != NULL) {
|
*nrecords = i;
|
||||||
if (n_read == n_alloc) {
|
*records = ary;
|
||||||
n_alloc += 32;
|
endutxent();
|
||||||
utmp = xrealloc(utmp, n_alloc * sizeof (struct utmpx));
|
return 0;
|
||||||
}
|
fail:
|
||||||
utmp[n_read++] = *u;
|
endutxent();
|
||||||
}
|
free(ary);
|
||||||
if (!u && errno) {
|
if (errno) {
|
||||||
free(utmp);
|
if (errno != EACCES)
|
||||||
|
err(EXIT_FAILURE, "%s", path);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
return -EINVAL;
|
||||||
endutxent();
|
|
||||||
|
|
||||||
*nents = n_read;
|
|
||||||
*res = utmp;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_wtmp(struct lslogins_control *ctl, char *path)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
rc = read_utmp(path, &ctl->wtmp_size, &ctl->wtmp);
|
|
||||||
if (rc < 0 && errno != EACCES)
|
|
||||||
err(EXIT_FAILURE, "%s", path);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_btmp(struct lslogins_control *ctl, char *path)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
rc = read_utmp(path, &ctl->btmp_size, &ctl->btmp);
|
|
||||||
if (rc < 0 && errno != EACCES)
|
|
||||||
err(EXIT_FAILURE, "%s", path);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_lastlog(struct lslogins_control *ctl, uid_t uid, void *dst, int what)
|
static void get_lastlog(struct lslogins_control *ctl, uid_t uid, void *dst, int what)
|
||||||
|
@ -565,6 +562,9 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
|
||||||
|
|
||||||
*list = xcalloc(1, ngroups * sizeof(gid_t));
|
*list = xcalloc(1, ngroups * sizeof(gid_t));
|
||||||
|
|
||||||
|
fprintf(stderr, "KZAK>>> alloc '%p' for %s\n", *list, pwd->pw_name);
|
||||||
|
|
||||||
|
|
||||||
/* now for the actual list of GIDs */
|
/* now for the actual list of GIDs */
|
||||||
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
|
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -757,7 +757,8 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
|
||||||
break;
|
break;
|
||||||
case COL_SGROUPS:
|
case COL_SGROUPS:
|
||||||
case COL_SGIDS:
|
case COL_SGIDS:
|
||||||
if (get_sgroups(&user->sgroups, &user->nsgroups, pwd))
|
if (!user->nsgroups &&
|
||||||
|
get_sgroups(&user->sgroups, &user->nsgroups, pwd) < 0)
|
||||||
err(EXIT_FAILURE, _("failed to get supplementary groups"));
|
err(EXIT_FAILURE, _("failed to get supplementary groups"));
|
||||||
break;
|
break;
|
||||||
case COL_HOME:
|
case COL_HOME:
|
||||||
|
@ -908,11 +909,14 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
|
||||||
|
|
||||||
static int str_to_uint(char *s, unsigned int *ul)
|
static int str_to_uint(char *s, unsigned int *ul)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end = NULL;
|
||||||
|
|
||||||
if (!s || !*s)
|
if (!s || !*s)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
*ul = strtoul(s, &end, 0);
|
*ul = strtoul(s, &end, 0);
|
||||||
if (!*end)
|
if (errno == 0 && end && !*end)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1048,7 +1052,6 @@ static int create_usertree(struct lslogins_control *ctl)
|
||||||
}
|
}
|
||||||
if (rc || !user)
|
if (rc || !user)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tsearch(user, &ctl->usertree, cmp_uid);
|
tsearch(user, &ctl->usertree, cmp_uid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1231,14 +1234,28 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
#ifdef HAVE_LIBSYSTEMD
|
||||||
|
static char *get_journal_data(sd_journal *j, const char *name)
|
||||||
|
{
|
||||||
|
const char *data = NULL, *p;
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
|
if (sd_journal_get_data(j, name, (const void **) &data, &len) < 0
|
||||||
|
|| !data || !len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Get rid of journal entry field identifiers */
|
||||||
|
p = strnchr(data, len, '=');
|
||||||
|
if (!p || !*(p + 1))
|
||||||
|
return NULL;
|
||||||
|
p++;
|
||||||
|
|
||||||
|
return xstrndup(p, len - (p - data));
|
||||||
|
}
|
||||||
|
|
||||||
static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode)
|
static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode)
|
||||||
{
|
{
|
||||||
sd_journal *j;
|
sd_journal *j;
|
||||||
char *match, *timestamp;
|
char *match;
|
||||||
uint64_t x;
|
|
||||||
time_t t;
|
|
||||||
const char *identifier, *pid, *message;
|
|
||||||
size_t identifier_len, pid_len, message_len;
|
|
||||||
|
|
||||||
if (journal_path)
|
if (journal_path)
|
||||||
sd_journal_open_directory(&j, journal_path, 0);
|
sd_journal_open_directory(&j, journal_path, 0);
|
||||||
|
@ -1252,30 +1269,27 @@ static void print_journal_tail(const char *journal_path, uid_t uid, size_t len,
|
||||||
sd_journal_previous_skip(j, len);
|
sd_journal_previous_skip(j, len);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (0 > sd_journal_get_data(j, "SYSLOG_IDENTIFIER",
|
char *id, *pid, *msg, *ts;
|
||||||
(const void **) &identifier, &identifier_len))
|
uint64_t x;
|
||||||
goto done;
|
time_t t;
|
||||||
if (0 > sd_journal_get_data(j, "_PID",
|
|
||||||
(const void **) &pid, &pid_len))
|
|
||||||
goto done;
|
|
||||||
if (0 > sd_journal_get_data(j, "MESSAGE",
|
|
||||||
(const void **) &message, &message_len))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
sd_journal_get_realtime_usec(j, &x);
|
sd_journal_get_realtime_usec(j, &x);
|
||||||
t = x / 1000000;
|
t = x / 1000000;
|
||||||
timestamp = make_time(time_mode, t);
|
ts = make_time(time_mode, t);
|
||||||
/* Get rid of journal entry field identifiers */
|
|
||||||
identifier = strchr(identifier, '=') + 1;
|
|
||||||
pid = strchr(pid, '=') + 1;
|
|
||||||
message = strchr(message, '=') + 1;
|
|
||||||
|
|
||||||
fprintf(stdout, "%s %s[%s]: %s\n", timestamp, identifier, pid,
|
id = get_journal_data(j, "SYSLOG_IDENTIFIER");
|
||||||
message);
|
pid = get_journal_data(j, "_PID");
|
||||||
free(timestamp);
|
msg = get_journal_data(j, "MESSAGE");
|
||||||
|
|
||||||
|
if (ts && id && pid && msg)
|
||||||
|
fprintf(stdout, "%s %s[%s]: %s\n", ts, id, pid, msg);
|
||||||
|
|
||||||
|
free(ts);
|
||||||
|
free(id);
|
||||||
|
free(pid);
|
||||||
|
free(msg);
|
||||||
} while (sd_journal_next(j));
|
} while (sd_journal_next(j));
|
||||||
|
|
||||||
done:
|
|
||||||
free(match);
|
free(match);
|
||||||
sd_journal_flush_matches(j);
|
sd_journal_flush_matches(j);
|
||||||
sd_journal_close(j);
|
sd_journal_close(j);
|
||||||
|
@ -1333,6 +1347,7 @@ static void free_user(void *f)
|
||||||
struct lslogins_user *u = f;
|
struct lslogins_user *u = f;
|
||||||
free(u->login);
|
free(u->login);
|
||||||
free(u->group);
|
free(u->group);
|
||||||
|
free(u->nprocs);
|
||||||
free(u->gecos);
|
free(u->gecos);
|
||||||
free(u->sgroups);
|
free(u->sgroups);
|
||||||
free(u->pwd_ctime);
|
free(u->pwd_ctime);
|
||||||
|
@ -1644,11 +1659,11 @@ int main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if (require_wtmp()) {
|
if (require_wtmp()) {
|
||||||
parse_wtmp(ctl, path_wtmp);
|
parse_utmpx(path_wtmp, &ctl->wtmp_size, &ctl->wtmp);
|
||||||
ctl->lastlogin_fd = open(path_lastlog, O_RDONLY, 0);
|
ctl->lastlogin_fd = open(path_lastlog, O_RDONLY, 0);
|
||||||
}
|
}
|
||||||
if (require_btmp())
|
if (require_btmp())
|
||||||
parse_btmp(ctl, path_btmp);
|
parse_utmpx(path_btmp, &ctl->btmp_size, &ctl->btmp);
|
||||||
|
|
||||||
if (logins || groups)
|
if (logins || groups)
|
||||||
get_ulist(ctl, logins, groups);
|
get_ulist(ctl, logins, groups);
|
||||||
|
|
|
@ -123,7 +123,7 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
{
|
{
|
||||||
char **look;
|
char **look;
|
||||||
int notfound = 1;
|
int notfound = 1;
|
||||||
char *pwd, *xpwd;
|
char *pwd, *xpwd, *spwd;
|
||||||
|
|
||||||
if (getuid() == 0)
|
if (getuid() == 0)
|
||||||
/* root may do anything */
|
/* root may do anything */
|
||||||
|
@ -144,8 +144,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
* as in /etc/passwd */
|
* as in /etc/passwd */
|
||||||
|
|
||||||
/* check /etc/gshadow */
|
/* check /etc/gshadow */
|
||||||
if (!(pwd = get_gshadow_pwd(ge->gr_name)))
|
spwd = get_gshadow_pwd(ge->gr_name);
|
||||||
pwd = ge->gr_passwd;
|
pwd = spwd ? spwd : ge->gr_passwd;
|
||||||
|
|
||||||
if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) {
|
if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) {
|
||||||
char *cbuf = crypt(xpwd, pwd);
|
char *cbuf = crypt(xpwd, pwd);
|
||||||
|
@ -162,6 +162,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(spwd);
|
||||||
|
|
||||||
/* default to denial */
|
/* default to denial */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,8 @@ static struct sigaction saved_sigchld;
|
||||||
static volatile sig_atomic_t alarm_rised;
|
static volatile sig_atomic_t alarm_rised;
|
||||||
static volatile sig_atomic_t sigchild;
|
static volatile sig_atomic_t sigchild;
|
||||||
|
|
||||||
|
#define SULOGIN_PASSWORD_BUFSIZ 128
|
||||||
|
|
||||||
#ifndef IUCLC
|
#ifndef IUCLC
|
||||||
# define IUCLC 0
|
# define IUCLC 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -602,13 +604,13 @@ static void setup(struct console *con)
|
||||||
* Ask for the password. Note that there is no default timeout as we normally
|
* Ask for the password. Note that there is no default timeout as we normally
|
||||||
* skip this during boot.
|
* skip this during boot.
|
||||||
*/
|
*/
|
||||||
static const char *getpasswd(struct console *con)
|
static char *getpasswd(struct console *con)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
struct termios tty;
|
struct termios tty;
|
||||||
static char pass[128], *ptr;
|
static char pass[SULOGIN_PASSWORD_BUFSIZ], *ptr;
|
||||||
struct chardata *cp;
|
struct chardata *cp;
|
||||||
const char *ret = pass;
|
char *ret = NULL;
|
||||||
unsigned char tc;
|
unsigned char tc;
|
||||||
char c, ascval;
|
char c, ascval;
|
||||||
int eightbit;
|
int eightbit;
|
||||||
|
@ -619,6 +621,7 @@ static const char *getpasswd(struct console *con)
|
||||||
cp = &con->cp;
|
cp = &con->cp;
|
||||||
tty = con->tio;
|
tty = con->tio;
|
||||||
|
|
||||||
|
ret = pass;
|
||||||
tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
|
tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
|
||||||
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ISIG);
|
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ISIG);
|
||||||
tc = (tcsetattr(fd, TCSAFLUSH, &tty) == 0);
|
tc = (tcsetattr(fd, TCSAFLUSH, &tty) == 0);
|
||||||
|
@ -711,6 +714,10 @@ quit:
|
||||||
tcfinal(con);
|
tcfinal(con);
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
out:
|
out:
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
if (ret == NULL)
|
||||||
|
explicit_bzero(pass, sizeof(pass));
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,7 +984,7 @@ int main(int argc, char **argv)
|
||||||
setup(con);
|
setup(con);
|
||||||
while (1) {
|
while (1) {
|
||||||
const char *passwd = pwd->pw_passwd;
|
const char *passwd = pwd->pw_passwd;
|
||||||
const char *answer;
|
char *answer;
|
||||||
int doshell = 0;
|
int doshell = 0;
|
||||||
int deny = !opt_e && locked_account_password(pwd->pw_passwd);
|
int deny = !opt_e && locked_account_password(pwd->pw_passwd);
|
||||||
|
|
||||||
|
@ -985,8 +992,12 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if ((answer = getpasswd(con)) == NULL)
|
if ((answer = getpasswd(con)) == NULL)
|
||||||
break;
|
break;
|
||||||
if (deny)
|
if (deny) {
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(answer, SULOGIN_PASSWORD_BUFSIZ);
|
||||||
|
#endif
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
/* no password or locked account */
|
/* no password or locked account */
|
||||||
if (!passwd[0] || locked_account_password(passwd))
|
if (!passwd[0] || locked_account_password(passwd))
|
||||||
|
@ -999,7 +1010,9 @@ int main(int argc, char **argv)
|
||||||
else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
|
else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
|
||||||
doshell++;
|
doshell++;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(answer, SULOGIN_PASSWORD_BUFSIZ);
|
||||||
|
#endif
|
||||||
if (doshell) {
|
if (doshell) {
|
||||||
/* sushell() unmask signals */
|
/* sushell() unmask signals */
|
||||||
sushell(pwd);
|
sushell(pwd);
|
||||||
|
|
|
@ -74,8 +74,16 @@ static time_t strtotime(const char *s_time)
|
||||||
static suseconds_t strtousec(const char *s_time)
|
static suseconds_t strtousec(const char *s_time)
|
||||||
{
|
{
|
||||||
const char *s = strchr(s_time, ',');
|
const char *s = strchr(s_time, ',');
|
||||||
if (s)
|
|
||||||
return (suseconds_t) atoi(s + 1);
|
if (s && *++s) {
|
||||||
|
suseconds_t us;
|
||||||
|
char *end = NULL;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
us = strtol(s, &end, 10);
|
||||||
|
if (errno == 0 && end && end > s)
|
||||||
|
return us;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +274,7 @@ static int gettok(char *line, char *dest, int size, int eatspace)
|
||||||
static void undump(FILE *in, FILE *out)
|
static void undump(FILE *in, FILE *out)
|
||||||
{
|
{
|
||||||
struct utmpx ut;
|
struct utmpx ut;
|
||||||
char s_addr[INET6_ADDRSTRLEN + 1], s_time[29], *linestart, *line;
|
char s_addr[INET6_ADDRSTRLEN + 1], s_time[29] = {}, *linestart, *line;
|
||||||
|
|
||||||
linestart = xmalloc(1024 * sizeof(*linestart));
|
linestart = xmalloc(1024 * sizeof(*linestart));
|
||||||
s_time[28] = 0;
|
s_time[28] = 0;
|
||||||
|
|
25
m4/ul.m4
25
m4/ul.m4
|
@ -67,28 +67,21 @@ AC_DEFUN([UL_SET_ARCH], [
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl UL_SET_FLAGS(CFLAGS, CPPFLAGS, LDFLAGS)
|
dnl UL_SET_LIBS(LIBS)
|
||||||
dnl
|
dnl
|
||||||
dnl Sets new global CFLAGS, CPPFLAGS and LDFLAG, the original
|
dnl Sets new global LIBS, the original setting could be restored by UL_RESTORE_LIBS()
|
||||||
dnl setting could be restored by UL_RESTORE_FLAGS()
|
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN([UL_SET_FLAGS], [
|
AC_DEFUN([UL_SET_LIBS], [
|
||||||
old_CFLAGS="$CFLAGS"
|
old_LIBS="$LIBS"
|
||||||
old_CPPFLAGS="$CPPFLAGS"
|
LIBS="$LIBS $1"
|
||||||
old_LDFLAGS="$LDFLAGS"
|
|
||||||
CFLAGS="$CFLAGS $1"
|
|
||||||
CPPFLAGS="$CPPFLAGS $2"
|
|
||||||
LDFLAGS="$LDFLAGS $3"
|
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl UL_RESTORE_FLAGS()
|
dnl UL_RESTORE_LIBS()
|
||||||
dnl
|
dnl
|
||||||
dnl Restores CFLAGS, CPPFLAGS and LDFLAG previously saved by UL_SET_FLAGS()
|
dnl Restores LIBS previously saved by UL_SET_LIBS()
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN([UL_RESTORE_FLAGS], [
|
AC_DEFUN([UL_RESTORE_LIBS], [
|
||||||
CFLAGS="$old_CFLAGS"
|
LIBS="$old_LIBS"
|
||||||
CPPFLAGS="$old_CPPFLAGS"
|
|
||||||
LDFLAGS="$old_LDFLAGS"
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
25
meson.build
25
meson.build
|
@ -264,11 +264,6 @@ lib_readline_static = dependency(
|
||||||
static : true,
|
static : true,
|
||||||
required : need_static_libs ? get_option('readline') : disabler())
|
required : need_static_libs ? get_option('readline') : disabler())
|
||||||
|
|
||||||
lib_pcre = dependency(
|
|
||||||
'libpcre2-posix',
|
|
||||||
required : get_option('libpcre2-posix'))
|
|
||||||
conf.set('HAVE_PCRE2_POSIX', lib_pcre.found() ? 1 : false)
|
|
||||||
|
|
||||||
lib_user = dependency(
|
lib_user = dependency(
|
||||||
'libuser',
|
'libuser',
|
||||||
version : '>= 0.58',
|
version : '>= 0.58',
|
||||||
|
@ -312,15 +307,24 @@ lib_cryptsetup = dependency(
|
||||||
required : get_option('cryptsetup'))
|
required : get_option('cryptsetup'))
|
||||||
conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
|
conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
|
||||||
|
|
||||||
lib_cryptsetup_dl = dependency(
|
if not get_option('cryptsetup').disabled() and get_option('cryptsetup-dlopen').enabled()
|
||||||
'dl',
|
lib_dl = cc.find_library(
|
||||||
required : get_option('cryptsetup-dlopen'))
|
'libdl',
|
||||||
conf.set('CRYPTSETUP_VIA_DLOPEN', lib_cryptsetup_dl.found() ? 1 : false)
|
required : true)
|
||||||
|
conf.set('CRYPTSETUP_VIA_DLOPEN', 1)
|
||||||
|
summary('cryptsetup support (dlopen)',
|
||||||
|
'enabled',
|
||||||
|
section : 'components')
|
||||||
|
else
|
||||||
|
summary('cryptsetup support',
|
||||||
|
lib_cryptsetup.found() ? 'enabled' : 'disabled',
|
||||||
|
section : 'components')
|
||||||
|
endif
|
||||||
|
|
||||||
have = cc.has_function(
|
have = cc.has_function(
|
||||||
'crypt_activate_by_signed_key',
|
'crypt_activate_by_signed_key',
|
||||||
dependencies : lib_cryptsetup)
|
dependencies : lib_cryptsetup)
|
||||||
conf.set('HAVE_CRYPTSETUP', have ? 1 : false)
|
conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
|
||||||
|
|
||||||
lib_cap_ng = dependency(
|
lib_cap_ng = dependency(
|
||||||
'libcap-ng')
|
'libcap-ng')
|
||||||
|
@ -2532,7 +2536,6 @@ exe = executable(
|
||||||
hardlink_sources,
|
hardlink_sources,
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
link_with : [lib_common],
|
link_with : [lib_common],
|
||||||
dependencies : [lib_pcre],
|
|
||||||
install_dir : usrbin_exec_dir,
|
install_dir : usrbin_exec_dir,
|
||||||
install : true)
|
install : true)
|
||||||
if not is_disabler(exe)
|
if not is_disabler(exe)
|
||||||
|
|
|
@ -28,7 +28,7 @@ usrbin_exec_PROGRAMS += logger
|
||||||
MANPAGES += misc-utils/logger.1
|
MANPAGES += misc-utils/logger.1
|
||||||
dist_noinst_DATA += misc-utils/logger.1.adoc
|
dist_noinst_DATA += misc-utils/logger.1.adoc
|
||||||
logger_SOURCES = misc-utils/logger.c lib/strutils.c lib/strv.c
|
logger_SOURCES = misc-utils/logger.c lib/strutils.c lib/strv.c
|
||||||
logger_LDADD = $(LDADD)
|
logger_LDADD = $(LDADD) libcommon.la
|
||||||
logger_CFLAGS = $(AM_CFLAGS)
|
logger_CFLAGS = $(AM_CFLAGS)
|
||||||
if HAVE_SYSTEMD
|
if HAVE_SYSTEMD
|
||||||
logger_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS) $(SYSTEMD_JOURNAL_LIBS)
|
logger_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS) $(SYSTEMD_JOURNAL_LIBS)
|
||||||
|
@ -244,8 +244,4 @@ dist_noinst_DATA += misc-utils/hardlink.1.adoc
|
||||||
hardlink_SOURCES = misc-utils/hardlink.c lib/monotonic.c
|
hardlink_SOURCES = misc-utils/hardlink.c lib/monotonic.c
|
||||||
hardlink_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS)
|
hardlink_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS)
|
||||||
hardlink_CFLAGS = $(AM_CFLAGS)
|
hardlink_CFLAGS = $(AM_CFLAGS)
|
||||||
if HAVE_PCRE2_POSIX
|
|
||||||
hardlink_LDADD += $(PCRE2_POSIX_LIBS)
|
|
||||||
hardlink_CFLAGS += $(PCRE2_POSIX_CFLAGS)
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -32,7 +32,8 @@ struct verify_context {
|
||||||
no_fsck : 1;
|
no_fsck : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap)
|
static void __attribute__ ((__format__ (__printf__, 3, 0)))
|
||||||
|
verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
if (!vfy->target_printed) {
|
if (!vfy->target_printed) {
|
||||||
fprintf(stdout, "%s\n", mnt_fs_get_target(vfy->fs));
|
fprintf(stdout, "%s\n", mnt_fs_get_target(vfy->fs));
|
||||||
|
@ -44,7 +45,8 @@ static void verify_mesg(struct verify_context *vfy, char type, const char *fmt,
|
||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_warn(struct verify_context *vfy, const char *fmt, ...)
|
static int __attribute__ ((__format__ (__printf__, 2, 3)))
|
||||||
|
verify_warn(struct verify_context *vfy, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
vfy->nwarnings++;
|
vfy->nwarnings++;
|
||||||
|
@ -54,7 +56,8 @@ static int verify_warn(struct verify_context *vfy, const char *fmt, ...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_err(struct verify_context *vfy, const char *fmt, ...)
|
static int __attribute__ ((__format__ (__printf__, 2, 3)))
|
||||||
|
verify_err(struct verify_context *vfy, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
vfy->nerrors++;
|
vfy->nerrors++;
|
||||||
|
@ -64,7 +67,8 @@ static int verify_err(struct verify_context *vfy, const char *fmt, ...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_ok(struct verify_context *vfy __attribute__((unused)),
|
static int __attribute__ ((__format__ (__printf__, 2, 3)))
|
||||||
|
verify_ok(struct verify_context *vfy __attribute__((unused)),
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -160,7 +164,10 @@ static int verify_target(struct verify_context *vfy)
|
||||||
static char *verify_tag(struct verify_context *vfy, const char *name,
|
static char *verify_tag(struct verify_context *vfy, const char *name,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
char *src = mnt_resolve_tag(name, value, cache);
|
char *src = NULL;
|
||||||
|
|
||||||
|
if (!(flags & FL_NOCACHE))
|
||||||
|
src = mnt_resolve_tag(name, value, cache);
|
||||||
|
|
||||||
if (!src) {
|
if (!src) {
|
||||||
if (mnt_fs_get_option(vfy->fs, "noauto", NULL, NULL) == 1)
|
if (mnt_fs_get_option(vfy->fs, "noauto", NULL, NULL) == 1)
|
||||||
|
@ -336,6 +343,18 @@ static int read_proc_filesystems(struct verify_context *vfy)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_proc_filesystems(struct verify_context *vfy)
|
||||||
|
{
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
if (!vfy->fs_ary)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (n = 0; n < vfy->fs_num; n++ )
|
||||||
|
free(vfy->fs_ary[n]);
|
||||||
|
free(vfy->fs_ary);
|
||||||
|
}
|
||||||
|
|
||||||
static int read_kernel_filesystems(struct verify_context *vfy)
|
static int read_kernel_filesystems(struct verify_context *vfy)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -388,14 +407,18 @@ static int read_kernel_filesystems(struct verify_context *vfy)
|
||||||
|
|
||||||
static int verify_fstype(struct verify_context *vfy)
|
static int verify_fstype(struct verify_context *vfy)
|
||||||
{
|
{
|
||||||
const char *src = mnt_resolve_spec(mnt_fs_get_source(vfy->fs), cache);
|
char *src = mnt_resolve_spec(mnt_fs_get_source(vfy->fs), cache);
|
||||||
const char *type, *realtype;
|
char *realtype = NULL;
|
||||||
|
const char *type;
|
||||||
int ambi = 0, isauto = 0, isswap = 0;
|
int ambi = 0, isauto = 0, isswap = 0;
|
||||||
|
|
||||||
if (!src)
|
if (!src)
|
||||||
return 0;
|
return 0;
|
||||||
if (mnt_fs_is_pseudofs(vfy->fs) || mnt_fs_is_netfs(vfy->fs))
|
|
||||||
return verify_ok(vfy, _("do not check %s FS type (pseudo/net)"), src);
|
if (mnt_fs_is_pseudofs(vfy->fs) || mnt_fs_is_netfs(vfy->fs)) {
|
||||||
|
verify_ok(vfy, _("do not check %s FS type (pseudo/net)"), src);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
type = mnt_fs_get_fstype(vfy->fs);
|
type = mnt_fs_get_fstype(vfy->fs);
|
||||||
|
|
||||||
|
@ -404,8 +427,10 @@ static int verify_fstype(struct verify_context *vfy)
|
||||||
|
|
||||||
if (none
|
if (none
|
||||||
&& mnt_fs_get_option(vfy->fs, "bind", NULL, NULL) == 1
|
&& mnt_fs_get_option(vfy->fs, "bind", NULL, NULL) == 1
|
||||||
&& mnt_fs_get_option(vfy->fs, "move", NULL, NULL) == 1)
|
&& mnt_fs_get_option(vfy->fs, "move", NULL, NULL) == 1) {
|
||||||
return verify_warn(vfy, _("\"none\" FS type is recommended for bind or move oprations only"));
|
verify_warn(vfy, _("\"none\" FS type is recommended for bind or move oprations only"));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(type, "auto") == 0)
|
if (strcmp(type, "auto") == 0)
|
||||||
isauto = 1;
|
isauto = 1;
|
||||||
|
@ -421,23 +446,33 @@ static int verify_fstype(struct verify_context *vfy)
|
||||||
|
|
||||||
if (!realtype) {
|
if (!realtype) {
|
||||||
if (isauto)
|
if (isauto)
|
||||||
return verify_err(vfy, _("cannot detect on-disk filesystem type"));
|
verify_err(vfy, _("cannot detect on-disk filesystem type"));
|
||||||
return verify_warn(vfy, _("cannot detect on-disk filesystem type"));
|
else
|
||||||
|
verify_warn(vfy, _("cannot detect on-disk filesystem type"));
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realtype) {
|
if (realtype) {
|
||||||
isswap = strcmp(realtype, "swap") == 0;
|
isswap = strcmp(realtype, "swap") == 0;
|
||||||
vfy->no_fsck = strcmp(realtype, "xfs") == 0;
|
vfy->no_fsck = strcmp(realtype, "xfs") == 0;
|
||||||
|
|
||||||
if (type && !isauto && strcmp(type, realtype) != 0)
|
if (type && !isauto && strcmp(type, realtype) != 0) {
|
||||||
return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
|
verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
|
||||||
|
goto done;
|
||||||
if (!isswap && !is_supported_filesystem(vfy, realtype))
|
}
|
||||||
return verify_err(vfy, _("on-disk %s seems unsupported by the current kernel"), realtype);
|
if (!isswap && !is_supported_filesystem(vfy, realtype)) {
|
||||||
|
verify_err(vfy, _("on-disk %s seems unsupported by the current kernel"), realtype);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
verify_ok(vfy, _("FS type is %s"), realtype);
|
verify_ok(vfy, _("FS type is %s"), realtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (!cache) {
|
||||||
|
free(src);
|
||||||
|
free(realtype);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,5 +558,8 @@ done:
|
||||||
} else
|
} else
|
||||||
fprintf(stdout, _("Success, no errors or warnings detected\n"));
|
fprintf(stdout, _("Success, no errors or warnings detected\n"));
|
||||||
|
|
||||||
|
|
||||||
|
free_proc_filesystems(&vfy);
|
||||||
|
|
||||||
return rc != 0 ? rc : vfy.nerrors + parse_nerrors;
|
return rc != 0 ? rc : vfy.nerrors + parse_nerrors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ LIBSMARTCOLS_DEBUG=all::
|
||||||
enables libsmartcols debug output
|
enables libsmartcols debug output
|
||||||
|
|
||||||
LIBSMARTCOLS_DEBUG_PADDING=on::
|
LIBSMARTCOLS_DEBUG_PADDING=on::
|
||||||
use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
|
use visible padding characters.
|
||||||
|
|
||||||
== EXAMPLES
|
== EXAMPLES
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,8 @@ In compatibility mode, leading '*-*' and '*{plus}*' characters in the short opti
|
||||||
|
|
||||||
== EXAMPLES
|
== EXAMPLES
|
||||||
|
|
||||||
// TRANSLATORS: Don't translate _{docdir}_.
|
// TRANSLATORS: Don't translate _{package-docdir}_.
|
||||||
Example scripts for (ba)sh and (t)csh are provided with the *getopt*(1) distribution, and are installed in _{docdir}_ directory.
|
Example scripts for (ba)sh and (t)csh are provided with the *getopt*(1) distribution, and are installed in _{package-docdir}_ directory.
|
||||||
|
|
||||||
== ENVIRONMENT
|
== ENVIRONMENT
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,7 @@
|
||||||
#include "monotonic.h"
|
#include "monotonic.h"
|
||||||
#include "optutils.h"
|
#include "optutils.h"
|
||||||
|
|
||||||
/* Use libpcre2posix if it's available */
|
|
||||||
#ifdef HAVE_PCRE2_POSIX
|
|
||||||
# include <pcre2posix.h>
|
|
||||||
# undef REG_NOSUB
|
|
||||||
# define REG_NOSUB 0 /* we do want backreferences in PCRE mode */
|
|
||||||
#else
|
|
||||||
#include <regex.h> /* regcomp(), regsearch() */
|
#include <regex.h> /* regcomp(), regsearch() */
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_XATTR_H
|
#ifdef HAVE_SYS_XATTR_H
|
||||||
# include <sys/xattr.h> /* listxattr, getxattr */
|
# include <sys/xattr.h> /* listxattr, getxattr */
|
||||||
|
|
|
@ -176,10 +176,11 @@ static int arg_to_signum(char *arg, int maskbit)
|
||||||
char *ep;
|
char *ep;
|
||||||
|
|
||||||
if (isdigit(*arg)) {
|
if (isdigit(*arg)) {
|
||||||
|
errno = 0;
|
||||||
numsig = strtol(arg, &ep, 10);
|
numsig = strtol(arg, &ep, 10);
|
||||||
if (NSIG <= numsig && maskbit && (numsig & 128) != 0)
|
if (NSIG <= numsig && maskbit && (numsig & 128) != 0)
|
||||||
numsig -= 128;
|
numsig -= 128;
|
||||||
if (*ep != 0 || numsig < 0 || NSIG <= numsig)
|
if (errno || *ep != 0 || numsig < 0 || NSIG <= numsig)
|
||||||
return -1;
|
return -1;
|
||||||
return numsig;
|
return numsig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "pwdutils.h"
|
||||||
|
|
||||||
#define SYSLOG_NAMES
|
#define SYSLOG_NAMES
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
@ -393,16 +394,6 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char const *xgetlogin(void)
|
|
||||||
{
|
|
||||||
char const *cp;
|
|
||||||
struct passwd *pw;
|
|
||||||
|
|
||||||
if (!(cp = getlogin()) || !*cp)
|
|
||||||
cp = (pw = getpwuid(geteuid()))? pw->pw_name : "<someone>";
|
|
||||||
return cp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this creates a timestamp based on current time according to the
|
/* this creates a timestamp based on current time according to the
|
||||||
* fine rules of RFC3164, most importantly it ensures in a portable
|
* fine rules of RFC3164, most importantly it ensures in a portable
|
||||||
* way that the month day is correctly written (with a SP instead
|
* way that the month day is correctly written (with a SP instead
|
||||||
|
@ -619,7 +610,8 @@ static void add_structured_data_param(struct list_head *ls, const char *param)
|
||||||
err_oom();
|
err_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_structured_data_paramf(struct list_head *ls, const char *fmt, ...)
|
static void __attribute__ ((__format__ (__printf__, 2, 3)))
|
||||||
|
add_structured_data_paramf(struct list_head *ls, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct structured_data *sd;
|
struct structured_data *sd;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -926,6 +918,8 @@ static void logger_open(struct logger_ctl *ctl)
|
||||||
syslog_local_header;
|
syslog_local_header;
|
||||||
if (!ctl->tag)
|
if (!ctl->tag)
|
||||||
ctl->tag = xgetlogin();
|
ctl->tag = xgetlogin();
|
||||||
|
if (!ctl->tag)
|
||||||
|
ctl->tag = "<someone>";
|
||||||
|
|
||||||
generate_syslog_header(ctl);
|
generate_syslog_header(ctl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "mangle.h"
|
#include "mangle.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
#include "strutils.h"
|
||||||
|
|
||||||
#include "lsblk.h"
|
#include "lsblk.h"
|
||||||
|
|
||||||
|
@ -111,11 +112,19 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
|
||||||
data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT");
|
data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT");
|
||||||
if(!data)
|
if(!data)
|
||||||
data = udev_device_get_property_value(dev, "ID_SERIAL");
|
data = udev_device_get_property_value(dev, "ID_SERIAL");
|
||||||
if (data)
|
if (data) {
|
||||||
prop->serial = xstrdup(data);
|
prop->serial = xstrdup(data);
|
||||||
|
normalize_whitespace((unsigned char *) prop->serial);
|
||||||
|
}
|
||||||
|
|
||||||
if ((data = udev_device_get_property_value(dev, "ID_MODEL")))
|
if ((data = udev_device_get_property_value(dev, "ID_MODEL_ENC"))) {
|
||||||
prop->model = xstrdup(data);
|
prop->model = xstrdup(data);
|
||||||
|
unhexmangle_string(prop->model);
|
||||||
|
normalize_whitespace((unsigned char *) prop->model);
|
||||||
|
} else if ((data = udev_device_get_property_value(dev, "ID_MODEL"))) {
|
||||||
|
prop->model = xstrdup(data);
|
||||||
|
normalize_whitespace((unsigned char *) prop->model);
|
||||||
|
}
|
||||||
|
|
||||||
udev_device_unref(dev);
|
udev_device_unref(dev);
|
||||||
DBG(DEV, ul_debugobj(ld, "%s: found udev properties", ld->name));
|
DBG(DEV, ul_debugobj(ld, "%s: found udev properties", ld->name));
|
||||||
|
|
|
@ -45,7 +45,7 @@ Use _column_ as a de-duplication key to de-duplicate output tree. If the key is
|
||||||
+
|
+
|
||||||
The usual use case is to de-duplicate output on system multi-path devices, for example by *-E WWN*.
|
The usual use case is to de-duplicate output on system multi-path devices, for example by *-E WWN*.
|
||||||
|
|
||||||
-e*, *--exclude* _list_::
|
*-e*, *--exclude* _list_::
|
||||||
Exclude the devices specified by the comma-separated _list_ of major device numbers. Note that RAM disks (major=1) are excluded by default if *--all* is not specified. The filter is applied to the top-level devices only. This may be confusing for *--list* output format where hierarchy of the devices is not obvious.
|
Exclude the devices specified by the comma-separated _list_ of major device numbers. Note that RAM disks (major=1) are excluded by default if *--all* is not specified. The filter is applied to the top-level devices only. This may be confusing for *--list* output format where hierarchy of the devices is not obvious.
|
||||||
|
|
||||||
*-f*, *--fs*::
|
*-f*, *--fs*::
|
||||||
|
@ -150,7 +150,7 @@ LIBSMARTCOLS_DEBUG=all::
|
||||||
enables *libsmartcols* debug output.
|
enables *libsmartcols* debug output.
|
||||||
|
|
||||||
LIBSMARTCOLS_DEBUG_PADDING=on::
|
LIBSMARTCOLS_DEBUG_PADDING=on::
|
||||||
use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
|
use visible padding characters.
|
||||||
|
|
||||||
== NOTES
|
== NOTES
|
||||||
|
|
||||||
|
|
|
@ -192,8 +192,10 @@ static char *get_filename_sz(ino_t inode, pid_t lock_pid, size_t *size)
|
||||||
!strcmp(dp->d_name, ".."))
|
!strcmp(dp->d_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
/* care only for numerical descriptors */
|
/* care only for numerical descriptors */
|
||||||
if (!strtol(dp->d_name, (char **) NULL, 10))
|
if (!strtol(dp->d_name, (char **) NULL, 10) || errno)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!fstatat(fd, dp->d_name, &sb, 0)
|
if (!fstatat(fd, dp->d_name, &sb, 0)
|
||||||
|
|
|
@ -99,7 +99,7 @@ readlink_to_namei(struct namei *nm, const char *path)
|
||||||
}
|
}
|
||||||
nm->abslink = xmalloc(sz + 1);
|
nm->abslink = xmalloc(sz + 1);
|
||||||
|
|
||||||
if (*sym != '/' && isrel) {
|
if (isrel) {
|
||||||
/* create the absolute path from the relative symlink */
|
/* create the absolute path from the relative symlink */
|
||||||
memcpy(nm->abslink, path, nm->relstart);
|
memcpy(nm->abslink, path, nm->relstart);
|
||||||
*(nm->abslink + nm->relstart) = '/';
|
*(nm->abslink + nm->relstart) = '/';
|
||||||
|
|
|
@ -105,6 +105,7 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
|
||||||
{
|
{
|
||||||
char *newname = NULL, *target = NULL;
|
char *newname = NULL, *target = NULL;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
ssize_t ssz;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if ( faccessat(AT_FDCWD, s, F_OK, AT_SYMLINK_NOFOLLOW) != 0 &&
|
if ( faccessat(AT_FDCWD, s, F_OK, AT_SYMLINK_NOFOLLOW) != 0 &&
|
||||||
|
@ -125,12 +126,15 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
target = xmalloc(sb.st_size + 1);
|
target = xmalloc(sb.st_size + 1);
|
||||||
if (readlink(s, target, sb.st_size + 1) < 0) {
|
|
||||||
|
ssz = readlink(s, target, sb.st_size + 1);
|
||||||
|
if (ssz < 0) {
|
||||||
warn(_("%s: readlink failed"), s);
|
warn(_("%s: readlink failed"), s);
|
||||||
free(target);
|
free(target);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
target[sb.st_size] = '\0';
|
target[ssz] = '\0';
|
||||||
|
|
||||||
if (string_replace(from, to, target, target, &newname) != 0)
|
if (string_replace(from, to, target, target, &newname) != 0)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,10 @@ static struct wipe_desc *get_desc_for_probe(struct wipe_control *ctl,
|
||||||
} else
|
} else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
*offset = strtoll(off, NULL, 10);
|
*offset = strtoll(off, NULL, 10);
|
||||||
|
if (errno)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Filter out by -t <type> */
|
/* Filter out by -t <type> */
|
||||||
if (ctl->type_pattern && !match_fstype(type, ctl->type_pattern))
|
if (ctl->type_pattern && !match_fstype(type, ctl->type_pattern))
|
||||||
|
|
3961
po/pt_BR.po
3961
po/pt_BR.po
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue