Compare commits

..

No commits in common. "imports/c9/coreutils-8.32-31.el9" and "c8" have entirely different histories.

39 changed files with 4562 additions and 3142 deletions

View File

@ -1 +1 @@
b2b12195e276c64c8e850cf40ea2cff9b3aa53f6 SOURCES/coreutils-8.32.tar.xz
bd5d495c162730873a2774acd1c5091fbf0c55a4 SOURCES/coreutils-8.30.tar.xz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/coreutils-8.32.tar.xz
SOURCES/coreutils-8.30.tar.xz

View File

@ -0,0 +1,32 @@
From c6418e3a5cb3a65af79117162a93a66026cc8c36 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 6 Dec 2018 14:28:00 +0100
Subject: [PATCH] doc: improve wording of the --kibibytes option description
Bug: https://bugzilla.redhat.com/1527391
---
doc/coreutils.texi | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 88d6506..772aab6 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7615,9 +7615,11 @@ Append @samp{*} for executable regular files, otherwise behave as for
@opindex --kibibytes
Set the default block size to its normal value of 1024 bytes,
overriding any contrary specification in environment variables
-(@pxref{Block size}). This option is in turn overridden by the
-@option{--block-size}, @option{-h} or @option{--human-readable}, and
-@option{--si} options.
+(@pxref{Block size}). If @option{--block-size}, @option{-h},
+@option{--human-readable}, or @option{--si} options are used,
+they take precedence over @option{-k} or @option{--kibibytes}
+even if @option{-k} or @option{--kibibytes} is placed after
+the other options.
The @option{-k} or @option{--kibibytes} option affects the
per-directory block count written by the @option{-l} and similar
--
2.17.2

View File

@ -0,0 +1,686 @@
From a13bc34f1eeebdf8b87e4b5a570341bb77a62f76 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Fri, 17 Jun 2016 16:58:18 +0200
Subject: [PATCH] downstream changes to default DIR_COLORS
---
DIR_COLORS | 41 ++++---
DIR_COLORS.256color | 300 ++++++++++++++++++++++++------------------------
DIR_COLORS.lightbgcolor | 211 ++++++++++++++++++----------------
3 files changed, 283 insertions(+), 269 deletions(-)
diff --git a/DIR_COLORS b/DIR_COLORS
index d2ea453..27af9d7 100644
--- a/DIR_COLORS
+++ b/DIR_COLORS
@@ -1,6 +1,10 @@
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
@@ -8,6 +12,9 @@
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
+# For compatibility, the pattern "^COLOR.*none" is recognized as a way to
+# disable colorization. See https://bugzilla.redhat.com/1349579 for details.
+
# Below are TERM entries, which can be a glob patterns, to match
# against the TERM environment variable to determine if it is colorizable.
TERM Eterm
@@ -56,7 +63,7 @@ DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
-MISSING 00 # ... and the files they point to
+MISSING 01;05;37;41 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
@@ -184,21 +191,21 @@ EXEC 01;32
.ogx 01;35
# audio formats
-.aac 00;36
-.au 00;36
-.flac 00;36
-.m4a 00;36
-.mid 00;36
-.midi 00;36
-.mka 00;36
-.mp3 00;36
-.mpc 00;36
-.ogg 00;36
-.ra 00;36
-.wav 00;36
+.aac 01;36
+.au 01;36
+.flac 01;36
+.m4a 01;36
+.mid 01;36
+.midi 01;36
+.mka 01;36
+.mp3 01;36
+.mpc 01;36
+.ogg 01;36
+.ra 01;36
+.wav 01;36
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
-.oga 00;36
-.opus 00;36
-.spx 00;36
-.xspf 00;36
+.oga 01;36
+.opus 01;36
+.spx 01;36
+.xspf 01;36
diff --git a/DIR_COLORS.256color b/DIR_COLORS.256color
index d2ea453..74c34ba 100644
--- a/DIR_COLORS.256color
+++ b/DIR_COLORS.256color
@@ -1,3 +1,9 @@
+# Configuration file for the 256color ls utility
+
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
@@ -8,32 +14,13 @@
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
+# For compatibility, the pattern "^COLOR.*none" is recognized as a way to
+# disable colorization. See https://bugzilla.redhat.com/1349579 for details.
+
# Below are TERM entries, which can be a glob patterns, to match
# against the TERM environment variable to determine if it is colorizable.
-TERM Eterm
-TERM ansi
-TERM *color*
-TERM con[0-9]*x[0-9]*
-TERM cons25
-TERM console
-TERM cygwin
-TERM dtterm
-TERM gnome
-TERM hurd
-TERM jfbterm
-TERM konsole
-TERM kterm
-TERM linux
-TERM linux-c
-TERM mlterm
-TERM putty
-TERM rxvt*
-TERM screen*
-TERM st
-TERM terminator
-TERM tmux*
-TERM vt100
-TERM xterm*
+TERM *256color*
+TERM rxvt-unicode256
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
@@ -43,29 +30,40 @@ TERM xterm*
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+# Text color(256 colors mode) codes:
+# Valid syntax for text 256color is 38;5;<color number> , where color number
+# is number between 0 and 255.
+# You may find following command useful to search the best one for you:
+# for ((x=0; x<=255; x++));do echo -e "${x}:\033[38;5;${x}mcolor\033[000m";done
+# Background color(256 colors mode) codes:
+# Valid syntax for background 256color is 48;5;<color number> , where
+# color number is number between 0 and 255.
+# You may find following command useful to search the best one for you:
+# for ((x=0; x<=255; x++));do echo -e "${x}:\033[48;5;${x}mcolor\033[000m";done
+
#NORMAL 00 # no color code at all
#FILE 00 # regular file: use no color at all
RESET 0 # reset to "normal" color
-DIR 01;34 # directory
-LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
+DIR 38;5;33 # directory
+LINK 38;5;51 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
-FIFO 40;33 # pipe
-SOCK 01;35 # socket
-DOOR 01;35 # door
-BLK 40;33;01 # block device driver
-CHR 40;33;01 # character device driver
-ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
-MISSING 00 # ... and the files they point to
-SETUID 37;41 # file that is setuid (u+s)
-SETGID 30;43 # file that is setgid (g+s)
-CAPABILITY 30;41 # file with capability
-STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
-OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
-STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
+FIFO 40;38;5;11 # pipe
+SOCK 38;5;13 # socket
+DOOR 38;5;5 # door
+BLK 48;5;232;38;5;11 # block device driver
+CHR 48;5;232;38;5;3 # character device driver
+ORPHAN 48;5;232;38;5;9 # symlink to nonexistent file, or non-stat'able file ...
+MISSING 01;05;37;41 # ... and the files they point to
+SETUID 48;5;196;38;5;15 # file that is setuid (u+s)
+SETGID 48;5;11;38;5;16 # file that is setgid (g+s)
+CAPABILITY 48;5;196;38;5;226 # file with capability
+STICKY_OTHER_WRITABLE 48;5;10;38;5;16 # dir that is sticky and other-writable (+t,o+w)
+OTHER_WRITABLE 48;5;10;38;5;21 # dir that is other-writable (o+w) and not sticky
+STICKY 48;5;21;38;5;15 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
-EXEC 01;32
+EXEC 38;5;40
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
@@ -83,122 +81,122 @@ EXEC 01;32
#.csh 01;32
# archives or compressed (bright red)
-.tar 01;31
-.tgz 01;31
-.arc 01;31
-.arj 01;31
-.taz 01;31
-.lha 01;31
-.lz4 01;31
-.lzh 01;31
-.lzma 01;31
-.tlz 01;31
-.txz 01;31
-.tzo 01;31
-.t7z 01;31
-.zip 01;31
-.z 01;31
-.dz 01;31
-.gz 01;31
-.lrz 01;31
-.lz 01;31
-.lzo 01;31
-.xz 01;31
-.zst 01;31
-.tzst 01;31
-.bz2 01;31
-.bz 01;31
-.tbz 01;31
-.tbz2 01;31
-.tz 01;31
-.deb 01;31
-.rpm 01;31
-.jar 01;31
-.war 01;31
-.ear 01;31
-.sar 01;31
-.rar 01;31
-.alz 01;31
-.ace 01;31
-.zoo 01;31
-.cpio 01;31
-.7z 01;31
-.rz 01;31
-.cab 01;31
-.wim 01;31
-.swm 01;31
-.dwm 01;31
-.esd 01;31
+.tar 38;5;9
+.tgz 38;5;9
+.arc 38;5;9
+.arj 38;5;9
+.taz 38;5;9
+.lha 38;5;9
+.lz4 38;5;9
+.lzh 38;5;9
+.lzma 38;5;9
+.tlz 38;5;9
+.txz 38;5;9
+.tzo 38;5;9
+.t7z 38;5;9
+.zip 38;5;9
+.z 38;5;9
+.dz 38;5;9
+.gz 38;5;9
+.lrz 38;5;9
+.lz 38;5;9
+.lzo 38;5;9
+.xz 38;5;9
+.zst 38;5;9
+.tzst 38;5;9
+.bz2 38;5;9
+.bz 38;5;9
+.tbz 38;5;9
+.tbz2 38;5;9
+.tz 38;5;9
+.deb 38;5;9
+.rpm 38;5;9
+.jar 38;5;9
+.war 38;5;9
+.ear 38;5;9
+.sar 38;5;9
+.rar 38;5;9
+.alz 38;5;9
+.ace 38;5;9
+.zoo 38;5;9
+.cpio 38;5;9
+.7z 38;5;9
+.rz 38;5;9
+.cab 38;5;9
+.wim 38;5;9
+.swm 38;5;9
+.dwm 38;5;9
+.esd 38;5;9
# image formats
-.jpg 01;35
-.jpeg 01;35
-.mjpg 01;35
-.mjpeg 01;35
-.gif 01;35
-.bmp 01;35
-.pbm 01;35
-.pgm 01;35
-.ppm 01;35
-.tga 01;35
-.xbm 01;35
-.xpm 01;35
-.tif 01;35
-.tiff 01;35
-.png 01;35
-.svg 01;35
-.svgz 01;35
-.mng 01;35
-.pcx 01;35
-.mov 01;35
-.mpg 01;35
-.mpeg 01;35
-.m2v 01;35
-.mkv 01;35
-.webm 01;35
-.ogm 01;35
-.mp4 01;35
-.m4v 01;35
-.mp4v 01;35
-.vob 01;35
-.qt 01;35
-.nuv 01;35
-.wmv 01;35
-.asf 01;35
-.rm 01;35
-.rmvb 01;35
-.flc 01;35
-.avi 01;35
-.fli 01;35
-.flv 01;35
-.gl 01;35
-.dl 01;35
-.xcf 01;35
-.xwd 01;35
-.yuv 01;35
-.cgm 01;35
-.emf 01;35
+.jpg 38;5;13
+.jpeg 38;5;13
+.mjpg 38;5;13
+.mjpeg 38;5;13
+.gif 38;5;13
+.bmp 38;5;13
+.pbm 38;5;13
+.pgm 38;5;13
+.ppm 38;5;13
+.tga 38;5;13
+.xbm 38;5;13
+.xpm 38;5;13
+.tif 38;5;13
+.tiff 38;5;13
+.png 38;5;13
+.svg 38;5;13
+.svgz 38;5;13
+.mng 38;5;13
+.pcx 38;5;13
+.mov 38;5;13
+.mpg 38;5;13
+.mpeg 38;5;13
+.m2v 38;5;13
+.mkv 38;5;13
+.webm 38;5;13
+.ogm 38;5;13
+.mp4 38;5;13
+.m4v 38;5;13
+.mp4v 38;5;13
+.vob 38;5;13
+.qt 38;5;13
+.nuv 38;5;13
+.wmv 38;5;13
+.asf 38;5;13
+.rm 38;5;13
+.rmvb 38;5;13
+.flc 38;5;13
+.avi 38;5;13
+.fli 38;5;13
+.flv 38;5;13
+.gl 38;5;13
+.dl 38;5;13
+.xcf 38;5;13
+.xwd 38;5;13
+.yuv 38;5;13
+.cgm 38;5;13
+.emf 38;5;13
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
-.ogv 01;35
-.ogx 01;35
+.ogv 38;5;13
+.ogx 38;5;13
# audio formats
-.aac 00;36
-.au 00;36
-.flac 00;36
-.m4a 00;36
-.mid 00;36
-.midi 00;36
-.mka 00;36
-.mp3 00;36
-.mpc 00;36
-.ogg 00;36
-.ra 00;36
-.wav 00;36
+.aac 38;5;45
+.au 38;5;45
+.flac 38;5;45
+.m4a 38;5;45
+.mid 38;5;45
+.midi 38;5;45
+.mka 38;5;45
+.mp3 38;5;45
+.mpc 38;5;45
+.ogg 38;5;45
+.ra 38;5;45
+.wav 38;5;45
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
-.oga 00;36
-.opus 00;36
-.spx 00;36
-.xspf 00;36
+.oga 38;5;45
+.opus 38;5;45
+.spx 38;5;45
+.xspf 38;5;45
diff --git a/DIR_COLORS.lightbgcolor b/DIR_COLORS.lightbgcolor
index d2ea453..95d6879 100644
--- a/DIR_COLORS.lightbgcolor
+++ b/DIR_COLORS.lightbgcolor
@@ -1,3 +1,9 @@
+# Configuration file for the color ls utility - modified for lighter backgrounds
+
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
@@ -8,6 +14,9 @@
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
+# For compatibility, the pattern "^COLOR.*none" is recognized as a way to
+# disable colorization. See https://bugzilla.redhat.com/1349579 for details.
+
# Below are TERM entries, which can be a glob patterns, to match
# against the TERM environment variable to determine if it is colorizable.
TERM Eterm
@@ -46,17 +55,17 @@ TERM xterm*
#NORMAL 00 # no color code at all
#FILE 00 # regular file: use no color at all
RESET 0 # reset to "normal" color
-DIR 01;34 # directory
-LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
+DIR 00;34 # directory
+LINK 00;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;33 # pipe
-SOCK 01;35 # socket
-DOOR 01;35 # door
+SOCK 00;35 # socket
+DOOR 00;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
-MISSING 00 # ... and the files they point to
+MISSING 01;05;37;41 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
@@ -65,7 +74,7 @@ OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
-EXEC 01;32
+EXEC 00;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
@@ -83,105 +92,105 @@ EXEC 01;32
#.csh 01;32
# archives or compressed (bright red)
-.tar 01;31
-.tgz 01;31
-.arc 01;31
-.arj 01;31
-.taz 01;31
-.lha 01;31
-.lz4 01;31
-.lzh 01;31
-.lzma 01;31
-.tlz 01;31
-.txz 01;31
-.tzo 01;31
-.t7z 01;31
-.zip 01;31
-.z 01;31
-.dz 01;31
-.gz 01;31
-.lrz 01;31
-.lz 01;31
-.lzo 01;31
-.xz 01;31
-.zst 01;31
-.tzst 01;31
-.bz2 01;31
-.bz 01;31
-.tbz 01;31
-.tbz2 01;31
-.tz 01;31
-.deb 01;31
-.rpm 01;31
-.jar 01;31
-.war 01;31
-.ear 01;31
-.sar 01;31
-.rar 01;31
-.alz 01;31
-.ace 01;31
-.zoo 01;31
-.cpio 01;31
-.7z 01;31
-.rz 01;31
-.cab 01;31
-.wim 01;31
-.swm 01;31
-.dwm 01;31
-.esd 01;31
+.tar 00;31
+.tgz 00;31
+.arc 00;31
+.arj 00;31
+.taz 00;31
+.lha 00;31
+.lz4 00;31
+.lzh 00;31
+.lzma 00;31
+.tlz 00;31
+.txz 00;31
+.tzo 00;31
+.t7z 00;31
+.zip 00;31
+.z 00;31
+.dz 00;31
+.gz 00;31
+.lrz 00;31
+.lz 00;31
+.lzo 00;31
+.xz 00;31
+.zst 00;31
+.tzst 00;31
+.bz2 00;31
+.bz 00;31
+.tbz 00;31
+.tbz2 00;31
+.tz 00;31
+.deb 00;31
+.rpm 00;31
+.jar 00;31
+.war 00;31
+.ear 00;31
+.sar 00;31
+.rar 00;31
+.alz 00;31
+.ace 00;31
+.zoo 00;31
+.cpio 00;31
+.7z 00;31
+.rz 00;31
+.cab 00;31
+.wim 00;31
+.swm 00;31
+.dwm 00;31
+.esd 00;31
# image formats
-.jpg 01;35
-.jpeg 01;35
-.mjpg 01;35
-.mjpeg 01;35
-.gif 01;35
-.bmp 01;35
-.pbm 01;35
-.pgm 01;35
-.ppm 01;35
-.tga 01;35
-.xbm 01;35
-.xpm 01;35
-.tif 01;35
-.tiff 01;35
-.png 01;35
-.svg 01;35
-.svgz 01;35
-.mng 01;35
-.pcx 01;35
-.mov 01;35
-.mpg 01;35
-.mpeg 01;35
-.m2v 01;35
-.mkv 01;35
-.webm 01;35
-.ogm 01;35
-.mp4 01;35
-.m4v 01;35
-.mp4v 01;35
-.vob 01;35
-.qt 01;35
-.nuv 01;35
-.wmv 01;35
-.asf 01;35
-.rm 01;35
-.rmvb 01;35
-.flc 01;35
-.avi 01;35
-.fli 01;35
-.flv 01;35
-.gl 01;35
-.dl 01;35
-.xcf 01;35
-.xwd 01;35
-.yuv 01;35
-.cgm 01;35
-.emf 01;35
+.jpg 00;35
+.jpeg 00;35
+.mjpg 00;35
+.mjpeg 00;35
+.gif 00;35
+.bmp 00;35
+.pbm 00;35
+.pgm 00;35
+.ppm 00;35
+.tga 00;35
+.xbm 00;35
+.xpm 00;35
+.tif 00;35
+.tiff 00;35
+.png 00;35
+.svg 00;35
+.svgz 00;35
+.mng 00;35
+.pcx 00;35
+.mov 00;35
+.mpg 00;35
+.mpeg 00;35
+.m2v 00;35
+.mkv 00;35
+.webm 00;35
+.ogm 00;35
+.mp4 00;35
+.m4v 00;35
+.mp4v 00;35
+.vob 00;35
+.qt 00;35
+.nuv 00;35
+.wmv 00;35
+.asf 00;35
+.rm 00;35
+.rmvb 00;35
+.flc 00;35
+.avi 00;35
+.fli 00;35
+.flv 00;35
+.gl 00;35
+.dl 00;35
+.xcf 00;35
+.xwd 00;35
+.yuv 00;35
+.cgm 00;35
+.emf 00;35
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
-.ogv 01;35
-.ogx 01;35
+.ogv 00;35
+.ogx 00;35
# audio formats
.aac 00;36
--
2.5.5

View File

