Commit 1088477c authored by Andreas Henriksson's avatar Andreas Henriksson

New upstream version 2.29

parents 3d45ba44 5bd2b14d
See version control history.
http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log;h=2.29-rc2
http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log;h=2.29
Note that items with (!) have high priority.
su/runuser:
- (!) remove usage(stderr) on command line errors (unsupported options, etc.)
su/runuser
----------
- (!) implement pty container for all su/runuser session (something like
script(1)) to separate user from the original terminal (see CVE-2016-2779)
- add functions strtime_short(), strtime_iso(), strtime_ctime(), ...
- cleanup lib/path.c:
cleanup lib/path.c:
------------------
- always return rc from all functions
- introduce control struct and use openat() from top-level path
(e.g. top-level is /proc, etc)
......@@ -24,6 +29,9 @@ lscpu
lsblk
-----
- (!) add --tree to force tree output for operations like --sort where the
--list is enabled by default.
- currently it does not show mountpoint for all devices in btrfs RAID. It's because
/proc/#/mountinfo contains reference to the one device only. Maybe we can add some
btrfs specific code to provide a better output for FS based stacks. Not sure.
......@@ -126,6 +134,9 @@ libblkid
libfdisk
--------
- (!) use fputs_quoted() when print partition name= and allow to use \x%02x
for input to escape unprintable chars and quotes.
- add support for Apple Partition Map (see libblkid/src/partitions/mac.c)
http://en.wikipedia.org/wiki/Apple_Partition_Map
......
......@@ -326,7 +326,7 @@ Version 1.11a (16-Feb-93): changes since 1.9a:
can't just open the tty's again.
Version 1.9a (18-Jan-93): changes since 1.8a:
Rick Faith sent me man-pages for most of the untilities in this
Rick Faith sent me man-pages for most of the utilities in this
package. They are now included.
Steven S. Dick <ssd@nevets.oau.org> sent me a patch for login.c
......
This diff is collapsed.
......@@ -3440,8 +3440,6 @@ MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NCURSESW_CFLAGS = @NCURSESW_CFLAGS@
NCURSESW_LIBS = @NCURSESW_LIBS@
NCURSES_CFLAGS = @NCURSES_CFLAGS@
NCURSES_LIBS = @NCURSES_LIBS@
NM = @NM@
......
util-linux 2.29: Nov 8 2016
* see Documentation/releases/v2.29-ReleaseNotes or the complete changelog at
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.29/v2.29-ChangeLog
util-linux 2.29-rc2: Oct 19 2016
* see Documentation/releases/v2.29-ReleaseNotes or the complete changelog at
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.29/v2.29-rc2-ChangeLog
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{print $3}' \
dnl libblkid version
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
LIBBLKID_DATE="19-Oct-2016"
LIBBLKID_DATE="08-Nov-2016"
LIBBLKID_LT_MAJOR=1
LIBBLKID_LT_MINOR=1
LIBBLKID_LT_MICRO=0
......@@ -778,14 +778,12 @@ AC_ARG_WITH([ncursesw],
)
have_ncursesw=no
AS_IF([test "x$with_ncursesw" != xno], [
PKG_CHECK_MODULES(NCURSESW, [ncursesw], [
have_ncursesw=yes
NCURSES_LIBS=${NCURSESW_LIBS}
NCURSES_CFLAGS=${NCURSESW_CFLAGS}
UL_NCURSES_CHECK([ncursesw])
AS_IF([test "x$have_ncursesw" = xyes], [
AC_DEFINE([HAVE_LIBNCURSESW], [1], [Define if ncursesw library available])
CURSES_LIB_NAME="ncursesw"
AC_CHECK_HEADERS([ncursesw/ncurses.h ncurses.h])
], [have_ncursesw=no])
])
])
AS_CASE([$with_ncursesw:$have_ncursesw],
[yes:no], [AC_MSG_ERROR([ncursesw selected, but library not found])])
......@@ -802,12 +800,12 @@ AS_CASE([$with_ncurses:$build_widechar],
[yes:yes], [AC_MSG_ERROR([wide-char support enabled, but non-wide ncurses selects])])
AS_IF([test "x$have_ncursesw" = xno -a "x$with_ncurses" != xno ], [
PKG_CHECK_MODULES(NCURSES, [ncurses], [
have_ncurses=yes
UL_NCURSES_CHECK([ncurses])
AS_IF([test "x$have_ncurses" = xyes], [
AC_DEFINE([HAVE_LIBNCURSES], [1], [Define if ncurses library available])
CURSES_LIB_NAME="ncurses"
AC_CHECK_HEADERS([ncurses/ncurses.h ncurses.h])
],[have_ncurses=no])
])
])
AS_CASE([$with_ncurses:$have_ncurses],
[yes:no], [AC_MSG_ERROR([ncurses selected, but library not found])])
......@@ -1809,7 +1807,7 @@ AC_ARG_ENABLE([pg],
[], [UL_DEFAULT_ENABLE([pg], [no])]
)
UL_BUILD_INIT([pg])
UL_REQUIRES_HAVE([pg], [ncursesw, ncurses], [ncurses or ncursesw library])
UL_REQUIRES_HAVE([pg], [ncursesw, ncurses], [ncursesw or ncurses library])
AM_CONDITIONAL([BUILD_PG], [test "x$build_pg" = xyes])
......@@ -1819,7 +1817,7 @@ AC_ARG_ENABLE([setterm],
)
UL_BUILD_INIT([setterm])
UL_REQUIRES_LINUX([setterm])
UL_REQUIRES_HAVE([setterm], [ncursesw, ncurses], [ncurses or ncurses library])
UL_REQUIRES_HAVE([setterm], [ncursesw, ncurses], [ncursesw or ncurses library])
AM_CONDITIONAL([BUILD_SETTERM], [test "x$build_setterm" = xyes])
# build_schedutils= is just configure-only variable to control
......
......@@ -75,8 +75,10 @@ void list_disk_geometry(struct fdisk_context *cxt)
fdisk_info(cxt, _("Disklabel type: %s"),
fdisk_label_get_name(lb));
if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id)
if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) {
fdisk_info(cxt, _("Disk identifier: %s"), id);
free(id);
}
}
void list_disklabel(struct fdisk_context *cxt)
......
......@@ -692,7 +692,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
struct fdisk_partition *pa = NULL;
size_t n;
int rc = 0;
unsigned long length;
uintmax_t length = 0;
assert(cxt);
assert(ent);
......@@ -709,7 +709,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
~(uint32_t)0, _("New maximum entries"), &length);
if (rc)
return rc;
return fdisk_gpt_set_npartitions(cxt, length);
return fdisk_gpt_set_npartitions(cxt, (uint32_t) length);
case 'M':
mbr = fdisk_new_nested_context(cxt, "dos");
if (!mbr)
......
......@@ -193,10 +193,10 @@ static int get_partno_from_device(char *partition, dev_t devno)
sz = strlen(partition);
p = partition + sz - 1;
if (!isdigit((unsigned int) *p))
if (!isdigit((unsigned char) *p))
goto err;
while (isdigit((unsigned int) *(p - 1))) p--;
while (isdigit((unsigned char) *(p - 1))) p--;
errno = 0;
partno = strtol(p, &end, 10);
......
......@@ -228,8 +228,6 @@ MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NCURSESW_CFLAGS = @NCURSESW_CFLAGS@
NCURSESW_LIBS = @NCURSESW_LIBS@
NCURSES_CFLAGS = @NCURSES_CFLAGS@
NCURSES_LIBS = @NCURSES_LIBS@
NM = @NM@
......
......@@ -31,7 +31,7 @@ extern "C" {
#endif
#define BLKID_VERSION "2.29."
#define BLKID_DATE "19-Oct-2016"
#define BLKID_DATE "08-Nov-2016"
/**
* blkid_dev:
......
......@@ -740,6 +740,8 @@ int blkid_probe_is_cdrom(blkid_probe pr)
return (pr->flags & BLKID_FL_CDROM_DEV);
}
#ifdef CDROM_GET_CAPABILITY
static int is_sector_readable(int fd, uint64_t sector)
{
char buf[512];
......@@ -754,7 +756,7 @@ static int is_sector_readable(int fd, uint64_t sector)
return 1;
failed:
DBG(LOWPROBE, ul_debug("CDROM: read sector %ju failed %m", sector));
DBG(LOWPROBE, ul_debug("CDROM: read sector %"PRIu64" failed %m", sector));
errno = 0;
return 0;
}
......@@ -785,6 +787,8 @@ failed:
pr->size = n << 9;
}
#endif
/**
* blkid_probe_set_device:
* @pr: probe
......
......@@ -32,11 +32,6 @@
# include <stdlib.h>
#endif
#ifdef TEST_PROGRAM
#define blkid_debug_dump_dev(dev) (debug_dump_dev(dev))
static void debug_dump_dev(blkid_dev dev);
#endif
/*
* File format:
*
......@@ -377,8 +372,6 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp)
goto done;
}
/*DBG(READ, blkid_debug_dump_dev(dev));*/
done:
return ret;
}
......@@ -452,31 +445,6 @@ errout:
}
#ifdef TEST_PROGRAM
static void debug_dump_dev(blkid_dev dev)
{
struct list_head *p;
if (!dev) {
printf(" dev: NULL\n");
return;
}
printf(" dev: name = %s\n", dev->bid_name);
printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno);
printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime);
printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
printf(" dev: flags = 0x%08X\n", dev->bid_flags);
list_for_each(p, &dev->bid_tags) {
blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
if (tag)
printf(" tag: %s=\"%s\"\n", tag->bit_name,
tag->bit_val);
else
printf(" tag: NULL\n");
}
printf("\n");
}
int main(int argc, char**argv)
{
......
......@@ -87,7 +87,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
memcpy(buff, p, sizeof(buff));
nvl = (struct nvlist *) buff;
DBG(LOWPROBE, ul_debug("zfs_extract: nvlist offset %jd\n", offset));
DBG(LOWPROBE, ul_debug("zfs_extract: nvlist offset %jd\n", (intmax_t)offset));
nvp = &nvl->nvl_nvpair;
while (left > sizeof(*nvp) && nvp->nvp_size != 0 && found < 3) {
......@@ -176,14 +176,14 @@ static int find_uberblocks(const void *label, loff_t *ub_offset, int *swap_endia
*ub_offset = offset;
*swap_endian = 0;
found++;
DBG(LOWPROBE, ul_debug("probe_zfs: found little-endian uberblock at %jd\n", offset >> 10));
DBG(LOWPROBE, ul_debug("probe_zfs: found little-endian uberblock at %jd\n", (intmax_t)offset >> 10));
}
if (ub->ub_magic == swab_magic) {
*ub_offset = offset;
*swap_endian = 1;
found++;
DBG(LOWPROBE, ul_debug("probe_zfs: found big-endian uberblock at %jd\n", offset >> 10));
DBG(LOWPROBE, ul_debug("probe_zfs: found big-endian uberblock at %jd\n", (intmax_t)offset >> 10));
}
}
......
......@@ -228,8 +228,6 @@ MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NCURSESW_CFLAGS = @NCURSESW_CFLAGS@
NCURSESW_LIBS = @NCURSESW_LIBS@
NCURSES_CFLAGS = @NCURSES_CFLAGS@
NCURSES_LIBS = @NCURSES_LIBS@
NM = @NM@
......
......@@ -350,7 +350,7 @@ int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable)
* See also fdisk_wipe_partition().
*
* This is no-op if any collision has not been detected by
* fdisk_assign_device(). See fdisk_has_collision(). The default is not wipe a
* fdisk_assign_device(). See fdisk_get_collision(). The default is not wipe a
* device.
*
* Returns: 0 on success, < 0 on error.
......
......@@ -433,6 +433,10 @@ struct fdisk_labelitem {
} data;
};
/* Use only internally for non-allocated items, never use
* refcouting for such items!
*/
#define FDISK_LABELITEM_INIT { .type = 0, .refcount = 0 }
/* ask.c */
struct fdisk_ask *fdisk_new_ask(void);
......
......@@ -1583,10 +1583,7 @@ static int gpt_entry_attrs_from_string(
DBG(LABEL, ul_debug(" parsing item '%s'", p));
if (strncmp(p, "GUID:", 5) == 0) {
p += 5;
continue;
} else if (strncmp(p, GPT_ATTRSTR_REQ,
if (strncmp(p, GPT_ATTRSTR_REQ,
sizeof(GPT_ATTRSTR_REQ) - 1) == 0) {
bit = GPT_ATTRBIT_REQ;
p += sizeof(GPT_ATTRSTR_REQ) - 1;
......@@ -1602,9 +1599,16 @@ static int gpt_entry_attrs_from_string(
sizeof(GPT_ATTRSTR_NOBLOCK) - 1) == 0) {
bit = GPT_ATTRBIT_NOBLOCK;
p += sizeof(GPT_ATTRSTR_NOBLOCK) - 1;
} else if (isdigit((unsigned int) *p)) {
/* GUID:<bit> as well as <bit> */
} else if (isdigit((unsigned char) *p)
|| (strncmp(p, "GUID:", 5) == 0
&& isdigit((unsigned char) *(p + 5)))) {
char *end = NULL;
if (*p == 'G')
p += 5;
errno = 0;
bit = strtol(p, &end, 0);
if (errno || !end || end == str
......@@ -1620,6 +1624,11 @@ static int gpt_entry_attrs_from_string(
return -EINVAL;
}
if (*p && *p != ',' && !isblank(*p)) {
fdisk_warnx(cxt, _("failed to parse GPT attribute string '%s'"), str);
return -EINVAL;
}
setbit(bits, bit);
while (isblank(*p)) p++;
......
#include <inttypes.h>
#include "fdiskP.h"
/**
......@@ -52,8 +54,11 @@ struct fdisk_labelitem *fdisk_new_labelitem(void)
*/
void fdisk_ref_labelitem(struct fdisk_labelitem *li)
{
if (li)
if (li) {
/* me sure we do not use refcouting for static items */
assert(li->refcount > 0);
li->refcount++;
}
}
/**
......@@ -94,6 +99,9 @@ void fdisk_unref_labelitem(struct fdisk_labelitem *li)
if (!li)
return;
/* me sure we do not use refcouting for static items */
assert(li->refcount > 0);
li->refcount--;
if (li->refcount <= 0) {
DBG(ITEM, ul_debugobj(li, "free"));
......@@ -213,7 +221,7 @@ static int test_listitems(struct fdisk_test *ts, int argc, char *argv[])
&& fdisk_labelitem_get_data_string(item, &str) == 0)
printf("%s: %s\n", name, str);
else if (fdisk_labelitem_get_data_u64(item, &num) == 0)
printf("%s: %ju\n", name, num);
printf("%s: %"PRIu64"\n", name, num);
break;
}
case 1: /* item unsuported by label -- ignore */
......
......@@ -416,7 +416,7 @@ int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name,
*/
int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id)
{
struct fdisk_labelitem item;
struct fdisk_labelitem item = FDISK_LABELITEM_INIT;
int rc;
if (!cxt || !cxt->label || !id)
......
......@@ -736,7 +736,7 @@ static char *next_token(char **str)
*tk_end = NULL,
*end = NULL,
*p;
int open_quote = 0;
int open_quote = 0, terminated = 0;
for (p = *str; p && *p; p++) {
if (!tk_begin) {
......@@ -758,9 +758,35 @@ static char *next_token(char **str)
if (!tk_end)
return NULL;
end = isblank(*tk_end) ? (char *) skip_blank(tk_end) : tk_end;
if (*end == ',' || *end == ';')
end = tk_end;
/* skip closing quotes */
if (*end == '"')
end++;
/* token is terminated by blank (or blank is before "," or ";") */
if (isblank(*end)) {
end = (char *) skip_blank(end);
terminated++;
}
/* token is terminated by "," or ";" */
if (*end == ',' || *end == ';') {
end++;
terminated++;
/* token is terminated by \0 */
} else if (!*end)
terminated++;
if (!terminated) {
DBG(SCRIPT, ul_debug("unterminated token '%s'", end));
return NULL;
}
/* skip extra space after terminator */
end = (char *) skip_blank(end);
*tk_end = '\0';
*str = end;
......@@ -885,8 +911,9 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
}
} else if (!strncasecmp(p, "bootable", 8)) {
/* we use next_token() to skip possible extra space */
char *tk = next_token(&p);
if (strcmp(tk, "bootable") == 0)
if (tk && strcasecmp(tk, "bootable") == 0)
pa->boot = 1;
else
rc = -EINVAL;
......@@ -904,11 +931,10 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
rc = next_string(&p, &pa->name);
} else if (!strncasecmp(p, "type=", 5) ||
!strncasecmp(p, "Id=", 3)) { /* backward compatibility */
char *type;
p += (*p == 'I' ? 3 : 5); /* "Id=" or "type=" */
p += ((*p == 'I' || *p == 'i') ? 3 : 5); /* "Id=", "type=" */
rc = next_string(&p, &type);
if (rc)
......@@ -1521,6 +1547,24 @@ done:
return 0;
}
static int test_tokens(struct fdisk_test *ts, int argc, char *argv[])
{
char *p, *str = argc == 2 ? strdup(argv[1]) : NULL;
int i;
for (i = 1, p = str; p && *p; i++) {
char *tk = next_token(&p);
if (!tk)
break;
printf("#%d: '%s'\n", i, tk);
}
free(str);
return 0;
}
int main(int argc, char *argv[])
{
struct fdisk_test tss[] = {
......@@ -1528,6 +1572,7 @@ int main(int argc, char *argv[])
{ "--read", test_read, "<file> read PT script from file" },
{ "--apply", test_apply, "<device> <file> try apply script from file to device" },
{ "--stdin", test_stdin, " read input like sfdisk" },
{ "--tokens", test_tokens, "<string> parse string" },
{ NULL }
};
......
......@@ -228,8 +228,6 @@ MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NCURSESW_CFLAGS = @NCURSESW_CFLAGS@
NCURSESW_LIBS = @NCURSESW_LIBS@
NCURSES_CFLAGS = @NCURSES_CFLAGS@
NCURSES_LIBS = @NCURSES_LIBS@
NM = @NM@
......
......@@ -369,7 +369,8 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
if (!*optstr)
return -ENOMEM;
if (cxt->user_mountflags & MNT_MS_USER) {
if ((cxt->user_mountflags & MNT_MS_USER) ||
(cxt->user_mountflags & MNT_MS_USERS)) {
/*
* This is unnecessary for real user-mounts as mount.<type>
* helpers always have to follow fstab rather than mount
......
......@@ -228,8 +228,6 @@ MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NCURSESW_CFLAGS = @NCURSESW_CFLAGS@
NCURSESW_LIBS = @NCURSESW_LIBS@
NCURSES_CFLAGS = @NCURSES_CFLAGS@
NCURSES_LIBS = @NCURSES_LIBS@
NM = @NM@
......
......@@ -38,7 +38,7 @@ static const struct column_flag flags[] = {
{ "none", 0 }
};
static long name_to_flag(const char *name, long unsigned int namesz)
static long name_to_flag(const char *name, size_t namesz)
{
size_t i;
......
......@@ -1146,8 +1146,8 @@ const char *scols_table_get_line_separator(const struct libscols_table *tb)
{
return tb->linesep;
}
static int cells_cmp_wrapper(struct list_head *a, struct list_head *b, void *data)
/* for lines in the struct libscols_line->ln_lines list */
static int cells_cmp_wrapper_lines(struct list_head *a, struct list_head *b, void *data)
{
struct libscols_column *cl = (struct libscols_column *) data;
struct libscols_line *ra, *rb;
......@@ -1165,6 +1165,43 @@ static int cells_cmp_wrapper(struct list_head *a, struct list_head *b, void *dat
return cl->cmpfunc(ca, cb, cl->cmpfunc_data);
}
/* for lines in the struct libscols_line->ln_children list */
static int cells_cmp_wrapper_children(struct list_head *a, struct list_head *b, void *data)
{
struct libscols_column *cl = (struct libscols_column *) data;
struct libscols_line *ra, *rb;
struct libscols_cell *ca, *cb;
assert(a);
assert(b);
assert(cl);
ra = list_entry(a, struct libscols_line, ln_children);
rb = list_entry(b, struct libscols_line, ln_children);
ca = scols_line_get_cell(ra, cl->seqnum);
cb = scols_line_get_cell(rb, cl->seqnum);
return cl->cmpfunc(ca, cb, cl->cmpfunc_data);
}
static int sort_line_children(struct libscols_line *ln, struct libscols_column *cl)
{
struct list_head *p;
if (list_empty(&ln->ln_branch))
return 0;
list_for_each(p, &ln->ln_branch) {
struct libscols_line *chld =
list_entry(p, struct libscols_line, ln_children);
sort_line_children(chld, cl);
}
list_sort(&ln->ln_branch, cells_cmp_wrapper_children, cl);
return 0;
}
/**
* scols_sort_table:
* @tb: table
......@@ -1180,7 +1217,17 @@ int scols_sort_table(struct libscols_table *tb, struct libscols_column *cl)
return -EINVAL;
DBG(TAB, ul_debugobj(tb, "sorting table"));
list_sort(&tb->tb_lines, cells_cmp_wrapper, cl);
list_sort(&tb->tb_lines, cells_cmp_wrapper_lines, cl);
if (scols_table_is_tree(tb)) {
struct libscols_line *ln;
struct libscols_iter itr;
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (scols_table_next_line(tb, &itr, &ln) == 0)
sort_line_children(ln, cl);
}
return 0;
}
......
......@@ -571,7 +571,7 @@ static int valid_pwd(const char *str)
const char *p;
for (p = str; p && *p; p++)
if (!isalnum((unsigned int) *p))
if (!isalnum((unsigned char) *p))
return 0;
return p > str ? 1 : 0;
}
......
......@@ -428,3 +428,38 @@ AC_DEFUN([UL_DEFAULT_ENABLE], [
enable_[]suffix=$2
fi