@ -0,0 +1,69 @@
From 6d059cebfdefbdf56910a858f8b603d37f10ef6d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 23 Sep 2018 14:13:52 +0200
Subject: [PATCH] vasnprintf: Fix heap memory overrun bug.
Reported by Ben Pfaff <blp@cs.stanford.edu> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00107.html>.
* lib/vasnprintf.c (convert_to_decimal): Allocate one more byte of
memory.
* tests/test-vasnprintf.c (test_function): Add another test.
Upstream-commit: 278b4175c9d7dd47c1a3071554aac02add3b3c35
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
gnulib-tests/test-vasnprintf.c | 21 ++++++++++++++++++++-
lib/vasnprintf.c | 4 +++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/gnulib-tests/test-vasnprintf.c b/gnulib-tests/test-vasnprintf.c
index 19731bc..93d81d7 100644
--- a/gnulib-tests/test-vasnprintf.c
+++ b/gnulib-tests/test-vasnprintf.c
@@ -53,7 +53,26 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (result != NULL);
ASSERT (strcmp (result, "12345") == 0);
ASSERT (length == 5);
- if (size < 6)
+ if (size < 5 + 1)
+ ASSERT (result != buf);
+ ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
+ if (result != buf)
+ free (result);
+ }
+
+ /* Note: This test assumes IEEE 754 representation of 'double' floats. */
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length;
+ char *result;
+
+ memcpy (buf, "DEADBEEF", 8);
+ length = size;
+ result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208") == 0);
+ ASSERT (length == 126);
+ if (size < 126 + 1)
ASSERT (result != buf);
ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
if (result != buf)
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 3b441d0..48ef7a6 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -860,7 +860,9 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
size_t a_len = a.nlimbs;
/* 0.03345 is slightly larger than log(2)/(9*log(10)). */
size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
- char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes));
+ /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the
+ digits of a, followed by 1 byte for the terminating NUL. */
+ char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));
if (c_ptr != NULL)
{
char *d_ptr = c_ptr;
--
2.17.1

View File

@ -0,0 +1,42 @@
From 5d6c2c9b3869938592025ce169659f0c7e9970fc Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Mon, 2 Dec 2019 14:02:02 +0100
Subject: [PATCH] chcon: do not validate security context if SELinux is
disabled
* src/chcon.c (main): Skip call of security_check_context()
in case SELinux is disabled to avoid unnecessary failure.
Bug: https://bugzilla.redhat.com/1777831
Upstream-commit: 5118a2e392c8cffb3c26eaffbb75e2b1ef7607f9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/chcon.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/chcon.c b/src/chcon.c
index 6414406..eea4235 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <getopt.h>
+#include <selinux/selinux.h>
#include "system.h"
#include "dev-ino.h"
@@ -557,7 +558,8 @@ main (int argc, char **argv)
else
{
specified_context = argv[optind++];
- if (security_check_context (se_const (specified_context)) < 0)
+ if (0 < is_selinux_enabled ()
+ && security_check_context (se_const (specified_context)) < 0)
die (EXIT_FAILURE, errno, _("invalid context: %s"),
quote (specified_context));
}
--
2.21.1

View File

@ -0,0 +1,69 @@
From ce137aaf4b0d62b3e4c88816485a3ab0f5c4b3f3 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 6 Dec 2018 13:14:00 +0100
Subject: [PATCH] cp --preserve=xattr: preserve NFSv4 ACL extended attributes
... that cannot be preserved by other means
---
src/copy.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/copy.c b/src/copy.c
index 1a9cdd1..d227e3e 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -640,6 +640,17 @@ copy_attr_free (struct error_context *ctx _GL_UNUSED,
{
}
+/* Include NFSv4 ACL extended attributes that cannot be preserved by
+ other means. Otherwise honor attributes configured for exclusion
+ in /etc/xattr.conf. Return zero to skip. */
+static int
+check_not_nfs4_acl (const char *name, struct error_context *ctx)
+{
+ return attr_copy_check_permissions(name, ctx)
+ || !STRNCMP_LIT (name, "system.nfs4_acl")
+ || !STRNCMP_LIT (name, "system.nfs4acl");
+}
+
/* Exclude SELinux extended attributes that are otherwise handled,
and are problematic to copy again. Also honor attributes
configured for exclusion in /etc/xattr.conf.
@@ -649,7 +660,7 @@ static int
check_selinux_attr (const char *name, struct error_context *ctx)
{
return STRNCMP_LIT (name, "security.selinux")
- && attr_copy_check_permissions (name, ctx);
+ && check_not_nfs4_acl (name, ctx);
}
/* If positive SRC_FD and DST_FD descriptors are passed,
@@ -663,6 +674,9 @@ copy_attr (char const *src_path, int src_fd,
bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
bool some_errors = (!all_errors && !x->reduce_diagnostics);
bool selinux_done = (x->preserve_security_context || x->set_security_context);
+ int (*check) (const char *, struct error_context *) = (selinux_done)
+ ? check_selinux_attr
+ : check_not_nfs4_acl;
struct error_context ctx =
{
.error = all_errors ? copy_attr_allerror : copy_attr_error,
@@ -670,12 +684,10 @@ copy_attr (char const *src_path, int src_fd,
.quote_free = copy_attr_free
};
if (0 <= src_fd && 0 <= dst_fd)
- ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
- selinux_done ? check_selinux_attr : NULL,
+ ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd, check,
(all_errors || some_errors ? &ctx : NULL));
else
- ret = attr_copy_file (src_path, dst_path,
- selinux_done ? check_selinux_attr : NULL,
+ ret = attr_copy_file (src_path, dst_path, check,
(all_errors || some_errors ? &ctx : NULL));
return ret == 0;
--
2.17.2

View File

@ -0,0 +1,74 @@
From b60a61d7e5f6504518095d9ee8c7c8b185bedb23 Mon Sep 17 00:00:00 2001
From: Marc Dionne <marc.dionne@auristor.com>
Date: Wed, 5 Feb 2020 13:35:12 -0800
Subject: [PATCH 1/2] mountlist: Consider AFS filesystems as remote
df --local relies on the ME_REMOTE macro to determine if a given
mount entry should be considered "local". There is special logic
for nfs and smb/cifs mounts, but /afs as mounted by OpenAFS, the
kernel's kafs module or AuriStorFS is treated as a local mount.
* lib/mountlist.c (ME_REMOTE): Treat mounts of type 'afs'
(OpenAFS, kernel kafs) and 'auristorfs' (AuriStorFS) as remote.
Copyright-paperwork-exempt: yes
Upstream-commit: 7a15069b68a376f26c5dca34ae2689c5bf8adc99
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/mountlist.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/mountlist.c b/lib/mountlist.c
index b691f38..1b1e5e4 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -224,6 +224,7 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
#ifndef ME_REMOTE
/* A file system is "remote" if its Fs_name contains a ':'
or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
+ or if it is of type (afs or auristorfs)
or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). */
# define ME_REMOTE(Fs_name, Fs_type) \
(strchr (Fs_name, ':') != NULL \
@@ -231,6 +232,8 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
&& (Fs_name)[1] == '/' \
&& (strcmp (Fs_type, "smbfs") == 0 \
|| strcmp (Fs_type, "cifs") == 0)) \
+ || strcmp (Fs_type, "afs") == 0 \
+ || strcmp (Fs_type, "auristorfs") == 0 \
|| (strcmp("-hosts", Fs_name) == 0))
#endif
--
2.21.1
From 41010dfb0cc100f41fb16d93f9fa36dc07e63ac6 Mon Sep 17 00:00:00 2001
From: Kenneth D'souza <kdsouza@redhat.com>
Date: Sat, 8 Feb 2020 13:54:35 +0000
Subject: [PATCH 2/2] mountlist: consider smb3 file systems as remote
* lib/mountlist.c (ME_REMOTE): Recognize file systems of type
"smb3" as remote.
Upstream-commit: 4d4a22ab1f719b7c6c3fe3dbf45d11baafd3c563
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/mountlist.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/mountlist.c b/lib/mountlist.c
index 1b1e5e4..8ad74a2 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -231,6 +231,7 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
|| ((Fs_name)[0] == '/' \
&& (Fs_name)[1] == '/' \
&& (strcmp (Fs_type, "smbfs") == 0 \
+ || strcmp (Fs_type, "smb3") == 0 \
|| strcmp (Fs_type, "cifs") == 0)) \
|| strcmp (Fs_type, "afs") == 0 \
|| strcmp (Fs_type, "auristorfs") == 0 \
--
2.21.1

View File

@ -0,0 +1,77 @@
From 2eabfbee57be82f755c74cbb05755dce1469ea7c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 6 Nov 2018 10:35:16 -0800
Subject: [PATCH 1/2] sync: fix open fallback bug
Problem caught by Coverity Analysis
and reported by Kamil Dudka (Bug#33287).
* src/sync.c (sync_arg): Fix typo in fallback code.
Upstream-commit: 94d364f157f007f2b23c70863ac8eefe9b21229d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/sync.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/sync.c b/src/sync.c
index bd3671a..607fa8f 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -111,8 +111,10 @@ sync_arg (enum sync_mode mode, char const *file)
if (open_flags != (O_WRONLY | O_NONBLOCK))
fd = open (file, O_WRONLY | O_NONBLOCK);
if (fd < 0)
- error (0, rd_errno, _("error opening %s"), quoteaf (file));
- return false;
+ {
+ error (0, rd_errno, _("error opening %s"), quoteaf (file));
+ return false;
+ }
}
/* We used O_NONBLOCK above to not hang with fifos,
--
2.17.2
From e62ff3068f1f1b1e84d3319f54f1b869bb0bf6cc Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Wed, 7 Nov 2018 00:26:01 +0100
Subject: [PATCH 2/2] sync: add test for the fix in the previous commit
* tests/misc/sync.sh: Add a test with a write-only file for the fix.
Upstream-commit: 4711c49312d54e84996c13c612f7081c95f821a6
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/misc/sync.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/misc/sync.sh b/tests/misc/sync.sh
index f60d28c..3bb6e17 100755
--- a/tests/misc/sync.sh
+++ b/tests/misc/sync.sh
@@ -19,7 +19,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sync
-touch file
+touch file || framework_failure_
# fdatasync+syncfs is nonsensical
returns_ 1 sync --data --file-system || fail=1
@@ -30,6 +30,11 @@ returns_ 1 sync -d || fail=1
# Test syncing of file (fsync) (little side effects)
sync file || fail=1
+# Test syncing of write-only file - which failed since adding argument
+# support to sync in coreutils-8.24.
+chmod 0200 file || framework_failure_
+sync file || fail=1
+
# Ensure multiple args are processed and diagnosed
returns_ 1 sync file nofile || fail=1
--
2.17.2

View File

@ -0,0 +1,451 @@
From 57ee8db4fee8eb6772df1ff18d275594c0b034d4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 5 Jul 2018 09:22:09 -0700
Subject: [PATCH 1/2] renameatu: rename from renameat2
It's looking like Glibc will add a renameat2 function
that is incompatible with Gnulib renameat2; see:
https://sourceware.org/ml/libc-alpha/2018-07/msg00064.html
To help avoid future confusion, rename renameat2 to something else.
Use the name 'renameatu', as the Gnulib function is close to the
Glibc function. Perhaps someday there will also be a renameat2
Gnulib module, which mimicks the future glibc renameat2, but that
can wait as nobody seems to need such a module now.
* NEWS: Mention this.
* lib/renameatu.c: Rename from lib/renameat2.c.
* lib/renameatu.h: Rename from lib/renameat2.h.
* modules/renameatu: Rename from modules/renameat2.
* modules/renameatu-tests: Rename from modules/renameat2-tests.
All uses of "renameat2" in identifiers or file name
changed to "renameatu", except for two instances in
lib/renameatu.c that deal with the Linux kernel's
renameat2 syscall.
Upstream-commit: 2522322e5304e7d86c63e607e2bc83c8d8b0a889
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
gnulib-tests/gnulib.mk | 12 +++---
.../{test-renameat2.c => test-renameatu.c} | 48 +++++++++++-----------
lib/backupfile.c | 4 +-
lib/gnulib.mk | 10 ++---
lib/renameat.c | 4 +-
lib/{renameat2.c => renameatu.c} | 9 ++--
lib/{renameat2.h => renameatu.h} | 8 ++--
7 files changed, 48 insertions(+), 47 deletions(-)
rename gnulib-tests/{test-renameat2.c => test-renameatu.c} (80%)
rename lib/{renameat2.c => renameatu.c} (94%)
rename lib/{renameat2.h => renameatu.h} (84%)
diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk
index be2b99e..891425b 100644
--- a/gnulib-tests/gnulib.mk
+++ b/gnulib-tests/gnulib.mk
@@ -1750,14 +1750,14 @@ EXTRA_DIST += test-rename.h test-renameat.c signature.h macros.h
## end gnulib module renameat-tests
-## begin gnulib module renameat2-tests
+## begin gnulib module renameatu-tests
-TESTS += test-renameat2
-check_PROGRAMS += test-renameat2
-test_renameat2_LDADD = $(LDADD) @LIBINTL@
-EXTRA_DIST += test-rename.h test-renameat2.c signature.h macros.h
+TESTS += test-renameatu
+check_PROGRAMS += test-renameatu
+test_renameatu_LDADD = $(LDADD) @LIBINTL@
+EXTRA_DIST += test-rename.h test-renameatu.c signature.h macros.h
-## end gnulib module renameat2-tests
+## end gnulib module renameatu-tests
## begin gnulib module rmdir-tests
diff --git a/gnulib-tests/test-renameat2.c b/gnulib-tests/test-renameatu.c
similarity index 80%
rename from gnulib-tests/test-renameat2.c
rename to gnulib-tests/test-renameatu.c
index 0104890..988428b 100644
--- a/gnulib-tests/test-renameat2.c
+++ b/gnulib-tests/test-renameatu.c
@@ -1,4 +1,4 @@
-/* Test renameat2.
+/* Test renameatu.
Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -18,12 +18,12 @@
#include <config.h>
-#include <renameat2.h>
+#include <renameatu.h>
#include <stdio.h>
#include "signature.h"
-SIGNATURE_CHECK (renameat2, int,
+SIGNATURE_CHECK (renameatu, int,
(int, char const *, int, char const *, unsigned int));
#include <dirent.h>
@@ -39,18 +39,18 @@ SIGNATURE_CHECK (renameat2, int,
#include "ignore-value.h"
#include "macros.h"
-#define BASE "test-renameat2.t"
+#define BASE "test-renameatu.t"
#include "test-rename.h"
static int dfd1 = AT_FDCWD;
static int dfd2 = AT_FDCWD;
-/* Wrapper to test renameat2 like rename. */
+/* Wrapper to test renameatu like rename. */
static int
do_rename (char const *name1, char const *name2)
{
- return renameat2 (dfd1, name1, dfd2, name2, 0);
+ return renameatu (dfd1, name1, dfd2, name2, 0);
}
int
@@ -67,24 +67,24 @@ main (void)
/* Test behaviour for invalid file descriptors. */
{
errno = 0;
- ASSERT (renameat2 (-1, "foo", AT_FDCWD, "bar", 0) == -1);
+ ASSERT (renameatu (-1, "foo", AT_FDCWD, "bar", 0) == -1);
ASSERT (errno == EBADF);
}
{
close (99);
errno = 0;
- ASSERT (renameat2 (99, "foo", AT_FDCWD, "bar", 0) == -1);
+ ASSERT (renameatu (99, "foo", AT_FDCWD, "bar", 0) == -1);
ASSERT (errno == EBADF);
}
ASSERT (close (creat (BASE "oo", 0600)) == 0);
{
errno = 0;
- ASSERT (renameat2 (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
+ ASSERT (renameatu (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
ASSERT (errno == EBADF);
}
{
errno = 0;
- ASSERT (renameat2 (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
+ ASSERT (renameatu (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
ASSERT (errno == EBADF);
}
ASSERT (unlink (BASE "oo") == 0);
@@ -133,13 +133,13 @@ main (void)
ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2);
ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2);
- ASSERT (renameat2 (fd1, file1, fd2, file2, 0) == 0);
+ ASSERT (renameatu (fd1, file1, fd2, file2, 0) == 0);
free (file1);
free (file2);
}
dfd2 = open ("..", O_RDONLY);
ASSERT (0 <= dfd2);
- ASSERT (renameat2 (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
+ ASSERT (renameatu (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
ASSERT (close (dfd2) == 0);
/* Now we change back to the parent directory, and set dfd to ".";
@@ -152,47 +152,47 @@ main (void)
ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
ASSERT (errno == EEXIST || errno == ENOTEMPTY);
ASSERT (unlink (BASE "sub2/file") == 0);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY
|| errno == ENOTEMPTY || errno == EEXIST
|| errno == ENOENT /* WSL */);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
|| errno == ENOENT /* WSL */);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
ASSERT (errno == EISDIR);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
ASSERT (errno == ENOENT);
errno = 0;
- ASSERT (renameat2 (dfd, "", dfd, BASE "17", 0) == -1);
+ ASSERT (renameatu (dfd, "", dfd, BASE "17", 0) == -1);
ASSERT (errno == ENOENT);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "17", dfd, "", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "17", dfd, "", 0) == -1);
ASSERT (errno == ENOENT);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
ASSERT (errno == ENOTDIR);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
ASSERT (errno == ENOTDIR);
errno = 0;
- ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
+ ASSERT (renameatu (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
ASSERT (errno == ENOTDIR || errno == ENOENT);
/* Finally, make sure we cannot overwrite existing files. */
ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
errno = 0;
- ASSERT ((renameat2 (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
+ ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
== -1)
&& errno == EEXIST);
- ASSERT ((renameat2 (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
+ ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
== -1)
&& errno == EEXIST);
diff --git a/lib/backupfile.c b/lib/backupfile.c
index d438455..637be6c 100644
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -23,7 +23,7 @@
#include "backup-internal.h"
#include "dirname.h"
-#include "renameat2.h"
+#include "renameatu.h"
#include "xalloc-oversized.h"
#include <fcntl.h>
@@ -353,7 +353,7 @@ backupfile_internal (char const *file, enum backup_type backup_type, bool rename
base_offset = 0;
}
unsigned flags = backup_type == simple_backups ? 0 : RENAME_NOREPLACE;
- if (renameat2 (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
+ if (renameatu (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
break;
int e = errno;
if (e != EEXIST)
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 04473d5..0b747e3 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alignof alloca announce-gen areadlink-with-size argmatch argv-iter assert autobuild backup-rename backupfile base32 base64 buffer-lcm c-strcase c-strtod c-strtold calloc-gnu canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type di-set diacrit dirfd dirname do-release-commit-and-tag dtoastr dup2 environ error euidaccess exclude exitfail explicit_bzero faccessat fadvise fchdir fchmodat fchownat fclose fcntl fcntl-safer fd-reopen fdatasync fdl fdopen fdutimensat file-has-acl file-type fileblocks filemode filenamecat filevercmp flexmember fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fstatat fsusage fsync ftoastr ftruncate fts full-read full-write getgroups gethrxtime getline getloadavg getlogin getndelim2 getopt-gnu getpagesize getpass-gnu gettext-h gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw heap host-os human idcache ignore-value inttostr inttypes isapipe isatty isblank largefile lchmod lchown ldtoastr lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc-gnu manywarnings mbrlen mbrtowc mbsalign mbschr mbslen mbswidth memcasecmp memchr memcmp2 mempcpy memrchr mgetgroups mkancesdirs mkdir mkdir-p mkfifo mknod mkostemp mkstemp mktime modechange mountlist mpsort netinet_in non-recursive-gnulib-prefix-hack nproc nstrftime obstack open parse-datetime pathmax perl physmem pipe-posix pipe2 posix-shell posixtm posixver priv-set progname propername pthread putenv quote quotearg randint randperm read-file readlink readtokens readtokens0 readutmp realloc-gnu regex remove rename renameat renameat2 rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at setenv settime sig2str sigaction smack ssize_t stat-macros stat-size stat-time statat stdbool stdlib-safer stpcpy stpncpy strdup-posix strncat strnumcmp strsignal strtod strtoimax strtoumax symlinkat sys_ioctl sys_resource sys_stat sys_wait tempname termios time_rz timer-time timespec tzset uname unicodeio unistd-safer unlink-busy unlinkat unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wchar-single wcswidth wcwidth winsz-ioctl winsz-termios write-any-file xalloc xbinary-io xdectoint xfts xgetcwd xgetgroups xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax year2038 yesno
+# Reproduce by: gnulib-tool --import --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alignof alloca announce-gen areadlink-with-size argmatch argv-iter assert autobuild backup-rename backupfile base32 base64 buffer-lcm c-strcase c-strtod c-strtold calloc-gnu canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type di-set diacrit dirfd dirname do-release-commit-and-tag dtoastr dup2 environ error euidaccess exclude exitfail explicit_bzero faccessat fadvise fchdir fchmodat fchownat fclose fcntl fcntl-safer fd-reopen fdatasync fdl fdopen fdutimensat file-has-acl file-type fileblocks filemode filenamecat filevercmp flexmember fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fstatat fsusage fsync ftoastr ftruncate fts full-read full-write getgroups gethrxtime getline getloadavg getlogin getndelim2 getopt-gnu getpagesize getpass-gnu gettext-h gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw heap host-os human idcache ignore-value inttostr inttypes isapipe isatty isblank largefile lchmod lchown ldtoastr lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc-gnu manywarnings mbrlen mbrtowc mbsalign mbschr mbslen mbswidth memcasecmp memchr memcmp2 mempcpy memrchr mgetgroups mkancesdirs mkdir mkdir-p mkfifo mknod mkostemp mkstemp mktime modechange mountlist mpsort netinet_in non-recursive-gnulib-prefix-hack nproc nstrftime obstack open parse-datetime pathmax perl physmem pipe-posix pipe2 posix-shell posixtm posixver priv-set progname propername pthread putenv quote quotearg randint randperm read-file readlink readtokens readtokens0 readutmp realloc-gnu regex remove rename renameat renameatu rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at setenv settime sig2str sigaction smack ssize_t stat-macros stat-size stat-time statat stdbool stdlib-safer stpcpy stpncpy strdup-posix strncat strnumcmp strsignal strtod strtoimax strtoumax symlinkat sys_ioctl sys_resource sys_stat sys_wait tempname termios time_rz timer-time timespec tzset uname unicodeio unistd-safer unlink-busy unlinkat unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wchar-single wcswidth wcwidth winsz-ioctl winsz-termios write-any-file xalloc xbinary-io xdectoint xfts xgetcwd xgetgroups xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax year2038 yesno
MOSTLYCLEANFILES += lib/core lib/*.stackdump
@@ -3218,15 +3218,15 @@ EXTRA_lib_libcoreutils_a_SOURCES += lib/renameat.c
## end gnulib module renameat
-## begin gnulib module renameat2
+## begin gnulib module renameatu
-lib_libcoreutils_a_SOURCES += lib/renameat2.c
+lib_libcoreutils_a_SOURCES += lib/renameatu.c
-EXTRA_DIST += lib/at-func2.c lib/renameat2.h
+EXTRA_DIST += lib/at-func2.c lib/renameatu.h
EXTRA_lib_libcoreutils_a_SOURCES += lib/at-func2.c
-## end gnulib module renameat2
+## end gnulib module renameatu
## begin gnulib module rewinddir
diff --git a/lib/renameat.c b/lib/renameat.c
index 0cb7d33..67be22b 100644
--- a/lib/renameat.c
+++ b/lib/renameat.c
@@ -16,10 +16,10 @@
#include <config.h>
#include <stdio.h>
-#include "renameat2.h"
+#include "renameatu.h"
int
renameat (int fd1, char const *src, int fd2, char const *dst)
{
- return renameat2 (fd1, src, fd2, dst, 0);
+ return renameatu (fd1, src, fd2, dst, 0);
}
diff --git a/lib/renameat2.c b/lib/renameatu.c
similarity index 94%
rename from lib/renameat2.c
rename to lib/renameatu.c
index a295ec3..b013ad6 100644
--- a/lib/renameat2.c
+++ b/lib/renameatu.c
@@ -18,7 +18,7 @@
#include <config.h>
-#include "renameat2.h"
+#include "renameatu.h"
#include <errno.h>
#include <stdio.h>
@@ -68,10 +68,13 @@ rename_noreplace (char const *src, char const *dst)
the restore_cwd fails, then give a diagnostic and exit nonzero.
Obey FLAGS when doing the renaming. If FLAGS is zero, this
- function is equivalent to renameat (FD1, SRC, FD2, DST). */
+ function is equivalent to renameat (FD1, SRC, FD2, DST).
+ Otherwise, attempt to implement FLAGS even if the implementation is
+ not atomic; this differs from the GNU/Linux native renameat2,
+ which fails if it cannot guarantee atomicity. */
int
-renameat2 (int fd1, char const *src, int fd2, char const *dst,
+renameatu (int fd1, char const *src, int fd2, char const *dst,
unsigned int flags)
{
int ret_val = -1;
diff --git a/lib/renameat2.h b/lib/renameatu.h
similarity index 84%
rename from lib/renameat2.h
rename to lib/renameatu.h
index aba7966..7d79775 100644
--- a/lib/renameat2.h
+++ b/lib/renameatu.h
@@ -16,15 +16,13 @@
/* written by Paul Eggert */
-/* Get RENAME_* macros from linux/fs.h if present, otherwise supply
+/* Get RENAME_* macros from <stdio.h> if present, otherwise supply
the traditional Linux values. */
-#if HAVE_LINUX_FS_H
-# include <linux/fs.h>
-#endif
+#include <stdio.h>
#ifndef RENAME_NOREPLACE
# define RENAME_NOREPLACE (1 << 0)
# define RENAME_EXCHANGE (1 << 1)
# define RENAME_WHITEOUT (1 << 2)
#endif
-extern int renameat2 (int, char const *, int, char const *, unsigned int);
+extern int renameatu (int, char const *, int, char const *, unsigned int);
--
2.14.4
From a6b7ff5ef538bbdff4550a56fed878e9cd951d6d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 5 Jul 2018 09:33:48 -0700
Subject: [PATCH 2/2] build: update gnulib submodule to latest
* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
Adjust to renaming of renameat2 to renameatu.
Upstream-commit: 439741053256618eb651e6d43919df29625b8714
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
bootstrap.conf | 2 +-
src/copy.c | 4 ++--
src/mv.c | 4 ++--
src/shred.c | 4 ++--
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 4da4f94..fcf29dc 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -210,7 +210,7 @@ gnulib_modules="
remove
rename
renameat
- renameat2
+ renameatu
rmdir
root-dev-ino
rpmatch
diff --git a/src/copy.c b/src/copy.c
index 58d2f6e..1a9cdd1 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -53,7 +53,7 @@
#include "ignore-value.h"
#include "ioblksize.h"
#include "quote.h"
-#include "renameat2.h"
+#include "renameatu.h"
#include "root-uid.h"
#include "same.h"
#include "savedir.h"
@@ -1873,7 +1873,7 @@ copy_internal (char const *src_name, char const *dst_name,
if (x->move_mode)
{
if (rename_errno < 0)
- rename_errno = (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name,
+ rename_errno = (renameatu (AT_FDCWD, src_name, AT_FDCWD, dst_name,
RENAME_NOREPLACE)
? errno : 0);
new_dst = rename_errno == 0;
diff --git a/src/mv.c b/src/mv.c
index b6dd72d..36fd1af 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -31,7 +31,7 @@
#include "error.h"
#include "filenamecat.h"
#include "remove.h"
-#include "renameat2.h"
+#include "renameatu.h"
#include "root-dev-ino.h"
#include "priv-set.h"
@@ -456,7 +456,7 @@ main (int argc, char **argv)
{
assert (2 <= n_files);
if (n_files == 2)
- x.rename_errno = (renameat2 (AT_FDCWD, file[0], AT_FDCWD, file[1],
+ x.rename_errno = (renameatu (AT_FDCWD, file[0], AT_FDCWD, file[1],
RENAME_NOREPLACE)
? errno : 0);
if (x.rename_errno != 0 && target_directory_operand (file[n_files - 1]))
diff --git a/src/shred.c b/src/shred.c
index 2ddaadd..270b1e9 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -93,7 +93,7 @@
#include "human.h"
#include "randint.h"
#include "randread.h"
-#include "renameat2.h"
+#include "renameatu.h"
#include "stat-size.h"
/* Default number of times to overwrite. */
@@ -1096,7 +1096,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
memset (base, nameset[0], len);
base[len] = 0;
bool rename_ok;
- while (! (rename_ok = (renameat2 (AT_FDCWD, oldname, AT_FDCWD, newname,
+ while (! (rename_ok = (renameatu (AT_FDCWD, oldname, AT_FDCWD, newname,
RENAME_NOREPLACE)
== 0))
&& errno == EEXIST && incname (base, len))
--
2.14.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,469 @@
From 95f427178720d047316e95f44777cfdf2ecf2b46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Fri, 4 Jan 2019 09:29:13 -0800
Subject: [PATCH 1/4] tail: don't exit immediately with filters on AIX
* src/tail.c: Fix the check_output_available check on AIX.
Note we don't use poll for all systems as the overhead
of adding the gnulib poll module wouldn't be worth it
just for this single use.
* tests/tail-2/pipe-f.sh: Fix the test which always passed
due to only the exit code of sleep being checked.
* NEWS: Mention the bug fix and rearrange alphabetically.
Fixes http://bugs.gnu.org/33946
Upstream-commit: d5ab4cbe424e3e95140eec22ef828f50b2fb3067
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tail.c | 13 +++++++++++++
tests/tail-2/pipe-f.sh | 5 ++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/tail.c b/src/tail.c
index ac001d7..d63aacc 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -30,6 +30,9 @@
#include <getopt.h>
#include <sys/types.h>
#include <signal.h>
+#ifdef _AIX
+# include <poll.h>
+#endif
#include "system.h"
#include "argmatch.h"
@@ -335,6 +338,16 @@ named file in a way that accommodates renaming, removal and creation.\n\
static void
check_output_alive (void)
{
+#ifdef _AIX
+ /* select on AIX was seen to give a readable event immediately. */
+ struct pollfd pfd;
+ pfd.fd = STDOUT_FILENO;
+ pfd.events = POLLERR;
+
+ if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
+ raise (SIGPIPE);
+#endif
+
if (! monitor_output)
return;
diff --git a/tests/tail-2/pipe-f.sh b/tests/tail-2/pipe-f.sh
index 76b0d90..1126c93 100755
--- a/tests/tail-2/pipe-f.sh
+++ b/tests/tail-2/pipe-f.sh
@@ -37,7 +37,10 @@ compare exp out || fail=1
# This would wait indefinitely before v8.28 due to no EPIPE being
# generated due to no data written after the first small amount
-timeout 10 tail -f $mode $fastpoll out | sleep .1 || fail=1
+(returns_ 124 timeout 10 tail -n2 -f $mode $fastpoll out && touch timed_out) |
+ sed 2q > out2
+test -e timed_out && fail=1
+compare exp out2 || fail=1
# This would wait indefinitely before v8.28 (until first write)
(returns_ 1 timeout 10 tail -f $mode $fastpoll /dev/null >&-) || fail=1
--
2.31.1
From 125bb79d3e9f414533b1c29237ee3f647053d0d6 Mon Sep 17 00:00:00 2001
From: Ayappan <ayappap2@in.ibm.com>
Date: Sun, 20 Jan 2019 00:17:33 -0800
Subject: [PATCH 2/4] tail: fix recent ineffective AIX change
* src/tail.c: Fix commit v8.30-40-gd5ab4cb which was ineffective.
Fixes http://bugs.gnu.org/33946
Upstream-commit: 17983b2cb3bccbb4fa69691178caddd99269bda9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tail.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/tail.c b/src/tail.c
index d63aacc..9ed6d48 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -338,6 +338,9 @@ named file in a way that accommodates renaming, removal and creation.\n\
static void
check_output_alive (void)
{
+ if (! monitor_output)
+ return;
+
#ifdef _AIX
/* select on AIX was seen to give a readable event immediately. */
struct pollfd pfd;
@@ -346,11 +349,7 @@ check_output_alive (void)
if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
raise (SIGPIPE);
-#endif
-
- if (! monitor_output)
- return;
-
+#else
struct timeval delay;
delay.tv_sec = delay.tv_usec = 0;
@@ -362,6 +361,7 @@ check_output_alive (void)
and implies an error condition on output like broken pipe. */
if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1)
raise (SIGPIPE);
+#endif
}
static bool
--
2.31.1
From 7741989c3e633aa44f01d8f91332cb65a9280ba3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Sun, 20 Jan 2019 00:13:15 -0800
Subject: [PATCH 3/4] tail: fix handling of broken pipes with SIGPIPE ignored
* init.cfg (trap_sigpipe_or_skip_): A new function refactored from...
* tests/misc/printf-surprise.sh: ...here.
* tests/misc/seq-epipe.sh. Likewise.
* src/tail.c (die_pipe): Ensure we exit upon sending SIGPIPE.
* tests/tail-2/pipe-f.sh: Ensure we exit even if SIGPIPE is ignored.
* NEWS: Mention the bug fix.
Upstream-commit: fa50623394f491b975dbd7ad73193519dd721771
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
init.cfg | 6 ++++++
src/tail.c | 14 +++++++++++---
tests/misc/printf-surprise.sh | 4 +---
tests/misc/seq-epipe.sh | 4 +---
tests/tail-2/pipe-f.sh | 19 ++++++++++++++-----
5 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/init.cfg b/init.cfg
index b6c81ab..985c8d3 100644
--- a/init.cfg
+++ b/init.cfg
@@ -613,6 +613,12 @@ mkfifo_or_skip_()
fi
}
+trap_sigpipe_or_skip_()
+{
+ (trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
+ skip_ 'trapping SIGPIPE is not supported'
+}
+
# Disable the current test if the working directory seems to have
# the setgid bit set.
skip_if_setgid_()
diff --git a/src/tail.c b/src/tail.c
index 9ed6d48..16e0d73 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -333,6 +333,14 @@ named file in a way that accommodates renaming, removal and creation.\n\
exit (status);
}
+/* Ensure exit, either with SIGPIPE or EXIT_FAILURE status. */
+static void ATTRIBUTE_NORETURN
+die_pipe (void)
+{
+ raise (SIGPIPE);
+ exit (EXIT_FAILURE);
+}
+
/* If the output has gone away, then terminate
as we would if we had written to this output. */
static void
@@ -348,7 +356,7 @@ check_output_alive (void)
pfd.events = POLLERR;
if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
- raise (SIGPIPE);
+ die_pipe ();
#else
struct timeval delay;
delay.tv_sec = delay.tv_usec = 0;
@@ -360,7 +368,7 @@ check_output_alive (void)
/* readable event on STDOUT is equivalent to POLLERR,
and implies an error condition on output like broken pipe. */
if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1)
- raise (SIGPIPE);
+ die_pipe ();
#endif
}
@@ -1658,7 +1666,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
{
/* readable event on STDOUT is equivalent to POLLERR,
and implies an error on output like broken pipe. */
- raise (SIGPIPE);
+ die_pipe ();
}
else
break;
diff --git a/tests/misc/printf-surprise.sh b/tests/misc/printf-surprise.sh
index fd88133..acac0b1 100755
--- a/tests/misc/printf-surprise.sh
+++ b/tests/misc/printf-surprise.sh
@@ -49,9 +49,7 @@ vm=$(get_min_ulimit_v_ env $prog %20f 0) \
# triggering the printf(3) misbehavior -- which, btw, is required by ISO C99.
mkfifo_or_skip_ fifo
-
-(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
- skip_ 'trapping SIGPIPE is not supported'
+trap_sigpipe_or_skip_
# Disable MALLOC_PERTURB_, to avoid triggering this bug
# https://bugs.debian.org/481543#77
diff --git a/tests/misc/seq-epipe.sh b/tests/misc/seq-epipe.sh
index 3e89158..127d61c 100755
--- a/tests/misc/seq-epipe.sh
+++ b/tests/misc/seq-epipe.sh
@@ -18,9 +18,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ seq
-
-(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
- skip_ 'trapping SIGPIPE is not supported'
+trap_sigpipe_or_skip_
# upon EPIPE with signals ignored, 'seq' should exit with an error.
timeout 10 sh -c \
diff --git a/tests/tail-2/pipe-f.sh b/tests/tail-2/pipe-f.sh
index 1126c93..f734a61 100755
--- a/tests/tail-2/pipe-f.sh
+++ b/tests/tail-2/pipe-f.sh
@@ -18,6 +18,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail
+trap_sigpipe_or_skip_
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
@@ -36,11 +37,19 @@ echo bar | returns_ 1 \
compare exp out || fail=1
# This would wait indefinitely before v8.28 due to no EPIPE being
-# generated due to no data written after the first small amount
-(returns_ 124 timeout 10 tail -n2 -f $mode $fastpoll out && touch timed_out) |
- sed 2q > out2
-test -e timed_out && fail=1
-compare exp out2 || fail=1
+# generated due to no data written after the first small amount.
+# Also check tail exits if SIGPIPE is being ignored.
+# Note 'trap - SIGPIPE' is ineffective if the initiating shell
+# has ignored SIGPIPE, but that's not the normal case.
+for disposition in '' '-'; do
+ (trap "$disposition" PIPE;
+ returns_ 124 timeout 10 \
+ tail -n2 -f $mode $fastpoll out && touch timed_out) |
+ sed 2q > out2
+ test -e timed_out && fail=1
+ compare exp out2 || fail=1
+ rm -f timed_out
+done
# This would wait indefinitely before v8.28 (until first write)
(returns_ 1 timeout 10 tail -f $mode $fastpoll /dev/null >&-) || fail=1
--
2.31.1
From 0f5760466d167e955d28a1250ffd0af347d48dc9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 26 Jun 2021 18:23:52 -0700
Subject: [PATCH 4/4] tail: use poll, not select
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes an unlikely stack out-of-bounds write reported by
Stepan Broz via Kamil Dudka (Bug#49209).
* src/tail.c: Do not include <sys/select.h>.
[!_AIX]: Include poll.h.
(check_output_alive) [!_AIX]: Use poll instead of select.
(tail_forever_inotify): Likewise. Simplify logic, as there is no
need for a while (len <= evbuf_off) loop.
Upstream-commit: da0d448bca62c6305fc432f67e2c5ccc2da75346
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tail.c | 101 +++++++++++++++++++++--------------------------------
1 file changed, 39 insertions(+), 62 deletions(-)
diff --git a/src/tail.c b/src/tail.c
index 16e0d73..d77c660 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -29,10 +29,8 @@
#include <assert.h>
#include <getopt.h>
#include <sys/types.h>
+#include <poll.h>
#include <signal.h>
-#ifdef _AIX
-# include <poll.h>
-#endif
#include "system.h"
#include "argmatch.h"
@@ -55,8 +53,6 @@
#if HAVE_INOTIFY
# include "hash.h"
# include <sys/inotify.h>
-/* 'select' is used by tail_forever_inotify. */
-# include <sys/select.h>
/* inotify needs to know if a file is local. */
# include "fs.h"
@@ -349,27 +345,12 @@ check_output_alive (void)
if (! monitor_output)
return;
-#ifdef _AIX
- /* select on AIX was seen to give a readable event immediately. */
struct pollfd pfd;
pfd.fd = STDOUT_FILENO;
pfd.events = POLLERR;
if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
die_pipe ();
-#else
- struct timeval delay;
- delay.tv_sec = delay.tv_usec = 0;
-
- fd_set rfd;
- FD_ZERO (&rfd);
- FD_SET (STDOUT_FILENO, &rfd);
-
- /* readable event on STDOUT is equivalent to POLLERR,
- and implies an error condition on output like broken pipe. */
- if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1)
- die_pipe ();
-#endif
}
static bool
@@ -1609,7 +1590,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
/* Wait for inotify events and handle them. Events on directories
ensure that watched files can be re-added when following by name.
This loop blocks on the 'safe_read' call until a new event is notified.
- But when --pid=P is specified, tail usually waits via the select. */
+ But when --pid=P is specified, tail usually waits via poll. */
while (1)
{
struct File_spec *fspec;
@@ -1626,54 +1607,51 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
return false;
}
- /* When watching a PID, ensure that a read from WD will not block
- indefinitely. */
- while (len <= evbuf_off)
+ if (len <= evbuf_off)
{
- struct timeval delay; /* how long to wait for file changes. */
+ /* Poll for inotify events. When watching a PID, ensure
+ that a read from WD will not block indefinitely.
+ If MONITOR_OUTPUT, also poll for a broken output pipe. */
- if (pid)
+ int file_change;
+ struct pollfd pfd[2];
+ do
{
- if (writer_is_dead)
- exit (EXIT_SUCCESS);
+ /* How many ms to wait for changes. -1 means wait forever. */
+ int delay = -1;
- writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM);
-
- if (writer_is_dead)
- delay.tv_sec = delay.tv_usec = 0;
- else
+ if (pid)
{
- delay.tv_sec = (time_t) sleep_interval;
- delay.tv_usec = 1000000 * (sleep_interval - delay.tv_sec);
+ if (writer_is_dead)
+ exit (EXIT_SUCCESS);
+
+ writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM);
+
+ if (writer_is_dead || sleep_interval <= 0)
+ delay = 0;
+ else if (sleep_interval < INT_MAX / 1000 - 1)
+ {
+ /* delay = ceil (sleep_interval * 1000), sans libm. */
+ double ddelay = sleep_interval * 1000;
+ delay = ddelay;
+ delay += delay < ddelay;
+ }
}
+
+ pfd[0].fd = wd;
+ pfd[0].events = POLLIN;
+ pfd[1].fd = STDOUT_FILENO;
+ pfd[1].events = pfd[1].revents = 0;
+ file_change = poll (pfd, monitor_output + 1, delay);
}
+ while (file_change == 0);
- fd_set rfd;
- FD_ZERO (&rfd);
- FD_SET (wd, &rfd);
- if (monitor_output)
- FD_SET (STDOUT_FILENO, &rfd);
-
- int file_change = select (MAX (wd, STDOUT_FILENO) + 1,
- &rfd, NULL, NULL, pid ? &delay: NULL);
-
- if (file_change == 0)
- continue;
- else if (file_change == -1)
- die (EXIT_FAILURE, errno,
- _("error waiting for inotify and output events"));
- else if (FD_ISSET (STDOUT_FILENO, &rfd))
- {
- /* readable event on STDOUT is equivalent to POLLERR,
- and implies an error on output like broken pipe. */
- die_pipe ();
- }
- else
- break;
- }
+ if (file_change < 0)
+ die (EXIT_FAILURE, errno,
+ _("error waiting for inotify and output events"));
+ if (pfd[1].revents)
+ die_pipe ();
- if (len <= evbuf_off)
- {
len = safe_read (wd, evbuf, evlen);
evbuf_off = 0;
@@ -2434,8 +2412,7 @@ main (int argc, char **argv)
if (forever && ignore_fifo_and_pipe (F, n_files))
{
/* If stdout is a fifo or pipe, then monitor it
- so that we exit if the reader goes away.
- Note select() on a regular file is always readable. */
+ so that we exit if the reader goes away. */
struct stat out_stat;
if (fstat (STDOUT_FILENO, &out_stat) < 0)
die (EXIT_FAILURE, errno, _("standard output"));
--
2.31.1

View File

@ -0,0 +1,36 @@
From ef6be60dcaf424bdb21392aff42331bd4dc272e0 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 14 Mar 2019 13:48:01 +0100
Subject: [PATCH] md5sum,b2sum,sha*sum: --help: add note about binary/text mode
* src/md5sum.c (usage): Make it clear that there is no difference
between binary mode and text mode on GNU systems.
Bug: https://bugzilla.redhat.com/406981
Bug: https://bugzilla.redhat.com/1688740
Upstream-commit: ae61b1066351bb784b54fbfd7b52caf129ec286c
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/md5sum.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/md5sum.c b/src/md5sum.c
index 3532f7b7a..f75b6de02 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -287,7 +287,10 @@ The following five options are useful only when verifying checksums:\n\
The sums are computed as described in %s. When checking, the input\n\
should be a former output of this program. The default mode is to print a\n\
line with checksum, a space, a character indicating input mode ('*' for binary,\
-\n' ' for text or where binary is insignificant), and name for each FILE.\n"),
+\n' ' for text or where binary is insignificant), and name for each FILE.\n\
+\n\
+Note: There is no difference between binary mode and text mode on GNU systems.\
+\n"),
DIGEST_REFERENCE);
emit_ancillary_info (PROGRAM_NAME);
}
--
2.17.2

View File

@ -1,100 +0,0 @@
From 81e25c8521937ecf7f444bab11fddaaf81cc3efd Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Fri, 17 Jun 2016 16:58:18 +0200
Subject: [PATCH] downstream changes to default DIR_COLORS
---
DIR_COLORS | 9 ++++++++-
DIR_COLORS.lightbgcolor | 21 +++++++++++++++------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/DIR_COLORS b/DIR_COLORS
index bd5df23..84f2417 100644
--- a/DIR_COLORS
+++ b/DIR_COLORS
@@ -1,3 +1,7 @@
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
@@ -8,6 +12,9 @@
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
+# For compatibility, the pattern "^COLOR.*none" is recognized as a way to
+# disable colorization. See https://bugzilla.redhat.com/1349579 for details.
+
# Below are TERM entries, which can be a glob patterns, to match
# against the TERM environment variable to determine if it is colorizable.
TERM Eterm
@@ -58,7 +65,7 @@ DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
-MISSING 00 # ... and the files they point to
+MISSING 01;37;41 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
diff --git a/DIR_COLORS.lightbgcolor b/DIR_COLORS.lightbgcolor
index 4316832..6402854 100644
--- a/DIR_COLORS.lightbgcolor
+++ b/DIR_COLORS.lightbgcolor
@@ -1,3 +1,9 @@
+# Configuration file for the color ls utility - modified for lighter backgrounds
+
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
@@ -8,6 +14,9 @@
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
+# For compatibility, the pattern "^COLOR.*none" is recognized as a way to
+# disable colorization. See https://bugzilla.redhat.com/1349579 for details.
+
# Below are TERM entries, which can be a glob patterns, to match
# against the TERM environment variable to determine if it is colorizable.
TERM Eterm
@@ -48,17 +57,17 @@ TERM xterm*
#NORMAL 00 # no color code at all
#FILE 00 # regular file: use no color at all
RESET 0 # reset to "normal" color
-DIR 01;34 # directory
-LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
+DIR 00;34 # directory
+LINK 00;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;33 # pipe
-SOCK 01;35 # socket
-DOOR 01;35 # door
+SOCK 00;35 # socket
+DOOR 00;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
-MISSING 00 # ... and the files they point to
+MISSING 01;37;41 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
@@ -67,7 +76,7 @@ OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
-EXEC 01;32
+EXEC 00;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
--
2.21.1

View File

@ -1,52 +0,0 @@
From 51b9a8ba0974d262e0b0f81a2078b3c7907b25ed Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 7 Apr 2021 17:29:59 -0700
Subject: [PATCH] utimens: fix confusing arg type in internal func
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Although the old code was technically correct, this was accidental
and it understandably confused Coverity. Reported by Ondrej Dubaj in:
https://lists.gnu.org/r/bug-tar/2021-04/msg00000.html
* lib/utimens.c (update_timespec): Change arg type from struct
timespec *[2] (pointer to array of 2 pointers to timespecs) to
struct timespec ** (pointer to pointer to the first timespec in
an array of 2 timespecs). Although the old code happened to be
technically correct, it was misleading and confused Coverity.
And though the type struct timespec (**)[2] (pointer to pointer
to array of 2 timespecs) would perhaps be more technically
correct, it would be almost as confusing and would require changes
elsewhere in this file; lets quit while were ahead.
Upstream-commit: a3a946f670718d0dee5a7425ad5ac0a29fb46ea1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/utimens.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/utimens.c b/lib/utimens.c
index 3f53942..ea8c672 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -123,14 +123,14 @@ validate_timespec (struct timespec timespec[2])
return result + (utime_omit_count == 1);
}
-/* Normalize any UTIME_NOW or UTIME_OMIT values in *TS, using stat
- buffer STATBUF to obtain the current timestamps of the file. If
+/* Normalize any UTIME_NOW or UTIME_OMIT values in (*TS)[0] and (*TS)[1],
+ using STATBUF to obtain the current timestamps of the file. If
both times are UTIME_NOW, set *TS to NULL (as this can avoid some
permissions issues). If both times are UTIME_OMIT, return true
(nothing further beyond the prior collection of STATBUF is
necessary); otherwise return false. */
static bool
-update_timespec (struct stat const *statbuf, struct timespec *ts[2])
+update_timespec (struct stat const *statbuf, struct timespec **ts)
{
struct timespec *timespec = *ts;
if (timespec[0].tv_nsec == UTIME_OMIT
--
2.26.3

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +0,0 @@
From 76126e2831580d0df20530f4d6f72189bd4f0b9a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 18 Jun 2020 22:16:24 -0700
Subject: [PATCH] cp: default to COW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Likewise for install. Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.
Upstream-commit: 25725f9d41735d176d73a757430739fb71c7d043
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/coreutils.texi | 19 ++++++++++++-------
src/copy.h | 4 ++--
src/cp.c | 2 +-
src/install.c | 2 +-
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 02e0c1c..2382a16 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -8854,12 +8854,14 @@ The @var{when} value can be one of the following:
@table @samp
@item always
-The default behavior: if the copy-on-write operation is not supported
+If the copy-on-write operation is not supported
then report the failure for each file and exit with a failure status.
+Plain @option{--reflink} is equivalent to @option{--reflink=when}.
@item auto
If the copy-on-write operation is not supported then fall back
to the standard copy behavior.
+This is the default if no @option{--reflink} option is given.
@item never
Disable copy-on-write operation and use the standard copy behavior.
@@ -8868,12 +8870,6 @@ Disable copy-on-write operation and use the standard copy behavior.
This option is overridden by the @option{--link}, @option{--symbolic-link}
and @option{--attributes-only} options, thus allowing it to be used
to configure the default data copying behavior for @command{cp}.
-For example, with the following alias, @command{cp} will use the
-minimum amount of space supported by the file system.
-
-@example
-alias cp='cp --reflink=auto --sparse=always'
-@end example
@item --remove-destination
@opindex --remove-destination
@@ -8918,6 +8914,15 @@ This is useful in creating a file for use with the @command{mkswap} command,
since such a file must not have any holes.
@end table
+For example, with the following alias, @command{cp} will use the
+minimum amount of space supported by the file system.
+(Older versions of @command{cp} can also benefit from
+@option{--reflink=auto} here.)
+
+@example
+alias cp='cp --sparse=always'
+@end example
+
@optStripTrailingSlashes
@item -s
diff --git a/src/copy.h b/src/copy.h
index 874d6f7..a0ad494 100644
--- a/src/copy.h
+++ b/src/copy.h
@@ -46,10 +46,10 @@ enum Sparse_type
/* Control creation of COW files. */
enum Reflink_type
{
- /* Default to a standard copy. */
+ /* Do a standard copy. */
REFLINK_NEVER,
- /* Try a COW copy and fall back to a standard copy. */
+ /* Try a COW copy and fall back to a standard copy; this is the default. */
REFLINK_AUTO,
/* Require a COW copy and fail if not available. */
diff --git a/src/cp.c b/src/cp.c
index 0193df8..9e7ad14 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -796,7 +796,7 @@ cp_option_init (struct cp_options *x)
x->move_mode = false;
x->install_mode = false;
x->one_file_system = false;
- x->reflink_mode = REFLINK_NEVER;
+ x->reflink_mode = REFLINK_AUTO;
x->preserve_ownership = false;
x->preserve_links = false;
diff --git a/src/install.c b/src/install.c
index 4ab44a6..aef16ca 100644
--- a/src/install.c
+++ b/src/install.c
@@ -264,7 +264,7 @@ cp_option_init (struct cp_options *x)
{
cp_options_default (x);
x->copy_as_regular = true;
- x->reflink_mode = REFLINK_NEVER;
+ x->reflink_mode = REFLINK_AUTO;
x->dereference = DEREF_ALWAYS;
x->unlink_dest_before_opening = true;
x->unlink_dest_after_failed_open = false;
--
2.25.4

View File

@ -1,81 +0,0 @@
From 9618fb718b75920f37e5be2049ad1d0bb5c4a28c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 26 Jan 2021 09:23:54 -0800
Subject: [PATCH] expr: fix bug with unmatched \(...\)
Problem reported by Qiuhao Li.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.
Upstream-commit: 735083ba24878075235007b4417982ad5700436d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/coreutils.texi | 14 ++++++++------
src/expr.c | 9 +++++++--
tests/misc/expr.pl | 3 +++
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 2382a16..5b2bb2c 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -13529,12 +13529,14 @@ second is considered to be a (basic, a la GNU @code{grep}) regular
expression, with a @code{^} implicitly prepended. The first argument is
then matched against this regular expression.
-If the match succeeds and @var{regex} uses @samp{\(} and @samp{\)}, the
-@code{:} expression returns the part of @var{string} that matched the
-subexpression; otherwise, it returns the number of characters matched.
-
-If the match fails, the @code{:} operator returns the null string if
-@samp{\(} and @samp{\)} are used in @var{regex}, otherwise 0.
+If @var{regex} does not use @samp{\(} and @samp{\)}, the @code{:}
+expression returns the number of characters matched, or 0 if the match
+fails.
+
+If @var{regex} uses @samp{\(} and @samp{\)}, the @code{:} expression
+returns the part of @var{string} that matched the subexpression, or
+the null string if the match failed or the subexpression did not
+contribute to the match.
@kindex \( @r{regexp operator}
Only the first @samp{\( @dots{} \)} pair is relevant to the return
diff --git a/src/expr.c b/src/expr.c
index e134872..0616a42 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -721,8 +721,13 @@ docolon (VALUE *sv, VALUE *pv)
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0)
{
- sv->u.s[re_regs.end[1]] = '\0';
- v = str_value (sv->u.s + re_regs.start[1]);
+ if (re_regs.end[1] < 0)
+ v = str_value ("");
+ else
+ {
+ sv->u.s[re_regs.end[1]] = '\0';
+ v = str_value (sv->u.s + re_regs.start[1]);
+ }
}
else
{
diff --git a/tests/misc/expr.pl b/tests/misc/expr.pl
index e45f8e7..e57f79d 100755
--- a/tests/misc/expr.pl
+++ b/tests/misc/expr.pl
@@ -84,6 +84,9 @@ my @Tests =
# In 5.94 and earlier, anchors incorrectly matched newlines.
['anchor', "'a\nb' : 'a\$'", {OUT => '0'}, {EXIT => 1}],
+ # In 8.32, \( ... \) that did not match caused memory errors.
+ ['emptysub', '"a" : "\\(b\\)*"', {OUT => ''}, {EXIT => 1}],
+
# These tests are taken from grep/tests/bre.tests.
['bre1', '"abc" : "a\\(b\\)c"', {OUT => 'b'}],
['bre2', '"a(" : "a("', {OUT => '2'}],
--
2.26.2

View File

@ -25,7 +25,7 @@ diff --git a/lib/mountlist.c b/lib/mountlist.c
index e0227b7..e5f6b07 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -170,6 +170,7 @@
@@ -173,6 +173,7 @@
|| strcmp (Fs_type, "debugfs") == 0 \
|| strcmp (Fs_type, "devpts") == 0 \
|| strcmp (Fs_type, "fusectl") == 0 \

View File

@ -1,48 +0,0 @@
From f61085aaa37f169365c56e44f5129d0491913b6a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 27 Aug 2020 17:52:58 -0700
Subject: [PATCH] perror, strerror_r: remove unportable tests
Problem reported by Florian Weimer in:
https://lists.gnu.org/r/bug-gnulib/2020-08/msg00220.html
* tests/test-perror2.c (main):
* tests/test-strerror_r.c (main): Omit unportable tests.
Upstream-commit: 175e0bc72808d564074c4adcc72aeadb74adfcc6
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
gnulib-tests/test-perror2.c | 3 ---
gnulib-tests/test-strerror_r.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/gnulib-tests/test-perror2.c b/gnulib-tests/test-perror2.c
index 1d14eda..c6214dd 100644
--- a/gnulib-tests/test-perror2.c
+++ b/gnulib-tests/test-perror2.c
@@ -79,9 +79,6 @@ main (void)
errno = -5;
perror ("");
ASSERT (!ferror (stderr));
- ASSERT (msg1 == msg2 || msg1 == msg4 || STREQ (msg1, str1));
- ASSERT (msg2 == msg4 || STREQ (msg2, str2));
- ASSERT (msg3 == msg4 || STREQ (msg3, str3));
ASSERT (STREQ (msg4, str4));
free (str1);
diff --git a/gnulib-tests/test-strerror_r.c b/gnulib-tests/test-strerror_r.c
index b11d6fd..c1dbcf8 100644
--- a/gnulib-tests/test-strerror_r.c
+++ b/gnulib-tests/test-strerror_r.c
@@ -165,9 +165,6 @@ main (void)
strerror_r (EACCES, buf, sizeof buf);
strerror_r (-5, buf, sizeof buf);
- ASSERT (msg1 == msg2 || msg1 == msg4 || STREQ (msg1, str1));
- ASSERT (msg2 == msg4 || STREQ (msg2, str2));
- ASSERT (msg3 == msg4 || STREQ (msg3, str3));
ASSERT (STREQ (msg4, str4));
free (str1);
--
2.25.4

View File

@ -1,164 +0,0 @@
From b9f9ed14bda93ecb407129b69e6476813c250046 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 15 Apr 2020 20:50:32 -0700
Subject: [PATCH] fts: remove NOSTAT_LEAF_OPTIMIZATION
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It caused find and du to dump core, and it was useful
only for obsolescent Linux filesystems anyway. Problem reported in:
https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html
Quite possibly there is still a serious underlying fts bug with
tight-loop-check and mutating file systems, but if so this patch
should cause the bug to be triggered less often.
* lib/fts.c (enum leaf_optimization): Remove
NOSTAT_LEAF_OPTIMIZATION, as its problematic.
(S_MAGIC_REISERFS, S_MAGIC_XFS): Remove; no longer needed.
(leaf_optimization): Remove special cases for ReiserFS and XFS.
(fts_read): Remove NOSTAT_LEAF_OPTIMIZATION code.
* lib/fts_.h (struct _ftsent.fts_n_dirs_remaining):
Remove. All uses removed.
Upstream-commit: 47bf2cf3184027c1eb9c1dfeea5c5b8b2d69710d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/fts.c | 56 ++++++++-------------------------------------------
lib/fts_.h | 5 -----
2 files changed, 8 insertions(+), 53 deletions(-)
diff --git a/lib/fts.c b/lib/fts.c
index 1093ce5..dfe3fef 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -445,7 +445,6 @@ fts_open (char * const *argv,
if ((parent = fts_alloc(sp, "", 0)) == NULL)
goto mem2;
parent->fts_level = FTS_ROOTPARENTLEVEL;
- parent->fts_n_dirs_remaining = -1;
}
/* The classic fts implementation would call fts_stat with
@@ -634,9 +633,8 @@ fts_close (FTS *sp)
}
/* Minimum link count of a traditional Unix directory. When leaf
- optimization is OK and MIN_DIR_NLINK <= st_nlink, then st_nlink is
- an upper bound on the number of subdirectories (counting "." and
- ".."). */
+ optimization is OK and a directory's st_nlink == MIN_DIR_NLINK,
+ then the directory has no subdirectories. */
enum { MIN_DIR_NLINK = 2 };
/* Whether leaf optimization is OK for a directory. */
@@ -645,12 +643,8 @@ enum leaf_optimization
/* st_nlink is not reliable for this directory's subdirectories. */
NO_LEAF_OPTIMIZATION,
- /* Leaf optimization is OK, but is not useful for avoiding stat calls. */
- OK_LEAF_OPTIMIZATION,
-
- /* Leaf optimization is not only OK: it is useful for avoiding
- stat calls, because dirent.d_type does not work. */
- NOSTAT_LEAF_OPTIMIZATION
+ /* st_nlink == 2 means the directory lacks subdirectories. */
+ OK_LEAF_OPTIMIZATION
};
#if (defined __linux__ || defined __ANDROID__) \
@@ -663,9 +657,7 @@ enum leaf_optimization
# define S_MAGIC_CIFS 0xFF534D42
# define S_MAGIC_NFS 0x6969
# define S_MAGIC_PROC 0x9FA0
-# define S_MAGIC_REISERFS 0x52654973
# define S_MAGIC_TMPFS 0x1021994
-# define S_MAGIC_XFS 0x58465342
# ifdef HAVE___FSWORD_T
typedef __fsword_t fsword;
@@ -786,23 +778,15 @@ dirent_inode_sort_may_be_useful (FTSENT const *p, int dir_fd)
}
/* Given an FTS entry P for a directory with descriptor DIR_FD,
- return true if it is both useful and valid to apply leaf optimization.
- The optimization is useful only for file systems that lack usable
- dirent.d_type info. The optimization is valid if an st_nlink value
- of at least MIN_DIR_NLINK is an upper bound on the number of
- subdirectories of D, counting "." and ".." as subdirectories.
+ return whether it is valid to apply leaf optimization.
+ The optimization is valid if a directory's st_nlink value equal
+ to MIN_DIR_NLINK means the directory has no subdirectories.
DIR_FD is negative if unavailable. */
static enum leaf_optimization
leaf_optimization (FTSENT const *p, int dir_fd)
{
switch (filesystem_type (p, dir_fd))
{
- /* List here the file system types that may lack usable dirent.d_type
- info, yet for which the optimization does apply. */
- case S_MAGIC_REISERFS:
- case S_MAGIC_XFS: /* XFS lacked it until 2013-08-22 commit. */
- return NOSTAT_LEAF_OPTIMIZATION;
-
case 0:
/* Leaf optimization is unsafe if the file system type is unknown. */
FALLTHROUGH;
@@ -1027,26 +1011,7 @@ check_for_dir:
if (p->fts_info == FTS_NSOK)
{
if (p->fts_statp->st_size == FTS_STAT_REQUIRED)
- {
- FTSENT *parent = p->fts_parent;
- if (parent->fts_n_dirs_remaining == 0
- && ISSET(FTS_NOSTAT)
- && ISSET(FTS_PHYSICAL)
- && (leaf_optimization (parent, sp->fts_cwd_fd)
- == NOSTAT_LEAF_OPTIMIZATION))
- {
- /* nothing more needed */
- }
- else
- {
- p->fts_info = fts_stat(sp, p, false);
- if (S_ISDIR(p->fts_statp->st_mode)
- && p->fts_level != FTS_ROOTLEVEL
- && 0 < parent->fts_n_dirs_remaining
- && parent->fts_n_dirs_remaining != (nlink_t) -1)
- parent->fts_n_dirs_remaining--;
- }
- }
+ p->fts_info = fts_stat(sp, p, false);
else
fts_assert (p->fts_statp->st_size == FTS_NO_STAT_REQUIRED);
}
@@ -1830,11 +1795,6 @@ err: memset(sbp, 0, sizeof(struct stat));
}
if (S_ISDIR(sbp->st_mode)) {
- p->fts_n_dirs_remaining
- = ((sbp->st_nlink < MIN_DIR_NLINK
- || p->fts_level <= FTS_ROOTLEVEL)
- ? -1
- : sbp->st_nlink - (ISSET (FTS_SEEDOT) ? 0 : MIN_DIR_NLINK));
if (ISDOT(p->fts_name)) {
/* Command-line "." and ".." are real directories. */
return (p->fts_level == FTS_ROOTLEVEL ? FTS_D : FTS_DOT);
diff --git a/lib/fts_.h b/lib/fts_.h
index d40a116..2e76cc4 100644
--- a/lib/fts_.h
+++ b/lib/fts_.h
@@ -227,11 +227,6 @@ typedef struct _ftsent {
size_t fts_namelen; /* strlen(fts_name) */
- /* If not (nlink_t) -1, an upper bound on the number of
- remaining subdirectories of interest. If this becomes
- zero, some work can be avoided. */
- nlink_t fts_n_dirs_remaining;
-
# define FTS_D 1 /* preorder directory */
# define FTS_DC 2 /* directory that causes cycles */
# define FTS_DEFAULT 3 /* none of the above */
--
2.21.1

View File

@ -1,153 +0,0 @@
From 8c022656320592dbad146f5d3a3ae1875f419446 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 5 Mar 2020 17:25:29 -0800
Subject: [PATCH 1/2] ls: restore 8.31 behavior on removed directories
* NEWS: Mention this.
* src/ls.c: Do not include <sys/sycall.h>
(print_dir): Don't worry about whether the directory is removed.
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
behavior.
Upstream-commit: 10fcb97bd728f09d4a027eddf8ad2900f0819b0a
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ls.c | 22 ----------------------
tests/ls/removed-directory.sh | 10 ++--------
2 files changed, 2 insertions(+), 30 deletions(-)
diff --git a/src/ls.c b/src/ls.c
index 9d25f62..850ecc2 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -49,10 +49,6 @@
# include <sys/ptem.h>
#endif
-#ifdef __linux__
-# include <sys/syscall.h>
-#endif
-
#include <stdio.h>
#include <assert.h>
#include <setjmp.h>
@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
struct dirent *next;
uintmax_t total_blocks = 0;
static bool first = true;
- bool found_any_entries = false;
errno = 0;
dirp = opendir (name);
@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
next = readdir (dirp);
if (next)
{
- found_any_entries = true;
if (! file_ignored (next->d_name))
{
enum filetype type = unknown;
@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
if (errno != EOVERFLOW)
break;
}
-#ifdef __linux__
- else if (! found_any_entries)
- {
- /* If readdir finds no directory entries at all, not even "." or
- "..", then double check that the directory exists. */
- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
- && errno != EINVAL)
- {
- /* We exclude EINVAL as that pertains to buffer handling,
- and we've passed NULL as the buffer for simplicity.
- ENOENT is returned if appropriate before buffer handling. */
- file_failure (command_line_arg, _("reading directory %s"), name);
- }
- break;
- }
-#endif
else
break;
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
index e8c835d..fe8f929 100755
--- a/tests/ls/removed-directory.sh
+++ b/tests/ls/removed-directory.sh
@@ -26,20 +26,14 @@ case $host_triplet in
*) skip_ 'non linux kernel' ;;
esac
-LS_FAILURE=2
-
-cat <<\EOF >exp-err || framework_failure_
-ls: reading directory '.': No such file or directory
-EOF
-
cwd=$(pwd)
mkdir d || framework_failure_
cd d || framework_failure_
rmdir ../d || framework_failure_
-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
+ls >../out 2>../err || fail=1
cd "$cwd" || framework_failure_
compare /dev/null out || fail=1
-compare exp-err err || fail=1
+compare /dev/null err || fail=1
Exit $fail
--
2.21.1
From 847324a0debd9d12062c79e7a7a9d3d8ce76390d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 7 Mar 2020 10:29:51 -0800
Subject: [PATCH 2/2] ls: improve removed-directory test
* tests/ls/removed-directory.sh: Remove host_triplet test.
Skip this test if one cannot remove the working directory.
From a suggestion by Bernhard Voelker (Bug#39929).
Upstream-commit: 672819c73f2e94e61386dc0584bddf9da860cc26
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/ls/removed-directory.sh | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
index fe8f929..63b209d 100755
--- a/tests/ls/removed-directory.sh
+++ b/tests/ls/removed-directory.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# If ls is asked to list a removed directory (e.g. the parent process's
-# current working directory that has been removed by another process), it
-# emits an error message.
+# If ls is asked to list a removed directory (e.g., the parent process's
+# current working directory has been removed by another process), it
+# should not emit an error message merely because the directory is removed.
# Copyright (C) 2020 Free Software Foundation, Inc.
@@ -21,15 +21,10 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ls
-case $host_triplet in
- *linux*) ;;
- *) skip_ 'non linux kernel' ;;
-esac
-
cwd=$(pwd)
mkdir d || framework_failure_
cd d || framework_failure_
-rmdir ../d || framework_failure_
+rmdir ../d || skip_ "can't remove working directory on this platform"
ls >../out 2>../err || fail=1
cd "$cwd" || framework_failure_
--
2.21.1

View File

@ -1,85 +0,0 @@
From 53c6b01e8e3fd338d7f53e5ff817ef86f9efa852 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 11 Nov 2020 17:22:33 +0000
Subject: [PATCH] ls: fix crash printing SELinux context for unstatable files
This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v6.9.90-11-g4245876e2
* src/ls.c (gobble_file): Ensure scontext is initialized
in the case where files are not statable.
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
and added test case for broken symlinks.
* tests/local.mk: Adjust for the renamed test.
Upstream-commit: 6fc695cb4a26f09dfeef8b1c24895a707055334e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ls.c | 3 +++
tests/local.mk | 2 +-
.../{proc-selinux-segfault.sh => selinux-segfault.sh} | 10 ++++++++--
3 files changed, 12 insertions(+), 3 deletions(-)
rename tests/ls/{proc-selinux-segfault.sh => selinux-segfault.sh} (77%)
diff --git a/src/ls.c b/src/ls.c
index 4acf5f4..8eb483d 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3412,6 +3412,9 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
provokes an exit status of 1. */
file_failure (command_line_arg,
_("cannot access %s"), full_name);
+
+ f->scontext = UNKNOWN_SECURITY_CONTEXT;
+
if (command_line_arg)
return 0;
diff --git a/tests/local.mk b/tests/local.mk
index 2aeff2b..2441fdc 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -616,7 +616,7 @@ all_tests = \
tests/ls/multihardlink.sh \
tests/ls/no-arg.sh \
tests/ls/no-cap.sh \
- tests/ls/proc-selinux-segfault.sh \
+ tests/ls/selinux-segfault.sh \
tests/ls/quote-align.sh \
tests/ls/readdir-mountpoint-inode.sh \
tests/ls/recursive.sh \
diff --git a/tests/ls/proc-selinux-segfault.sh b/tests/ls/selinux-segfault.sh
similarity index 77%
rename from tests/ls/proc-selinux-segfault.sh
rename to tests/ls/selinux-segfault.sh
index 831a00e..e2b7ef6 100755
--- a/tests/ls/proc-selinux-segfault.sh
+++ b/tests/ls/selinux-segfault.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1
+# Ensure we don't segfault in selinux handling
# Copyright (C) 2008-2020 Free Software Foundation, Inc.
@@ -19,9 +19,15 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ls
+# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1
f=/proc/sys
test -r $f || f=.
-
ls -l $f > out || fail=1
+# ls <= 8.32 would segfault when printing
+# the security context of broken symlink targets
+mkdir sedir || framework_failure_
+ln -sf missing sedir/broken || framework_failure_
+returns_ 1 ls -L -R -Z -m sedir > out || fail=1
+
Exit $fail
--
2.26.2

View File

@ -1,186 +0,0 @@
From be77b4ab7cb68fd2daf9de90bd75d844392788ac Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 25 Mar 2021 11:57:56 +0100
Subject: [PATCH 1/4] ln: fix memory leaks in do_link
* src/ln.c (do_link): Free memory allocated by convert_abs_rel
on all code paths (Bug#47373).
Upstream-commit: 6e98f67758260579d7d44ea5f2df4c82d28c9f58
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ln.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/ln.c b/src/ln.c
index ffa278e..9b52602 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -229,14 +229,14 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
if (errno != ENOENT)
{
error (0, errno, _("failed to access %s"), quoteaf (dest));
- return false;
+ goto fail;
}
force = false;
}
else if (S_ISDIR (dest_stats.st_mode))
{
error (0, 0, _("%s: cannot overwrite directory"), quotef (dest));
- return false;
+ goto fail;
}
else if (seen_file (dest_set, dest, &dest_stats))
{
@@ -245,7 +245,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
error (0, 0,
_("will not overwrite just-created %s with %s"),
quoteaf_n (0, dest), quoteaf_n (1, source));
- return false;
+ goto fail;
}
else
{
@@ -274,7 +274,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
{
error (0, 0, _("%s and %s are the same file"),
quoteaf_n (0, source), quoteaf_n (1, dest));
- return false;
+ goto fail;
}
}
@@ -285,7 +285,10 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
fprintf (stderr, _("%s: replace %s? "),
program_name, quoteaf (dest));
if (!yesno ())
- return true;
+ {
+ free(rel_source);
+ return true;
+ }
}
if (backup_type != no_backups)
@@ -304,7 +307,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
{
error (0, rename_errno, _("cannot backup %s"),
quoteaf (dest));
- return false;
+ goto fail;
}
force = false;
}
@@ -397,6 +400,10 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
free (backup_base);
free (rel_source);
return link_errno <= 0;
+
+fail:
+ free (rel_source);
+ return false;
}
void
--
2.26.3
From c051578e69bd8acf8f8a469566ae34e855345532 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 25 Mar 2021 09:15:50 -0700
Subject: [PATCH 2/4] maint: indenting
* src/ln.c: Fix indenting.
Upstream-commit: 8980b7c898046d899646da01c296fd15f0cced21
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ln.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ln.c b/src/ln.c
index 9b52602..8881d6a 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -286,7 +286,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
program_name, quoteaf (dest));
if (!yesno ())
{
- free(rel_source);
+ free (rel_source);
return true;
}
}
@@ -304,7 +304,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
free (backup_base);
backup_base = NULL;
if (rename_errno != ENOENT)
- {
+ {
error (0, rename_errno, _("cannot backup %s"),
quoteaf (dest));
goto fail;
--
2.26.3
From 0d6a4afe5bee0e397fb2fc3b205a29b32a69af9d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 25 Mar 2021 09:16:36 -0700
Subject: [PATCH 3/4] hostname: use puts
* src/hostname.c (main): Prefer puts to printf "%s\n".
Upstream-commit: c7a588ac3632aae21642d4d568497177950d36bf
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/hostname.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hostname.c b/src/hostname.c
index 0b5c0cf..62cc98c 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -103,7 +103,7 @@ main (int argc, char **argv)
hostname = xgethostname ();
if (hostname == NULL)
die (EXIT_FAILURE, errno, _("cannot determine hostname"));
- printf ("%s\n", hostname);
+ puts (hostname);
}
if (optind + 1 < argc)
--
2.26.3
From 19c98d2080251edbaad9fb271aa10ad34f953500 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 25 Mar 2021 11:20:18 -0700
Subject: [PATCH 4/4] hostname: pacify valgrind
* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).
Upstream-commit: 4698e284f37844bc9b9f63f00eb556ccaaed5030
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/hostname.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/hostname.c b/src/hostname.c
index 62cc98c..7210248 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -104,6 +104,7 @@ main (int argc, char **argv)
if (hostname == NULL)
die (EXIT_FAILURE, errno, _("cannot determine hostname"));
puts (hostname);
+ IF_LINT (free (hostname));
}
if (optind + 1 < argc)
--
2.26.3

View File

@ -1,104 +0,0 @@
From 09400b7f7f48d8eedc0df55de8073a43bc0aac96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Tue, 27 Oct 2020 20:15:43 +0000
Subject: [PATCH 1/2] stat,tail: sync file system constants from the linux
kernel
* src/stat.c: Add magic constants for "devmem", and
"zonefs" file systems.
* NEWS: Mention the improvement.
Upstream-commit: ff80b6b0a0507e24f39cc1aad09d147f5187430b
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/stat.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/stat.c b/src/stat.c
index 5012622..8cd69da 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -347,6 +347,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "debugfs";
case S_MAGIC_DEVFS: /* 0x1373 local */
return "devfs";
+ case S_MAGIC_DEVMEM: /* 0x454D444D local */
+ return "devmem";
case S_MAGIC_DEVPTS: /* 0x1CD1 local */
return "devpts";
case S_MAGIC_DMA_BUF: /* 0x444D4142 local */
@@ -549,6 +551,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "z3fold";
case S_MAGIC_ZFS: /* 0x2FC12FC1 local */
return "zfs";
+ case S_MAGIC_ZONEFS: /* 0x5A4F4653 local */
+ return "zonefs";
case S_MAGIC_ZSMALLOC: /* 0x58295829 local */
return "zsmallocfs";
--
2.25.4
From d5948fd41013dfe4d2d10083111821667977c6d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Tue, 27 Oct 2020 21:04:14 +0000
Subject: [PATCH 2/2] mountlist: recognize more file system types as remote
Sync "remote" file systems from stat.c in coreutils.
Note we only consider file systems that do not use host:resource
mount source. I.e. those that don't generally use a colon when
mounting, as that case is already considered. Searching for
"<fstype> /etc/fstab" was informative for identifying these.
The full list of "remote" file systems in coreutils is currently:
acfs afs ceph cifs coda fhgfs fuseblk fusectl
gfs gfs2 gpfs ibrix k-afs lustre novell nfs nfsd
ocfs2 panfs prl_fs smb smb2 snfs vboxsf vmhgfs vxfs
Note also we do not include virtual machine file systems,
as even though they're remote to the current kernel,
they are generally not distributed to separate hosts.
* lib/mountlist.c (ME_REMOTE): Sync previously unconsidered
"remote" file systems from stat.c in coreutils.
Upstream-commit: dd1fc46be12d671c1a9d9dc5a6fa8c766e99aa2f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/mountlist.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/mountlist.c b/lib/mountlist.c
index 7abe024..e0227b7 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -221,8 +221,9 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
#ifndef ME_REMOTE
/* A file system is "remote" if its Fs_name contains a ':'
or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
- or if it is of type (afs or auristorfs)
- or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). */
+ or if it is of any other of the listed types
+ or Fs_name is equal to "-hosts" (used by autofs to mount remote fs).
+ "VM" file systems like prl_fs or vboxsf are not considered remote here. */
# define ME_REMOTE(Fs_name, Fs_type) \
(strchr (Fs_name, ':') != NULL \
|| ((Fs_name)[0] == '/' \
@@ -230,8 +231,15 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
&& (strcmp (Fs_type, "smbfs") == 0 \
|| strcmp (Fs_type, "smb3") == 0 \
|| strcmp (Fs_type, "cifs") == 0)) \
+ || strcmp (Fs_type, "acfs") == 0 \
|| strcmp (Fs_type, "afs") == 0 \
+ || strcmp (Fs_type, "coda") == 0 \
|| strcmp (Fs_type, "auristorfs") == 0 \
+ || strcmp (Fs_type, "fhgfs") == 0 \
+ || strcmp (Fs_type, "gpfs") == 0 \
+ || strcmp (Fs_type, "ibrix") == 0 \
+ || strcmp (Fs_type, "ocfs2") == 0 \
+ || strcmp (Fs_type, "vxfs") == 0 \
|| strcmp ("-hosts", Fs_name) == 0)
#endif
--
2.25.4

View File

@ -1,32 +0,0 @@
From b87f944c87ffe04db6e5476b007a8e4979de933d Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 18 Feb 2021 11:18:04 +0100
Subject: [PATCH] stat,tail: add support for the exfat file system
Bug: https://bugzilla.redhat.com/1921427
* src/stat.c (human_fstype): Add case for the 'exfat' file system type.
Fixes https://bugs.gnu.org/46613
Upstream-commit: a5e0d8f387e81e854427addbbaf2504541bbf4b9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/stat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/stat.c b/src/stat.c
index 8cd69da..4e1c8e3 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -361,6 +361,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "efs";
case S_MAGIC_EROFS_V1: /* 0xE0F5E1E2 local */
return "erofs";
+ case S_MAGIC_EXFAT: /* 0x2011BAB0 local */
+ return "exfat";
case S_MAGIC_EXFS: /* 0x45584653 local */
return "exfs";
case S_MAGIC_EXOFS: /* 0x5DF5 local */
--
2.26.2

View File

@ -1,181 +0,0 @@
From c7a04cef4075da864a3468e63a5bb79334d8f556 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 26 Jun 2021 18:23:52 -0700
Subject: [PATCH] tail: use poll, not select
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes an unlikely stack out-of-bounds write reported by
Stepan Broz via Kamil Dudka (Bug#49209).
* src/tail.c: Do not include <sys/select.h>.
[!_AIX]: Include poll.h.
(check_output_alive) [!_AIX]: Use poll instead of select.
(tail_forever_inotify): Likewise. Simplify logic, as there is no
need for a while (len <= evbuf_off) loop.
Upstream-commit: da0d448bca62c6305fc432f67e2c5ccc2da75346
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/tail.c | 100 +++++++++++++++++++++--------------------------------
1 file changed, 39 insertions(+), 61 deletions(-)
diff --git a/src/tail.c b/src/tail.c
index 1c88723..5b4f21a 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -28,12 +28,9 @@
#include <stdio.h>
#include <assert.h>
#include <getopt.h>
-#include <sys/select.h>
+#include <poll.h>
#include <sys/types.h>
#include <signal.h>
-#ifdef _AIX
-# include <poll.h>
-#endif
#include "system.h"
#include "argmatch.h"
@@ -351,27 +348,12 @@ check_output_alive (void)
if (! monitor_output)
return;
-#ifdef _AIX
- /* select on AIX was seen to give a readable event immediately. */
struct pollfd pfd;
pfd.fd = STDOUT_FILENO;
pfd.events = POLLERR;
if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
die_pipe ();
-#else
- struct timeval delay;
- delay.tv_sec = delay.tv_usec = 0;
-
- fd_set rfd;
- FD_ZERO (&rfd);
- FD_SET (STDOUT_FILENO, &rfd);
-
- /* readable event on STDOUT is equivalent to POLLERR,
- and implies an error condition on output like broken pipe. */
- if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1)
- die_pipe ();
-#endif
}
static bool
@@ -1612,7 +1594,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
/* Wait for inotify events and handle them. Events on directories
ensure that watched files can be re-added when following by name.
This loop blocks on the 'safe_read' call until a new event is notified.
- But when --pid=P is specified, tail usually waits via the select. */
+ But when --pid=P is specified, tail usually waits via poll. */
while (1)
{
struct File_spec *fspec;
@@ -1629,54 +1611,51 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
return false;
}
- /* When watching a PID, ensure that a read from WD will not block
- indefinitely. */
- while (len <= evbuf_off)
+ if (len <= evbuf_off)
{
- struct timeval delay; /* how long to wait for file changes. */
+ /* Poll for inotify events. When watching a PID, ensure
+ that a read from WD will not block indefinitely.
+ If MONITOR_OUTPUT, also poll for a broken output pipe. */
- if (pid)
+ int file_change;
+ struct pollfd pfd[2];
+ do
{
- if (writer_is_dead)
- exit (EXIT_SUCCESS);
+ /* How many ms to wait for changes. -1 means wait forever. */
+ int delay = -1;
- writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM);
-
- if (writer_is_dead)
- delay.tv_sec = delay.tv_usec = 0;
- else
+ if (pid)
{
- delay.tv_sec = (time_t) sleep_interval;
- delay.tv_usec = 1000000 * (sleep_interval - delay.tv_sec);
+ if (writer_is_dead)
+ exit (EXIT_SUCCESS);
+
+ writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM);
+
+ if (writer_is_dead || sleep_interval <= 0)
+ delay = 0;
+ else if (sleep_interval < INT_MAX / 1000 - 1)
+ {
+ /* delay = ceil (sleep_interval * 1000), sans libm. */
+ double ddelay = sleep_interval * 1000;
+ delay = ddelay;
+ delay += delay < ddelay;
+ }
}
+
+ pfd[0].fd = wd;
+ pfd[0].events = POLLIN;
+ pfd[1].fd = STDOUT_FILENO;
+ pfd[1].events = pfd[1].revents = 0;
+ file_change = poll (pfd, monitor_output + 1, delay);
}
+ while (file_change == 0);
- fd_set rfd;
- FD_ZERO (&rfd);
- FD_SET (wd, &rfd);
- if (monitor_output)
- FD_SET (STDOUT_FILENO, &rfd);
-
- int file_change = select (MAX (wd, STDOUT_FILENO) + 1,
- &rfd, NULL, NULL, pid ? &delay: NULL);
-
- if (file_change == 0)
- continue;
- else if (file_change == -1)
- die (EXIT_FAILURE, errno,
- _("error waiting for inotify and output events"));
- else if (FD_ISSET (STDOUT_FILENO, &rfd))
- {
- /* readable event on STDOUT is equivalent to POLLERR,
- and implies an error on output like broken pipe. */
- die_pipe ();
- }
- else
- break;
- }
+ if (file_change < 0)
+ die (EXIT_FAILURE, errno,
+ _("error waiting for inotify and output events"));
+ if (pfd[1].revents)
+ die_pipe ();
- if (len <= evbuf_off)
- {
len = safe_read (wd, evbuf, evlen);
evbuf_off = 0;
@@ -2437,8 +2416,7 @@ main (int argc, char **argv)
if (forever && ignore_fifo_and_pipe (F, n_files))
{
/* If stdout is a fifo or pipe, then monitor it
- so that we exit if the reader goes away.
- Note select() on a regular file is always readable. */
+ so that we exit if the reader goes away. */
struct stat out_stat;
if (fstat (STDOUT_FILENO, &out_stat) < 0)
die (EXIT_FAILURE, errno, _("standard output"));
--
2.31.1

View File

@ -1,99 +0,0 @@
From fc6318841f008dadc1e7c93e539f10d24aa83e90 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Wed, 21 Apr 2021 00:12:00 +0200
Subject: [PATCH 1/2] tests: fix FP in ls/stat-free-color.sh
On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls
newfstatat(STDOUT_FILENO, ...), but only when there is something to
output.
* tests/ls/stat-free-color.sh: Add -a option to the reference invocation
of ls, thus enforcing something gets output.
Upstream-commit: b7091093bb6505c33279f9bc940b2e94763a6e5d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/ls/stat-free-color.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
index 00942f7..87bed1c 100755
--- a/tests/ls/stat-free-color.sh
+++ b/tests/ls/stat-free-color.sh
@@ -56,12 +56,14 @@ eval $(dircolors -b color-without-stat)
# The system may perform additional stat-like calls before main.
# Furthermore, underlying library functions may also implicitly
# add an extra stat call, e.g. opendir since glibc-2.21-360-g46f894d.
-# To avoid counting those, first get a baseline count for running
-# ls with one empty directory argument. Then, compare that with the
-# invocation under test.
+# Finally, ls(1) makes a stat call for stdout, but only in the case
+# when there is something to output.
+# To get the comparison right, first get a baseline count for running
+# 'ls -a' with one empty directory argument. Then, compare that with
+# the invocation under test.
mkdir d || framework_failure_
-strace -q -o log1 -e $stats ls --color=always d || fail=1
+strace -q -o log1 -e $stats ls -a --color=always d || fail=1
n_stat1=$(grep -vF '+++' log1 | wc -l) || framework_failure_
test $n_stat1 = 0 \
--
2.31.1
From c16ca58f17a088e925c0d1c4015c48332c380a00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Sun, 9 May 2021 23:41:00 +0100
Subject: [PATCH 2/2] tests: fix tests/cp/sparse-2.sh false failure on some
systems
* tests/cp/sparse-2.sh: Double check cp --sparse=always,
with dd conv=sparse, in the case where the former didn't
create a sparse file. Now that this test is being newly run
on macos, we're seeing a failure due to seek() not creating
holes on apfs unless the size is >= 16MiB.
Upstream-commit: 6b499720fecae935dc00e236d6aefe94d9010482
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/cp/fiemap-2.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/tests/cp/fiemap-2.sh b/tests/cp/fiemap-2.sh
index 548a376..e20ce54 100755
--- a/tests/cp/fiemap-2.sh
+++ b/tests/cp/fiemap-2.sh
@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ cp
+print_ver_ cp stat dd
# Require a fiemap-enabled FS.
touch fiemap_chk # check a file rather than current dir for best coverage
@@ -46,10 +46,17 @@ dd bs=1k seek=1 of=k count=255 < /dev/zero || framework_failure_
# cp should detect the all-zero blocks and convert some of them to holes.
# How many it detects/converts currently depends on io_blksize.
-# Currently, on my F14/ext4 desktop, this K starts off with size 256KiB,
+# Currently, on my F14/ext4 desktop, this K file starts off with size 256KiB,
# (note that the K in the preceding test starts off with size 4KiB).
# cp from coreutils-8.9 with --sparse=always reduces the size to 32KiB.
cp --sparse=always k k2 || fail=1
-test $(stat -c %b k2) -lt $(stat -c %b k) || fail=1
+if test $(stat -c %b k2) -ge $(stat -c %b k); then
+ # If not sparse, then double check by creating with dd
+ # as we're not guaranteed that seek will create a hole.
+ # apfs on darwin 19.2.0 for example was seen to not to create holes < 16MiB.
+ hole_size=$(stat -c %o k2) || framework_failure_
+ dd if=k of=k2.dd bs=$hole_size conv=sparse || framework_failure_
+ test $(stat -c %b k2) -eq $(stat -c %b k2.dd) || fail=1
+fi
Exit $fail
--
2.31.1

View File

@ -0,0 +1,87 @@
From f4422844dbcd839ce486bcbc15b7bd5b72c9198d Mon Sep 17 00:00:00 2001
From: Rohan Sable <rsable@redhat.com>
Date: Mon, 7 Mar 2022 14:14:13 +0000
Subject: [PATCH 1/2] ls: avoid triggering automounts
statx() has different defaults wrt automounting
compared to stat() or lstat(), so explicitly
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
and avoid unintended operations or potential errors.
* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
Fixes https://bugs.gnu.org/54286
Signed-off-by: Rohan Sable <rsable@redhat.com>
Upstream-commit: 85c975df2c25bd799370b04bb294e568e001102f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ls.c b/src/ls.c
index 1047801..fe0e9f8 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1126,7 +1126,7 @@ do_statx (int fd, const char *name, struct stat *st, int flags,
unsigned int mask)
{
struct statx stx;
- int ret = statx (fd, name, flags, mask, &stx);
+ int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx);
if (ret >= 0)
statx_to_stat (&stx, st);
return ret;
--
2.34.1
From 3d227f9e4f3fe806064721e4b9451ee06526bc80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Mon, 7 Mar 2022 23:29:20 +0000
Subject: [PATCH 2/2] stat: only automount with --cached=never
Revert to the default behavior before the introduction of statx().
* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
* doc/coreutils.texi (stat invocation): Mention the automount
behavior with --cached=never.
Fixes https://bugs.gnu.org/54287
Upstream-commit: 92cb8427c537f37edd43c5cef1909585201372ab
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/coreutils.texi | 1 +
src/stat.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 19b535c..0f5c16a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12204,6 +12204,7 @@ Always read the already cached attributes if available.
@item never
Always sychronize with the latest file system attributes.
+This also mounts automounted files.
@item default
Leave the caching behavior to the underlying file system.
diff --git a/src/stat.c b/src/stat.c
index 0c34501..803340a 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1343,6 +1343,9 @@ do_stat (char const *filename, char const *format, char const *format2)
else if (force_sync)
flags |= AT_STATX_FORCE_SYNC;
+ if (! force_sync)
+ flags |= AT_NO_AUTOMOUNT;
+
fd = statx (fd, pathname, flags, format_to_mask (format), &stx);
if (fd < 0)
{
--
2.34.1

View File

@ -15,6 +15,11 @@ alias l. 'ls -d .*'
set COLORS=/etc/DIR_COLORS
if ($?TERM) then
if ( -e "/etc/DIR_COLORS.256color" ) then
if ( "`/usr/bin/tput colors`" == "256" ) then
set COLORS=/etc/DIR_COLORS.256color
endif
endif
if ( -e "/etc/DIR_COLORS.$TERM" ) then
set COLORS="/etc/DIR_COLORS.$TERM"
endif

View File

@ -22,6 +22,10 @@ if [ -z "$USER_LS_COLORS" ]; then
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.$TERM" ] && \
COLORS="/etc/DIR_COLORS.$TERM"
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \
[ "x`/usr/bin/tty -s && /usr/bin/tput colors 2>/dev/null`" = "x256" ] && \
COLORS="/etc/DIR_COLORS.256color"
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS" ] && \
COLORS="/etc/DIR_COLORS"

View File

@ -1,8 +1,20 @@
From 6e36198f10a2f63b89c89ebb5d5c185b20fb3a63 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Mon, 29 Mar 2010 17:20:34 +0000
Subject: [PATCH] coreutils-df-direct.patch
---
doc/coreutils.texi | 7 ++++++
src/df.c | 34 ++++++++++++++++++++++++++--
tests/df/direct.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 2 deletions(-)
create mode 100755 tests/df/direct.sh
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index a507280..400e135 100644
index 5b9a597..6810c15 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -11303,6 +11303,13 @@ some systems (notably SunOS), doing this yields more up to date results,
@@ -11898,6 +11898,13 @@ some systems (notably SunOS), doing this yields more up to date results,
but in general this option makes @command{df} much slower, especially when
there are many or very busy file systems.
@ -17,10 +29,10 @@ index a507280..400e135 100644
@opindex --total
@cindex grand total of disk size, usage and available space
diff --git a/src/df.c b/src/df.c
index 8f760db..a7385fd 100644
index 48025b9..c8efa5b 100644
--- a/src/df.c
+++ b/src/df.c
@@ -120,6 +120,9 @@ static bool print_type;
@@ -125,6 +125,9 @@ static bool print_type;
/* If true, print a grand total at the end. */
static bool print_grand_total;
@ -30,7 +42,7 @@ index 8f760db..a7385fd 100644
/* Grand total data. */
static struct fs_usage grand_fsu;
@@ -247,13 +250,15 @@ enum
@@ -252,13 +255,15 @@ enum
NO_SYNC_OPTION = CHAR_MAX + 1,
SYNC_OPTION,
TOTAL_OPTION,
@ -47,7 +59,7 @@ index 8f760db..a7385fd 100644
{"inodes", no_argument, NULL, 'i'},
{"human-readable", no_argument, NULL, 'h'},
{"si", no_argument, NULL, 'H'},
@@ -509,7 +514,10 @@ get_header (void)
@@ -561,7 +566,10 @@ get_header (void)
for (col = 0; col < ncolumns; col++)
{
char *cell = NULL;
@ -59,7 +71,7 @@ index 8f760db..a7385fd 100644
if (columns[col]->field == SIZE_FIELD
&& (header_mode == DEFAULT_MODE
@@ -1397,6 +1405,19 @@ get_point (const char *point, const struct stat *statp)
@@ -1464,6 +1472,17 @@ get_point (const char *point, const struct stat *statp)
static void
get_entry (char const *name, struct stat const *statp)
{
@ -68,9 +80,7 @@ index 8f760db..a7385fd 100644
+ char *resolved = canonicalize_file_name (name);
+ if (resolved)
+ {
+ char *mp = find_mount_point (name, statp);
+ get_dev (NULL, mp, resolved, NULL, NULL, false, false, NULL, false);
+ free(mp);
+ get_dev (NULL, resolved, name, NULL, NULL, false, false, NULL, false);
+ free (resolved);
+ return;
+ }
@ -79,7 +89,7 @@ index 8f760db..a7385fd 100644
if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
&& get_disk (name))
return;
@@ -1467,6 +1488,7 @@ or all file systems by default.\n\
@@ -1534,6 +1553,7 @@ or all file systems by default.\n\
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\
'-BM' prints sizes in units of 1,048,576 bytes;\n\
see SIZE format below\n\
@ -87,7 +97,7 @@ index 8f760db..a7385fd 100644
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\
-H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\
"), stdout);
@@ -1557,6 +1579,9 @@ main (int argc, char **argv)
@@ -1624,6 +1644,9 @@ main (int argc, char **argv)
xstrtol_fatal (e, oi, c, long_options, optarg);
}
break;
@ -97,7 +107,7 @@ index 8f760db..a7385fd 100644
case 'i':
if (header_mode == OUTPUT_MODE)
{
@@ -1653,6 +1678,13 @@ main (int argc, char **argv)
@@ -1720,6 +1743,13 @@ main (int argc, char **argv)
}
}
@ -172,3 +182,6 @@ index 0000000..8e4cfb8
+compare file_out file_exp || fail=1
+
+Exit $fail
--
2.31.1

View File

@ -23,7 +23,6 @@ Co-authored-by: Pádraig Brady <pbrady@redhat.com>
lib/mbfile.h | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
m4/mbfile.m4 | 14 +++
src/expand.c | 43 +++++----
src/local.mk | 4 +-
src/unexpand.c | 54 +++++++----
tests/expand/mb.sh | 98 ++++++++++++++++++++
tests/local.mk | 2 +
@ -459,21 +458,6 @@ index 9fa2e10..380e020 100644
}
}
diff --git a/src/local.mk b/src/local.mk
index 72db9c704..ef3bfa469 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -415,8 +415,8 @@ src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS)
src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
-src_expand_SOURCES = src/expand.c src/expand-common.c
-src_unexpand_SOURCES = src/unexpand.c src/expand-common.c
+src_expand_SOURCES = src/expand.c src/expand-common.c lib/mbfile.c
+src_unexpand_SOURCES = src/unexpand.c src/expand-common.c lib/mbfile.c
# Ensure we don't link against libcoreutils.a as that lib is
# not compiled with -fPIC which causes issues on 64 bit at least
diff --git a/src/unexpand.c b/src/unexpand.c
index 7801274..569a7ee 100644
--- a/src/unexpand.c
@ -588,16 +572,18 @@ index 7801274..569a7ee 100644
{
/* Go back one column, and force recalculation of the
next tab stop. */
@@ -221,7 +235,7 @@ unexpand (void)
@@ -221,16 +235,20 @@ unexpand (void)
}
else
{
- column++;
- if (!column)
+ const uintmax_t orig_column = column;
+ column += mb_width (c);
if (!column)
+ if (column < orig_column)
die (EXIT_FAILURE, 0, _("input line is too long"));
}
@@ -229,8 +243,11 @@ unexpand (void)
if (pending)
{
if (pending > 1 && one_blank_before_tab_stop)
@ -611,7 +597,7 @@ index 7801274..569a7ee 100644
die (EXIT_FAILURE, errno, _("write error"));
pending = 0;
one_blank_before_tab_stop = false;
@@ -240,16 +257,17 @@ unexpand (void)
@@ -240,16 +258,17 @@ unexpand (void)
convert &= convert_entire_line || blank;
}

View File

@ -1,28 +0,0 @@
From 02424bfcd719bbaa695f4e1c3ef17ad91b0d23c0 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 28 Jan 2016 20:57:22 +0100
Subject: [PATCH] unexpand: fix blank line handling
echo '' |./src/unexpand -a
Really?
---
src/unexpand.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/unexpand.c b/src/unexpand.c
index 569a7ee..3bbbd66 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -233,7 +233,7 @@ unexpand (void)
next_tab_column = column;
tab_index -= !!tab_index;
}
- else
+ else if (!mb_iseq (c, '\n'))
{
column += mb_width (c);
if (!column)
--
2.7.4

View File

@ -6,23 +6,23 @@ Subject: [PATCH] coreutils-i18n.patch
TODO: merge upstream
---
lib/linebuffer.h | 8 +
src/fold.c | 308 +++++++++++++--
src/join.c | 359 ++++++++++++++---
src/pr.c | 443 +++++++++++++++++++--
src/sort.c | 764 ++++++++++++++++++++++++++++++++++--
src/uniq.c | 119 +++++-
src/fold.c | 308 ++++++++++++++++--
src/join.c | 359 ++++++++++++++++++---
src/pr.c | 443 ++++++++++++++++++++++---
src/sort.c | 764 +++++++++++++++++++++++++++++++++++++++++---
src/uniq.c | 265 ++++++++++++++-
tests/i18n/sort.sh | 29 ++
tests/local.mk | 2 +
tests/misc/expand.pl | 42 ++
tests/misc/expand.pl | 42 +++
tests/misc/fold.pl | 50 ++-
tests/misc/join.pl | 50 +++
tests/misc/sort-mb-tests.sh | 45 +++
tests/misc/sort-merge.pl | 42 ++
tests/misc/sort.pl | 40 +-
tests/misc/unexpand.pl | 39 ++
tests/misc/uniq.pl | 55 +++
tests/misc/sort-merge.pl | 42 +++
tests/misc/sort.pl | 40 ++-
tests/misc/unexpand.pl | 39 +++
tests/misc/uniq.pl | 55 ++++
tests/pr/pr-tests.pl | 49 +++
17 files changed, 2290 insertions(+), 154 deletions(-)
17 files changed, 2430 insertions(+), 160 deletions(-)
create mode 100755 tests/i18n/sort.sh
create mode 100755 tests/misc/sort-mb-tests.sh
@ -893,7 +893,7 @@ index 98b461c..9990f38 100644
}
putchar (eolchar);
}
@@ -1098,20 +1344,43 @@ main (int argc, char **argv)
@@ -1099,20 +1345,43 @@ main (int argc, char **argv)
case 't':
{
@ -975,8 +975,8 @@ index 26f221f..633f50e 100644
#include "system.h"
#include "die.h"
#include "error.h"
@@ -325,6 +343,18 @@
#include "xstrtol-error.h"
@@ -324,6 +342,18 @@
#include "xstrtol.h"
#include "xdectoint.h"
+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
@ -994,7 +994,7 @@ index 26f221f..633f50e 100644
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "pr"
@@ -417,7 +447,20 @@ struct COLUMN
@@ -416,7 +446,20 @@ struct COLUMN
typedef struct COLUMN COLUMN;
@ -1016,7 +1016,7 @@ index 26f221f..633f50e 100644
static bool read_line (COLUMN *p);
static bool print_page (void);
static bool print_stored (COLUMN *p);
@@ -429,6 +472,7 @@ static void add_line_number (COLUMN *p);
@@ -428,6 +471,7 @@ static void add_line_number (COLUMN *p);
static void getoptnum (const char *n_str, int min, int *num,
const char *errfmt);
static void getoptarg (char *arg, char switch_char, char *character,
@ -1024,7 +1024,7 @@ index 26f221f..633f50e 100644
int *number);
static void print_files (int number_of_files, char **av);
static void init_parameters (int number_of_files);
@@ -442,7 +486,6 @@ static void store_char (char c);
@@ -441,7 +485,6 @@ static void store_char (char c);
static void pad_down (unsigned int lines);
static void read_rest_of_line (COLUMN *p);
static void skip_read (COLUMN *p, int column_number);
@ -1032,7 +1032,7 @@ index 26f221f..633f50e 100644
static void cleanup (void);
static void print_sep_string (void);
static void separator_string (const char *optarg_S);
@@ -454,7 +497,7 @@ static COLUMN *column_vector;
@@ -453,7 +496,7 @@ static COLUMN *column_vector;
we store the leftmost columns contiguously in buff.
To print a line from buff, get the index of the first character
from line_vector[i], and print up to line_vector[i + 1]. */
@ -1041,7 +1041,7 @@ index 26f221f..633f50e 100644
/* Index of the position in buff where the next character
will be stored. */
@@ -558,7 +601,7 @@ static int chars_per_column;
@@ -557,7 +600,7 @@ static int chars_per_column;
static bool untabify_input = false;
/* (-e) The input tab character. */
@ -1050,7 +1050,7 @@ index 26f221f..633f50e 100644
/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ...
where the leftmost column is 1. */
@@ -568,7 +611,10 @@ static int chars_per_input_tab = 8;
@@ -567,7 +610,10 @@ static int chars_per_input_tab = 8;
static bool tabify_output = false;
/* (-i) The output tab character. */
@ -1062,7 +1062,7 @@ index 26f221f..633f50e 100644
/* (-i) The width of the output tab. */
static int chars_per_output_tab = 8;
@@ -638,7 +684,13 @@ static int line_number;
@@ -637,7 +683,13 @@ static int line_number;
static bool numbered_lines = false;
/* (-n) Character which follows each line number. */
@ -1077,7 +1077,7 @@ index 26f221f..633f50e 100644
/* (-n) line counting starts with 1st line of input file (not with 1st
line of 1st page printed). */
@@ -691,6 +743,7 @@ static bool use_col_separator = false;
@@ -690,6 +742,7 @@ static bool use_col_separator = false;
-a|COLUMN|-m is a 'space' and with the -J option a 'tab'. */
static char const *col_sep_string = "";
static int col_sep_length = 0;
@ -1085,7 +1085,7 @@ index 26f221f..633f50e 100644
static char *column_separator = (char *) " ";
static char *line_separator = (char *) "\t";
@@ -852,6 +905,13 @@ separator_string (const char *optarg_S)
@@ -851,6 +904,13 @@ separator_string (const char *optarg_S)
integer_overflow ();
col_sep_length = len;
col_sep_string = optarg_S;
@ -1099,7 +1099,7 @@ index 26f221f..633f50e 100644
}
int
@@ -876,6 +936,21 @@ main (int argc, char **argv)
@@ -875,6 +935,21 @@ main (int argc, char **argv)
atexit (close_stdout);
@ -1121,7 +1121,7 @@ index 26f221f..633f50e 100644
n_files = 0;
file_names = (argc > 1
? xnmalloc (argc - 1, sizeof (char *))
@@ -952,8 +1027,12 @@ main (int argc, char **argv)
@@ -951,8 +1026,12 @@ main (int argc, char **argv)
break;
case 'e':
if (optarg)
@ -1136,7 +1136,7 @@ index 26f221f..633f50e 100644
/* Could check tab width > 0. */
untabify_input = true;
break;
@@ -966,8 +1045,12 @@ main (int argc, char **argv)
@@ -965,8 +1044,12 @@ main (int argc, char **argv)
break;
case 'i':
if (optarg)
@ -1151,7 +1151,7 @@ index 26f221f..633f50e 100644
/* Could check tab width > 0. */
tabify_output = true;
break;
@@ -985,8 +1068,8 @@ main (int argc, char **argv)
@@ -984,8 +1067,8 @@ main (int argc, char **argv)
case 'n':
numbered_lines = true;
if (optarg)
@ -1162,7 +1162,7 @@ index 26f221f..633f50e 100644
break;
case 'N':
skip_count = false;
@@ -1011,6 +1094,7 @@ main (int argc, char **argv)
@@ -1010,6 +1093,7 @@ main (int argc, char **argv)
/* Reset an additional input of -s, -S dominates -s */
col_sep_string = "";
col_sep_length = 0;
@ -1170,7 +1170,7 @@ index 26f221f..633f50e 100644
use_col_separator = true;
if (optarg)
separator_string (optarg);
@@ -1166,10 +1250,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err)
@@ -1165,10 +1249,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err)
a number. */
static void
@ -1218,7 +1218,7 @@ index 26f221f..633f50e 100644
if (*arg)
{
long int tmp_long;
@@ -1191,6 +1310,11 @@ static void
@@ -1190,6 +1309,11 @@ static void
init_parameters (int number_of_files)
{
int chars_used_by_number = 0;
@ -1230,7 +1230,7 @@ index 26f221f..633f50e 100644
lines_per_body = lines_per_page - lines_per_header - lines_per_footer;
if (lines_per_body <= 0)
@@ -1228,7 +1352,7 @@ init_parameters (int number_of_files)
@@ -1227,7 +1351,7 @@ init_parameters (int number_of_files)
else
col_sep_string = column_separator;
@ -1239,7 +1239,7 @@ index 26f221f..633f50e 100644
use_col_separator = true;
}
/* It's rather pointless to define a TAB separator with column
@@ -1258,11 +1382,11 @@ init_parameters (int number_of_files)
@@ -1257,11 +1381,11 @@ init_parameters (int number_of_files)
+ TAB_WIDTH (chars_per_input_tab, chars_per_number); */
/* Estimate chars_per_text without any margin and keep it constant. */
@ -1253,7 +1253,7 @@ index 26f221f..633f50e 100644
/* The number is part of the column width unless we are
printing files in parallel. */
@@ -1271,7 +1395,7 @@ init_parameters (int number_of_files)
@@ -1270,7 +1394,7 @@ init_parameters (int number_of_files)
}
int sep_chars, useful_chars;
@ -1262,7 +1262,7 @@ index 26f221f..633f50e 100644
sep_chars = INT_MAX;
if (INT_SUBTRACT_WRAPV (chars_per_line - chars_used_by_number, sep_chars,
&useful_chars))
@@ -1294,7 +1418,7 @@ init_parameters (int number_of_files)
@@ -1293,7 +1417,7 @@ init_parameters (int number_of_files)
We've to use 8 as the lower limit, if we use chars_per_default_tab = 8
to expand a tab which is not an input_tab-char. */
free (clump_buff);
@ -1271,7 +1271,7 @@ index 26f221f..633f50e 100644
}
/* Open the necessary files,
@@ -1400,7 +1524,7 @@ init_funcs (void)
@@ -1399,7 +1523,7 @@ init_funcs (void)
/* Enlarge p->start_position of first column to use the same form of
padding_not_printed with all columns. */
@ -1280,7 +1280,7 @@ index 26f221f..633f50e 100644
/* This loop takes care of all but the rightmost column. */
@@ -1434,7 +1558,7 @@ init_funcs (void)
@@ -1433,7 +1557,7 @@ init_funcs (void)
}
else
{
@ -1289,7 +1289,7 @@ index 26f221f..633f50e 100644
h_next = h + chars_per_column;
}
}
@@ -1725,9 +1849,9 @@ static void
@@ -1724,9 +1848,9 @@ static void
align_column (COLUMN *p)
{
padding_not_printed = p->start_position;
@ -1301,7 +1301,7 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2002,13 +2126,13 @@ store_char (char c)
@@ -2001,13 +2125,13 @@ store_char (char c)
/* May be too generous. */
buff = X2REALLOC (buff, &buff_allocated);
}
@ -1317,7 +1317,7 @@ index 26f221f..633f50e 100644
char *s;
int num_width;
@@ -2025,22 +2149,24 @@ add_line_number (COLUMN *p)
@@ -2024,22 +2148,24 @@ add_line_number (COLUMN *p)
/* Tabification is assumed for multiple columns, also for n-separators,
but 'default n-separator = TAB' hasn't been given priority over
equal column_width also specified by POSIX. */
@ -1346,7 +1346,7 @@ index 26f221f..633f50e 100644
output_position = POS_AFTER_TAB (chars_per_output_tab,
output_position);
}
@@ -2199,7 +2325,7 @@ print_white_space (void)
@@ -2198,7 +2324,7 @@ print_white_space (void)
while (goal - h_old > 1
&& (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal)
{
@ -1355,7 +1355,7 @@ index 26f221f..633f50e 100644
h_old = h_new;
}
while (++h_old <= goal)
@@ -2219,6 +2345,7 @@ print_sep_string (void)
@@ -2218,6 +2344,7 @@ print_sep_string (void)
{
char const *s = col_sep_string;
int l = col_sep_length;
@ -1363,7 +1363,7 @@ index 26f221f..633f50e 100644
if (separators_not_printed <= 0)
{
@@ -2230,6 +2357,7 @@ print_sep_string (void)
@@ -2229,6 +2356,7 @@ print_sep_string (void)
{
for (; separators_not_printed > 0; --separators_not_printed)
{
@ -1371,7 +1371,7 @@ index 26f221f..633f50e 100644
while (l-- > 0)
{
/* 3 types of sep_strings: spaces only, spaces and chars,
@@ -2243,12 +2371,15 @@ print_sep_string (void)
@@ -2242,12 +2370,15 @@ print_sep_string (void)
}
else
{
@ -1388,7 +1388,7 @@ index 26f221f..633f50e 100644
/* sep_string ends with some spaces */
if (spaces_not_printed > 0)
print_white_space ();
@@ -2276,7 +2407,7 @@ print_clump (COLUMN *p, int n, char *clump)
@@ -2275,7 +2406,7 @@ print_clump (COLUMN *p, int n, char *clump)
required number of tabs and spaces. */
static void
@ -1397,7 +1397,7 @@ index 26f221f..633f50e 100644
{
if (tabify_output)
{
@@ -2300,6 +2431,74 @@ print_char (char c)
@@ -2299,6 +2430,74 @@ print_char (char c)
putchar (c);
}
@ -1472,7 +1472,7 @@ index 26f221f..633f50e 100644
/* Skip to page PAGE before printing.
PAGE may be larger than total number of pages. */
@@ -2477,9 +2676,9 @@ read_line (COLUMN *p)
@@ -2476,9 +2675,9 @@ read_line (COLUMN *p)
align_empty_cols = false;
}
@ -1484,7 +1484,7 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2548,7 +2747,7 @@ print_stored (COLUMN *p)
@@ -2547,7 +2746,7 @@ print_stored (COLUMN *p)
COLUMN *q;
int line = p->current_line++;
@ -1493,7 +1493,7 @@ index 26f221f..633f50e 100644
/* FIXME
UMR: Uninitialized memory read:
* This is occurring while in:
@@ -2560,7 +2759,7 @@ print_stored (COLUMN *p)
@@ -2559,7 +2758,7 @@ print_stored (COLUMN *p)
xmalloc [xmalloc.c:94]
init_store_cols [pr.c:1648]
*/
@ -1502,7 +1502,7 @@ index 26f221f..633f50e 100644
pad_vertically = true;
@@ -2580,9 +2779,9 @@ print_stored (COLUMN *p)
@@ -2579,9 +2778,9 @@ print_stored (COLUMN *p)
}
}
@ -1514,7 +1514,7 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2595,8 +2794,8 @@ print_stored (COLUMN *p)
@@ -2594,8 +2793,8 @@ print_stored (COLUMN *p)
if (spaces_not_printed == 0)
{
output_position = p->start_position + end_vector[line];
@ -1525,7 +1525,7 @@ index 26f221f..633f50e 100644
}
return true;
@@ -2615,7 +2814,7 @@ print_stored (COLUMN *p)
@@ -2614,7 +2813,7 @@ print_stored (COLUMN *p)
number of characters is 1.) */
static int
@ -1534,7 +1534,7 @@ index 26f221f..633f50e 100644
{
unsigned char uc = c;
char *s = clump_buff;
@@ -2625,10 +2824,10 @@ char_to_clump (char c)
@@ -2624,10 +2823,10 @@ char_to_clump (char c)
int chars;
int chars_per_c = 8;
@ -1547,7 +1547,7 @@ index 26f221f..633f50e 100644
{
width = TAB_WIDTH (chars_per_c, input_position);
@@ -2709,6 +2908,164 @@ char_to_clump (char c)
@@ -2708,6 +2907,164 @@ char_to_clump (char c)
return chars;
}
@ -1731,7 +1731,7 @@ index 6d2eec5..f189a0d 100644
#include "system.h"
#include "argmatch.h"
#include "die.h"
@@ -157,14 +165,39 @@ static int decimal_point;
@@ -169,14 +177,39 @@ static int decimal_point;
/* Thousands separator; if -1, then there isn't one. */
static int thousands_sep;
@ -1772,7 +1772,7 @@ index 6d2eec5..f189a0d 100644
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
@@ -338,13 +371,11 @@ static bool reverse;
@@ -350,13 +383,11 @@ static bool reverse;
they were read if all keys compare equal. */
static bool stable;
@ -1789,7 +1789,7 @@ index 6d2eec5..f189a0d 100644
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
@@ -802,6 +833,46 @@ reap_all (void)
@@ -814,6 +845,46 @@ reap_all (void)
reap (-1);
}
@ -1836,7 +1836,7 @@ index 6d2eec5..f189a0d 100644
/* Clean up any remaining temporary files. */
static void
@@ -1270,7 +1341,7 @@ zaptemp (char const *name)
@@ -1264,7 +1335,7 @@ zaptemp (char const *name)
free (node);
}
@ -1845,7 +1845,7 @@ index 6d2eec5..f189a0d 100644
static int
struct_month_cmp (void const *m1, void const *m2)
@@ -1285,7 +1356,7 @@ struct_month_cmp (void const *m1, void const *m2)
@@ -1279,7 +1350,7 @@ struct_month_cmp (void const *m1, void const *m2)
/* Initialize the character class tables. */
static void
@ -1854,7 +1854,7 @@ index 6d2eec5..f189a0d 100644
{
size_t i;
@@ -1297,7 +1368,7 @@ inittables (void)
@@ -1291,7 +1362,7 @@ inittables (void)
fold_toupper[i] = toupper (i);
}
@ -1863,7 +1863,7 @@ index 6d2eec5..f189a0d 100644
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
@@ -1379,6 +1450,84 @@ specify_nmerge (int oi, char c, char const *s)
@@ -1373,6 +1444,84 @@ specify_nmerge (int oi, char c, char const *s)
xstrtol_fatal (e, oi, c, long_options, s);
}
@ -1948,7 +1948,7 @@ index 6d2eec5..f189a0d 100644
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (int oi, char c, char const *s)
@@ -1610,7 +1759,7 @@ buffer_linelim (struct buffer const *buf)
@@ -1604,7 +1753,7 @@ buffer_linelim (struct buffer const *buf)
by KEY in LINE. */
static char *
@ -1957,7 +1957,7 @@ index 6d2eec5..f189a0d 100644
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword;
@@ -1619,10 +1768,10 @@ begfield (struct line const *line, struct keyfield const *key)
@@ -1613,10 +1762,10 @@ begfield (struct line const *line, struct keyfield const *key)
/* The leading field separator itself is included in a field when -t
is absent. */
@ -1970,7 +1970,7 @@ index 6d2eec5..f189a0d 100644
++ptr;
if (ptr < lim)
++ptr;
@@ -1648,11 +1797,70 @@ begfield (struct line const *line, struct keyfield const *key)
@@ -1642,11 +1791,70 @@ begfield (struct line const *line, struct keyfield const *key)
return ptr;
}
@ -2042,7 +2042,7 @@ index 6d2eec5..f189a0d 100644
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar;
@@ -1667,10 +1875,10 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1661,10 +1869,10 @@ limfield (struct line const *line, struct keyfield const *key)
'beginning' is the first character following the delimiting TAB.
Otherwise, leave PTR pointing at the first 'blank' character after
the preceding field. */
@ -2055,7 +2055,7 @@ index 6d2eec5..f189a0d 100644
++ptr;
if (ptr < lim && (eword || echar))
++ptr;
@@ -1716,10 +1924,10 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1710,10 +1918,10 @@ limfield (struct line const *line, struct keyfield const *key)
*/
/* Make LIM point to the end of (one byte past) the current field. */
@ -2068,7 +2068,7 @@ index 6d2eec5..f189a0d 100644
if (newlim)
lim = newlim;
}
@@ -1750,6 +1958,130 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1744,6 +1952,130 @@ limfield (struct line const *line, struct keyfield const *key)
return ptr;
}
@ -2199,7 +2199,7 @@ index 6d2eec5..f189a0d 100644
/* Fill BUF reading from FP, moving buf->left bytes from the end
of buf->buf to the beginning first. If EOF is reached and the
file wasn't terminated by a newline, supply one. Set up BUF's line
@@ -1836,8 +2168,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
@@ -1830,8 +2162,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
else
{
if (key->skipsblanks)
@ -2224,7 +2224,7 @@ index 6d2eec5..f189a0d 100644
line->keybeg = line_start;
}
}
@@ -1987,7 +2333,7 @@ human_numcompare (char const *a, char const *b)
@@ -1981,7 +2327,7 @@ human_numcompare (char const *a, char const *b)
hideously fast. */
static int
@ -2233,7 +2233,7 @@ index 6d2eec5..f189a0d 100644
{
while (blanks[to_uchar (*a)])
a++;
@@ -1997,6 +2343,25 @@ numcompare (char const *a, char const *b)
@@ -1991,6 +2337,25 @@ numcompare (char const *a, char const *b)
return strnumcmp (a, b, decimal_point, thousands_sep);
}
@ -2258,8 +2258,8 @@ index 6d2eec5..f189a0d 100644
+
/* Work around a problem whereby the long double value returned by glibc's
strtold ("NaN", ...) contains uninitialized bits: clear all bytes of
A and B before calling strtold. FIXME: remove this function if
@@ -2047,7 +2412,7 @@ general_numcompare (char const *sa, char const *sb)
A and B before calling strtold. FIXME: remove this function once
@@ -2041,7 +2406,7 @@ general_numcompare (char const *sa, char const *sb)
Return 0 if the name in S is not recognized. */
static int
@ -2268,7 +2268,7 @@ index 6d2eec5..f189a0d 100644
{
size_t lo = 0;
size_t hi = MONTHS_PER_YEAR;
@@ -2323,15 +2688,14 @@ debug_key (struct line const *line, struct keyfield const *key)
@@ -2317,15 +2682,14 @@ debug_key (struct line const *line, struct keyfield const *key)
char saved = *lim;
*lim = '\0';
@ -2286,7 +2286,7 @@ index 6d2eec5..f189a0d 100644
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric)
@@ -2465,7 +2829,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
@@ -2459,7 +2823,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
/* Warn about significant leading blanks. */
bool implicit_skip = key_numeric (key) || key->month;
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
@ -2295,7 +2295,7 @@ index 6d2eec5..f189a0d 100644
&& ((!key->skipsblanks && !implicit_skip)
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
@@ -2523,11 +2887,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
@@ -2517,11 +2881,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
@ -2384,7 +2384,7 @@ index 6d2eec5..f189a0d 100644
{
struct keyfield *key = keylist;
@@ -2612,7 +3052,7 @@ keycompare (struct line const *a, struct line const *b)
@@ -2606,7 +3046,7 @@ keycompare (struct line const *a, struct line const *b)
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
@ -2393,7 +2393,7 @@ index 6d2eec5..f189a0d 100644
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
@@ -2728,6 +3168,211 @@ keycompare (struct line const *a, struct line const *b)
@@ -2722,6 +3162,211 @@ keycompare (struct line const *a, struct line const *b)
return key->reverse ? -diff : diff;
}
@ -2605,7 +2605,7 @@ index 6d2eec5..f189a0d 100644
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
@@ -2755,7 +3400,7 @@ compare (struct line const *a, struct line const *b)
@@ -2749,7 +3394,7 @@ compare (struct line const *a, struct line const *b)
diff = - NONZERO (blen);
else if (blen == 0)
diff = 1;
@ -2614,7 +2614,7 @@ index 6d2eec5..f189a0d 100644
{
/* xmemcoll0 is a performance enhancement as
it will not unconditionally write '\0' after the
@@ -4145,6 +4790,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype)
@@ -4144,6 +4789,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype)
break;
case 'f':
key->translate = fold_toupper;
@ -2622,7 +2622,7 @@ index 6d2eec5..f189a0d 100644
break;
case 'g':
key->general_numeric = true;
@@ -4224,7 +4870,7 @@ main (int argc, char **argv)
@@ -4223,7 +4869,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@ -2631,7 +2631,7 @@ index 6d2eec5..f189a0d 100644
hard_LC_TIME = hard_locale (LC_TIME);
#endif
@@ -4245,6 +4891,29 @@ main (int argc, char **argv)
@@ -4244,6 +4890,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -2661,7 +2661,7 @@ index 6d2eec5..f189a0d 100644
have_read_stdin = false;
inittables ();
@@ -4519,13 +5188,34 @@ main (int argc, char **argv)
@@ -4518,13 +5187,34 @@ main (int argc, char **argv)
case 't':
{
@ -2700,7 +2700,7 @@ index 6d2eec5..f189a0d 100644
else
{
/* Provoke with 'sort -txx'. Complain about
@@ -4536,9 +5226,11 @@ main (int argc, char **argv)
@@ -4535,9 +5225,11 @@ main (int argc, char **argv)
quote (optarg));
}
}
@ -2714,7 +2714,7 @@ index 6d2eec5..f189a0d 100644
}
break;
@@ -4767,12 +5459,10 @@ main (int argc, char **argv)
@@ -4765,12 +5457,10 @@ main (int argc, char **argv)
sort (files, nfiles, outfile, nthreads);
}
@ -2749,8 +2749,12 @@ index 87a0c93..9f755d9 100644
#include "system.h"
#include "argmatch.h"
#include "linebuffer.h"
@@ -33,6 +44,18 @@
#include "memcasecmp.h"
@@ -32,9 +43,21 @@
#include "stdio--.h"
#include "xmemcoll.h"
#include "xstrtol.h"
-#include "memcasecmp.h"
+#include "xmemcoll.h"
#include "quote.h"
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
@ -2768,7 +2772,7 @@ index 87a0c93..9f755d9 100644
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "uniq"
@@ -139,6 +162,10 @@ enum
@@ -144,6 +167,10 @@ enum
GROUP_OPTION = CHAR_MAX + 1
};
@ -2779,7 +2783,7 @@ index 87a0c93..9f755d9 100644
static struct option const longopts[] =
{
{"count", no_argument, NULL, 'c'},
@@ -253,7 +280,7 @@ size_opt (char const *opt, char const *msgid)
@@ -260,7 +287,7 @@ size_opt (char const *opt, char const *msgid)
return a pointer to the beginning of the line's field to be compared. */
static char * _GL_ATTRIBUTE_PURE
@ -2788,7 +2792,7 @@ index 87a0c93..9f755d9 100644
{
size_t count;
char const *lp = line->buffer;
@@ -273,6 +300,83 @@ find_field (struct linebuffer const *line)
@@ -280,6 +307,83 @@ find_field (struct linebuffer const *line)
return line->buffer + i;
}
@ -2872,7 +2876,228 @@ index 87a0c93..9f755d9 100644
/* Return false if two strings OLD and NEW match, true if not.
OLD and NEW point not to the beginnings of the lines
but rather to the beginnings of the fields to compare.
@@ -493,6 +597,19 @@ main (int argc, char **argv)
@@ -288,6 +392,8 @@ find_field (struct linebuffer const *line)
static bool
different (char *old, char *new, size_t oldlen, size_t newlen)
{
+ char *copy_old, *copy_new;
+
if (check_chars < oldlen)
oldlen = check_chars;
if (check_chars < newlen)
@@ -295,15 +401,104 @@ different (char *old, char *new, size_t oldlen, size_t newlen)
if (ignore_case)
{
- /* FIXME: This should invoke strcoll somehow. */
- return oldlen != newlen || memcasecmp (old, new, oldlen);
+ size_t i;
+
+ copy_old = xmalloc (oldlen + 1);
+ copy_new = xmalloc (oldlen + 1);
+
+ for (i = 0; i < oldlen; i++)
+ {
+ copy_old[i] = toupper (old[i]);
+ copy_new[i] = toupper (new[i]);
+ }
+ bool rc = xmemcoll (copy_old, oldlen, copy_new, newlen);
+ free (copy_old);
+ free (copy_new);
+ return rc;
}
- else if (hard_LC_COLLATE)
- return xmemcoll (old, oldlen, new, newlen) != 0;
else
- return oldlen != newlen || memcmp (old, new, oldlen);
+ {
+ copy_old = (char *)old;
+ copy_new = (char *)new;
+ }
+
+ return xmemcoll (copy_old, oldlen, copy_new, newlen);
+
}
+#if HAVE_MBRTOWC
+static int
+different_multi (const char *old, const char *new, size_t oldlen, size_t newlen, mbstate_t oldstate, mbstate_t newstate)
+{
+ size_t i, j, chars;
+ const char *str[2];
+ char *copy[2];
+ size_t len[2];
+ mbstate_t state[2];
+ size_t mblength;
+ wchar_t wc, uwc;
+ mbstate_t state_bak;
+
+ str[0] = old;
+ str[1] = new;
+ len[0] = oldlen;
+ len[1] = newlen;
+ state[0] = oldstate;
+ state[1] = newstate;
+
+ for (i = 0; i < 2; i++)
+ {
+ copy[i] = xmalloc (len[i] + 1);
+ memset (copy[i], '\0', len[i] + 1);
+
+ for (j = 0, chars = 0; j < len[i] && chars < check_chars; chars++)
+ {
+ state_bak = state[i];
+ mblength = mbrtowc (&wc, str[i] + j, len[i] - j, &(state[i]));
+
+ switch (mblength)
+ {
+ case (size_t)-1:
+ case (size_t)-2:
+ state[i] = state_bak;
+ /* Fall through */
+ case 0:
+ mblength = 1;
+ break;
+
+ default:
+ if (ignore_case)
+ {
+ uwc = towupper (wc);
+
+ if (uwc != wc)
+ {
+ mbstate_t state_wc;
+ size_t mblen;
+
+ memset (&state_wc, '\0', sizeof(mbstate_t));
+ mblen = wcrtomb (copy[i] + j, uwc, &state_wc);
+ assert (mblen != (size_t)-1);
+ }
+ else
+ memcpy (copy[i] + j, str[i] + j, mblength);
+ }
+ else
+ memcpy (copy[i] + j, str[i] + j, mblength);
+ }
+ j += mblength;
+ }
+ copy[i][j] = '\0';
+ len[i] = j;
+ }
+ int rc = xmemcoll (copy[0], len[0], copy[1], len[1]);
+ free (copy[0]);
+ free (copy[1]);
+ return rc;
+
+}
+#endif
+
/* Output the line in linebuffer LINE to standard output
provided that the switches say it should be output.
MATCH is true if the line matches the previous line.
@@ -367,19 +562,38 @@ check_file (const char *infile, const char *outfile, char delimiter)
char *prevfield IF_LINT ( = NULL);
size_t prevlen IF_LINT ( = 0);
bool first_group_printed = false;
+#if HAVE_MBRTOWC
+ mbstate_t prevstate;
+
+ memset (&prevstate, '\0', sizeof (mbstate_t));
+#endif
while (!feof (stdin))
{
char *thisfield;
size_t thislen;
bool new_group;
+#if HAVE_MBRTOWC
+ mbstate_t thisstate;
+#endif
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
break;
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ {
+ thisstate = thisline->state;
+ new_group = (prevline->length == 0
+ || different_multi (thisfield, prevfield,
+ thislen, prevlen,
+ thisstate, prevstate));
+ }
+ else
+#endif
new_group = (prevline->length == 0
|| different (thisfield, prevfield, thislen, prevlen));
@@ -397,6 +611,10 @@ check_file (const char *infile, const char *outfile, char delimiter)
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ prevstate = thisstate;
+#endif
first_group_printed = true;
}
}
@@ -409,17 +627,26 @@ check_file (const char *infile, const char *outfile, char delimiter)
size_t prevlen;
uintmax_t match_count = 0;
bool first_delimiter = true;
+#if HAVE_MBRTOWC
+ mbstate_t prevstate;
+#endif
if (readlinebuffer_delim (prevline, stdin, delimiter) == 0)
goto closefiles;
prevfield = find_field (prevline);
prevlen = prevline->length - 1 - (prevfield - prevline->buffer);
+#if HAVE_MBRTOWC
+ prevstate = prevline->state;
+#endif
while (!feof (stdin))
{
bool match;
char *thisfield;
size_t thislen;
+#if HAVE_MBRTOWC
+ mbstate_t thisstate = thisline->state;
+#endif
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{
if (ferror (stdin))
@@ -428,6 +655,14 @@ check_file (const char *infile, const char *outfile, char delimiter)
}
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ {
+ match = !different_multi (thisfield, prevfield,
+ thislen, prevlen, thisstate, prevstate);
+ }
+ else
+#endif
match = !different (thisfield, prevfield, thislen, prevlen);
match_count += match;
@@ -460,6 +695,9 @@ check_file (const char *infile, const char *outfile, char delimiter)
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
+#if HAVE_MBRTOWC
+ prevstate = thisstate;
+#endif
if (!match)
match_count = 0;
}
@@ -506,6 +744,19 @@ main (int argc, char **argv)
atexit (close_stdout);
@ -2931,7 +3156,7 @@ diff --git a/tests/local.mk b/tests/local.mk
index 568944e..192f776 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -369,6 +369,8 @@ all_tests = \
@@ -362,6 +362,8 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
@ -3100,7 +3325,7 @@ index 4d399d8..07f2823 100755
my $delim = chr 0247;
sub t_subst ($)
{
@@ -333,8 +342,49 @@ foreach my $t (@tv)
@@ -329,8 +338,49 @@ foreach my $t (@tv)
push @Tests, $new_ent;
}

View File

@ -0,0 +1,625 @@
From 5a6af47c3db45b6303bac4dcd6da186fd5cd178c Mon Sep 17 00:00:00 2001
From: Ondrej Valousek <ondrej.valousek.xm@renesas.com>
Date: Fri, 2 Dec 2022 13:40:19 +0100
Subject: [PATCH 1/3] file-has-acl: Basic support for checking NFSv4 ACLs in
Linux.
* lib/acl-internal.h (acl_nfs4_nontrivial): New declaration.
* lib/acl-internal.c (acl_nfs4_nontrivial): New function.
* lib/file-has-acl.c: Include <arpa/inet.h>.
(XATTR_NAME_NFSV4_ACL, TRIVIAL_NFS4_ACL_MAX_LENGTH): New macros.
(file_has_acl): Test for NFSv4 ACLs.
* doc/acl-nfsv4.txt: New file.
Upstream-commit: b0604a8e134dbcc307c0ffdd5ebd3693e9de7081
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/acl-nfsv4.txt | 17 ++++++++
lib/acl-internal.c | 100 +++++++++++++++++++++++++++++++++++++++++++++
lib/acl-internal.h | 3 ++
lib/file-has-acl.c | 21 ++++++++++
4 files changed, 141 insertions(+)
create mode 100644 doc/acl-nfsv4.txt
diff --git a/doc/acl-nfsv4.txt b/doc/acl-nfsv4.txt
new file mode 100644
index 0000000..71352f5
--- /dev/null
+++ b/doc/acl-nfsv4.txt
@@ -0,0 +1,17 @@
+General introduction:
+ https://linux.die.net/man/5/nfs4_acl
+
+The NFSv4 acls are defined in RFC7530 and as such, every NFSv4 server supporting ACLs
+will support this kind of ACLs (note the difference from POSIX draft ACLs)
+
+The ACLs can be obtained via the nfsv4-acl-tools, i.e.
+
+$ nfs4_getfacl <file>
+
+# file: <file>
+A::OWNER@:rwaDxtTnNcCy
+A::GROUP@:rwaDxtTnNcy
+A::EVERYONE@:rwaDxtTnNcy
+
+Gnulib is aiming to only provide a basic support of these, i.e. recognize trivial
+and non-trivial ACLs
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index be244c6..4c65dff 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -25,6 +25,9 @@
#if USE_ACL && HAVE_ACL_GET_FILE
+# include <string.h>
+# include <arpa/inet.h>
+
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
@@ -122,6 +125,103 @@ acl_default_nontrivial (acl_t acl)
return (acl_entries (acl) > 0);
}
+# define ACE4_WHO_OWNER "OWNER@"
+# define ACE4_WHO_GROUP "GROUP@"
+# define ACE4_WHO_EVERYONE "EVERYONE@"
+
+# define ACE4_ACCESS_ALLOWED_ACE_TYPE 0
+# define ACE4_ACCESS_DENIED_ACE_TYPE 1
+
+/* ACE flag values */
+# define ACE4_IDENTIFIER_GROUP 0x00000040
+# define ROUNDUP(x, y) (((x) + (y) - 1) & - (y))
+
+int
+acl_nfs4_nontrivial (char *xattr, int len)
+{
+ int bufs = len;
+ uint32_t num_aces = ntohl (*((uint32_t*)(xattr))), /* Grab the number of aces in the acl */
+ num_a_aces = 0,
+ num_d_aces = 0;
+ char *bufp = xattr;
+
+ bufp += 4; /* sizeof(uint32_t); */
+ bufs -= 4;
+
+ for (uint32_t ace_n = 0; num_aces > ace_n ; ace_n++)
+ {
+ int d_ptr;
+ uint32_t flag,
+ wholen,
+ type;
+
+ /* Get the acl type */
+ if (bufs <= 0)
+ return -1;
+
+ type = ntohl (*((uint32_t*)bufp));
+
+ bufp += 4;
+ bufs -= 4;
+ if (bufs <= 0)
+ return -1;
+
+ flag = ntohl (*((uint32_t*)bufp));
+ /* As per RFC 7530, the flag should be 0, but we are just generous to Netapp
+ * and also accept the Group flag
+ */
+ if (flag & ~ACE4_IDENTIFIER_GROUP)
+ return 1;
+
+ /* we skip mask -
+ * it's too risky to test it and it does not seem to be actually needed */
+ bufp += 2*4;
+ bufs -= 2*4;
+
+ if (bufs <= 0)
+ return -1;
+
+ wholen = ntohl (*((uint32_t*)bufp));
+
+ bufp += 4;
+ bufs -= 4;
+
+ /* Get the who string */
+ if (bufs <= 0)
+ return -1;
+
+ /* for trivial ACL, we expect max 5 (typically 3) ACES, 3 Allow, 2 deny */
+ if (((strncmp (bufp, ACE4_WHO_OWNER, wholen) == 0)
+ || (strncmp (bufp, ACE4_WHO_GROUP, wholen) == 0))
+ && wholen == 6)
+ {
+ if (type == ACE4_ACCESS_ALLOWED_ACE_TYPE)
+ num_a_aces++;
+ if (type == ACE4_ACCESS_DENIED_ACE_TYPE)
+ num_d_aces++;
+ }
+ else
+ if ((strncmp (bufp, ACE4_WHO_EVERYONE, wholen) == 0)
+ && (type == ACE4_ACCESS_ALLOWED_ACE_TYPE)
+ && (wholen == 9))
+ num_a_aces++;
+ else
+ return 1;
+
+ d_ptr = ROUNDUP (wholen, 4);
+ bufp += d_ptr;
+ bufs -= d_ptr;
+
+ /* Make sure we aren't outside our domain */
+ if (bufs < 0)
+ return -1;
+
+ }
+ return !((num_a_aces <= 3) && (num_d_aces <= 2)
+ && (num_a_aces + num_d_aces == num_aces));
+
+}
+
# endif
#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 9353376..2a249ff 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -143,6 +143,9 @@ rpl_acl_set_fd (int fd, acl_t acl)
# define acl_entries rpl_acl_entries
extern int acl_entries (acl_t);
# endif
+/* Return 1 if given ACL in XDR format is non-trivial
+ * Return 0 if it is trivial */
+extern int acl_nfs4_nontrivial (char *, int);
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index e02f062..1710234 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -32,6 +32,11 @@
#if GETXATTR_WITH_POSIX_ACLS
# include <sys/xattr.h>
# include <linux/xattr.h>
+# include <arpa/inet.h>
+# ifndef XATTR_NAME_NFSV4_ACL
+# define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
+# endif
+# define TRIVIAL_NFS4_ACL_MAX_LENGTH 128
#endif
/* Return 1 if NAME has a nontrivial access control list,
@@ -67,6 +72,22 @@ file_has_acl (char const *name, struct stat const *sb)
return 1;
}
+ if (ret < 0)
+ { /* we might be on NFS, so try to check NFSv4 ACLs too */
+ char xattr[TRIVIAL_NFS4_ACL_MAX_LENGTH];
+
+ errno = 0; /* we need to reset errno set by the previous getxattr() */
+ ret = getxattr (name, XATTR_NAME_NFSV4_ACL, xattr, TRIVIAL_NFS4_ACL_MAX_LENGTH);
+ if (ret < 0 && errno == ENODATA)
+ ret = 0;
+ else
+ if (ret < 0 && errno == ERANGE)
+ return 1; /* we won't fit into the buffer, so non-trivial ACL is presented */
+ else
+ if (ret > 0)
+ /* looks like trivial ACL, but we need to investigate further */
+ return acl_nfs4_nontrivial (xattr, ret);
+ }
if (ret < 0)
return - acl_errno_valid (errno);
return ret;
--
2.38.1
From c5266d204a446bea619fa18da8520dceb0a54192 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 23 Dec 2022 15:18:29 -0800
Subject: [PATCH 2/3] file-has-acl: improve recent NFSv4 support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes a link failure with emacsclient on GNU/Linux. This
program wants file_has_acl but none of the other ACL primitives,
so it doesnt link acl-internal.o; this way it doesnt need to
link with -lacl. While I was at it I reviewed the recent changes,
fixed some unlikely overflow bugs, and adjusted to GNU style.
* doc/acl-nfsv4.txt: Remove. Its contents are now in a
comment in lib/file-has-acl.c.
* lib/acl-internal.c, lib/acl-internal.h: Move recent changes
relating to acl_nfs4_nontrivial to lib/file-has-acl.c, so that
there is no trouble linking programs that need only file_has_acl.
* lib/file-has-acl.c (acl_nfs4_nontrivial): Move here from
lib/acl-internal.c, so that we needn't link -lacl in
programs that want only file_has_acl, such as emacsclient.
Do not assume a char buffer is aligned for uint32_t.
Check more carefully for buffer read overrun.
Allow up to 6 ACEs, since other code does; but check
that theyre distinct. Avoid integer overflow.
Use memcmp rather than strncmp to compare memory blocks.
(file_has_acl): Preserve initial errno instead of setting to 0.
Allocate a bit more room for trivial ACL buffer.
Use EINVAL for botchedk NFSv4 ACLs (which shouldnt happen).
Upstream-commit: 35bd46f0c816948dc1a0430c8ba8b10a01167320
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/acl-nfsv4.txt | 17 ------
lib/acl-internal.c | 100 -----------------------------------
lib/acl-internal.h | 3 --
lib/file-has-acl.c | 129 +++++++++++++++++++++++++++++++++++++++------
4 files changed, 113 insertions(+), 136 deletions(-)
delete mode 100644 doc/acl-nfsv4.txt
diff --git a/doc/acl-nfsv4.txt b/doc/acl-nfsv4.txt
deleted file mode 100644
index 71352f5..0000000
--- a/doc/acl-nfsv4.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-General introduction:
- https://linux.die.net/man/5/nfs4_acl
-
-The NFSv4 acls are defined in RFC7530 and as such, every NFSv4 server supporting ACLs
-will support this kind of ACLs (note the difference from POSIX draft ACLs)
-
-The ACLs can be obtained via the nfsv4-acl-tools, i.e.
-
-$ nfs4_getfacl <file>
-
-# file: <file>
-A::OWNER@:rwaDxtTnNcCy
-A::GROUP@:rwaDxtTnNcy
-A::EVERYONE@:rwaDxtTnNcy
-
-Gnulib is aiming to only provide a basic support of these, i.e. recognize trivial
-and non-trivial ACLs
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index 4c65dff..be244c6 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -25,9 +25,6 @@
#if USE_ACL && HAVE_ACL_GET_FILE
-# include <string.h>
-# include <arpa/inet.h>
-
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
@@ -125,103 +122,6 @@ acl_default_nontrivial (acl_t acl)
return (acl_entries (acl) > 0);
}
-# define ACE4_WHO_OWNER "OWNER@"
-# define ACE4_WHO_GROUP "GROUP@"
-# define ACE4_WHO_EVERYONE "EVERYONE@"
-
-# define ACE4_ACCESS_ALLOWED_ACE_TYPE 0
-# define ACE4_ACCESS_DENIED_ACE_TYPE 1
-
-/* ACE flag values */
-# define ACE4_IDENTIFIER_GROUP 0x00000040
-# define ROUNDUP(x, y) (((x) + (y) - 1) & - (y))
-
-int
-acl_nfs4_nontrivial (char *xattr, int len)
-{
- int bufs = len;
- uint32_t num_aces = ntohl (*((uint32_t*)(xattr))), /* Grab the number of aces in the acl */
- num_a_aces = 0,
- num_d_aces = 0;
- char *bufp = xattr;
-
- bufp += 4; /* sizeof(uint32_t); */
- bufs -= 4;
-
- for (uint32_t ace_n = 0; num_aces > ace_n ; ace_n++)
- {
- int d_ptr;
- uint32_t flag,
- wholen,
- type;
-
- /* Get the acl type */
- if (bufs <= 0)
- return -1;
-
- type = ntohl (*((uint32_t*)bufp));
-
- bufp += 4;
- bufs -= 4;
- if (bufs <= 0)
- return -1;
-
- flag = ntohl (*((uint32_t*)bufp));
- /* As per RFC 7530, the flag should be 0, but we are just generous to Netapp
- * and also accept the Group flag
- */
- if (flag & ~ACE4_IDENTIFIER_GROUP)
- return 1;
-
- /* we skip mask -
- * it's too risky to test it and it does not seem to be actually needed */
- bufp += 2*4;
- bufs -= 2*4;
-
- if (bufs <= 0)
- return -1;
-
- wholen = ntohl (*((uint32_t*)bufp));
-
- bufp += 4;
- bufs -= 4;
-
- /* Get the who string */
- if (bufs <= 0)
- return -1;
-
- /* for trivial ACL, we expect max 5 (typically 3) ACES, 3 Allow, 2 deny */
- if (((strncmp (bufp, ACE4_WHO_OWNER, wholen) == 0)
- || (strncmp (bufp, ACE4_WHO_GROUP, wholen) == 0))
- && wholen == 6)
- {
- if (type == ACE4_ACCESS_ALLOWED_ACE_TYPE)
- num_a_aces++;
- if (type == ACE4_ACCESS_DENIED_ACE_TYPE)
- num_d_aces++;
- }
- else
- if ((strncmp (bufp, ACE4_WHO_EVERYONE, wholen) == 0)
- && (type == ACE4_ACCESS_ALLOWED_ACE_TYPE)
- && (wholen == 9))
- num_a_aces++;
- else
- return 1;
-
- d_ptr = ROUNDUP (wholen, 4);
- bufp += d_ptr;
- bufs -= d_ptr;
-
- /* Make sure we aren't outside our domain */
- if (bufs < 0)
- return -1;
-
- }
- return !((num_a_aces <= 3) && (num_d_aces <= 2)
- && (num_a_aces + num_d_aces == num_aces));
-
-}
-
# endif
#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 2a249ff..9353376 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -143,9 +143,6 @@ rpl_acl_set_fd (int fd, acl_t acl)
# define acl_entries rpl_acl_entries
extern int acl_entries (acl_t);
# endif
-/* Return 1 if given ACL in XDR format is non-trivial
- * Return 0 if it is trivial */
-extern int acl_nfs4_nontrivial (char *, int);
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 1710234..676523b 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -29,14 +29,97 @@
#include "acl-internal.h"
-#if GETXATTR_WITH_POSIX_ACLS
+#if USE_ACL && GETXATTR_WITH_POSIX_ACLS
+# include <string.h>
+# include <arpa/inet.h>
# include <sys/xattr.h>
# include <linux/xattr.h>
-# include <arpa/inet.h>
# ifndef XATTR_NAME_NFSV4_ACL
# define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
# endif
-# define TRIVIAL_NFS4_ACL_MAX_LENGTH 128
+
+enum {
+ /* ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000, */
+ ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001,
+ ACE4_IDENTIFIER_GROUP = 0x00000040
+};
+
+/* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial.
+ -1 upon failure to determine it. Possibly change errno. Assume that
+ the ACL is valid, except avoid undefined behavior even if invalid.
+
+ See <https://linux.die.net/man/5/nfs4_acl>. The NFSv4 acls are
+ defined in Internet RFC 7530 and as such, every NFSv4 server
+ supporting ACLs should support NFSv4 ACLs (they differ from from
+ POSIX draft ACLs). The ACLs can be obtained via the
+ nfsv4-acl-tools, e.g., the nfs4_getfacl command. Gnulib provides
+ only basic support of NFSv4 ACLs, i.e., recognize trivial vs
+ nontrivial ACLs. */
+
+static int
+acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
+{
+ enum { BYTES_PER_NETWORK_UINT = 4};
+
+ /* Grab the number of aces in the acl. */
+ nbytes -= BYTES_PER_NETWORK_UINT;
+ if (nbytes < 0)
+ return -1;
+ uint32_t num_aces = ntohl (*xattr++);
+ if (6 < num_aces)
+ return 1;
+ int ace_found = 0;
+
+ for (int ace_n = 0; ace_n < num_aces; ace_n++)
+ {
+ /* Get the acl type and flag. Skip the mask; it's too risky to
+ test it and it does not seem to be needed. Get the wholen. */
+ nbytes -= 4 * BYTES_PER_NETWORK_UINT;
+ if (nbytes < 0)
+ return -1;
+ uint32_t type = ntohl (xattr[0]);
+ uint32_t flag = ntohl (xattr[1]);
+ uint32_t wholen = ntohl (xattr[3]);
+ xattr += 4;
+ int64_t wholen4 = wholen;
+ wholen4 = ((wholen4 + (BYTES_PER_NETWORK_UINT))
+ & ~ (BYTES_PER_NETWORK_UINT - 1));
+
+ /* Trivial ACLs have only ACE4_ACCESS_ALLOWED_ACE_TYPE or
+ ACE4_ACCESS_DENIED_ACE_TYPE. */
+ if (ACE4_ACCESS_DENIED_ACE_TYPE < type)
+ return 1;
+
+ /* RFC 7530 says FLAG should be 0, but be generous to NetApp and
+ also accept the group flag. */
+ if (flag & ~ACE4_IDENTIFIER_GROUP)
+ return 1;
+
+ /* Get the who string. Check NBYTES - WHOLEN4 before storing
+ into NBYTES, to avoid truncation on conversion. */
+ if (nbytes - wholen4 < 0)
+ return -1;
+ nbytes -= wholen4;
+
+ /* For a trivial ACL, max 6 (typically 3) ACEs, 3 allow, 3 deny.
+ Check that there is at most one ACE of each TYPE and WHO. */
+ int who2
+ = (wholen == 6 && memcmp (xattr, "OWNER@", 6) == 0 ? 0
+ : wholen == 6 && memcmp (xattr, "GROUP@", 6) == 0 ? 2
+ : wholen == 9 && memcmp (xattr, "EVERYONE@", 9) == 0 ? 4
+ : -1);
+ if (who2 < 0)
+ return 1;
+ int ace_found_bit = 1 << (who2 | type);
+ if (ace_found & ace_found_bit)
+ return 1;
+ ace_found |= ace_found_bit;
+
+ xattr = (uint32_t *) ((char *) xattr + wholen4);
+ }
+
+ return 0;
+}
#endif
/* Return 1 if NAME has a nontrivial access control list,
@@ -56,6 +139,7 @@ file_has_acl (char const *name, struct stat const *sb)
# if GETXATTR_WITH_POSIX_ACLS
ssize_t ret;
+ int initial_errno = errno;
ret = getxattr (name, XATTR_NAME_POSIX_ACL_ACCESS, NULL, 0);
if (ret < 0 && errno == ENODATA)
@@ -73,20 +157,33 @@ file_has_acl (char const *name, struct stat const *sb)
}
if (ret < 0)
- { /* we might be on NFS, so try to check NFSv4 ACLs too */
- char xattr[TRIVIAL_NFS4_ACL_MAX_LENGTH];
-
- errno = 0; /* we need to reset errno set by the previous getxattr() */
- ret = getxattr (name, XATTR_NAME_NFSV4_ACL, xattr, TRIVIAL_NFS4_ACL_MAX_LENGTH);
- if (ret < 0 && errno == ENODATA)
- ret = 0;
+ {
+ /* Check for NFSv4 ACLs. The max length of a trivial
+ ACL is 6 words for owner, 6 for group, 7 for everyone,
+ all times 2 because there are both allow and deny ACEs.
+ There are 6 words for owner because of type, flag, mask,
+ wholen, "OWNER@"+pad and similarly for group; everyone is
+ another word to hold "EVERYONE@". */
+ uint32_t xattr[2 * (6 + 6 + 7)];
+
+ ret = getxattr (name, XATTR_NAME_NFSV4_ACL, xattr, sizeof xattr);
+ if (ret < 0)
+ switch (errno)
+ {
+ case ENODATA: return 0;
+ case ERANGE : return 1; /* ACL must be nontrivial. */
+ }
else
- if (ret < 0 && errno == ERANGE)
- return 1; /* we won't fit into the buffer, so non-trivial ACL is presented */
- else
- if (ret > 0)
- /* looks like trivial ACL, but we need to investigate further */
- return acl_nfs4_nontrivial (xattr, ret);
+ {
+ /* It looks like a trivial ACL, but investigate further. */
+ ret = acl_nfs4_nontrivial (xattr, ret);
+ if (ret < 0)
+ {
+ errno = EINVAL;
+ return ret;
+ }
+ errno = initial_errno;
+ }
}
if (ret < 0)
return - acl_errno_valid (errno);
--
2.38.1
From faf965110372c82cd99e9f44f0c64f03cdabb2c1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 27 Dec 2022 20:00:58 -0800
Subject: [PATCH 3/3] file-has-acl: fix recently-introduced NFSv4 bug
* lib/file-has-acl.c (acl_nfs4_nontrivial): Fix off-by-one
error when rounding WHOLEN up to next multiple of 4.
Pacify GCC 12.2.1 -Wcast-align.
Upstream-commit: d65e5a8ba77595a598c9ddb8dfa09c4aea732659
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
lib/file-has-acl.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 676523b..7876edc 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -81,9 +81,10 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
uint32_t flag = ntohl (xattr[1]);
uint32_t wholen = ntohl (xattr[3]);
xattr += 4;
- int64_t wholen4 = wholen;
- wholen4 = ((wholen4 + (BYTES_PER_NETWORK_UINT))
- & ~ (BYTES_PER_NETWORK_UINT - 1));
+ int whowords = (wholen / BYTES_PER_NETWORK_UINT
+ + (wholen % BYTES_PER_NETWORK_UINT != 0));
+ int64_t wholen4 = whowords;
+ wholen4 *= BYTES_PER_NETWORK_UINT;
/* Trivial ACLs have only ACE4_ACCESS_ALLOWED_ACE_TYPE or
ACE4_ACCESS_DENIED_ACE_TYPE. */
@@ -115,7 +116,7 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
return 1;
ace_found |= ace_found_bit;
- xattr = (uint32_t *) ((char *) xattr + wholen4);
+ xattr += whowords;
}
return 0;
--
2.38.1

View File

@ -1,9 +1,37 @@
Provides: bundled(gnulib)
# make it possible to install the latest available Adobe Reader RPM for Linux
Provides: /bin/basename
Provides: /bin/cat
Provides: /bin/chgrp
Provides: /bin/chmod
Provides: /bin/chown
Provides: /bin/cp
Provides: /bin/cut
Provides: /bin/date
Provides: /bin/dd
Provides: /bin/df
Provides: /bin/echo
Provides: /bin/env
Provides: /bin/false
Provides: /bin/ln
Provides: /bin/ls
Provides: /bin/mkdir
Provides: /bin/mknod
Provides: /bin/mktemp
Provides: /bin/mv
Provides: /bin/nice
Provides: /bin/pwd
Provides: /bin/readlink
Provides: /bin/rm
Provides: /bin/rmdir
Provides: /bin/sleep
Provides: /bin/sort
Provides: /bin/stty
Provides: /bin/sync
Provides: /bin/touch
Provides: /bin/true
Provides: /bin/uname
Provides: bundled(gnulib)
Provides: fileutils = %{version}-%{release}
Provides: mktemp = 4:%{version}-%{release}
Provides: sh-utils = %{version}-%{release}
Provides: stat = %{version}-%{release}
Provides: textutils = %{version}-%{release}

View File

@ -1,7 +1,6 @@
%{_bindir}/arch
%{_bindir}/b2sum
%{_bindir}/basename
%{_bindir}/basenc
%{_bindir}/cat
%{_bindir}/chgrp
%{_bindir}/chmod

View File

@ -1,8 +1,9 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.32
Release: 31%{?dist}
Version: 8.30
Release: 15%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
Source50: supported_utils
@ -13,65 +14,62 @@ Source106: coreutils-colorls.csh
# do not make coreutils-single depend on /usr/bin/coreutils
%global __requires_exclude ^%{_bindir}/coreutils$
# ls: restore 8.31 behavior on removed directories
Patch1: coreutils-8.32-ls-removed-dir.patch
# rename gnulib's renameat2 to renameatu to avoid clash with glibc (#1598518)
Patch1: coreutils-8.30-renameatu.patch
# du: simplify leaf optimization for XFS (#1823247)
Patch2: coreutils-8.32-leaf-opt-xfs.patch
# fix heap-based buffer overflow in vasnprintf() (CVE-2018-17942)
Patch2: coreutils-8.30-CVE-2018-17942.patch
# cp: default to --reflink=auto (#1861108)
Patch3: coreutils-8.32-cp-reflink-auto.patch
# sync: fix open() fallback bug (#1602463)
Patch3: coreutils-8.30-fsync-fallback.patch
# eliminate unportable gnulib tests
Patch4: coreutils-8.32-gnulib-perror-test.patch
# cp --preserve=xattr: preserve NFSv4 ACL extended attributes (#1646985)
Patch4: coreutils-8.30-cp-preserve-xattr-NFSv4-ACL.patch
# df,stat,tail: recognize more file system types
Patch5: coreutils-8.32-new-fs-types.patch
# chcon: do not validate security context if SELinux is disabled (#1777831)
Patch5: coreutils-8.30-chcon-invalid-context.patch
# md5sum,b2sum,sha*sum: --help: add note about binary/text mode
Patch6: coreutils-8.31-sums-man-pages.patch
# df --local: recognize afs, auristorfs, and smb3 as remote fs (#1798030)
Patch7: coreutils-8.30-df-local-fs.patch
# use statx instead of stat when available (#1760300)
Patch8: coreutils-8.30-statx.patch
# rm: do not skip files upon failure to remove an empty dir (#1905481)
Patch6: coreutils-8.32-rm-stray-skip.patch
# expr: fix invalid read with unmatched \(...\) (#1919775)
Patch7: coreutils-8.32-expr-unmatched-par.patch
Patch9: coreutils-8.32-rm-stray-skip.patch
# split: fix --number=K/N to output correct part of file (#1921246)
Patch8: coreutils-8.32-split-number.patch
Patch10: coreutils-8.32-split-number.patch
# ls: fix crash printing SELinux context for unstatable files (#1921249)
Patch9: coreutils-8.32-ls-scontext-crash.patch
# mountlist: recognize fuse.portal as dummy file system (#1952714)
Patch11: coreutils-8.32-fuse-portal.patch
# stat: add support for the exfat file system (#1921427)
Patch10: coreutils-8.32-stat-exfat.patch
# tail: fix stack out-of-bounds write with --follow (#1974784)
Patch12: coreutils-8.30-tail-use-poll.patch
# cp: use copy_file_range if available
Patch11: coreutils-8.32-cp-file-range.patch
# doc: improve description of the --kibibytes option of ls (#1527391)
Patch13: coreutils-8.22-doc-ls-kibibytes.patch
# hostname,ln: fix memory leaks detected by Coverity
Patch12: coreutils-8.32-mem-leaks.patch
# utimens: fix confusing arg type in internal func
Patch13: coreutils-8.32-coverity-utimens.patch
# fix false positives in the upstrem test-suite (#1960792)
Patch14: coreutils-8.32-tests-false-positives.patch
# mountlist: recognize fuse.portal as dummy file system (#1913358)
Patch15: coreutils-8.32-fuse-portal.patch
# tail: fix stack out-of-bounds write with --follow
Patch16: coreutils-8.32-tail-use-poll.patch
# df: fix duplicated remote entries due to bind mounts (#1979814)
# df: fix duplicated remote entries due to bind mounts (#1962515)
Patch17: coreutils-8.32-df-duplicated-entries.patch
# ls, stat: avoid triggering automounts (#2044981)
Patch18: coreutils-9.0-autofs-no-mount.patch
# basic support for checking NFSv4 ACLs (#2158747)
Patch19: coreutils-nfsv4-acls.patch
# disable the test-lock gnulib test prone to deadlock
Patch100: coreutils-8.26-test-lock.patch
# require_selinux_(): use selinuxenabled(8) if available
Patch105: coreutils-8.26-selinuxenable.patch
Patch101: coreutils-8.26-selinuxenable.patch
# downstream changes to default DIR_COLORS
Patch102: coreutils-8.32-DIR_COLORS.patch
Patch102: coreutils-8.25-DIR_COLORS.patch
#do display processor type for uname -p/-i based on uname(2) syscall
Patch103: coreutils-8.2-uname-processortype.patch
#df --direct
@ -90,8 +88,6 @@ Patch800: coreutils-i18n.patch
Patch801: coreutils-i18n-expand-unexpand.patch
# i18n patch for cut - old version - used
Patch804: coreutils-i18n-cut-old.patch
# The unexpand patch above is not correct. Sent to the patch authors
Patch803: coreutils-i18n-fix-unexpand.patch
#(un)expand - allow multiple files on input - broken by patch 801
Patch805: coreutils-i18n-fix2-expand-unexpand.patch
#(un)expand - test BOM headers
@ -124,22 +120,17 @@ BuildRequires: libattr-devel
BuildRequires: libcap-devel
BuildRequires: libselinux-devel
BuildRequires: libselinux-utils
BuildRequires: make
BuildRequires: openssl-devel
BuildRequires: strace
BuildRequires: texinfo
# test-only dependencies
BuildRequires: perl-interpreter
BuildRequires: perl(FileHandle)
%if 23 < 0%{?fedora} || 7 < 0%{?rhel}
# needed by i18n test-cases
BuildRequires: glibc-langpack-en
BuildRequires: glibc-langpack-fr
BuildRequires: glibc-langpack-ko
%endif
Requires: %{name}-common = %{version}-%{release}
Requires: ncurses
Provides: coreutils-full = %{version}-%{release}
%include %{SOURCE51}
@ -170,10 +161,8 @@ packaged as a single multicall binary.
# yum obsoleting rules explained at:
# https://bugzilla.redhat.com/show_bug.cgi?id=1107973#c7
Obsoletes: %{name} < 8.24-100
# info doc refers to "Specifying the Time Zone" from glibc-doc (#959597)
Suggests: glibc-doc
Requires(preun): /sbin/install-info
Requires(post): /sbin/install-info
Summary: coreutils common optional components
%description common
Optional though recommended components,
@ -182,19 +171,9 @@ including documentation and translations.
%prep
%autosetup -N
# will be regenerated in the build directories
rm -f src/fs.h
# will be further modified by coreutils-8.32-DIR_COLORS.patch
sed src/dircolors.hin \
-e 's| 00;36$| 01;36|' \
> DIR_COLORS
sed src/dircolors.hin \
-e 's| 01;31$| 00;31|' \
-e 's| 01;35$| 00;35|' \
> DIR_COLORS.lightbgcolor
# git add DIR_COLORS{,.lightbgcolor}
# will be modified by coreutils-8.25-DIR_COLORS.patch
tee DIR_COLORS{,.256color,.lightbgcolor} <src/dircolors.hin >/dev/null
# git add DIR_COLORS{,.256color,.lightbgcolor}
# git commit -m "clone DIR_COLORS before patching"
# apply all patches
@ -208,29 +187,10 @@ autoreconf -fiv
%build
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic"
# disable -flto on ppc64le to make test-float pass (#1789115)
%ifarch ppc64le
CFLAGS="$CFLAGS -fno-lto"
%endif
# Upstream suggests to build with -Dlint for static analyzers:
# https://lists.gnu.org/archive/html/coreutils/2018-06/msg00110.html
# ... and even for production binary RPMs:
# https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00130.html
# There is currently no measurable performance drop or other known downside.
CFLAGS="$CFLAGS -Dlint"
# make mknod work again in chroot without /proc being mounted (#1811038)
export ac_cv_func_lchmod="no"
# needed for out-of-tree build
%global _configure ../configure
%{expand:%%global optflags %{optflags} -D_GNU_SOURCE=1}
for type in separate single; do
mkdir -p $type && \
(cd $type || exit $?
mkdir $type && \
(cd $type && ln -s ../configure || exit 1
if test $type = 'single'; then
config_single='--enable-single-binary'
config_single="$config_single --without-openssl" # smaller/slower sha*sum
@ -244,10 +204,10 @@ for type in separate single; do
--enable-no-install-program=kill,uptime \
--with-tty-group \
DEFAULT_POSIX2_VERSION=200112 alternative=199209 || :
%make_build all V=1
make all %{?_smp_mflags}
# make sure that parse-datetime.{c,y} ends up in debuginfo (#1555079)
ln -fv ../lib/parse-datetime.{c,y} .
ln -v ../lib/parse-datetime.{c,y} .
)
done
@ -285,7 +245,8 @@ for type in separate single; do
done
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -p -c -m644 DIR_COLORS{,.lightbgcolor} $RPM_BUILD_ROOT%{_sysconfdir}
install -p -c -m644 DIR_COLORS{,.256color,.lightbgcolor} \
$RPM_BUILD_ROOT%{_sysconfdir}
install -p -c -m644 %SOURCE105 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/colorls.sh
install -p -c -m644 %SOURCE106 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/colorls.csh
@ -296,6 +257,18 @@ grep LC_TIME %name.lang | cut -d'/' -f1-6 | sed -e 's/) /) %%dir /g' >>%name.lan
# (sb) Deal with Installed (but unpackaged) file(s) found
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%preun common
if [ $1 = 0 ]; then
if [ -f %{_infodir}/%{name}.info.gz ]; then
/sbin/install-info --delete %{_infodir}/%{name}.info.gz %{_infodir}/dir || :
fi
fi
%post common
if [ -f %{_infodir}/%{name}.info.gz ]; then
/sbin/install-info %{_infodir}/%{name}.info.gz %{_infodir}/dir || :
fi
%files -f supported_utils
%exclude %{_bindir}/*.single
%dir %{_libexecdir}/coreutils
@ -320,156 +293,48 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com>
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Jan 02 2023 Kamil Dudka <kdudka@redhat.com> - 8.30-15
- basic support for checking NFSv4 ACLs (#2158747)
* Wed Jul 07 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-30
- df: fix duplicated remote entries due to bind mounts (#1979814)
* Mon Aug 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.30-14
- prevent unexpand from failing on control characters (#2112870)
* Thu Jul 01 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-29
- tail: fix stack out-of-bounds write with --follow (#1976935)
* Tue Mar 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.30-13
- ls, stat: avoid triggering automounts (#2044981)
- make `df --direct` work again (#2058686)
- doc: improve description of the --kibibytes option of ls (#1527391)
* Tue Jun 15 2021 Mohan Boddu <mboddu@redhat.com> - 8.32-28
- Rebuilt for RHEL 9 BETA for openssl 3.0 (#1971065)
* Wed Jul 07 2021 Kamil Dudka <kdudka@redhat.com> - 8.30-12
- df: fix duplicated remote entries due to bind mounts (#1962515)
* Tue Jun 08 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-27
- mountlist: recognize fuse.portal as dummy file system (#1913358)
* Thu Jul 01 2021 Kamil Dudka <kdudka@redhat.com> - 8.30-11
- tail: fix stack out-of-bounds write with --follow (#1974784)
* Mon May 17 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-26
- cp: pick additional copy_file_range()-related fixes from upstream
* Tue Jun 08 2021 Kamil Dudka <kdudka@redhat.com> - 8.30-10
- mountlist: recognize fuse.portal as dummy file system (#1952714)
* Mon May 03 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-25
- copy: ensure we enforce --reflink=never
* Tue Apr 27 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-24
- copy: do not refuse to copy a swap file (#1953669)
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com>
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Fri Apr 09 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-22
- weaken the dependency on glibc-doc to reduce minimal installations
- drop the last use of ncurses no longer needed (#1830318)
- utimens: fix confusing arg type in internal func
* Fri Mar 26 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-21
- hostname,ln: fix memory leaks detected by Coverity
* Wed Mar 24 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-20
- cp: use copy_file_range if available
* Thu Feb 18 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-19
- stat: add support for the exfat file system (#1921427)
* Wed Feb 03 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-18
- make coreutils-common recommend glibc-doc for info doc refs (#959597)
* Tue Feb 02 2021 Kamil Dudka <kdudka@redhat.com> - 8.32-17
- ls: fix crash printing SELinux context for unstatable files (#1921249)
* Fri Mar 26 2021 Kamil Dudka <kdudka@redhat.com> - 8.30-9
- split: fix --number=K/N to output correct part of file (#1921246)
- expr: fix invalid read with unmatched \(...\) (#1919775)
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Dec 08 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-15
- rm: do not skip files upon failure to remove an empty dir (#1905481)
* Tue Nov 03 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-14
- df,stat,tail: recognize more file system types
* Wed Oct 14 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-13
- make the %%build section idempotent
* Mon Aug 17 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-12
- do not install /etc/DIR_COLORS.256color (#1830318)
* Thu Jul 30 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-11
- cp: default to --reflink=auto (#1861108)
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jul 24 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-9
- disable -flto on ppc64le to make test-float pass (#1789115)
* Mon Jul 13 2020 Tom Stellard <tstellar@redhat.com> - 8.32-8
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Fri Jun 26 2020 James Cassell <cyberpear@fedoraproject.org> - 8.32-7
- move ncurses to -common package since it's needed for colorls.sh
- make ncurses optional
* Fri May 15 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-6
- compile with -Dlint to enable optional initialization and cleanup code
* Thu Apr 23 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-5
- du: simplify leaf optimization for XFS (#1823247)
* Fri Apr 17 2020 Tom Stellard <tstellar@redhat.com> - 8.32-4
- Fix missing inline function definition
* Wed Mar 11 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-3
- uniq: remove collation handling as required by newer POSIX
* Mon Mar 09 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-2
- make mknod work again in chroot without /proc being mounted (#1811038)
- ls: restore 8.31 behavior on removed directories
* Thu Mar 05 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-1
- new upstream release 8.32
* Tue Feb 11 2020 Kamil Dudka <kdudka@redhat.com> - 8.31-10
- make upstream test-suite work with root privileges (#1800597)
* Wed Feb 05 2020 Kamil Dudka <kdudka@redhat.com> - 8.31-9
- use upstream fix the cp/proc-short-read test
* Thu Jan 30 2020 Kamil Dudka <kdudka@redhat.com> - 8.31-8
- skip a test that relies on /proc/kallsyms having immutable content
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Oct 17 2019 Kamil Dudka <kdudka@redhat.com> - 8.31-6
- temporarily disable the use of statx (#1760300)
* Fri Oct 11 2019 Kamil Dudka <kdudka@redhat.com> - 8.31-5
- use statx instead of stat when available (#1760300)
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Apr 14 2020 Kamil Dudka <kdudka@redhat.com> - 8.30-8
- df --local: recognize afs, auristorfs, and smb3 as remote fs (#1798030)
- fix formatting of sha512sum(1) man page (#1688744)
* Tue Jul 16 2019 Kamil Dudka <kdudka@redhat.com> - 8.31-3
- disable flashing in ls colors for broken symbolic links (#1728986)
* Wed Jan 29 2020 Kamil Dudka <kdudka@redhat.com> - 8.30-7
- chcon: do not validate security context if SELinux is disabled (#1777831)
* Mon Mar 18 2019 Kamil Dudka <kdudka@redhat.com> - 8.31-2
- fix formatting of sha512sum(1) man page (#1688740)
* Fri Jan 11 2019 Kamil Dudka <kdudka@redhat.com> - 8.30-6
- cp --preserve=xattr: preserve NFSv4 ACL extended attributes (#1646985)
* Mon Mar 11 2019 Kamil Dudka <kdudka@redhat.com> - 8.31-1
- new upstream release 8.31
* Wed Nov 07 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-5
- sync: fix open() fallback bug (#1602463)
- fix implicit declaration warning in coreutils-getgrouplist.patch (#1602463)
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Nov 07 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-8
- sync: fix open() fallback bug
- fix implicit declaration warning in coreutils-getgrouplist.patch
* Sat Nov 03 2018 Kevin Fenzi <kevin@scrye.com> - 8.30-7
- Also remove Requires pre/post used by info scriptlets.
* Sat Nov 03 2018 Kevin Fenzi <kevin@scrye.com> - 8.30-6
- Remove no longer needed info scriptlets
* Thu Oct 11 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-5
* Thu Oct 11 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-4
- fix heap-based buffer overflow in vasnprintf() (CVE-2018-17942)
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.30-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jul 10 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-3
- rename gnulib's renameat2 to renameatu to avoid clash with glibc (#1598518)
@ -479,31 +344,22 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
* Mon Jul 02 2018 Kamil Dudka <kdudka@redhat.com> - 8.30-1
- new upstream release 8.30
* Wed May 30 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-12
- add provides to coreutils-single to make it a drop-in replacement
* Mon May 28 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-11
* Mon May 28 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-8
- ls: increase the allowed abmon width from 5 to 12 (#1577872)
- date, ls: pick strftime fixes from glibc to improve locale support (#1577872)
* Fri Apr 20 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-10
* Fri May 04 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-7
- add provides to coreutils-single to make it a drop-in replacement (#1572693)
- reintroduce very old Provides (mktemp, sh-utils, textwrap, fileutils, stat)
* Fri Apr 20 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-6
- fix crash caused by mistakenly enabled leaf optimization (#1558249)
* Fri Mar 23 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-9
- make it possible to install the latest available Adobe Reader RPM for Linux
* Mon Mar 19 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-8
* Wed Mar 21 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-5
- drop BR for bison, which is not used during the build
* Fri Mar 16 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-7
- make sure that parse-datetime.{c,y} ends up in debuginfo (#1555079)
* Tue Mar 06 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-6
- fix build failure with glibc-2.28
* Mon Feb 26 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 8.29-5
- Remove /bin/* Provides
* Mon Feb 19 2018 Kamil Dudka <kdudka@redhat.com> - 8.29-4
- add explicit BR for the gcc compiler