bug#21876: Please list ACFS in the list of remote filesystems

2015-11-11 Thread Ondřej Vašík
Hi,
as reported in https://bugzilla.redhat.com/show_bug.cgi?id=1280333 ,
Oracle ADVM/ACFS is not listed among the remote filesystems and in
stat.c . Can you please add S_MAGIC_ACFS (0x61636673) to stat.c as a
remote filesystem? Not sending as a patch, as this is quite simple
change.

Thanks in advance!

Regards,
   Ondrej






bug#21369: Coreutils RHEL 6.7 runuser

2015-08-31 Thread Ondřej Vašík
Bob Proulx píše v Pá 28. 08. 2015 v 13:10 -0600:
> tag 21369 + notabug moreinfo
> thanks
> billy_k_woo...@homedepot.com wrote:
> > /sbin/runuser issue on RHEL 6.7 when executing `whoami` as tomcat.
...
> For another you are reporting a problem about "Coreutils RHEL 6.7
> runuser" but runuser is not a coreutils program.  AFAIK runuser comes
> from the util-linux package.  That isn't something we over here in the
> coreutils project have anything to do with.  Plus 'ksh'.  Plus the
> entirety of the (unknown contents of) profile.  And then finally the
> 'whoami' command, which is a coreutils program.  Even if we fully
> understand what you are reporting it is unlikely we can do anything
> about it.  That is why I have initially tagged this report as
> "notabug" concerning coreutils.

Actually, in RHEL 6(.7) is still part of coreutils package - and is
based on su.c (in RHEL 7 it was moved to util-linux). In any case, I
would suggest to use either Red Hat support or filing Red Hat bugzilla
directly - as this issue has nothing to do with current upstream
coreutils.
(thanks Bob for the answers/replies)

Regards,
   Ondrej






Re: [PATCH] status=noinfo option for dd

2010-02-19 Thread Ondřej Vašík
Hi,

Pozsar Balazs wrote:
 New (hopefully better) version of the patch.
 
 dd: status=noinfo operand suppresses the transfer count information
 when the program exits.

I think that option does not follow POSIX. 
Similar thing was requested this week at 
https://bugzilla.redhat.com/show_bug.cgi?id=566079 , I suggested some
wrapper script to achieve this.

dd POSIX says:

On completion, dd shall write the number of input and output blocks to
standard error. In the POSIX locale the following formats shall be used:
...
In addition, when there is at least one truncated block, the number of
truncated blocks shall be written to standard error. In the POSIX
locale, the format shall be:


With this option, it will not output POSIX-required informations on
stderr on completition and therefore it should not be possible to
supress those informations (at least with POSIXLY_CORRECT but doing
additionally this hack looks silly to me)

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


[PATCH] tests/cp/cp-a-selinux: skip the test if no loopdevices available

2010-02-01 Thread Ondřej Vašík
Hello,

as reported in rhbz #558898 , cp-a-selinux test could fail if there are
no loop devices available or if the kernel has no support for loop
devices. Other similar tests just skip if the mount or filesystem
creation fails. Attached patch does the same for the cp/cp-a-selinux
test.

Greetings,
 Ondřej Vašík

From 67bc8118e98f99f59d1f601d06c121f3ed2c4f58 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 1 Feb 2010 16:29:27 +0100
Subject: [PATCH] tests: cp-a-selinux :skip the test if no loopdevices available

* tests/cp/cp-a-selinux: skip the test (instead of fail) if no
loopdevices available
---
 tests/cp/cp-a-selinux |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux
index b1359c0..539c512 100755
--- a/tests/cp/cp-a-selinux
+++ b/tests/cp/cp-a-selinux
@@ -48,12 +48,15 @@ ls -Z f | grep $ctx || fail=1
 
 # Create a file system, then mount it with the context=... option.
 dd if=/dev/zero of=blob bs=8192 count=200  /dev/null 21 \
- || framework_failure
-mkdir mnt|| framework_failure
+ || skip=1
+mkdir mnt|| skip=1
 mkfs -t ext2 -F blob ||
   skip_test_ failed to create an ext2 file system
 
-mount -oloop,context=$ctx blob mnt   || framework_failure
+mount -oloop,context=$ctx blob mnt   || skip=1
+test $skip = 1 \
+ skip_test_ insufficient mount/ext2 support
+
 cd mnt   || framework_failure
 
 echo  f || framework_failure
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: date and printf commands

2010-01-07 Thread Ondřej Vašík
Hi,
Eric Blake wrote:
 According to David Venus on 12/23/2009 3:35 PM:
  2) Be able to say things like fist day of year (20090101), week
  (20091220), month (20091201), etc.
  
  3) Be able to say things like last day of year (20091231), week
  (20091226), month (20091231), etc.
 
 Improvements to getdate.y are welcome, if you'd like to try your hand at them.

It reminds me that my last patch for getdate.y was without any
answer/reaction (
http://lists.gnu.org/archive/html/bug-gnulib/2009-09/msg00244.html ) 

Just as a note - keywords first and last are already used and getdate.y
grammar is a bit fragile. There are already ways how to display those
things, but they may look a bit strange.

Greetings,
  Ondrej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: Build failures of coreutils-8.1 in Fedora build system koji

2009-11-24 Thread Ondřej Vašík
Hi,
Ondřej Vašík wrote:
 Hi,
 I'm trying to package coreutils-8.1 for Fedora Rawhide, but few tests
 are failing
 ( http://koji.fedoraproject.org/koji/getfile?taskID=1819634name=build.log ).
 I removed all Fedora-only patches to prevent patch-related issues. Koji
 build system uses mock build hosted on machine with old RHEL-5 xen
 kernel, so this may be the culprit of the issues. Generally there are
 two issues - 
 1) test 126 = 127  ... koji kernel seems to return EXIT_CANNOT_INVOKE
 (126) exit code in cases where EXIT_ENOENT (127) is expected by
 testsuite.

Thanks Jim for quick fix...

 2) futimens time functions seem to return ENOSYS there, so the tests are
 failing. There are already some workarounds for the RHEL-5 kernels in
 utimens.c gnulib file, but it seems some recent change brought the issue
 back.

So this one still make troubles - two tests still failing. Relevant part
of strace attached - full log in
http://koji.fedoraproject.org/koji/getfile?taskID=1826816name=build.log ...
...
futex(0x7fffa494fddc, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7fffa494fddc, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 
2af9b2dd40e0) = -1 ENOSYS (Function not implemented)
rt_sigaction(SIGRTMIN, {0x2af9b2bbb860, [], SA_RESTORER|SA_SIGINFO, 
0x2af9b2bc54a0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x2af9b2bbb8f0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 
0x2af9b2bc54a0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
brk(0)  = 0x144c3000
brk(0x144e4000) = 0x144e4000
utimensat(AT_FDCWD, file, NULL, AT_SYMLINK_NOFOLLOW) = -1 ENOSYS (Function 
not implemented)
utimensat(AT_FDCWD, file, NULL, AT_SYMLINK_NOFOLLOW) = -1 ENOSYS (Function 
not implemented)
write(2, touch: , 7touch: )  = 7
write(2, setting times of `file', 23setting times of `file') = 23
write(2, : Function not implemented, 26: Function not implemented) = 26
write(2, \n, 1
...

Those two failing tests (touch/no-dereference and touch/trailing-slash) seems 
to be new in coreutils test-suite (added in 8.1), so the issue was likely there 
even before 8.1 and now shows in koji...


Ondra


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: Build failures of coreutils-8.1 in Fedora build system koji

2009-11-23 Thread Ondřej Vašík
Hi Jim,

Jim Meyering wrote:
 Ondřej Vašík wrote:
  I'm trying to package coreutils-8.1 for Fedora Rawhide, but few tests
  are failing
  ( http://koji.fedoraproject.org/koji/getfile?taskID=1819634name=build.log 
  ).
  I removed all Fedora-only patches to prevent patch-related issues. Koji
  build system uses mock build hosted on machine with old RHEL-5 xen
  kernel, so this may be the culprit of the issues. Generally there are
  two issues -
  1) test 126 = 127  ... koji kernel seems to return EXIT_CANNOT_INVOKE
  (126) exit code in cases where EXIT_ENOENT (127) is expected by
  testsuite.
 
 Hi Ondřej,
 
 Thanks for the report.
 For the 126 vs 127 problems, it looks like execvp is
 failing with errno != ENOENT.  I.e., when you run env no_such,
 we expect execvp to fail with errno == ENOENT, and hence env should
 exit with EXIT_ENOENT (127).  Since it's actually exiting with status
 of 126, execvp must be failing with some other errno value.
 
   ...
   execvp (argv[optind], argv[optind]);
 
   {
 int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
 error (0, errno, %s, argv[optind]);
 exit (exit_status);
   }
 
 Can you strace it?
 That would show the unexpected errno value.

relevant part
(http://koji.fedoraproject.org/koji/getfile?taskID=1824793name=build.log)

...
execve(/usr/X11R6/bin/no_such, [no_such], [/* 57 vars */]) = -1
ENOENT (No such file or directory)
execve(/root/bin/no_such, [no_such], [/* 57 vars */]) = -1 EACCES 
(Permission denied)
execve(/usr/local/sbin/no_such, [no_such], [/* 57 vars */]) = -1 ENOENT (No 
such file or directory)
write(2, env: , 5env: )= 5
write(2, no_such, 7no_such)  = 7
write(2, : Permission denied, 19: Permission denied) = 19
write(2, \n, 1
)   = 1
close(1)= 0
close(2)= 0
exit_group(126) = ?


/root/bin/ directory is not created in koji buildroot (it is not created by 
default at all) - so that might be the difference.

Greetings,
  Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Build failures of coreutils-8.1 in Fedora build system koji

2009-11-20 Thread Ondřej Vašík
Hi,
I'm trying to package coreutils-8.1 for Fedora Rawhide, but few tests
are failing
( http://koji.fedoraproject.org/koji/getfile?taskID=1819634name=build.log ).
I removed all Fedora-only patches to prevent patch-related issues. Koji
build system uses mock build hosted on machine with old RHEL-5 xen
kernel, so this may be the culprit of the issues. Generally there are
two issues - 
1) test 126 = 127  ... koji kernel seems to return EXIT_CANNOT_INVOKE
(126) exit code in cases where EXIT_ENOENT (127) is expected by
testsuite.
2) futimens time functions seem to return ENOSYS there, so the tests are
failing. There are already some workarounds for the RHEL-5 kernels in
utimens.c gnulib file, but it seems some recent change brought the issue
back.

Thanks in advance for considering fixes/suggesting workarounds ( yes,
the easiest is to skip those failing tests for a while ;) ).

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


[PATCH]: chcon: no longer abort on SELinux disabled kernel

2009-10-05 Thread Ondřej Vašík
Hello,
as reported in https://bugzilla.redhat.com/show_bug.cgi?id=527142 by
Yanko Kaneti, chcon aborts on SELinux disabled kernel due to missing
check for SELinux enabled kernel. Attached patch is fixing the issue. 

Additionally - for consistency - error message of this check in runcon
was changed to not hardcode runcon program name.

Greetings,
 Ondřej Vašík

From 3dbd792b3e9379a4795d1becdc4252de236429bc Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 5 Oct 2009 09:20:48 +0200
Subject: [PATCH] chcon: no longer abort on SELinux disabled kernel

* src/chcon.c (main): Check SELinux enabled kernel.
  Reported in https://bugzilla.redhat.com/show_bug.cgi?id=527142 by
  Yanko Kaneti.
* src/runcon.c (main): Do not hardcode program name in error message
  of SELinux enabled kernel check.
* NEWS: Mention it.
* THANKS: Update.
---
 NEWS |3 +++
 THANKS   |1 +
 src/chcon.c  |4 
 src/runcon.c |2 +-
 4 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index aff0744..3ed2d75 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ GNU coreutils NEWS-*- outline -*-
   [The race was introduced in coreutils-7.5,
and the unnecessary delay was present since textutils-1.22o]
 
+  chcon no longer aborts on SELinux disabled system.
+  [the bug dates back to the initial implementation]
+
 ** Portability
 
   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/THANKS b/THANKS
index e0e14e5..65ac1bb 100644
--- a/THANKS
+++ b/THANKS
@@ -612,6 +612,7 @@ Wis Macomsonwis.macom...@intel.com
 Wojciech Purczynski cl...@isec.pl
 Wolfram Kleff   kl...@cs.uni-bonn.de
 Won-kyu Parkwkp...@chem.skku.ac.kr
+Yanko Kanetiyan...@declera.com
 Yann Dirson dir...@debian.org
 Zvi Har'El  r...@math.technion.ac.il
 
diff --git a/src/chcon.c b/src/chcon.c
index fbfdb4d..c0da694 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -519,6 +519,10 @@ main (int argc, char **argv)
   usage (EXIT_FAILURE);
 }
 
+  if (is_selinux_enabled () != 1)
+error (EXIT_FAILURE, 0,
+   _(%s may be used only on a SELinux kernel), program_name);
+
   if (reference_file)
 {
   if (getfilecon (reference_file, ref_context)  0)
diff --git a/src/runcon.c b/src/runcon.c
index e0019da..f87eada 100644
--- a/src/runcon.c
+++ b/src/runcon.c
@@ -195,7 +195,7 @@ main (int argc, char **argv)
 
   if (is_selinux_enabled () != 1)
 error (EXIT_FAILURE, 0,
-   _(runcon may be used only on a SELinux kernel));
+   _(%s may be used only on a SELinux kernel), program_name);
 
   if (context)
 {
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH]: ls: do not show long iso time format for en_* locales

2009-09-26 Thread Ondřej Vašík
Paul Eggert wrote:
 Ondřej Vašík ova...@redhat.com writes:
 
  as reported in https://bugzilla.redhat.com/show_bug.cgi?id=525134 by
  Daniel Qarras, ls -l shows iso long format for en_* locales.
 
 I just now read that Bugzilla report, and the diagnosis and the
 patch do not seem correct.  The diagnosis says:
 
  In ls.c (case locale_time_style)  is dcgettext (NULL, long_time_format[i],
  LC_TIME); ... that translates the string, but the translation is THE SAME as
  the default - as the format is the same for en_* locales.
 
 But that is not what the ls.c source code does.  The code does this:
 
 char const *locale_format =
   dcgettext (NULL, long_time_format[i], LC_TIME);
 if (locale_format == long_time_format[i])
   goto case_long_iso_time_style;
 
 The == test returns true when dcgettext returns the msgid (its 2nd
 argument) because it finds no translation.  If it found a translation,
 dcgettext would return a different string, so the == test would
 return false, and the code would use the translation.  Even if the
 translation has the same _contents_ as the msgid, it will have a
 different _address_, so the code is correct as-is and does not need
 this modification.

Ah, sorry... you are right, the address should be different, so the code
is correct, I got confused somehow.
 
 Also, the proposed patch would use U.S. styles for all English
 locales, which certainly is not right.
 
 I suspect the diagnosis given by Jim Meyering in comment #3 at that
 bug report is correct, and that something is going wrong at install
 time.

But as Pádraig wrote in the reply, there are no translation for en_*
languages, so long iso style is used - which is imho wrong. The patch is
fixing it (although it seems to be only a workaround and wrong
approach). Better would be to have translations even for en_* locales in
some cases - like this. This is better way than this workaround... Is it
possible add those translations?

Sorry for noise...

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH]: ls: do not show long iso time format for en_* locales

2009-09-26 Thread Ondřej Vašík
Jim Meyering wrote:
 Here's an incomplete patch.
 It needs a test and a NEWS entry.
 Ondřej, can you adjust your test to work (or skip)
 if there is no en* locale?

Maybe something like that (attachment)?
It's checking for existence of locale binary and en_US locale and
performing the test only if both exists. I guess en_US locale is better
than random choosing of one en_* locale. Also NEWS entry added although
it maybe needs some tweaks as usually.

Greetings,
 Ondřej

From 3e327dd41c55c5f25180c779a766549b90af59fa Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 25 Sep 2009 15:20:47 +0200
Subject: [PATCH] tests/misc/ls-time: ls shouldn't show long iso time format for en_* locales

* tests/misc/ls-time: test if ls doesn't show long iso time format
  when en_US locale is present
* NEWS: mention that ls no longer shows long iso time format for en_* locales
---
 NEWS   |4 
 tests/misc/ls-time |   13 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 1571c9c..2cf8b33 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ GNU coreutils NEWS-*- outline -*-
   when the color of a more specific type is disabled.
   [bug introduced in coreutils-5.90]
 
+  ls -l now correctly shows en_* locale timestamps of files instead of
+  long iso format.
+  [bug introduced in coreutils-6.0]
+
 ** Portability
 
   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/tests/misc/ls-time b/tests/misc/ls-time
index abdd429..39108f0 100755
--- a/tests/misc/ls-time
+++ b/tests/misc/ls-time
@@ -123,4 +123,17 @@ EOF
   fail=1
 fi
 
+# The output for english locale should differ from long iso format
+# This failed between 6.0 and 7.7
+# Do the test only when locale binary and any en_US locale is available
+if (locale --version)  /dev/null 21; then
+  en_locale=`locale -a | grep ^en_US$`
+  if test -n $en_locale; then
+LC_ALL=$en_locale ls -l c en_output
+ls -l --time-style=long-iso c liso_output
+compare en_output liso_output  { fail=1;
+  echo Long format timestamp for $en_locale locale is same as for long iso. 12; }
+  fi
+fi
+
 Exit $fail
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


[PATCH]: ls: do not show long iso time format for en_* locales

2009-09-25 Thread Ondřej Vašík
Hello,
as reported in https://bugzilla.redhat.com/show_bug.cgi?id=525134 by
Daniel Qarras, ls -l shows iso long format for en_* locales. This is
caused by
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=6837183d42a0ccdf7b7106794ea693c5b609aea5
. After that commit ls in locale time style checks if the translation
differs from defaults. If not, it fallbacks to long iso time style
format. However - for english locales is this default time style format
(same as C) expected, so the check for missing translation is wrong. 

Attached patch should fix this, allowing the default timestyle for en_*
locales. However - I guess it would be maybe better to remove the check
for possibly messed translation completely - as the default time-style
(the same as C style) could be in use in more LC_TIME styles and
fallback to C style for locales with missing translation is not that bad
behaviour (imho better than long iso style).

Greetings,
 Ondřej Vašík

From e82f581055af6eadcf3e99ff7aa3f5f3479c7c22 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 25 Sep 2009 15:20:47 +0200
Subject: [PATCH] ls: do not show long iso time format for en_* locales

* src/ls.c (decode_switches): Do not fallback to long iso time format for
  en_* locales.
  Introduced by commit 6837183d, 11-08-2005 and reported
  in https://bugzilla.redhat.com/show_bug.cgi?id=525134 by Daniel Qarras.
* tests/misc/ls-time: test it
* NEWS: mention it
---
 NEWS   |3 +++
 src/ls.c   |8 ++--
 tests/misc/ls-time |7 +++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 1571c9c..502355a 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ GNU coreutils NEWS-*- outline -*-
   when the color of a more specific type is disabled.
   [bug introduced in coreutils-5.90]
 
+  ls -l now correctly show locale timestamp of files instead of long iso format
+  [bug introduced in coreutils-6.0]
+
 ** Portability
 
   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/src/ls.c b/src/ls.c
index 1bb6873..3a1d2d1 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2027,13 +2027,17 @@ decode_switches (int argc, char **argv)
 if (hard_locale (LC_TIME))
   {
 /* Ensure that the locale has translations for both
-   formats.  If not, fall back on long-iso format.  */
+   formats (translation differs from default).  If not,
+   fall back on long-iso format, unless unchanged
+   format is expected (for english locales).  */
 int i;
+const char *lc_time = setlocale (LC_TIME, NULL);
 for (i = 0; i  2; i++)
   {
 char const *locale_format =
   dcgettext (NULL, long_time_format[i], LC_TIME);
-if (locale_format == long_time_format[i])
+if (lc_time  strncmp(lc_time, en_, 3) 
+locale_format == long_time_format[i])
   goto case_long_iso_time_style;
 long_time_format[i] = locale_format;
   }
diff --git a/tests/misc/ls-time b/tests/misc/ls-time
index abdd429..86868a7 100755
--- a/tests/misc/ls-time
+++ b/tests/misc/ls-time
@@ -123,4 +123,11 @@ EOF
   fail=1
 fi
 
+# The output for english locale should differ from long iso format
+# This failed between 6.0 and 7.7
+LC_ALL=en_US ls -l c en_output
+ls -l --time-style=long-iso c liso_output
+compare en_output liso_output  { fail=1;
+ echo Long format timestamp for en_US locale is same as for long iso. 12; }
+
 Exit $fail
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-15 Thread Ondřej Vašík
Pádraig Brady wrote:
 Yes I agree that the change is required.
 I've tweaked it so that the geteuid() syscall is only called
 if readonly files. Also I removed the error message on chmod failure
 as the user will still get an error message _if_ the copy_xattr fails.
 Also I ran it through indent and did s/write access rights/write access/.
 I'll push it soon if there are no objections.

Thanks for word tweaks and other patch-amending. I spotted one error -
initial value of access_changed was not changed to false when you
changed the name and logic from access_unchanged (fixed by attached
patch).

Greetings,
 Ondřej

From a4aee231c48e1cb80e63762fd65b6d09f4936bb2 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Tue, 15 Sep 2009 08:57:43 +0200
Subject: [PATCH] cp: fix initial value of access_changed variable

* src/copy.c (copy_reg): fix initial value of access_changed variable
---
 src/copy.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/copy.c b/src/copy.c
index ad2060b..b7d113f 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -839,7 +839,7 @@ copy_reg (char const *src_name, char const *dst_name,
  by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree.  */
   if (x-preserve_xattr)
 {
-  bool access_changed = true;
+  bool access_changed = false;
 
   if (!(sb.st_mode  S_IWUSR)  geteuid() != 0)
 access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-15 Thread Ondřej Vašík
Jim Meyering wrote:
 Ondřej Vašík wrote:
  Pádraig Brady wrote:
  Yes I agree that the change is required.
  I've tweaked it so that the geteuid() syscall is only called
  if readonly files. Also I removed the error message on chmod failure
  as the user will still get an error message _if_ the copy_xattr fails.
  Also I ran it through indent and did s/write access rights/write access/.
  I'll push it soon if there are no objections.
 
  Thanks for word tweaks and other patch-amending. I spotted one error -
  initial value of access_changed was not changed to false when you
  changed the name and logic from access_unchanged (fixed by attached
  patch).
 
 Thanks, Ondřej!
 Can you contrive a test that would expose that?

I'm not sure if this is useful - as this boolean is just saving chmod
call for the case, that the chmod was not necessary. So even the
Pádraig's patch works, but for files with write access there is one
unnecessary chmod call. Adding test would probably mean strace usage, so
if such test is really required, I would prefer to have that test
separate.

greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-14 Thread Ondřej Vašík
Pádraig Brady wrote:
 Since we're only doing u+rw, and we've already stat'd it's
 probably better to just (sb.mode  S_IWUSR) rather than access(...).
 Also a couple of the  if statements are indented too far.

Hopefully ok with the attached patch.

 This should now be safer but as Jim says it
 only effects file systems mounted user_xattr.
 Perhaps we should wait until coreutils-7.7 and
 also feedback from libattr devs so as we can put
 an accurate comment in the code.

As libattr feedback is already here at
http://lists.gnu.org/archive/html/bug-coreutils/2009-09/msg00166.html
and it seems it is not a bug in libattr (just strange requirement by
kernel), I modified the comment about workaround - as the culprit is
probably in kernel. 

Greetings,
 Ondřej Vašík

From 500acf63e78cc6bdb4fdd8b84c1f5e2305b96fb1 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Thu, 3 Sep 2009 16:10:21 +0200
Subject: [PATCH] cp,mv: do preserve extended attributes even for read-only source files

* src/copy.c (copy_reg): Set mode on file descriptor to 0600 for copying
extended attributes to prevent failures when source file doesn't have
write access rights. Reported by Ernest N. Mamikonyan.
* tests/misc/xattr: Test that change.
* NEWS (Bug fixes): Mention it.
---
 NEWS |6 ++
 src/copy.c   |   33 -
 tests/misc/xattr |   42 --
 3 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 980fb54..0ba0d50 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU coreutils NEWS-*- outline -*-
 
 * Noteworthy changes in release ?.? (-??-??) [?]
 
+** Bug fixes
+
+  cp --preserve=xattr and --archive now preserves extended attributes even
+  when the source file doesn't have write access rights
+  [bug introduced in coreutils-7.1]
+
 ** Changes in behavior
 
   id no longer prints SELinux  context=... when the POSIXLY_CORRECT
diff --git a/src/copy.c b/src/copy.c
index f3ff5a2..0cb6094 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -834,6 +834,34 @@ copy_reg (char const *src_name, char const *dst_name,
 }
 }
 
+  /* To allow copying extended attributes on read-only files, change
+ destination file descriptor access rights to 0600 for a while
+ if required.
+ This workaround is required as full permission check is done
+ by xattr_permission in fs/xattr.c of the kernel tree. */
+  if (x-preserve_xattr)
+   {
+ bool access_unchanged = true;
+
+ if (geteuid () != 0  !(sb.st_mode  S_IWUSR) 
+ (access_unchanged = fchmod_or_lchmod (dest_desc, dst_name, 0600)))
+   {
+ if (!x-reduce_diagnostics || x-require_preserve_xattr)
+   error (0, errno,
+ _(failed to set writable mode for %s, copying xattrs may fail),
+ quote (dst_name));
+   }
+
+ if (! copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
+ x-require_preserve_xattr)
+   return_val = false;
+
+ if (!access_unchanged)
+   fchmod_or_lchmod (dest_desc, dst_name,
+ dst_mode  ~omitted_permissions);
+   }
+
+
   if (x-preserve_ownership  ! SAME_OWNER_AND_GROUP (*src_sb, sb))
 {
   switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, sb))
@@ -850,11 +878,6 @@ copy_reg (char const *src_name, char const *dst_name,
 
   set_author (dst_name, dest_desc, src_sb);
 
-  if (x-preserve_xattr  ! copy_attr_by_fd (src_name, source_desc,
-  dst_name, dest_desc, x)
-   x-require_preserve_xattr)
-return_val = false;
-
   if (x-preserve_mode || x-move_mode)
 {
   if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
diff --git a/tests/misc/xattr b/tests/misc/xattr
index a27e1f6..404085f 100755
--- a/tests/misc/xattr
+++ b/tests/misc/xattr
@@ -29,7 +29,7 @@ fi
 
 # Skip this test if cp was built without xattr support:
 touch src dest || framework_failure
-cp --preserve=xattr -n src dest 2/dev/null \
+cp --preserve=xattr -n src dest \
   || skip_test_ coreutils built without xattr support
 
 # this code was taken from test mv/backup-is-src
@@ -46,13 +46,13 @@ xattr_pair=$xattr_name=\$xattr_value\
 # create new file and check its xattrs
 touch a || framework_failure
 getfattr -d a out_a || skip_test_ failed to get xattr of file
-grep -F $xattr_pair out_a /dev/null  framework_failure
+grep -F $xattr_pair out_a  framework_failure
 
 # try to set user xattr on file
 setfattr -n $xattr_name -v $xattr_value a out_a \
   || skip_test_ failed to set xattr of file
 getfattr -d a out_a || skip_test_ failed to get xattr of file
-grep -F $xattr_pair out_a /dev/null \
+grep -F $xattr_pair out_a \
   || skip_test_ failed to set xattr of file
 
 fail=0
@@ -60,36 +60,50 @@ fail=0
 # cp should not preserve xattr by default
 cp a b || fail=1
 getfattr -d b out_b || skip_test_ failed to get xattr of file

[PATCH] doc: du - clarify default blocksize in usage/manpage

2009-09-09 Thread Ondřej Vašík
Hello,
as requested via https://bugzilla.redhat.com/show_bug.cgi?id=511188 , it
would be nice to clarify default blocksize used by du in manpage/--help
output. Although I closed that bugzilla as notabug, further
communication via private emails convinced me to propose that change to
upstream.
As it breaks translation strings, I guess it would be better to postpone
commit after 7.6 (if accepted).

Greetings,
 Ondřej Vašík


From f5f6875b2d8828218105b3601c80ebfdc7eeefb4 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 9 Sep 2009 10:00:32 +0200
Subject: [PATCH] doc: du - clarify default blocksize in usage

* src/du.c (usage): clarify default blocksize - requested by
  https://bugzilla.redhat.com/show_bug.cgi?id=511188
---
 src/du.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/du.c b/src/du.c
index 9da901a..30b7dd4 100644
--- a/src/du.c
+++ b/src/du.c
@@ -284,7 +284,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
   fragmentation, indirect blocks, and the like\n\
 ), stdout);
   fputs (_(\
-  -B, --block-size=SIZE  use SIZE-byte blocks\n\
+  -B, --block-size=SIZE  use SIZE-byte blocks,\n\
+ default blocksize is 1024 bytes\n\
   -b, --bytes   equivalent to `--apparent-size --block-size=1'\n\
   -c, --total   produce a grand total\n\
   -D, --dereference-args  dereference only symlinks that are listed on the\n\
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] doc: du - clarify default blocksize in usage/manpage

2009-09-09 Thread Ondřej Vašík
Eric Blake wrote:
 According to Ondřej Vašík on 9/9/2009 2:19 AM:
  Hello,
  as requested via https://bugzilla.redhat.com/show_bug.cgi?id=511188 , it
  would be nice to clarify default blocksize used by du in manpage/--help
  output. Although I closed that bugzilla as notabug, further
  communication via private emails convinced me to propose that change to
  upstream.
  As it breaks translation strings, I guess it would be better to postpone
  commit after 7.6 (if accepted).
 
 The default block size depends on POSIXLY_CORRECT (which requires 512, not
 1024) and on BLOCK_SIZE (which the user can set to a different size).
 Maybe a better thing to do would be adding a blurb about environment
 variables that affect block size.

I knew about that, but tried to keep it simple. But you are right,
keeping it simple might be even more confusing.

 Also, df and ls need the same treatment, whatever we decide to do.

Good, point. Added blurb about the environment variables to all of those
utilities.

Greetings,
 Ondřej

From 82ef7e63149eaedb7ed40e94f975fdb799ed5f41 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 9 Sep 2009 10:00:32 +0200
Subject: [PATCH] doc: du,df,ls - clarify default blocksize in usage

* src/du.c (usage): clarify default blocksize - requested by
  https://bugzilla.redhat.com/show_bug.cgi?id=511188
* src/ls.c (usage): likewise
* src/df.c (usage): likewise
---
 src/df.c |5 +
 src/du.c |5 +
 src/ls.c |5 +
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/df.c b/src/df.c
index 86fd0e3..d322da6 100644
--- a/src/df.c
+++ b/src/df.c
@@ -834,6 +834,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
   fputs (_(\n\
+If none of the environment variables BLOCKSIZE, BLOCK_SIZE or \n\
+COMMAND_BLOCKSIZE is specified, blocksize defaults to 1024 bytes.\n\
+(or 512 bytes when POSIXLY_CORRECT environment variable is set)\n\
+), stdout);
+  fputs (_(\n\
 SIZE may be (or may be an integer optionally followed by) one of following:\n\
 kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
 ), stdout);
diff --git a/src/du.c b/src/du.c
index 9da901a..db0e7c7 100644
--- a/src/du.c
+++ b/src/du.c
@@ -331,6 +331,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
   fputs (_(\n\
+If none of the environment variables BLOCKSIZE, BLOCK_SIZE or \n\
+COMMAND_BLOCKSIZE is specified, blocksize defaults to 1024 bytes.\n\
+(or 512 bytes when POSIXLY_CORRECT environment variable is set)\n\
+), stdout);
+  fputs (_(\n\
 SIZE may be (or may be an integer optionally followed by) one of following:\n\
 kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
 ), stdout);
diff --git a/src/ls.c b/src/ls.c
index 553090d..82e129f 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4665,6 +4665,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
   fputs (_(\n\
+If none of the environment variables BLOCKSIZE, BLOCK_SIZE or \n\
+COMMAND_BLOCKSIZE is specified, blocksize defaults to 1024 bytes.\n\
+(or 512 bytes when POSIXLY_CORRECT environment variable is set)\n\
+), stdout);
+  fputs (_(\n\
 SIZE may be (or may be an integer optionally followed by) one of following:\n\
 kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
 ), stdout);
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] doc: du - clarify default blocksize in usage/manpage

2009-09-09 Thread Ondřej Vašík
Jim Meyering wrote:
 Eric Blake wrote:
  This repetition begs for a helper method in system.h.  It would look better
  like:
 
  emit_blocksize (program_name);
 
 I agree.
 Though please call it something like emit_blocksize_note
 so it's name doesn't imply it's printing a bare number.
 
  where emit_blocksize takes care of converting program_name to uppercase in 
  its
  spelling of %s_BLOCKSIZE.

Called emit_blocksize_note(), I don't think it is good to rely on
program_name variable and convert it internally to uppercased string -
as those envvars are not program_name dependent.
So I called emit_blocksize_note with constant string (uppercased).
Additionally I factored out duplicities about SIZE's - to same function
in system.h

Greetings,
 Ondřej Vašík

From abec47c101b23d138bc185e590e3be969fb666f2 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 9 Sep 2009 10:00:32 +0200
Subject: [PATCH] doc: du,df,ls - clarify default blocksize in usage

* src/du.c (usage): clarify default blocksize - requested by
  https://bugzilla.redhat.com/show_bug.cgi?id=511188
* src/ls.c (usage): likewise
* src/df.c (usage): likewise
* src/system.h: new function emit_blocksize_note to factor out
 duplicities from du/df/ls usage about blocksize/size
---
 src/df.c |5 +
 src/du.c |5 +
 src/ls.c |5 +
 src/system.h |   14 ++
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/df.c b/src/df.c
index 86fd0e3..e89770e 100644
--- a/src/df.c
+++ b/src/df.c
@@ -833,10 +833,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
 ), stdout);
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
-  fputs (_(\n\
-SIZE may be (or may be an integer optionally followed by) one of following:\n\
-kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
-), stdout);
+  emit_blocksize_note (DF);
   emit_bug_reporting_address ();
 }
   exit (status);
diff --git a/src/du.c b/src/du.c
index 9da901a..7f1b93d 100644
--- a/src/du.c
+++ b/src/du.c
@@ -330,10 +330,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
 ), stdout);
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
-  fputs (_(\n\
-SIZE may be (or may be an integer optionally followed by) one of following:\n\
-kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
-), stdout);
+  emit_blocksize_note (DU);
   emit_bug_reporting_address ();
 }
   exit (status);
diff --git a/src/ls.c b/src/ls.c
index 553090d..2eb4038 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4664,10 +4664,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
 ), stdout);
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
-  fputs (_(\n\
-SIZE may be (or may be an integer optionally followed by) one of following:\n\
-kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
-), stdout);
+  emit_blocksize_note (LS);
   fputs (_(\
 \n\
 By default, color is not used to distinguish types of files.  That is\n\
diff --git a/src/system.h b/src/system.h
index 3a05501..156402b 100644
--- a/src/system.h
+++ b/src/system.h
@@ -616,6 +616,20 @@ ptr_align (void const *ptr, size_t alignment)
 ? false : (((Accum) = (Accum) * 10 + (Digit_val)), true))		\
   )
 
+static inline void
+emit_blocksize_note (char const *program)
+{
+  printf (_(\n\
+If none of the environment variables BLOCKSIZE, BLOCK_SIZE or \n\
+%s_BLOCK_SIZE is specified, blocksize defaults to 1024 bytes.\n\
+(or 512 bytes when POSIXLY_CORRECT environment variable is set)\n\
+), program);
+  fputs (_(\n\
+SIZE may be (or may be an integer optionally followed by) one of following:\n\
+kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
+), stdout);
+}
+
 #include hard-locale.h
 static inline void
 emit_bug_reporting_address (void)
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-07 Thread Ondřej Vašík
Hi,

Jim Meyering wrote:
 Pádraig Brady wrote:
  Ondřej Vašík wrote:
  As reported in
  http://lists.gnu.org/archive/html/bug-coreutils/2009-08/msg00342.html by
  Ernest N. Mamikonyan, cp/mv fails to preserve extended attributes for
  read-only source files.
  Following patch fixes the issue for me, although maybe it's not perfect
  solution. But I don't know about better one at the moment.
  Test included...
 
  Thanks for that, and especially the test.
  It looks to me that the cause of this is actually a bug
  in fsetxattr() (called by attr_copy_fd) as it's being
  passed a writable fd, but still giving permission denied?
 
 Hi Ondřej,
 
 Thanks for working on that.
 Note that your patch relaxes permissions
 on the destination and does not restore them.
 
 If you continue to work on this, please use the adjusted patch below.
 It makes the test script detect that failure, and also removes most
 of the redirections to /dev/null.  Now that nearly all test-related
 output is directed to a log file, there's no point in redirecting small
 outputs like that, and seeing them in the log can even make it easier
 to diagnose problems.
 
 Since this problem affects only users of file systems
 mounted with user_xattr, I may defer the fix until coreutils-7.7.

Ah, I knew I forgot to do something :). Thanks for spotting this.

Restoring to dest_mode  ~omitted_permissions done in attached patch,
dropped redirections from the test as well. Additionally - I modified
the copy.c patch a bit - failure of mode change now doesn't mean that I
don't try to preserve extended attributes (as it still could pass). 
Pádraig is right that it looks like some kind of bug in libattr and
fsetxattr() function, as the descriptor should be writable, anyway this
should workaround it - at least until they'll fix/change it or other way
of solution will be found.
Ok with passing to 7.7, although with such small impact and relatively
low danger, it could maybe included to 7.6 (if more snapshots will be
before real release).

Greetings,
 Ondřej

From 5fca1fbaf2e7594496c854f4c3eef60bd3013697 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Thu, 3 Sep 2009 16:10:21 +0200
Subject: [PATCH] cp,mv: do preserve extended attributes even for read-only source files

* src/copy.c (copy_reg): Set mode on file descriptor to 0600 for copying
extended attributes to prevent failures when source file doesn't have
write access rights. Reported by Ernest N. Mamikonyan.
* tests/misc/xattr: Test that change.
* NEWS (Bug fixes): Mention it.
---
 NEWS |4 
 src/copy.c   |   21 +
 tests/misc/xattr |   42 --
 3 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/NEWS b/NEWS
index 59270eb..8c511c6 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ GNU coreutils NEWS-*- outline -*-
   cp --preserve=xattr no longer leaks resources on each preservation failure.
   [bug introduced in coreutils-7.1]
 
+  cp --preserve=xattr and --archive now preserves extended attributes even
+  when the source file doesn't have write access rights
+  [bug introduced in coreutils-7.1]
+
   dd now returns non-zero status if it encountered a write error while
   printing a summary to stderr.
   [bug introduced in coreutils-6.11]
diff --git a/src/copy.c b/src/copy.c
index e604ec5..9506fb4 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -850,10 +850,23 @@ copy_reg (char const *src_name, char const *dst_name,
 
   set_author (dst_name, dest_desc, src_sb);
 
-  if (x-preserve_xattr  ! copy_attr_by_fd (src_name, source_desc,
-  dst_name, dest_desc, x)
-   x-require_preserve_xattr)
-return_val = false;
+  /* to allow copying extended attributes on read-only files, change
+ destination file descriptor access rights to 0600 for a while. */
+  if (x-preserve_xattr)
+   {
+ if (! fchmod_or_lchmod (dest_desc, dst_name, 0600))
+   {
+ if (!x-reduce_diagnostics || x-require_preserve_xattr)
+error (0, errno,
+  _(failed to set writable mode for %s, copying xattrs may fail),
+  quote (dst_name));
+   }
+ if (! copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
+ x-require_preserve_xattr)
+ return_val = false;
+ fchmod_or_lchmod (dest_desc, dst_name, dst_mode  ~omitted_permissions);
+   }
+
 
   if (x-preserve_mode || x-move_mode)
 {
diff --git a/tests/misc/xattr b/tests/misc/xattr
index a27e1f6..404085f 100755
--- a/tests/misc/xattr
+++ b/tests/misc/xattr
@@ -29,7 +29,7 @@ fi
 
 # Skip this test if cp was built without xattr support:
 touch src dest || framework_failure
-cp --preserve=xattr -n src dest 2/dev/null \
+cp --preserve=xattr -n src dest \
   || skip_test_ coreutils built without xattr support
 
 # this code was taken from test mv/backup-is-src
@@ -46,13 +46,13

Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-07 Thread Ondřej Vašík
Pádraig Brady wrote:
 Ondřej Vašík wrote:
  Ah, I knew I forgot to do something :). Thanks for spotting this.
  
  Restoring to dest_mode  ~omitted_permissions done in attached patch,
  dropped redirections from the test as well. Additionally - I modified
  the copy.c patch a bit - failure of mode change now doesn't mean that I
  don't try to preserve extended attributes (as it still could pass). 
 
 
  Pádraig is right that it looks like some kind of bug in libattr and
  fsetxattr() function, as the descriptor should be writable, anyway this
  should workaround it - at least until they'll fix/change it or other way
  of solution will be found.
 
 What's the best place to report that?
 It would be good to add a comment in the code that this is a workaround
 rather than expected behaviour (after confirming the bug of course).

libattr upstream has mailing list xfs at oss.sgi.com , so maybe the best
place is there. 

  Ok with passing to 7.7, although with such small impact and relatively
  low danger, it could maybe included to 7.6 (if more snapshots will be
  before real release).
 
 To minimize side affects perhaps we should only do the chmod(600)
 if (geteuid () != 0  !access (src_name, W_OK)) ?

Good idea, it would reduce possibility of security leak, playing with
access rights is always a bit dangerous (although here we play with
rights on destination descriptor, which is imho much more safe).

Additionally - Jim is correct that for different owner 0600 rights are
not sufficient for different owner of the file - and 0666 is too much
devil-like ;) . Any idea?

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp, mv: do preserve extended attributes even for read-only source files

2009-09-07 Thread Ondřej Vašík
Pádraig Brady wrote:
 Ondřej Vašík wrote:
  Pádraig Brady wrote:
  To minimize side affects perhaps we should only do the chmod(600)
  if (geteuid () != 0  !access (src_name, W_OK)) ?
  
  Good idea, it would reduce possibility of security leak, playing with
  access rights is always a bit dangerous (although here we play with
  rights on destination descriptor, which is imho much more safe).
  
  Additionally - Jim is correct that for different owner 0600 rights are
  not sufficient for different owner of the file - and 0666 is too much
  devil-like ;) . Any idea?
 
 preserve_xattr before preserve_ownership ?

Good idea, moved there and used that (geteuid () != 0  access
(src_name, W_OK)) construction - additionally I tried to reduce those
chmod calls (call for returning permissions only when the write_access 
granting call was used) - so it should be safer now.

Anyway, added comment that real problem is in libattr and this is just
workaround and added FIXME. Better now?

Greetings,
 Ondřej


From 3aae1734c715cb8246a4961f5bea5e6fa58c1d61 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Thu, 3 Sep 2009 16:10:21 +0200
Subject: [PATCH] cp,mv: do preserve extended attributes even for read-only source files

* src/copy.c (copy_reg): Set mode on file descriptor to 0600 for copying
extended attributes to prevent failures when source file doesn't have
write access rights. Reported by Ernest N. Mamikonyan.
* tests/misc/xattr: Test that change.
* NEWS (Bug fixes): Mention it.
---
 NEWS |4 
 src/copy.c   |   34 +-
 tests/misc/xattr |   42 --
 3 files changed, 61 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 59270eb..8c511c6 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ GNU coreutils NEWS-*- outline -*-
   cp --preserve=xattr no longer leaks resources on each preservation failure.
   [bug introduced in coreutils-7.1]
 
+  cp --preserve=xattr and --archive now preserves extended attributes even
+  when the source file doesn't have write access rights
+  [bug introduced in coreutils-7.1]
+
   dd now returns non-zero status if it encountered a write error while
   printing a summary to stderr.
   [bug introduced in coreutils-6.11]
diff --git a/src/copy.c b/src/copy.c
index e604ec5..c8f0a45 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -834,6 +834,35 @@ copy_reg (char const *src_name, char const *dst_name,
 }
 }
 
+  /* To allow copying extended attributes on read-only files, change
+ destination file descriptor access rights to 0600 for a while
+ if required.
+ Note: it's just workaround - fsetxattr from libattr needs write
+ access rights even with file descriptor opened with O_WRONLY
+ FIXME: remove that ugly access rights change. */
+  if (x-preserve_xattr)
+   {
+ bool access_unchanged = true;
+
+ if (geteuid () != 0  !access (src_name, W_OK) 
+ (access_unchanged = fchmod_or_lchmod (dest_desc, dst_name, 0600)))
+   {
+ if (!x-reduce_diagnostics || x-require_preserve_xattr)
+error (0, errno,
+  _(failed to set writable mode for %s, copying xattrs may fail),
+  quote (dst_name));
+   }
+
+ if (! copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
+ x-require_preserve_xattr)
+ return_val = false;
+
+ if (!access_unchanged)
+ fchmod_or_lchmod (dest_desc, dst_name,
+   dst_mode  ~omitted_permissions);
+   }
+
+
   if (x-preserve_ownership  ! SAME_OWNER_AND_GROUP (*src_sb, sb))
 {
   switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, sb))
@@ -850,11 +879,6 @@ copy_reg (char const *src_name, char const *dst_name,
 
   set_author (dst_name, dest_desc, src_sb);
 
-  if (x-preserve_xattr  ! copy_attr_by_fd (src_name, source_desc,
-  dst_name, dest_desc, x)
-   x-require_preserve_xattr)
-return_val = false;
-
   if (x-preserve_mode || x-move_mode)
 {
   if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
diff --git a/tests/misc/xattr b/tests/misc/xattr
index a27e1f6..404085f 100755
--- a/tests/misc/xattr
+++ b/tests/misc/xattr
@@ -29,7 +29,7 @@ fi
 
 # Skip this test if cp was built without xattr support:
 touch src dest || framework_failure
-cp --preserve=xattr -n src dest 2/dev/null \
+cp --preserve=xattr -n src dest \
   || skip_test_ coreutils built without xattr support
 
 # this code was taken from test mv/backup-is-src
@@ -46,13 +46,13 @@ xattr_pair=$xattr_name=\$xattr_value\
 # create new file and check its xattrs
 touch a || framework_failure
 getfattr -d a out_a || skip_test_ failed to get xattr of file
-grep -F $xattr_pair out_a /dev/null  framework_failure
+grep -F $xattr_pair out_a  framework_failure
 
 # try to set user xattr on file
 setfattr -n $xattr_name

[PATCH] cp,mv: do preserve extended attributes even for read-only source files

2009-09-03 Thread Ondřej Vašík
As reported in
http://lists.gnu.org/archive/html/bug-coreutils/2009-08/msg00342.html by
Ernest N. Mamikonyan, cp/mv fails to preserve extended attributes for
read-only source files.
Following patch fixes the issue for me, although maybe it's not perfect
solution. But I don't know about better one at the moment.
Test included...

Greetings,
 Ondřej Vašík

From cae691907fe50e2ab05198a7c647fe4140e3669e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Thu, 3 Sep 2009 16:10:21 +0200
Subject: [PATCH] cp,mv: do preserve extended attributes even for read-only source files

* src/copy.c (copy_reg): Set mode on file descriptor to 0600 for copying
 extended attributes to prevent failures when source file doesn't have
 write access rights (reported by Ernest N. Mamikonyan)
* tests/misc/xattr: test that change
* NEWS: mention that change
---
 NEWS |4 
 src/copy.c   |   24 
 tests/misc/xattr |7 +++
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 59270eb..8c511c6 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ GNU coreutils NEWS-*- outline -*-
   cp --preserve=xattr no longer leaks resources on each preservation failure.
   [bug introduced in coreutils-7.1]
 
+  cp --preserve=xattr and --archive now preserves extended attributes even
+  when the source file doesn't have write access rights
+  [bug introduced in coreutils-7.1]
+
   dd now returns non-zero status if it encountered a write error while
   printing a summary to stderr.
   [bug introduced in coreutils-6.11]
diff --git a/src/copy.c b/src/copy.c
index e604ec5..b645a9a 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -850,10 +850,26 @@ copy_reg (char const *src_name, char const *dst_name,
 
   set_author (dst_name, dest_desc, src_sb);
 
-  if (x-preserve_xattr  ! copy_attr_by_fd (src_name, source_desc,
-  dst_name, dest_desc, x)
-   x-require_preserve_xattr)
-return_val = false;
+  /* to allow copying extended attributes on read-only files, change
+ destination file descriptor access rights to 0600 for a while. */
+  if (x-preserve_xattr)
+   {
+ if (! fchmod_or_lchmod (dest_desc, dst_name, 0600))
+   {
+ if (! copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
+ x-require_preserve_xattr)
+   return_val = false;
+   }
+ else
+   {
+  if (!x-reduce_diagnostics || x-require_preserve_xattr)
+error (0, errno, _(can't write extended attributes to %s),
+   quote (dst_name));
+  if (x-require_preserve_xattr)
+return_val = false;
+   }
+}
+
 
   if (x-preserve_mode || x-move_mode)
 {
diff --git a/tests/misc/xattr b/tests/misc/xattr
index a27e1f6..828e871 100755
--- a/tests/misc/xattr
+++ b/tests/misc/xattr
@@ -77,6 +77,13 @@ cp -a a d 2err  test -s err  fail=1
 getfattr -d d out_d || skip_test_ failed to get xattr of file
 grep -F $xattr_pair out_d /dev/null || fail=1
 
+#test if --preserve=xattr works even for files without write rights
+chmod a-w a || framework_failure
+cp --preserve=xattr a e || fail=1
+getfattr -d e out_e || skip_test_ failed to get xattr of file
+grep -F  $xattr_pair out_e /dev/null || fail=1
+chmod a+w a || framework_failure
+
 rm b || framework_failure
 
 # install should never preserve xattr
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: cp(1) extended attributes bug + [PATCH]: fix the leak in copy_reg()

2009-09-02 Thread Ondřej Vašík
Ernest N. Mamikonyan wrote:
[returning mailing list to CC, please keep it there]

 On Tue, 01 Sep 2009 02:16:28 -0400, Ondřej Vašík ova...@redhat.com wrote:
  Ernest N. Mamikonyan wrote:
  Cp(1) doesn't correctly copy extended attributes for read-only files:
 
  touch foo
  setfattr -n user.key -v value foo
  chmod a-w foo
  cp --preserve=xattr foo bar
  cp: setting attribute `user.key' for `user.key': Permission denied
 
  This error message is not produced by coreutils sources, but by libattr
  - all messages about extended attributes are generated there. I'm not
  sure why they are trying to set attributes for source file - maybe they
  are not and access rights for destination file are more relevant.
  Strace/ltrace of the failure could be helpful as well.
 The problem is quite simple! Cp(1) tries to change the xattrs of a file
 with mode 0400 (see attached trace). Is opening the destination file with
 initial an mode of 0600 a security (or some other) risk? I suppose that's
 what needs to be done.

Sorry, I got confused ... it's obvious - not sure about the risk, so not
trying to fix this now. What do you think, Jim/Pádraig?

Additionally it looks like there is a leak (about 36k per file for
failing xattr preserve) in copy_reg() - as the return false; should be
changed to return_val=false; - sending patch for this... but it's not
fixing the reported issue.

  If one uses cp -a instead, it simply strips the metadata and doesn't
  complain.
 
  cp -a shouldn't complain, but the xattrs are likely not preserved in
  this case - just error message from xattr preservation is suppressed and
  not preserving extended attributes is not considered as error in that
  case.
 Well, the manpage says that cp -a is the same as cp -dR --preserve=all.

But the manpage also says that relevant source of information is info
documentation. And info documentation mention that little difference in
behaviour. In fact cp -a behaves like cp -dR --preserve=all, but is
silent about the failures of preserving SELinux context and/or extended
attributes.

 PS. I forgot to mention the version; it's Coreutils 7.5.
 
 Thanks
 Ernest N. Mamikonyan 


Greetings,
  Ondřej Vašík
execve(/bin/cp, [cp, --preserve=all, foo, bar], [/* 16 vars */]) = 0
brk(0)  = 0x8f37000
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or directory)
open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=89435, ...}) = 0
mmap2(NULL, 89435, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f39000
close(3)= 0
open(/lib/libattr.so.1, O_RDONLY) = 3
read(3, \177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\20\0\0004\0\0\0h..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=17784, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f38000
mmap2(NULL, 20652, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7f32000
mmap2(0xb7f36000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0xb7f36000
close(3)= 0
open(/lib/libc.so.6, O_RDONLY)= 3
read(3, \177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360k\1\0004\0\0\0\244..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1478940, ...}) = 0
mmap2(NULL, 1489192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7dc6000
mprotect(0xb7f2b000, 4096, PROT_NONE)   = 0
mmap2(0xb7f2c000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x165) = 0xb7f2c000
mmap2(0xb7f2f000, 10536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f2f000
close(3)= 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7dc5000
set_thread_area({entry_number:-1 - 6, base_addr:0xb7dc56c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb7f2c000, 8192, PROT_READ)   = 0
mprotect(0xb7f36000, 4096, PROT_READ)   = 0
mprotect(0x805e000, 4096, PROT_READ)= 0
mprotect(0xb7f6f000, 4096, PROT_READ)   = 0
munmap(0xb7f39000, 89435)   = 0
brk(0)  = 0x8f37000
brk(0x8f58000)  = 0x8f58000
open(/usr/lib/locale/locale-archive, O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1821680, ...}) = 0
mmap2(NULL, 1821680, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7c08000
close(3)= 0
geteuid32() = 100
stat64(bar, 0xbf924ed4)   = -1 ENOENT (No such file or directory)
stat64(foo, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
stat64(bar, 0xbf924cfc)   = -1 ENOENT (No such file or directory)
open(foo, O_RDONLY|O_LARGEFILE)   = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
open(bar, O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0400) = 5
fstat64(5, {st_mode=S_IFREG|0400, st_size=0, ...}) = 0
read(3, ..., 32768

Re: [PATCH] ls -i: print consistent inode numbers also for mount points

2009-08-31 Thread Ondřej Vašík
Jim Meyering wrote:
 Following up on a long thread from a year ago, here's a patch
 to fix the 3.5-year-old readdir-vs-mountpoint-inode bug in ls -i.

Checked on my system and works fine...

 It's a shame to have to pessimize ls -i performance, even by this
 small amount on linux-based kernels, but correctness definitely
 trumps performance, here.

Yep, it has some performance impact...
checked `time ./ls -i1R /home /dev /usr /var /lib myinodes with
approximate number of 31k dirs, 450k files on ext3

and results are
old binary without the patch:
real2m5.631s
user0m3.012s
sys 0m4.815s

new binary:
real6m8.560s
user0m3.947s
sys 0m30.572s

But correctness should be preferred as this is not so common usecase...

 Review appreciated.

Looks ok from my point of view.

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] ls -i: print consistent inode numbers also for mount points

2009-08-31 Thread Ondřej Vašík
Pádraig Brady wrote:
 So there was a lot more disk access with the new binary.
 but the NEWS suggests that should only be the case for
 systems with dysfunctional readdir.
 
 What was your system?

Quite ancient system... I checked this on my old Fedora Core 6...
Anyway could check with something newer if required... :)

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


Re: [PATCH] cp: ignore obscure failure to preserve symlink time stamps,

2009-08-24 Thread Ondřej Vašík
Jim Meyering wrote:
 Kamil Dudka wrote:
  On Monday 24 of August 2009 10:46:26 Jim Meyering wrote:
  Actually, the comment I added above has a typo.
  s/ENOTSUP/ENOSYS/.
 
  The diagnostic reported corresponds to ENOSYS.
  The adjusted patch is here:
 
 
  http://www.redhat.com/archives/fedora-devel-list/2009-August/msg01220.html
 
  s/Kamil Dudka/Jeff Garzik/
 
 No.  Someone reported a koji build failure last week.
 If it wasn't you, then it must have been Ondřej.
 Sorry about that.

Yep, it was me, I reported that on Friday just before I left office -
but actually my workaround for koji caused the build failure reported on
fedora-devel-list by Todd and I thought Kamil reported privately that on
weekend so I was silent about the patch. Adjusted patch is already built
in fedora rawhide so everything should be fine now.

Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy


[PATCH]: remove one duplicity in copy.c caused by factorization

2009-07-08 Thread Ondřej Vašík
Hello,
while making coreutils update for F-11, I spotted one duplicity in
copy.c caused by
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=e0cf592f48b4e67dc31d0482ae4f4dbc820e883e
 factorization commit. Attached patch removes this duplicity.


Greetings,
 Ondřej Vašík

From 430ea6c024fdef7598d676438cc37b341912be75 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 8 Jul 2009 17:00:47 +0200
Subject: [PATCH] copy.c: remove duplicity caused by factorization

* copy.c (copy_attr_error): remove duplicity caused by factorization
---
 src/copy.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/copy.c b/src/copy.c
index 511f705..4c8c432 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -146,7 +146,6 @@ copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
   va_list ap;
 
   if (!errno_unsupported (errno))
-  if (errno != ENOTSUP  errno != ENODATA)
 {
   /* use verror module to print error message */
   va_start (ap, fmt);
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: su command failing on RHEL5

2009-06-12 Thread Ondřej Vašík
Hello,

Sanjay Kumar wrote:
 [r...@omvm6 ~]# su poo -c cat /dev/tty
 cat: /dev/tty: No such device or address
 open(/dev/tty, O_RDONLY)  = -1 ENXIO (No such device or
 address)

1) su command is not failing
2) cat is working as expected

su -c creates new process in RHEL-5 - which is expected behaviour as it
could cause security problems. This process has apparently no
controlling terminal /dev/tty. There was non-upstream longoption
--session-command added in RHEL-5 to restore RHEL-4 behaviour. Consider
using it in this case.

 Please let us know the fix available or not.

Next time it would be better to use RHEL product support or RedHat
bugzilla. Please try to use it instead of upstream mailing list, if
--session-command is not solving your issue.

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH] dd: do not unnecesarilly allocate memory for input block size, when not needed

2009-05-22 Thread Ondřej Vašík
Hello,
as reported in https://bugzilla.redhat.com/show_bug.cgi?id=502026, in dd
is an unnecessary memory allocation for input block even if input block
buffer is not needed (skip and count set to 0). Attached patch should
prevent memory exhaustion error in that very special case. I guess
mentioning in NEWS is not required in that case...

Greetings,
 Ondřej Vašík

From 5c9811896936341f462f67fd192748cac2f49dbd Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 22 May 2009 09:47:34 +0200
Subject: [PATCH] dd: do not unnecesarilly allocate memory for input block size, when not needed

* src/dd.c: do not allocate memory when count=0 and skip=0
  (and input block buffer is not needed)
* tests/dd/no-allocate: new test to check this change
* tests/Makefile.am: run that test
---
 src/dd.c |4 
 tests/Makefile.am|1 +
 tests/dd/no-allocate |   34 ++
 3 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100755 tests/dd/no-allocate

diff --git a/src/dd.c b/src/dd.c
index 3ba616b..be6d544 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1553,6 +1553,10 @@ dd_copy (void)
   int exit_status = EXIT_SUCCESS;
   size_t n_bytes_read;
 
+  /* Do not unnecessarily allocate memory */
+  if (max_records == 0  skip_records == 0)
+return exit_status;
+
   /* Leave at least one extra byte at the beginning and end of `ibuf'
  for conv=swab, but keep the buffer address even.  But some peculiar
  device drivers work only with word-aligned buffers, so leave an
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5591331..fd2fc90 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -291,6 +291,7 @@ TESTS =		\
   cp/symlink-slash\
   cp/thru-dangling\
   dd/misc	\
+  dd/no-allocate\
   dd/not-rewound\
   dd/reblock	\
   dd/skip-seek	\
diff --git a/tests/dd/no-allocate b/tests/dd/no-allocate
new file mode 100755
index 000..19629f2
--- /dev/null
+++ b/tests/dd/no-allocate
@@ -0,0 +1,34 @@
+#!/bin/sh
+# make sure that dd doesn't allocate memory unnecessarily
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+
+if test $VERBOSE = yes; then
+  set -x
+  dd --version
+fi
+
+. $srcdir/test-lib.sh
+
+fail=0
+
+#count and skip is zero, we don't need to allocate memory for input block
+(ulimit -v 1;dd if=/dev/zero of=x bs=10M seek=1 count=0) || fail=1
+
+#skip is not zero, we need to allocate input block size (and we should fail)
+(ulimit -v 1;dd if=/dev/zero of=x bs=10M seek=1 skip=1 count=0)  fail=1
+
+Exit $fail
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] dd: do not unnecesarilly allocate memory for input block size, when not needed

2009-05-22 Thread Ondřej Vašík
Pádraig Brady wrote:
 So that would not run skip(STDOUT_FILENO,...) if count==0.
 Would this break existing scripts that for example used
 this command to position a non seekable device?
 
   dd count=0 of=/dev/tape seek=1234

Thanks for objection, you are right, my patch seems to be not correct
way as it doesn't run that part and could break something. However - for
many cases (when file_size  offset  OFF_T_MAX and file seekable)
buffer allocation is not required in skip(), so it could be handled
somehow for those cases even without buffer allocation...

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

2009-04-28 Thread Ondřej Vašík
Ondřej Vašík wrote:
 Hello,
 as requested via IRC, adding separate test cases for patches added
 previously in that thread. It should check correct diagnostics for
 SELinux context/xattrs on filesystem without xattr/SELinux
 support(fat32).

Sorry for added dosfstools dependency, ext2 mounted without user xattr 
support should be sufficient, corrected patch attached...

Greetings,
 Ondřej


From e6d3f340ad40635425a63a2edceb7c4a833e048e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 27 Apr 2009 17:20:23 +0200
Subject: [PATCH] tests: add tests for xattr diagnostics on file system without xattr support

* tests/Makefile.am: add new root-only test
* tests/cp/cp-mv-enotsup-xattr: check if xattr diagnostics are displayed
 correctly on filesystem without xattr support
---
 tests/Makefile.am|1 +
 tests/cp/cp-mv-enotsup-xattr |   90 ++
 2 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100755 tests/cp/cp-mv-enotsup-xattr

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3a15a87..5591331 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,7 @@ root_tests =	\
   cp/cp-a-selinux\
   cp/preserve-gid\
   cp/special-bits\
+  cp/cp-mv-enotsup-xattr\
   dd/skip-seek-past-dev\
   install/install-C-root			\
   ls/capability	\
diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr
new file mode 100755
index 000..d7f15d7
--- /dev/null
+++ b/tests/cp/cp-mv-enotsup-xattr
@@ -0,0 +1,90 @@
+#!/bin/sh
+# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work
+# as expected on filesystem without their support and do show correct
+# diagnostics when required
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+
+if test $VERBOSE = yes; then
+  set -x
+  cp --version
+  mv --version
+fi
+
+. $srcdir/test-lib.sh
+require_root_
+
+cwd=`pwd`
+cleanup_() { cd /; umount $cwd/mnt; }
+
+# Create a file system without user xattr support, then mount it.
+dd if=/dev/zero of=blob bs=8192 count=200  /dev/null 21 \
+ || framework_failure
+mkdir mnt|| framework_failure
+mkfs -t ext2 -F blob ||
+  skip_test_ failed to create ext2 file system
+
+mount -oloop,nouser_xattr blob mnt   || framework_failure
+echo test  mnt/f|| framework_failure
+test -s mnt/f|| framework_failure
+
+# testing xattr name-value pair
+xattr_name=user.foo
+xattr_value=bar
+xattr_pair=$xattr_name=\$xattr_value\
+
+echo test  a || framework_failure
+getfattr -d a out_a || skip_test_ failed to get xattr of file
+grep -F $xattr_pair out_a /dev/null  framework_failure
+setfattr -n $xattr_name -v $xattr_value a out_a \
+  || skip_test_ failed to set xattr of file
+getfattr -d a out_a || skip_test_ failed to get xattr of file
+grep -F $xattr_pair out_a /dev/null \
+  || skip_test_ failed to set xattr of file
+
+fail=0   || framework_failure
+
+
+#This should pass without diagnostics
+cp -a a mnt/ 2err  || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+rm -f err mnt/a
+
+#This should pass without diagnostics
+cp --preserve=all a mnt/ 2err  || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+rm -f err mnt/a
+
+#This should fail with coresponding diagnostics
+cp -a --preserve=xattr a mnt/ 2err   fail=1
+cat \EOF  exp || fail=1
+cp: setting attributes for `mnt/a': Operation not supported
+EOF
+
+compare err exp || fail=1
+
+rm -f err mnt/a
+
+#This should pass without diagnostics
+mv a mnt/ 2err || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+Exit $fail
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Human readable sort

2009-04-27 Thread Ondřej Vašík
Pádraig Brady wrote:
 Pádraig Brady wrote:
 Attached is the full patch, which hopefully we can push soon.

I'm not objecting anything relevant in that patch, just the tab/spaces
mixing looks inconsistent with the rest of the code in added lines in
sort.c . Only cosmetic thing ... but is this intentional?

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

2009-04-27 Thread Ondřej Vašík
Hello,
as requested via IRC, adding separate test cases for patches added
previously in that thread. It should check correct diagnostics for
SELinux context/xattrs on filesystem without xattr/SELinux
support(fat32).

Greetings,
 Ondřej

From e6d3f340ad40635425a63a2edceb7c4a833e048e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 27 Apr 2009 17:20:23 +0200
Subject: [PATCH] tests: add tests for xattr diagnostics on file system without xattr support

* tests/Makefile.am: add new root-only test
* tests/cp/cp-mv-enotsup-xattr: check if xattr diagnostics are displayed
 correctly on filesystem without xattr support
---
 tests/Makefile.am|1 +
 tests/cp/cp-mv-enotsup-xattr |   90 ++
 2 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100755 tests/cp/cp-mv-enotsup-xattr

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3a15a87..5591331 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,7 @@ root_tests =	\
   cp/cp-a-selinux\
   cp/preserve-gid\
   cp/special-bits\
+  cp/cp-mv-enotsup-xattr\
   dd/skip-seek-past-dev\
   install/install-C-root			\
   ls/capability	\
diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr
new file mode 100755
index 000..d7f15d7
--- /dev/null
+++ b/tests/cp/cp-mv-enotsup-xattr
@@ -0,0 +1,90 @@
+#!/bin/sh
+# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work
+# as expected on filesystem without their support (FAT32) and do show
+# correct diagnostics when required
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+
+if test $VERBOSE = yes; then
+  set -x
+  cp --version
+  mv --version
+fi
+
+. $srcdir/test-lib.sh
+require_root_
+
+cwd=`pwd`
+cleanup_() { cd /; umount $cwd/mnt; }
+
+# Create a FAT32 file system, then mount it.
+dd if=/dev/zero of=blob bs=8192 count=200  /dev/null 21 \
+ || framework_failure
+mkdir mnt|| framework_failure
+mkdosfs -v -F 32 blob ||
+  skip_test_ failed to create vfat file system
+
+mount -oloop blob mnt|| framework_failure
+echo test  mnt/f|| framework_failure
+test -s mnt/f|| framework_failure
+
+# testing xattr name-value pair
+xattr_name=user.foo
+xattr_value=bar
+xattr_pair=$xattr_name=\$xattr_value\
+
+echo test  a || framework_failure
+getfattr -d a out_a || skip_test_ failed to get xattr of file
+grep -F $xattr_pair out_a /dev/null  framework_failure
+setfattr -n $xattr_name -v $xattr_value a out_a \
+  || skip_test_ failed to set xattr of file
+getfattr -d a out_a || skip_test_ failed to get xattr of file
+grep -F $xattr_pair out_a /dev/null \
+  || skip_test_ failed to set xattr of file
+
+fail=0   || framework_failure
+
+
+#This should pass without diagnostics
+cp -a a mnt/ 2err  || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+rm -f err mnt/a
+
+#This should pass without diagnostics
+cp --preserve=all a mnt/ 2err  || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+rm -f err mnt/a
+
+#This should fail with coresponding diagnostics
+cp -a --preserve=xattr a mnt/ 2err   fail=1
+cat \EOF  exp || fail=1
+cp: setting attributes for `mnt/a': Operation not supported
+EOF
+
+compare err exp || fail=1
+
+rm -f err mnt/a
+
+#This should pass without diagnostics
+mv a mnt/ 2err || fail=1
+test -s mnt/a   || fail=1  #destination file must not be empty
+test -s err  fail=1  #there must be no stderr output
+
+Exit $fail
-- 
1.5.6.1.156.ge903b


From 0122c2cf362d54da220eb9be9c41586914e5b70d Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 27 Apr 2009 17:29:53 +0200
Subject: [PATCH] tests: (cp) ensure that -a option doesn't silence --preserve=context

* tests/cp/cp-a-selinux: -a option should not silence error diagnostics
 from --preserve=context (when preserving context is required)
---
 tests/cp/cp-a-selinux |   11 +++
 1 files changed, 11 

Re: join utility segfults

2009-04-24 Thread Ondřej Vašík
Ondřej Vašík wrote: 
 Pádraig Brady wrote:
  Roman Kirillov wrote:
   [kiril...@chiark py-src]$ join s1.txt s2.txt
   Segmentation fault
   files: http://sigizmund.info/upload/s12.tgz (28 mb)
  
  This issue seems related to the i18n patch applied by your distro
 Just would like to add that it's already fixed in Fedora rawhide
 package, so I'll fix it in next Fedora coreutils update for F-9/F-10.
 In F-8 not, it's already EOL.

To keep the list informed about the conclusion...
It turned out that it was not really fixed in rawhide at the time of my
reply. Just due to better memory management change in join.c done by
Bo Borgerson between 6.12 and 7.0 was the occurance chance of the
segfault reduced from 100% to ~10%. After investigation of the problem
the culprit is now known. Multibyte patch was checking for exact
equality/non-equality with the limit of the file, so the limit was
skipped(and therefore SIGSEGV occured). Problem was fixed and built in
koji (Rawhide branch) as
http://koji.fedoraproject.org/koji/buildinfo?buildID=99330 and reported
against RHEL-5 as https://bugzilla.redhat.com/show_bug.cgi?id=497368 .
Patch to fix the issue could be found in that bugzilla, should work for
affected Fedora's and RHEL (or derived Distros). Additionally the issue
could be easily workarounded by using singlebyte locales (e.g. LC_ALL=C
join).

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

2009-04-24 Thread Ondřej Vašík
Hello,

Ondřej Vašík wrote: 
 Jim Meyering píše v Pá 17. 04. 2009 v 13:54 +0200:
  Ondřej Vašík wrote:
   as reported in rhbz #496142 by Eric Sandeen, mv produces a lot of
   unwanted messages when moving files to filesystem without xattr support.
   I guess mv selinux/xattr diagnostic error messages should be reduced as
   is done for cp -a, attached patch should do that.
  ...
   +  mv: do not produce diagnostic errors for preserving xattr's to
   +  prevent message spam on file systems without xattr support.
  
  Thanks for the patch, but mv's charter is stricter than that of cp -a.
  I.e., people expect mv to preserve all attributes when the source
  and destination are on the same file system, so IMHO, failure to
  preserve any attribute (e.g., for an inter-device mv) requires
  _some_ diagnosis.

  However, when there are many files, and mv is failing to preserve some
  attribute repeatedly, it would make sense to print only the first N
  such diagnostics, and then for the N+1st, print one more saying that
  there have been additional attribute-preservation failures, but mv will
  not display any more.
 
 Changing proposed patch to not display diagnostics for ENODATA and
 ENOTSUP errno's - as is done for mv and SELinux contexts.

Actually I found that it was not exactly the same - as for
require-preserve=xattr error was hidden even for the failure. This
should be addressed by the first patch.

It reminds me another issue - due to reduce_diagnostic, if you use cp -a
--preserve=xattr,context , failure diagnostic is reduced, but the
command itself fails. Additionally for cp and --require-preserve=context
and ENODATA/ENOTSUP errors on destination filesystem cp just passes
without error - with no context preserved. All those things are
addressed by the second patch.

Greetings,
 Ondřej Vašík

From 3bf0e97d6564ef1aee5a4bf97931884df1b9501a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 17 Apr 2009 11:00:35 +0200
Subject: [PATCH] mv: do not produce xattr preserving failures when not supported by filesystem

*src/copy.c: Do not show error diagnostics when xattrs not supported and
   preservation of xattrs is not explicitly required  (reported by
   Eric Sandeen in rhbz #496142)
---
 NEWS   |3 +++
 src/copy.c |   20 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index d8ffde0..063d07f 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,9 @@ GNU coreutils NEWS-*- outline -*-
   LS_COLORS environment variable. To disable it you can add something like
   this to your profile: eval `dircolors | sed s/hl=[^:]*:/hl=:/`
 
+  mv: do not produce diagnostic errors for preserving xattr's on file
+  systems without xattr support.
+
 
 * Noteworthy changes in release 7.1 (2009-02-21) [stable]
 
diff --git a/src/copy.c b/src/copy.c
index 9b0e139..d9db23c 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -139,6 +139,22 @@ copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
   int err = errno;
   va_list ap;
 
+  if (errno != ENOTSUP  errno != ENODATA)
+{
+  /* use verror module to print error message */
+  va_start (ap, fmt);
+  verror (0, err, fmt, ap);
+  va_end (ap);
+}
+}
+
+static void
+copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED,
+		 char const *fmt, ...)
+{
+  int err = errno;
+  va_list ap;
+
   /* use verror module to print error message */
   va_start (ap, fmt);
   verror (0, err, fmt, ap);
@@ -163,7 +179,7 @@ copy_attr_by_fd (char const *src_path, int src_fd,
 {
   struct error_context ctx =
   {
-.error = copy_attr_error,
+.error = x-require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
 .quote = copy_attr_quote,
 .quote_free = copy_attr_free
   };
@@ -177,7 +193,7 @@ copy_attr_by_name (char const *src_path, char const *dst_path,
 {
   struct error_context ctx =
   {
-.error = copy_attr_error,
+.error = x-require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
 .quote = copy_attr_quote,
 .quote_free = copy_attr_free
   };
-- 
1.5.6.1.156.ge903b


From 5023cacf5c62c95b1f9c41ef7c7684209a5abc82 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 24 Apr 2009 14:29:45 +0200
Subject: [PATCH] cp: diagnose failure when preserving xattr/context required even with -a option

* src/copy.c (copy_attr_by_fs): Always show diagnostics when preserving xattrs
is required
 (copy_attr_by_name): Likewise
 (copy_reg): Always show diagnostics when preserving SELinux
context is required
 (copy_internal): Likewise + Do not ignore ENOTSUP and ENODATA
errors when preserving SELinux context is required
* NEWS (Bug fixes): mention it
---
 NEWS   |5 +
 src/copy.c |   16 +---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 063d07f..b3fb475 100644
--- a/NEWS

Re: [PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

2009-04-24 Thread Ondřej Vašík
Ondřej Vašík wrote:
 Ondřej Vašík wrote: 
 It reminds me another issue - due to reduce_diagnostic, if you use cp -a
 --preserve=xattr,context , failure diagnostic is reduced, but the
 command itself fails. Additionally for cp and --require-preserve=context
 and ENODATA/ENOTSUP errors on destination filesystem cp just passes
 without error - with no context preserved. All those things are
 addressed by the second patch.

The second patch was incorrect, sorry, it's Friday afternoon...
corrected version attached...

Greetings,
 Ondřej

From 0191d1b04d89e29d346a941246ffc27c4248438e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 24 Apr 2009 14:29:45 +0200
Subject: [PATCH] cp: diagnose failure when preserving xattr/context required even with -a option

* src/copy.c (copy_attr_by_fs): Always show diagnostics when preserving xattrs
is required
 (copy_attr_by_name): Likewise
 (copy_reg): Always show diagnostics when preserving SELinux
context is required
 (copy_internal): Likewise + Do not ignore ENOTSUP and ENODATA
errors when preserving SELinux context is required
* NEWS (Bug fixes): mention it
---
 NEWS   |5 +
 src/copy.c |   16 +---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 063d07f..b3fb475 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,11 @@ GNU coreutils NEWS-*- outline -*-
   The bug strikes only with both --recursive (-r, -R) and --link (-l).
   [bug introduced in coreutils-7.1]
 
+  cp now correctly diagnoses selinux/xattr failures when option
+  --preserve=context,xattr is specified with combination with option -a.
+  Additionally do not ignore unsupported operation error when preserving
+  SELinux context was explicitly requested.
+
   ls --sort=version (-v) sorted names beginning with . inconsistently.
   Now, names that start with . are always listed before those that don't.
 
diff --git a/src/copy.c b/src/copy.c
index d9db23c..6450826 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -184,7 +184,8 @@ copy_attr_by_fd (char const *src_path, int src_fd,
 .quote_free = copy_attr_free
   };
   return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
-x-reduce_diagnostics ? NULL : ctx);
+(x-reduce_diagnostics
+  !x-require_preserve_xattr)? NULL : ctx);
 }
 
 static bool
@@ -198,7 +199,8 @@ copy_attr_by_name (char const *src_path, char const *dst_path,
 .quote_free = copy_attr_free
   };
   return 0 == attr_copy_file (src_path, dst_path, 0,
-  x- reduce_diagnostics ? NULL :ctx);
+  (x- reduce_diagnostics
+!x-require_preserve_xattr)? NULL :ctx);
 }
 #else /* USE_XATTR */
 
@@ -481,7 +483,7 @@ copy_reg (char const *src_name, char const *dst_name,
 	  security_context_t con = NULL;
 	  if (getfscreatecon (con)  0)
 	{
-	  if (!x-reduce_diagnostics)
+	  if (!x-reduce_diagnostics || x-require_preserve_context)
 	error (0, errno, _(failed to get file system create context));
 	  if (x-require_preserve_context)
 		{
@@ -494,7 +496,7 @@ copy_reg (char const *src_name, char const *dst_name,
 	{
 	  if (fsetfilecon (dest_desc, con)  0)
 		{
-		  if (!x-reduce_diagnostics)
+		  if (!x-reduce_diagnostics || x-require_preserve_context)
 		error (0, errno,
 			   _(failed to set the security context of %s to %s),
 			   quote_n (0, dst_name), quote_n (1, con));
@@ -1747,7 +1749,7 @@ copy_internal (char const *src_name, char const *dst_name,
 	{
 	  if (setfscreatecon (con)  0)
 	{
-	  if (!x-reduce_diagnostics)
+	  if (!x-reduce_diagnostics || x-require_preserve_context)
 	error (0, errno,
 		   _(failed to set default file creation context to %s),
 		   quote (con));
@@ -1761,9 +1763,9 @@ copy_internal (char const *src_name, char const *dst_name,
 	}
   else
 	{
-	  if (errno != ENOTSUP  errno != ENODATA)
+	  if ((errno != ENOTSUP  errno != ENODATA) || x-require_preserve_context)
 	{
-	  if (!x-reduce_diagnostics)
+	  if (!x-reduce_diagnostics || x-require_preserve_context)
 	error (0, errno,
 		   _(failed to get security context of %s),
 		   quote (src_name));
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: join utility segfults

2009-04-23 Thread Ondřej Vašík
Pádraig Brady wrote:
 Roman Kirillov wrote:
  Hi guys,
  
  Probably found a bug in 'join':
  
  [kiril...@chiark py-src]$ join s1.txt s2.txt
  Segmentation fault
  
  files: http://sigizmund.info/upload/s12.tgz (28 mb)
 
 This issue seems related to the i18n patch applied by your distro
 
 ~/git/coreutils/src$ ./join s1.txt s2.txt  /dev/null
 ./join: file 1 is not in sorted order
 ./join: file 2 is not in sorted order
 fedora-8:~$ LANG=C join s1.txt s2.txt  /dev/null
 fedora-8:~$ join s1.txt s2.txt  /dev/null
 Segmentation fault (core dumped)

Just would like to add that it's already fixed in Fedora rawhide
package, so I'll fix it in next Fedora coreutils update for F-9/F-10.
In F-8 not, it's already EOL.

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

2009-04-17 Thread Ondřej Vašík
Hello,
as reported in rhbz #496142 by Eric Sandeen, mv produces a lot of
unwanted messages when moving files to filesystem without xattr support.
I guess mv selinux/xattr diagnostic error messages should be reduced as
is done for cp -a, attached patch should do that.

Greetings,
 Ondřej Vašík

From 02c4948b688d55dc28b9adad3ebe7ef2afbe3c4b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Fri, 17 Apr 2009 11:00:35 +0200
Subject: [PATCH] mv: do not produce diagnostics for xattr/selinux preserving failures

src/mv.c: Set reduce_diagnostics to reduce unwanted message spam
  (reported by Eric Sandeen in rhbz #496142)
---
 NEWS |3 +++
 src/mv.c |2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index d8ffde0..0d2e524 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,9 @@ GNU coreutils NEWS-*- outline -*-
   LS_COLORS environment variable. To disable it you can add something like
   this to your profile: eval `dircolors | sed s/hl=[^:]*:/hl=:/`
 
+  mv: do not produce diagnostic errors for preserving xattr's to
+  prevent message spam on file systems without xattr support.
+
 
 * Noteworthy changes in release 7.1 (2009-02-21) [stable]
 
diff --git a/src/mv.c b/src/mv.c
index 73bd3ef..746ac7c 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -116,7 +116,7 @@ cp_option_init (struct cp_options *x)
   x-preserve_mode = true;
   x-preserve_timestamps = true;
   x-preserve_security_context = selinux_enabled;
-  x-reduce_diagnostics = false;
+  x-reduce_diagnostics = true;
   x-require_preserve = false;  /* FIXME: maybe make this an option */
   x-require_preserve_context = false;
   x-preserve_xattr = true;
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: ls -v is still inconsistent

2009-03-25 Thread Ondřej Vašík
Jim Meyering wrote:
 Pushed.
 
 http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=1721cf06d9

I guess info doc about suffix regex should be updated too...

Greetings,
 Ondrej

From 88ebd00c46668f2b677c8da9a7e40584d5b97d9b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 25 Mar 2009 12:04:11 +0100
Subject: [PATCH] doc: Update suffix regex in version sort

* doc/coreutils.texi: Reflect current filevercmp regex
---
 doc/coreutils.texi |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 04db676..9c8b8c3 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -6667,7 +6667,7 @@ foo.zml-6.gz   foo.zml-100.gz
 
 Version-sorted strings are compared such that if @var{ver1} and @var{ver2}
 are version numbers and @var{prefix} and @var{suffix} (@var{suffix} matching
-the regular expression @samp{(\.[A-Za-z][A-Za-z0-9]*)*}) are strings then
+the regular expression @samp{(\.[A-Za-z~][A-Za-z0-9~]*)*}) are strings then
 @var{ver1}  @var{ver2} implies that the name composed of
 `...@var{prefix} @var{ver1} @var{suffix}'' sorts before
 `...@var{prefix} @var{ver2} @var{suffix}''.
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

2009-03-11 Thread Ondřej Vašík
Hello,

Jim Meyering wrote:
 Ondřej Vašík ova...@redhat.com wrote:
  Jim Meyering wrote:
  Ondřej Vašík ova...@redhat.com wrote:
   What about to split that into two patches? One for SELinux changes and
   one for xattr changes (commited after 7.1) - to make it more safe - and
   to give other distros more time to fix the leak...
  
  That sounds even better.  I see that debian stable's libattr1-dev
  is at 1:2.4.43-2, which means it has the leak.
  Please do.
 
  Ok, split patches attached.
 
 Thanks!  Looking at them now.
 
  Note: in the xattr patch there is no NEWS at the moment as it would
  cause conflict when added after 7.1 release - I guess something like
  cp: -a option tries to preserve xattrs but doesn't inform about
  failure would be ok.

I guess it's time to add the amended cp-a-xattr patch... attached

Greetings,
 Ondrej

From f28d49d3315d6e57ce9654a05d3831335d3efc72 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Wed, 11 Mar 2009 16:08:20 +0100
Subject: [PATCH] cp: make -a option preserve xattrs with reduced diagnostics

* copy.c (copy_attr_by_fd): Reduce xattr diagnostics for 'cp -a'.
  (copy_attr_by_name): Likewise.
* cp.c (main):  preserve xattrs with -a option, when possible
* doc/coreutils.texi: document that xattrs are preserved with
  cp -a, with no added diagnostics
* NEWS : mention that change
* tests/misc/xattr: Add tests for 'cp --preserve=all' and 'cp -a'.
---
 NEWS   |3 +++
 doc/coreutils.texi |7 +++
 src/copy.c |   22 +-
 src/cp.c   |1 +
 tests/misc/xattr   |   15 +--
 5 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index 9ace313..3d06ae0 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,9 @@ GNU coreutils NEWS-*- outline -*-
   at a time.  This was seen to increase throughput.  Up to 2 times
   when reading cached files on linux for example.
 
+  cp -a now tries to preserve extended attributes (xattr), doesn't inform
+  about failure, unlike with --preserve=all
+
 * Noteworthy changes in release 7.1 (2009-02-21) [stable]
 
 ** New features
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 2c1fae5..0bf978a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7262,10 +7262,9 @@ Preserve as much as possible of the structure and attributes of the
 original files in the copy (but do not attempt to preserve internal
 directory structure; i.e., @samp{ls -U} may list the entries in a copied
 directory in a different order).
-Try to preserve SELinux security context, but ignore any failure to do that
-and print no corresponding diagnostic.
-This option does not preserve extended attributes(xattr) at the moment.
-Equivalent to @option{-dR --preserve=all} with a few exceptions.
+Try to preserve SELinux security context and extended attributes (xattr),
+but ignore any failure to do that and print no corresponding diagnostic.
+Equivalent to @option{-dR --preserve=all} with the reduced diagnostics.
 
 @item -b
 @itemx @w...@kbd{--backup}[=@var{method}]}
diff --git a/src/copy.c b/src/copy.c
index e37fead..7b4dc08 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -153,13 +153,13 @@ copy_attr_quote (struct error_context *ctx ATTRIBUTE_UNUSED, char const *str)
 
 static void
 copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED,
-		char const *str ATTRIBUTE_UNUSED)
+char const *str ATTRIBUTE_UNUSED)
 {
 }
 
 static bool
 copy_attr_by_fd (char const *src_path, int src_fd,
-		 char const *dst_path, int dst_fd)
+ char const *dst_path, int dst_fd, const struct cp_options *x)
 {
   struct error_context ctx =
   {
@@ -167,11 +167,13 @@ copy_attr_by_fd (char const *src_path, int src_fd,
 .quote = copy_attr_quote,
 .quote_free = copy_attr_free
   };
-  return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0, ctx);
+  return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
+x-reduce_diagnostics ? NULL : ctx);
 }
 
 static bool
-copy_attr_by_name (char const *src_path, char const *dst_path)
+copy_attr_by_name (char const *src_path, char const *dst_path,
+   const struct cp_options *x)
 {
   struct error_context ctx =
   {
@@ -179,19 +181,21 @@ copy_attr_by_name (char const *src_path, char const *dst_path)
 .quote = copy_attr_quote,
 .quote_free = copy_attr_free
   };
-  return 0 == attr_copy_file (src_path, dst_path, 0, ctx);
+  return 0 == attr_copy_file (src_path, dst_path, 0,
+  x- reduce_diagnostics ? NULL :ctx);
 }
 #else /* USE_XATTR */
 
 static bool
 copy_attr_by_fd (char const *src_path, int src_fd,
-		 char const *dst_path, int dst_fd)
+ char const *dst_path, int dst_fd, const struct cp_options *x)
 {
   return true;
 }
 
 static bool
-copy_attr_by_name (char const *src_path, char const *dst_path)
+copy_attr_by_name (char const *src_path

[PATCH]: Invalid longoption for -v in nl usage

2009-02-17 Thread Ondřej Vašík
Hello,
as reported in rhbz #485712 , nl incorrectly states that long format for
-v is --first-page. Info documentation is correct and informs about
--starting-line-number as correct long option for -v. I guess best way
is to fix usage (and to not add --first-page option) as afaik nobody
complained so far.

Greetings,
 Ondrej

From 351bde49a4f5218528772a925ed1a2a42df30365 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Tue, 17 Feb 2009 13:29:33 +0100
Subject: [PATCH] nl: correct long-option name for -v in usage

* nl.c (usage): Use starting-line-number instead of first-page for -v
---
 src/nl.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/nl.c b/src/nl.c
index ddd0fcf..578a7aa 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -198,7 +198,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
   -s, --number-separator=STRING   add STRING after (possible) line number\n\
 ), stdout);
   fputs (_(\
-  -v, --first-page=NUMBER first line number on each logical page\n\
+  -v, --starting-line-number=NUMBER  first line number on each logical page\n\
   -w, --number-width=NUMBER   use NUMBER columns for line numbers\n\
 ), stdout);
   fputs (HELP_OPTION_DESCRIPTION, stdout);
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

2009-02-17 Thread Ondřej Vašík
Jim Meyering wrote:
 When will the libattr fix be in F10?

Upstream report:
http://oss.sgi.com/archives/xfs/2009-02/msg00331.html

Talked with Fedora attr maintainer and he will do an update for F-10 and
Rawhide in day or two - upon the upstream reaction. So it should be in
F-10 early next week.

 If you think a libattr fix *will* make it to F10 this week, then
 please ensure that no other major distribution is affected.

What about to split that into two patches? One for SELinux changes and
one for xattr changes (commited after 7.1) - to make it more safe - and
to give other distros more time to fix the leak...

Greetings,
 Ondrej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

2009-02-17 Thread Ondřej Vašík
Jim Meyering wrote:
 Ondřej Vašík ova...@redhat.com wrote:
  What about to split that into two patches? One for SELinux changes and
  one for xattr changes (commited after 7.1) - to make it more safe - and
  to give other distros more time to fix the leak...
 
 That sounds even better.  I see that debian stable's libattr1-dev
 is at 1:2.4.43-2, which means it has the leak.
 Please do.

Ok, split patches attached.
Note: in the xattr patch there is no NEWS at the moment as it would
cause conflict when added after 7.1 release - I guess something like
cp: -a option tries to preserve xattrs but doesn't inform about
failure would be ok.

Greetings,
 Ondrej

From 4f560d6e5e5678763f736f974862fd253b3285a3 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Tue, 17 Feb 2009 15:53:39 +0100
Subject: [PATCH] cp: make -a option preserve SELinux ctx with reduced diagnostics

* copy.c (copy_reg): Reduce SELinux context diagnostics for 'cp -a'.
  (copy_internal): Likewise
* copy.h (cp_options): Add boolean reduce_diagnostics.
* cp.c (usage): Mention that --archive (-a) behaves like -dR --preserve=all.
  (cp_option_init): Initialize added reduce_diagnostics.
  (main): Add reduce_diagnostics for -a option and preserve SELinux context,
  if possible.
* mv.c (cp_options_init): Set initial value for added booleans in cp_options.
* install.c (cp_option_init): Likewise.
* NEWS: Mention those behaviour changes.
* doc/coreutils.texi: Document --preserve=context, document that
  diagnostics are not shown for failures of non-mandatory attributes
  (just SELinux at the moment).
* tests/cp/cp-a-selinux: Check not only failures, but succesful use
  of preserving SELinux context in cp.
---
 NEWS  |5 -
 doc/coreutils.texi|   14 +++---
 src/copy.c|   28 
 src/copy.h|6 ++
 src/cp.c  |8 ++--
 src/install.c |2 ++
 src/mv.c  |2 ++
 tests/cp/cp-a-selinux |   22 ++
 8 files changed, 65 insertions(+), 22 deletions(-)

diff --git a/NEWS b/NEWS
index 2b17e74..c01756d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@ GNU coreutils NEWS-*- outline -*-
 
   Add extended attribute support available on certain filesystems like ext2
   and XFS.
-cp: Tries to copy xattrs when --preserve=xattr specified
+cp: Tries to copy xattrs when --preserve=xattr or --preserve=all specified
 mv: Always tries to copy xattrs
 install: Never copies xattrs
 
@@ -32,6 +32,9 @@ GNU coreutils NEWS-*- outline -*-
 
   cp uses much less memory in some situations
 
+  cp -a now correctly tries to preserve SELinux context (announced in 6.9.90),
+  doesn't inform about failure unlike with --preserve=all
+
   du --files0-from=FILE no longer reads all of FILE into RAM before
   processing the first file name
 
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index ba1e74e..ba6f6e0 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7261,8 +7261,11 @@ The program accepts the following options.  Also see @ref{Common options}.
 Preserve as much as possible of the structure and attributes of the
 original files in the copy (but do not attempt to preserve internal
 directory structure; i.e., @samp{ls -U} may list the entries in a copied
-directory in a different order).
-Equivalent to @option{-dpR}.
+directory in a different order). Try to preserve SELinux security context,
+but do not fail when this is not succesful. Diagnostic errors are not
+displayed for this non-guaranteed attribute. Option doesn't preserve
+extended attributes(xattr) at the moment.
+Equivalent to @option{-dR --preserve=all} with few exceptions.
 
 @item -b
 @itemx @w...@kbd{--backup}[=@var{method}]}
@@ -7404,6 +7407,9 @@ Preserve in the destination files
 any links between corresponding source files.
 @c Give examples illustrating how hard links are preserved.
 @c Also, show how soft links map to hard links with -L and -H.
+...@itemx context
+Preserve SELinux security context of the file. @command{cp} will fail
+if the preserving of SELinux security context is not succesful.
 @itemx xattr
 Preserve extended attributes if @command{cp} is built with xattr support,
 and xattrs are supported and enabled on your file system.
@@ -7411,7 +7417,9 @@ If SELinux context and/or ACLs are implemented using xattrs,
 they are preserved by this option as well.
 @itemx all
 Preserve all file attributes.
-Equivalent to specifying all of the above.
+Equivalent to specifying all of the above. Ignore failure
+to preserve SELinux security context or extended attributes,
+but show diagnostic messages about failures.
 @end table
 
 Using @option{--preserve} with no @var{attribute_list} is equivalent
diff --git a/src/copy.c b/src/copy.c
index a6ca9dd..7a7fae4 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -450,7 +450,8 @@ copy_reg

Re: [PATCH]: cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

2009-02-16 Thread Ondřej Vašík
Jim Meyering wrote:
 Unfortunately, with this patch, make check fails the cp/link-heap test.
 Investigating why, I discovered that it introduces a huge leak into
 cp -a, at least on F10.  80MB worth in this case.
 
 I'll let you investigate that one ;-)

Leak is in libattr - added by 2.4.43 (~8 months ago) - reported as 
RHBZ #485473 . Kamil Dudka already proposed patch for it. Leak doesn't
occur for older libattr or libattrs with that patch.

 Also, please fold the following into your patch for next time.
 Without the first hunk, with -Werror (via ./configure --enable-gcc-warnings)
 your new code doesn't even compile.

Actually, I dropped new ignore_attr_error() function completely - it
should be safe to pass just NULL instead of ctx to ignore error
messages. Other mentioned cosmetic indentation/ChangeLog format issues
fixed. New version attached.

Greetings,
 Ondrej

From 45c8ee820c3e9781433ef3b81d5fb9befebc164e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 9 Feb 2009 15:44:00 +0100
Subject: [PATCH] cp: make -a option preserve SELinux ctx and xattrs with reduced diagnostics

* copy.c (copy_reg): Reduce SELinux context diagnostics for 'cp -a'.
  (copy_internal): Likewise
  (copy_attr_by_fd): Reduce xattr diagnostics for 'cp -a'.
  (copy_attr_by_name): Likewise.
* copy.h (cp_options): Add boolean reduce_diagnostics.
* cp.c (usage): Mention that --archive (-a) behaves like -dR --preserve=all.
  (cp_option_init): Initialize added reduce_diagnostics.
  (main): Add reduce_diagnostics for -a option, preserve xattrs and
   SELinux context, if possible.
* mv.c (cp_options_init): Set initial value for added booleans in cp_options.
* install.c (cp_option_init): Likewise.
* NEWS: Mention those behaviour changes.
* doc/coreutils.texi: Document --preserve=context, document that
  diagnostics are not shown for failures of non-mandatory attributes
  (xattr,SELinux).
* tests/cp/cp-a-selinux: Check not only failures, but succesful use
  of preserving SELinux context in cp.
* tests/misc/xattr: Add tests for 'cp --preserve=all' and 'cp -a'.
---
 NEWS  |6 -
 doc/coreutils.texi|   14 ++--
 src/copy.c|   50 
 src/copy.h|6 +
 src/cp.c  |9 ++-
 src/install.c |2 +
 src/mv.c  |2 +
 tests/cp/cp-a-selinux |   22 +---
 tests/misc/xattr  |   15 -
 9 files changed, 93 insertions(+), 33 deletions(-)

diff --git a/NEWS b/NEWS
index 8eae7cc..9e8e85e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,8 @@ GNU coreutils NEWS-*- outline -*-
 
   Add extended attribute support available on certain filesystems like ext2
   and XFS.
-cp: Tries to copy xattrs when --preserve=xattr specified
+cp: Tries to copy xattrs when --preserve=xattr or --preserve=all specified,
+ -a option tries to preserve xattrs but doesn't inform about failure
 mv: Always tries to copy xattrs
 install: Never copies xattrs
 
@@ -27,6 +28,9 @@ GNU coreutils NEWS-*- outline -*-
 
   cp uses much less memory in some situations
 
+  cp -a now correctly tries to preserve SELinux context (announced in 6.9.90),
+  doesn't inform about failure unlike with --preserve=all
+
   du --files0-from=FILE no longer reads all of FILE into RAM before
   processing the first file name
 
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index c3a1164..3d52390 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7253,8 +7253,11 @@ The program accepts the following options.  Also see @ref{Common options}.
 Preserve as much as possible of the structure and attributes of the
 original files in the copy (but do not attempt to preserve internal
 directory structure; i.e., @samp{ls -U} may list the entries in a copied
-directory in a different order).
-Equivalent to @option{-dpR}.
+directory in a different order). Try to preserve SELinux security context
+and extended attributes (xattrs) as well, but do not fail when this is not
+succesful. Diagnostic errors are not displayed for those non-guaranteed
+attributes.
+Equivalent to @option{-dR --preserve=all}.
 
 @item -b
 @itemx @w...@kbd{--backup}[=@var{method}]}
@@ -7396,6 +7399,9 @@ Preserve in the destination files
 any links between corresponding source files.
 @c Give examples illustrating how hard links are preserved.
 @c Also, show how soft links map to hard links with -L and -H.
+...@itemx context
+Preserve SELinux security context of the file. @command{cp} will fail
+if the preserving of SELinux security context is not succesful.
 @itemx xattr
 Preserve extended attributes if @command{cp} is built with xattr support,
 and xattrs are supported and enabled on your file system.
@@ -7403,7 +7409,9 @@ If SELinux context and/or ACLs are implemented using xattrs,
 they are preserved by this option as 

[PATCH]: cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

2009-02-09 Thread Ondřej Vašík
Hello,
I sent patch about cp -a and it's failure to preserve SELinux context in
October 08. Meanwhile xattr support was added to cp. As described in
info pages -a option means Preserve as much as possible of the
structure and attributes of the original files. Therefore it should
preserve xattr if possible as well. This would mean additional possible
failure reports, which are not acceptable for cp -a option. Therefore I
had to remove displaying them for it.

After patch it should work like:
1) cp -a tries to preserve SELinux context and xattr, but doesn't inform
about possible failures
2) cp --preserve=all tries to preserve SELinux context and xattr, but
does inform about failures and doesn't fail if xattr/SELinux context are
not preserved
3) cp --preserve=context,xattr obviously tries to preserve attributes,
inform about failures and does fail if xattr/SELinux context is not
preserved

NOTE: Added documentation of --preserve=context, description of current
behaviour to cp --preserve=all and cp -a documentation. Added tests to
ensure that cp -a actually works with SELinux (until now it was checking
just failures. 


Greetings,
 Ondřej Vašík

From 09030e76d86411b86b6f64c6e0a8b8278f3f0c1f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= ova...@redhat.com
Date: Mon, 9 Feb 2009 15:44:00 +0100
Subject: [PATCH] cp: make -a option preserve SELinux context and xattrs with reduced diagnostics

NEWS: mention that behaviour
doc/coreutils.texi: document --preserve=context, document that diagnostics are
  not shown for failures of non-mandatory attributes(xattr,SELinux)
copy.c: reduce diagnostics for -a for SELinux context and xattr
copy.h: add boolean reduce_diagnostics to cp_options struct
cp.c: add preserving of xattr and SELinux context to -a, reduce failure
  diagnostics for it, add preserving xattr to --preserve=all, mention
  that cp -a behaves (almost) like cp -dR --preserve=all in usage
mv.c: set initial value for added boolean in cp_options
install.c: set initial value for added boolean in cp_options
tests/cp/cp-a-selinux: check not only failures, but succesful use
  of preserving SELinux context in cp
tests/misc/xattr: add tests for cp --preserve=all and cp -a
---
 NEWS  |6 +-
 doc/coreutils.texi|   14 +++---
 src/copy.c|   48 ++--
 src/copy.h|6 ++
 src/cp.c  |9 +++--
 src/install.c |2 ++
 src/mv.c  |2 ++
 tests/cp/cp-a-selinux |   22 ++
 tests/misc/xattr  |   15 +--
 9 files changed, 94 insertions(+), 30 deletions(-)

diff --git a/NEWS b/NEWS
index 8eae7cc..9e8e85e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,8 @@ GNU coreutils NEWS-*- outline -*-
 
   Add extended attribute support available on certain filesystems like ext2
   and XFS.
-cp: Tries to copy xattrs when --preserve=xattr specified
+cp: Tries to copy xattrs when --preserve=xattr or --preserve=all specified,
+ -a option tries to preserve xattrs but doesn't inform about failure
 mv: Always tries to copy xattrs
 install: Never copies xattrs
 
@@ -27,6 +28,9 @@ GNU coreutils NEWS-*- outline -*-
 
   cp uses much less memory in some situations
 
+  cp -a now correctly tries to preserve SELinux context (announced in 6.9.90),
+  doesn't inform about failure unlike with --preserve=all
+
   du --files0-from=FILE no longer reads all of FILE into RAM before
   processing the first file name
 
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index c3a1164..3d52390 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7253,8 +7253,11 @@ The program accepts the following options.  Also see @ref{Common options}.
 Preserve as much as possible of the structure and attributes of the
 original files in the copy (but do not attempt to preserve internal
 directory structure; i.e., @samp{ls -U} may list the entries in a copied
-directory in a different order).
-Equivalent to @option{-dpR}.
+directory in a different order). Try to preserve SELinux security context
+and extended attributes (xattrs) as well, but do not fail when this is not
+succesful. Diagnostic errors are not displayed for those non-guaranteed
+attributes.
+Equivalent to @option{-dR --preserve=all}.
 
 @item -b
 @itemx @w...@kbd{--backup}[=@var{method}]}
@@ -7396,6 +7399,9 @@ Preserve in the destination files
 any links between corresponding source files.
 @c Give examples illustrating how hard links are preserved.
 @c Also, show how soft links map to hard links with -L and -H.
+...@itemx context
+Preserve SELinux security context of the file. @command{cp} will fail
+if the preserving of SELinux security context is not succesful.
 @itemx xattr
 Preserve extended attributes if @command{cp} is built with xattr support,
 and xattrs are supported and enabled on your file

Re: date --date 4:59:54 1 hour 53 min 46 sec ago

2009-01-29 Thread Ondřej Vašík
Eric Blake wrote: 
 Bauke Jan Douma bjdouma at xs4all.nl writes:
 
 ~ $ date --date 4:59:54 1 hour 53 min 46 sec ago
 Wed Jan 28 06:52:08 CST 2009
 I've verified that the parse is unchanged between 6.10 and now (7.0+).
 It's got to be one of these gnulib patches:
 git log 30ffdfc..81e61b -- lib/getdate.y

Just as additional info - tried with basic 5.97 (without our patches)
and the different parsing is already there ... so I would say between
5.2.1 and 5.97 (to reduce number of commits to check)

Greetings,
  Ondrej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH]: chmod, chown, chgrp: Reduce verbosity of silent mode

2008-11-27 Thread Ondřej Vašík
Hello,
I got recently got one complaint ( no rhbz number at the moment :( )
about too verbose silent mode since using fts for directory traversal in
chmod/chown/chgrp. I guess those error messages should be suppressed in
silent mode.
Attached patch is doing that (making those error messages conditional).

Greetings,
 Ondřej Vašík

From 18b8f5bf5c18115d0546e42951dc951da58a549c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Thu, 27 Nov 2008 15:04:10 +0100
Subject: [PATCH] chmod, chown, chgrp: Reduce verbosity of silent mode

* chmod.c (process_file): Do not show fts directory-traversal errors
in silent mode
* chown-core.c (change_file_owner): Likewise
---
 src/chmod.c  |   24 +++-
 src/chown-core.c |   20 +---
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/chmod.c b/src/chmod.c
index 80fc363..75a25a5 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -67,7 +67,7 @@ static mode_t umask_value;
 /* If true, change the modes of directories recursively. */
 static bool recurse;
 
-/* If true, force silence (no error messages). */
+/* If true, force silence (suppress most of error messages). */
 static bool force_silent;
 
 /* If true, diagnose surprises from naive misuses like chmod -r file.
@@ -121,7 +121,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
 
   if (stat (file, new_stats) != 0)
 	{
-	  if (!force_silent)
+	  if (! force_silent)
 	error (0, errno, _(getting new attributes of %s), quote (file));
 	  return false;
 	}
@@ -203,24 +203,29 @@ process_file (FTS *fts, FTSENT *ent)
 	  fts_set (fts, ent, FTS_AGAIN);
 	  return true;
 	}
-  error (0, ent-fts_errno, _(cannot access %s), quote (file_full_name));
+  if (! force_silent)
+error (0, ent-fts_errno, _(cannot access %s),
+ quote (file_full_name));
   ok = false;
   break;
 
 case FTS_ERR:
-  error (0, ent-fts_errno, _(%s), quote (file_full_name));
+  if (! force_silent)
+error (0, ent-fts_errno, _(%s), quote (file_full_name));
   ok = false;
   break;
 
 case FTS_DNR:
-  error (0, ent-fts_errno, _(cannot read directory %s),
-	 quote (file_full_name));
+  if (! force_silent)
+error (0, ent-fts_errno, _(cannot read directory %s),
+	quote (file_full_name));
   ok = false;
   break;
 
 case FTS_SLNONE:
-  error (0, 0, _(cannot operate on dangling symlink %s),
-	 quote (file_full_name));
+  if (! force_silent)
+error (0, 0, _(cannot operate on dangling symlink %s),
+	quote (file_full_name));
   ok = false;
 
 default:
@@ -319,7 +324,8 @@ process_files (char **files, int bit_flags)
 	  if (errno != 0)
 	{
 	  /* FIXME: try to give a better message  */
-	  error (0, errno, _(fts_read failed));
+	  if (! force_silent)
+	error (0, errno, _(fts_read failed));
 	  ok = false;
 	}
 	  break;
diff --git a/src/chown-core.c b/src/chown-core.c
index 4ab52ac..9dbe374 100644
--- a/src/chown-core.c
+++ b/src/chown-core.c
@@ -296,18 +296,22 @@ change_file_owner (FTS *fts, FTSENT *ent,
 	  fts_set (fts, ent, FTS_AGAIN);
 	  return true;
 	}
-  error (0, ent-fts_errno, _(cannot access %s), quote (file_full_name));
+  if (! chopt-force_silent)
+error (0, ent-fts_errno, _(cannot access %s),
+ quote (file_full_name));
   ok = false;
   break;
 
 case FTS_ERR:
-  error (0, ent-fts_errno, _(%s), quote (file_full_name));
+  if (! chopt-force_silent)
+error (0, ent-fts_errno, _(%s), quote (file_full_name));
   ok = false;
   break;
 
 case FTS_DNR:
-  error (0, ent-fts_errno, _(cannot read directory %s),
-	 quote (file_full_name));
+  if (! chopt-force_silent)
+error (0, ent-fts_errno, _(cannot read directory %s),
+	quote (file_full_name));
   ok = false;
   break;
 
@@ -338,8 +342,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
 	{
 	  if (fstatat (fts-fts_cwd_fd, file, stat_buf, 0) != 0)
 	{
-	  error (0, errno, _(cannot dereference %s),
-		 quote (file_full_name));
+	  if (! chopt-force_silent)
+	error (0, errno, _(cannot dereference %s),
+		quote (file_full_name));
 	  ok = false;
 	}
 
@@ -492,7 +497,8 @@ chown_files (char **files, int bit_flags,
 	  if (errno != 0)
 	{
 	  /* FIXME: try to give a better message  */
-	  error (0, errno, _(fts_read failed));
+	  if (! chopt-force_silent)
+	error (0, errno, _(fts_read failed));
 	  ok = false;
 	}
 	  break;
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH]: typo in last units factorization patch

2008-11-26 Thread Ondřej Vašík
Hi Jim,
I spotted typo in your last factorization patch.
Patch to fix that attached, it also removes runcon/chcon item from TODO.

Ondřej

From 26563a7e759b5f9c2515d06b1efe7d1ccc2ca0ca Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Wed, 26 Nov 2008 16:00:57 +0100
Subject: [PATCH] doc: fix typo in units factorization, removed TODO items

* doc/coreutils: switch typo (switched gibibytes/gigabytes)
* TODO:  removed missing chcon and runcon documentation from list
---
 TODO   |2 --
 doc/coreutils.texi |8 
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/TODO b/TODO
index 7eaa157..f38c0b6 100644
--- a/TODO
+++ b/TODO
@@ -12,8 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime
   Discussed more recently on http://bugs.debian.org/497514.
 
 document the following in coreutils.texi:
-  runcon
-  chcon
   mktemp
   [
   pinky
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 16acd7e..cf56cad 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -630,8 +630,8 @@ multiplicative suffixes:
 @samp{K}  =   1024 (KibiBytes)
 @samp{MB} =  1000*1000 (MegaBytes)
 @samp{M}  =  1024*1024 (MebiBytes)
[EMAIL PROTECTED] = 1000*1000*1000 (GibiBytes)
[EMAIL PROTECTED]  = 1024*1024*1024 (GigaBytes)
[EMAIL PROTECTED] = 1000*1000*1000 (GigaBytes)
[EMAIL PROTECTED]  = 1024*1024*1024 (GibiBytes)
 @end example
 and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}.
 @end macro
@@ -645,8 +645,8 @@ multiplicative suffixes:
 @samp{K}  =   1024 (KibiBytes)
 @samp{MB} =  1000*1000 (MegaBytes)
 @samp{M}  =  1024*1024 (MebiBytes)
[EMAIL PROTECTED] = 1000*1000*1000 (GibiBytes)
[EMAIL PROTECTED]  = 1024*1024*1024 (GigaBytes)
[EMAIL PROTECTED] = 1000*1000*1000 (GigaBytes)
[EMAIL PROTECTED]  = 1024*1024*1024 (GibiBytes)
 @end example
 and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}.
 @end macro
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: ls: add --user-format option for user defined format

2008-11-20 Thread Ondřej Vašík
Pádraig Brady wrote:
 Ondřej Vašík wrote:
  Let's do some summary, feel free to add/comment items if you have
  something not mentioned here:
  
  What patched ls --user-format can and upstream find -printf not:
  1) colored files by LS_COLORS or automatically if requested
  2) could be used simply as ls alias for normal users - as they could
  still specify additional ls options like time-style, quoting-style,
  sorting style, blocksize, units and other things without modifying
  format string
  6) Automated column width computation (in find -printf you have to
  hardcode the column width in %N.NX syntax yourself, otherwise there is
  no defined human-readable column structure.)
 
  I guess points #1, #2, #6 are the most important things, as #1 and #2
  makes the output more user friendly and #6 generally readable by human
 
 Right.
 
 As I see it ls output is tuned for human consumption,
 while find is tuned for further consumption by other scripts/utils.

Exactly - I have the same opinion and I wrote it in the previous
email ... and as humans do differ and they could have different wishes
about format of output, I would expect something to tune output in ls -
without processing through awk/sed/whatever utilities.

 In my experience I've only needed to tweak output like this
 to ease the subsequent processing in scripts/utils. I.E. I've never needed it 
 in ls,

I'm quite sure that you (and Jim) never needed that option. Otherwise it
would had been already implemented. In my case it is slightly different.
I never needed that option, but I sometimes wished to have it.  For me
is ls -l too verbose and other ls formats too simple. I would like to
have something like with format colored_name_with_link
(owner:group:filetype:octalmode) Human-readable_size - so e.g.

bar  (bar :root:-:0664)  24K
baz  (baz :root:-:0664) 100K
bazlink - ./baz (root:root:l:0777)5
foo  (foo :foo :-:0664)  10K

That would be enough for me in most cases (octal form is enough for me,
in most cases I don't need ACL char, number of links and mostly not even
the time). Now I have to parse things out of very verbose long format
(and every user has to parse it). Easy, but I wish to have another
choice - and this choice could be --user-format option.

 I'm not sure it's
 worth duplicating this in ls (adding a lot of interface
 for all users to parse and most ignore).

You are right, it is a lot of interface for all users to parse. So
probably user-format description should be removed from --help
completely - and there should be only pointer that format is described
in info documentation.

Greetings,
 Ondrej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: chmod - do inform about using different mode than requested with SGID/SUID/sticky bits without permissions to change them

2008-11-20 Thread Ondřej Vašík
Jim Meyering wrote:
 Ondřej Vašík [EMAIL PROTECTED] wrote:
  as reported in
  https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/187315 by Aaron
  Toponce , chmod could display confusing messages when used for
  SGID/SUID/sticky bits without permissions to change them.
 
  e.g. with non-root sudoers user following scenario
  mkdir tmp;sudo chown .root tmp;ls -ld tmp;chmod -v 2755 tmp;ls -ld tmp;
  would lead to:
  drwxrwxr-x 2 Reset root 4096 24. říj 17.33 tmp
  mode of `tmp' changed to 2755 (rwxr-sr-x)
  drwxr-xr-x 2 Reset root 4096 24. říj 17.33 tmp
 
  So user is informed that sticky bit was set even if it was not.
 So, rather than trying to fix --changes, I'm leaning towards
 starting the process to remove it altogether.  From chmod,
 chown, and chgrp.
 
 This may seem extreme, until you realize that the option is inherently
 inaccurate in some cases.  And the only way it can be accurate is if
 PROG --changes ... were to stat each file after operating on it.
 Of course, I wouldn't do that for real.  We'd have to first
 deprecate the targeted options, making any use provoke a warning,
 and then -- years later -- un-document and finally, remove them.
 And I probably wouldn't even deprecate --verbose.
 
 What do you think?

Throwing out --changes should be ok, if user wants to be informed, he
can parse verbose output easily and common case is to use it without
verbose mode at all. Anyway --verbose output is affected by this issue
as well, so I would prefer to 
1) depricate --changes option as it could be substituted by --verbose
and grep
2) fix the verbose output to show correct output in every case where it
is possible. E.g. if the stat fails, it should inform the user that the
mode/owner/whatever is unknown. E.g. SGID bit case or stat failed is the
thing where user should be informed in verbose mode about something
unusual.

Greetings,
 Ondrej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: chmod - do inform about using different mode than requested with SGID/SUID/sticky bits without permissions to change them

2008-11-20 Thread Ondřej Vašík
Jim Meyering wrote:
 Ondřej Vašík [EMAIL PROTECTED] wrote:
  Throwing out --changes should be ok, if user wants to be informed, he
  can parse verbose output easily and common case is to use it without
  verbose mode at all. Anyway --verbose output is affected by this issue
  as well, so I would prefer to
  1) depricate --changes option as it could be substituted by --verbose
  and grep
  2) fix the verbose output to show correct output in every case where it
  is possible. E.g. if the stat fails, it should inform the user that the
  mode/owner/whatever is unknown. E.g. SGID bit case or stat failed is the
  thing where user should be informed in verbose mode about something
  unusual.
 
 Actually, I was thinking of making --verbose output *less* informative,
 so that it can be truthful, albeit less informative, without adding
 extra stat/lstat calls.  Sort of like chcon, which says simply
 
   changing security context of FILE
 
 While I do see the down-side of doing that, it seems better to print
 less information, with a guarantee of no lies, than to print
 usually-true messages along with the occasional untruth.

For me verbose mode is something useful to track problems. Therefore I
do prefer more informations there. Common usage of
chown/chmod/chgrp/chcon utilities is without --verbose/--changes mode,
so it would affect very low (close to zero) amount of users anyway.
 
I guess burden of of additional stat/lstat calls could be acceptable for
some kind of very verbose mode as it doesn't affect common users at all
and makes tracking of problems easier. Even for the price of potentially
untruth informations in very rare cases - if that risk is mentioned in
documentation.

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: chmod - do inform about using different mode than requested with SGID/SUID/sticky bits without permissions to change them

2008-11-20 Thread Ondřej Vašík
Andreas Schwab wrote:
 Eric Blake [EMAIL PROTECTED] writes:
 
  Would a double --verbose make sense?
 
 --verbose=2

Rather than some level-numbers I do prefer --verbose and
--verbose=high ...

Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: ls: add --user-format option for user defined format

2008-11-20 Thread Ondřej Vašík
Jim Meyering wrote:
   - is it worthwhile to add a --printf option to ls?
   I don't like the --user-format name)

  You know my opinion ... I guess it is worthwhile, as the consumer of
ls output is generally human and human wishes do differ. I'm ok with
--printf option, you are right - it would be better to keep conventions.

   - if so, should it use use a find -printf-compatible format string
   or one compatible to stat --printf?  Either way, it'll need a few
   extensions.

  I guess it should use find -printf style with some extensions. As ls
doesn't change much, I guess there will be not so many changes in the
interface in future. Some extensions would be necessary, some things,
maybe they could be mentioned explicitly in findutils and ls. Anyway it
is bad that there are already two different tools and interfaces (stat
--printf and find --printf) for exactly the same thing... as both are
usable only in scripts. Adding option to ls means human readability.
Additionally it would be good to unify stat --printf and find -printf
format at least for the %{filename} style format which was proposed as
possible future extension.

 I'm still on the fence.  On the one hand, I don't like to bloat
 ls further, even if it ends up using code that's shared with GNU find.
 On the other, I understand and sympathize with the desire to make ls
 output more useful/readable.

  There were already some wishes/requests to add that feature to ls.
Additionally - as I said, if the implementation of ls --printf option
would be improved (and I think it could be improved easily), it could
even simplify the ls.c code, as format options could be replaced just by
--printf format strings - so functions like print_with_commas,
print_horizontal, print_many_per_line and others could be removed
completely.
  As Pádraig mentioned there are some implementations of 'ls-like'
utilities doing the same (sls, limo and maybe others) - always
mentioning that the utility is add-on to ls - simply because users
expect that feature from ls. And I guess it would be better to have it
centralized in ls...

 Finally, if investing in ls, I'd rather invest in converting it to use
 fts for its hierarchy traversal.

  As the base code for ls --printf option (almost) exists, I hope I'll
be able to change the options (and to amend documentation) quite quickly
if the option with the objections from the discussion (at the moment I
guess verbosity on --help, different format from find -printf, name of
that option) will be generally accepted. Changing ls to use fts seems to
take much more time for me at the moment. But good TODO task...

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [Bug 294348] Re: ubuntu directing users to coreutils mailing list for general problems

2008-11-10 Thread Ondřej Vašík
Hi,
Jim Meyering wrote:
 James Youngman [EMAIL PROTECTED] wrote:
  Perhaps something like the attached patch to the usage message might
  be worthwhile (though I think it is probably too wordy).
 How about this?
 From 1ae69757c63e2d0d7e1103f7d17d7d256d625e55 Mon Sep 17 00:00:00 2001
 From: James Youngman [EMAIL PROTECTED]
 Date: Sat, 8 Nov 2008 21:55:50 +
 Subject: [PATCH] install: indicate clearly it's not for installing packages
  
 * src/install.c (usage): Indicate the program copies files,
 as opposed to installing packages.
 ...
 program_name, program_name, program_name, program_name);
fputs (_(\
 +\n\
 +This install program copies files (often just compiled) into destination\n\
 +locations you choose.  If you want to download and install a ready-to-use\n\
 +package on a GNU/Linux system, you should be using a package manager\n\
 +like yum(1) or apt-get(1).\n\
 +\n\
  In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to\n\
  the existing DIRECTORY, while setting permission modes and owner/group.\n\
  In the 4th form, create all components of the given DIRECTORY(ies).\n\
 --
 1.6.0.3.866.gc189b

Just two ideas:
1) I guess program_name variable should be used instead of install in
the first added sentence... although it is no-difference change on
almost every system and could be meant This install program generally
and not just This 'install' program.
2 (heretical)) What about shipping ginstall (and ginstall.1) with
install/install.1 just as symlinks pointing there ... Then you will get
pointer to ginstall manpage even for man install and such change should
not break anything ... In report bugs section will be something like
Report ginstall bugs to bug-coreutils@gnu.org which could be more
clear for everyone (ginstall word is simply not install word and
could not cause confusion).

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: ls: add --user-format option for user defined format

2008-11-10 Thread Ondřej Vašík
 code duplicities/amount caused by current ls
 --user-format patch. Additionally some options could be added to ls
 --user-format to choose e.g. displaying of total blocksize at the
 beginning of the output.
 I'm sure that I could reduce addition to the 4550 lines ls.c code
 to ~450 instead of 600 at the moment, which might be more acceptable.
 Some sections of code might be worth of sharing with find -printf.

 Will take considerable lower amount of time - as the functionality
 already works in ls --user-format patch, parser will be unified with
 the most of find -printf things, factorization could be done later.

3) To add some words about possibility of making user-defined output
 of file list by using find -printf to ls --format section and to
 improve find -printf support to support filetype colored filenames,
 SELinux/ACL character, SELinux context(and parts), human readable
 filesize and maybe other things which should be easy to add there.

 Will take lowest amount of time, but the functionality of ls will
 be not extended, some advantages thrown away. I don't like that
 solution as for me that patch is NOT duplicating find -printf
 functionality - it is offering additional value to ls usability.

I would prefer solution #2. Just want to note, that there is already
one completely different user-format style - in stat utility. So it
could be discussed whether to follow coreutils stat format style or
findutils find -printf format style more. Changing style for existing
utility is no-way, so we could not modify stat user-format I guess.

Complete implementation of find -printf options seems to be duplicate
work for me - e.g. time/style format options in find are not completely
documented in find man pages and basically you could do the same with
--time-style options (both using strftime() format), so there is already
one option to handle time-style and no need to duplicate it in the ls
format - as usually you need only one time-style for whole file entry.
But the rest should comply.
 
I tried to not affect the rest of code for non_user-format, so the patch
should have no performance impact for the rest. Benefit is that many
things are shared with the common ls formats, so it is consistent with
ls features (find output could differ - e.g. file types, size output for
devices (I guess it would be impossible to get output similar to ls -l
from find -printf when using on /dev )).

IMHO is that new long option for ls only additional value for ls and
generally useful thing... find -printf could reduce column width, but
could not compute automatic width, so if you would like to have general
alias without loss of data/wasting space, you can't. 

Generally find -printf use case is NOT the same as ls --user-format (or
printf, if renaming will be required).

Additionally, ls has simpler syntax to print directory content - e.g.
instead of
find . -mindepth 1 -maxdepth 1 \! -name .\* -printf my format
, you can just (for most of formats) use
ls --user-format=my format

I looked why the previous patches/requests for that ls option were
rejected, they generally do not have documentation, affects
unnecessarily general parts of the ls code and contain only basic subset
of possible format options. This patch covers all the ls functionality
(if not, please let me know what is missing), has minimal impact on the
rest of code and it is documented. Therefore please consider that long
option for ls again.

Greetings,
 Ondřej Vašík


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: ls: add --user-format option for user defined format

2008-11-04 Thread Ondřej Vašík
Pádraig Brady wrote:
 Thanks for doing that.
 However I thought that item had been removed from the TODO:
 http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00115.html
 This is a large patch to do essentially what `find -printf` already does.

Sorry, haven't seen that thread before.

I guess there are some things which you can't do with find -printf and
which you can do with that --user-format ls extension.
I would say there are few reasons why to use ls --user-format instead of
find -printf.

1) It has scalable column width (even possible to reduce width)
2) It has some options unavailable in findutils e.g. for SELinux
   context handling and filemode splitting/handling.
3) It is based on the informations you have completed by ls - so it 
   could be considered more reliable, e.g. it could have EXACTLY 
   the same output as ls -l otherwise have.
4) Is more frequent to use ls than find -printf for listing files, you
   could get colored filenames output with column. 

I agree that the patch is quite large, anyway what I have heard from the
guys around me, it would be useful to have that thing in ls. I tried to
not impact the rest of the ls code, so the changes to the main ls code
are pretty minimal (only some counting (and even that only for
user_format selected) and factorization of one function in
print_long_format).

Please consider those things before throwing that patch away.

Greetings,
 Ondřej


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: chmod - do inform about using different mode than requested with SGID/SUID/sticky bits without permissions to change them

2008-10-25 Thread Ondřej Vašík
Hello,
thanks for review and objections.

Paul Eggert wrote:
 Ondřej Vašík [EMAIL PROTECTED] writes:
 
  -  bool changed = (chmod_succeeded
  -  mode_changed (file, old_mode, new_mode));
  +  bool mode_change = mode_changed (file, old_mode, new_mode);
  +  bool changed = (chmod_succeeded  mode change);

Sorry, that change was obviously redundant...

  +
  +  if (chmod_succeeded  ((old_mode ^ new_mode)  CHMOD_MODE_BITS))
  +{
  +
  +  /* Changed to another mode than requested */
 
 This doesn't look right to me.  First, surely there's no need to invoke
 mode_changed if chmod_succeeded is false.  Second, ((old_mode ^
 new_mode)  CHMOD_MODE_BITS) doesn't tell us whether we changed to
 another mode than requested; mode_change tells us that.

About first you are right, that change was accidently added for other
approach and I forgot to remove it.
About second - that's not everytime true - as shown in the example -
SUID, SGID and sticky bits could be ignored in mode changed. That's
documented in info changes. Anyway user is then mistakenly informed that
mode was changed e.g. to 2755, but the real change was to 0755 - and
that's imho wrong.

  +  struct stat new_stats;
  +  char perms_requested[12];
  +  char perms_actual[12];
  +
  +  if (stat (file, new_stats) != 0)
 
 Third, this means we've invoked 'stat' twice on the file afterwards,
 once here, and once in mode_changed.  We should invoke 'stat' only in
 mode_changed.

You are right, that stat() call easy to reduce. So better solution for
that issue would be to check everything in mode_changed() function. 

Proposed amended patch is attached, should solve all your objections
about the previous patch.

Greetings,
  Ondřej Vašík

From ea697d3aa266f2d281b098b8c0b98157ed10e9b8 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 24 Oct 2008 17:24:09 +0200
Subject: [PATCH] chmod: inform in verbose if used mode for chmod was different than requested

* chmod (mode changed): Display a message in verbose when SUID, SGID or
sticky bit change was requested but not performed. Suggested by Aaron Toponce
* NEWS: Mention that change
---
 NEWS|3 +++
 src/chmod.c |   28 ++--
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 3fc0349..86f415b 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ GNU coreutils NEWS-*- outline -*-
   Rm was improved directly, while the others inherit the improvement
   from the newer version of fts in gnulib.
 
+  chmod now displays a message when SUID, SGID or sticky bit change was
+  requested, but not performed.
+
   comm now verifies that the inputs are in sorted order.  This check can
   be turned off with the --nocheck-order option.
 
diff --git a/src/chmod.c b/src/chmod.c
index 80fc363..3cdbf61 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -110,9 +110,9 @@ static struct option const long_options[] =
The old mode was OLD_MODE, but it was changed to NEW_MODE.  */
 
 static bool
-mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
+mode_changed (char const *file, mode_t old_mode, mode_t *new_mode)
 {
-  if (new_mode  (S_ISUID | S_ISGID | S_ISVTX))
+  if (*new_mode  (S_ISUID | S_ISGID | S_ISVTX))
 {
   /* The new mode contains unusual bits that the call to chmod may
 	 have silently cleared.  Check whether they actually changed.  */
@@ -125,11 +125,27 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
 	error (0, errno, _(getting new attributes of %s), quote (file));
 	  return false;
 	}
-
-  new_mode = new_stats.st_mode;
+  if (((new_stats.st_mode ^ *new_mode)  CHMOD_MODE_BITS) 
+ (verbosity == V_high)  ((old_mode ^ *new_mode)  CHMOD_MODE_BITS))
+{
+  /* Do we ignore SUID/SGID/sticky bit? Inform user in verbose! */
+  strmode (*new_mode, perms_requested);
+  perms_requested[10] = '\0';
+  strmode (new_stats.st_mode, perms_actual);
+  perms_actual[10] = '\0';
+  printf(
+_(can't change mode of %s to %04lo (%s), using %04lo (%s)\n),
+quote (file),
+(unsigned long int) (*new_mode  CHMOD_MODE_BITS),
+perms_requested[1],
+(unsigned long int) (new_stats.st_mode  CHMOD_MODE_BITS),
+perms_actual[1]);
+}
+
+  *new_mode = new_stats.st_mode;
 }
 
-  return ((old_mode ^ new_mode)  CHMOD_MODE_BITS) != 0;
+  return ((old_mode ^ *new_mode)  CHMOD_MODE_BITS) != 0;
 }
 
 /* Tell the user how/if the MODE of FILE has been changed.
@@ -260,7 +276,7 @@ process_file (FTS *fts, FTSENT *ent)
   if (verbosity != V_off)
 {
   bool changed = (chmod_succeeded
-		   mode_changed (file, old_mode, new_mode));
+		   mode_changed (file, old_mode, new_mode));
 
   if (changed || verbosity == V_high

[PATCH]: chmod - do inform about using different mode than requested with SGID/SUID/sticky bits without permissions to change them

2008-10-24 Thread Ondřej Vašík
Hello,
as reported in
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/187315 by Aaron
Toponce , chmod could display confusing messages when used for
SGID/SUID/sticky bits without permissions to change them.

e.g. with non-root sudoers user following scenario
mkdir tmp;sudo chown .root tmp;ls -ld tmp;chmod -v 2755 tmp;ls -ld tmp;
would lead to:
drwxrwxr-x 2 Reset root 4096 24. říj 17.33 tmp
mode of `tmp' changed to 2755 (rwxr-sr-x)
drwxr-xr-x 2 Reset root 4096 24. říj 17.33 tmp

So user is informed that sticky bit was set even if it was not.

After my patch output will be:
drwxrwxr-x 2 Reset root 4096 24. říj 17.35 tmp
can't change mode of `tmp' to 2755 (rwxr-sr-x), using 0755 (rwxr-xr-x)
mode of `tmp' changed to 0755 (rwxr-xr-x)
drwxr-xr-x 2 Reset root 4096 24. říj 17.35 tmp

That should reduce user's confusion and clarify what's really done by
chmod command.

Greetings,
 Ondřej Vašík

From 4eaf35f250ab6eec036b7ab21a482a76289f8303 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 24 Oct 2008 17:24:09 +0200
Subject: [PATCH] chmod: inform in verbose if used mode for chmod was different than requested

* chmod (process_file): Display a message when SUID, SGID or sticky bit change
was requested but not performed. Suggested by Aaron Toponce
* NEWS: Mention that change.
---
 NEWS|3 +++
 src/chmod.c |   37 +++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 3fc0349..86f415b 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ GNU coreutils NEWS-*- outline -*-
   Rm was improved directly, while the others inherit the improvement
   from the newer version of fts in gnulib.
 
+  chmod now displays a message when SUID, SGID or sticky bit change was
+  requested, but not performed.
+
   comm now verifies that the inputs are in sorted order.  This check can
   be turned off with the --nocheck-order option.
 
diff --git a/src/chmod.c b/src/chmod.c
index 80fc363..87f8199 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -259,8 +259,41 @@ process_file (FTS *fts, FTSENT *ent)
 
   if (verbosity != V_off)
 {
-  bool changed = (chmod_succeeded
-		   mode_changed (file, old_mode, new_mode));
+  bool mode_change = mode_changed (file, old_mode, new_mode);
+  bool changed = (chmod_succeeded  mode change);
+
+  if (chmod_succeeded  ((old_mode ^ new_mode)  CHMOD_MODE_BITS))
+{
+
+  /* Changed to another mode than requested */
+  struct stat new_stats;
+  char perms_requested[12];
+  char perms_actual[12];
+
+  if (stat (file, new_stats) != 0)
+{
+  if (!force_silent)
+error (0, errno, _(getting new attributes of %s),
+  quote (file));
+  ok = false;
+}
+
+  strmode (new_mode, perms_requested);
+  perms_requested[10] = '\0';
+  strmode (new_stats.st_mode, perms_actual);
+  perms_actual[10] = '\0';
+  printf(
+_(can't change mode of %s to %04lo (%s), using %04lo (%s)\n),
+quote (file),
+(unsigned long int) (new_mode  CHMOD_MODE_BITS),
+perms_requested[1],
+(unsigned long int) (new_stats.st_mode  CHMOD_MODE_BITS),
+perms_actual[1]);
+
+/* Change mode to actual mode after change for verbose output */
+new_mode = new_stats.st_mode;
+  }
+
 
   if (changed || verbosity == V_high)
 	{
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH] : ls: clarify documentation of exit statuses

2008-10-09 Thread Ondřej Vašík
Hello,
as reported in rh bz#446294 , ls is not very clear with it's exit status
documentation. This patch should clarify it a bit.

Greetings,
 Ondřej Vašík

From a3ef5a58f396b53287d7870d2cf35198789240cf Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Thu, 9 Oct 2008 10:56:54 +0200
Subject: [PATCH] ls: clarify exit status of command

ls.c (exit_status): clarify comments of exit statuses
 (usage): specify what is minor and serious trouble
coreutils.texi (ls invocation): clarify exit status documentation
---
 doc/coreutils.texi |6 --
 src/ls.c   |   12 +---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 11b9ab9..e0b0249 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -6070,8 +6070,10 @@ Exit status:
 
 @display
 0 success
-1 minor problems (e.g., a subdirectory was not found)
-2 serious trouble (e.g., memory exhausted)
+1 minor problems (e.g., a subdirectory not mentioned in command line
+  argument was not found)
+2 serious trouble (e.g., memory exhausted, invalid option or could
+  not find file or directory specified in command line argument)
 @end display
 
 Also see @ref{Common options}.
diff --git a/src/ls.c b/src/ls.c
index e107162..3d0550a 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -716,10 +716,11 @@ static int exit_status;
 enum
   {
 /* ls had a minor problem (e.g., it could not stat a directory
-   entry).  */
+   entry not mentioned in command line argument).  */
 LS_MINOR_PROBLEM = 1,
 
-/* ls had more serious trouble.  */
+/* ls had more serious trouble (e.g., memory exhausted, invalid
+   option or could not stat an entry from command line argument.  */
 LS_FAILURE = 2
   };
 
@@ -4527,7 +4528,12 @@ colors, and can be set easily by the dircolors command.\n\
 ), stdout);
   fputs (_(\
 \n\
-Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.\n\
+Exit status:\n\
+0 if OK,
+1 if minor problems(e.g., a subdirectory not mentioned in command line\n\
+  argument was not found),\n\
+2 if serious trouble(e.g., memory exhausted, invalid option or could\n\
+  not find file or directory specified in command line argument).\n\
 ), stdout);
   emit_bug_reporting_address ();
 }
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: Basic info documentation for SELinux context related commands runcon and chcon

2008-10-07 Thread Ondřej Vašík
Hi,

Jim Meyering wrote:
 Ondřej Vašík [EMAIL PROTECTED] wrote:
  as those commands were not documented in info documentation, I wrote
  basic info documentation for runcon and chcon command (and related
  SELinux context menu section). It is completely based on man
  documentation, I would say just the first step to have them documented.
  Patch is in attachement.
 
 Thanks for doing that!
 
 I've added to your patch with the following.
 Please fold this into yours and add similar mark-up for runcon.
 Also, it'd be good to document the exit status values that runcon uses,
 as is done for at least nohup and timeout.
 
 From 246ef8da7b03037e1666c9a1ff479ab3fdec14e2 Mon Sep 17 00:00:00 2001
 From: Jim Meyering [EMAIL PROTECTED]
 Date: Tue, 7 Oct 2008 00:03:35 +0200
 Subject: [PATCH] tweak wording, add formatting like @var, @option
 
 ---
  doc/coreutils.texi |   81 ---
  1 files changed, 38 insertions(+), 43 deletions(-)

Thanks for review and suggested/requested changes. Here is amended patch
with all of your changes(and similar changes for runcon). 

Greetings,
 Ondřej

P.S. sorry for double post, accidently forgot to cc mailing list


From cd506e1bd2995fd2c322362a39a6d35b8e474d48 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Mon, 6 Oct 2008 14:18:53 +0200
Subject: [PATCH] Coreutils.texi: Document runcon and chcon in SELinux context section

* coreutils.texi: Document commands runcon and chcon,
add SELinux context section
---
 doc/coreutils.texi |  182 +++-
 1 files changed, 181 insertions(+), 1 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 67da740..4dfde8a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -32,7 +32,6 @@
 @c * [: (coreutils)[ invocation.   File/string tests.
 @c * pinky: (coreutils)pinky invocation.   FIXME.
 @c * mktemp: (coreutils)mktemp invocation. FIXME.
[EMAIL PROTECTED] * chcon: (coreutils)chcon invocation.   FIXME.
 
 @dircategory Individual utilities
 @direntry
@@ -40,6 +39,7 @@
 * base64: (coreutils)base64 invocation. Base64 encode/decode data.
 * basename: (coreutils)basename invocation. Strip directory and suffix.
 * cat: (coreutils)cat invocation.   Concatenate and write files.
+* chcon: (coreutils)chcon invocation.   Change SELinux CTX of files.
 * chgrp: (coreutils)chgrp invocation.   Change file groups.
 * chmod: (coreutils)chmod invocation.   Change file permissions.
 * chown: (coreutils)chown invocation.   Change file owners/groups.
@@ -95,6 +95,7 @@
 * readlink: (coreutils)readlink invocation. Print referent of a symlink.
 * rm: (coreutils)rm invocation. Remove files.
 * rmdir: (coreutils)rmdir invocation.   Remove empty directories.
+* runcon: (coreutils)runcon invocation. Run in specified SELinux CTX.
 * seq: (coreutils)seq invocation.   Print numeric sequences
 * sha1sum: (coreutils)sha1sum invocation.   Print or check SHA-1 digests.
 * sha2: (coreutils)sha2 utilities.  Print or check SHA-2 digests.
@@ -194,6 +195,7 @@ Free Documentation License''.
 * Working context::pwd stty printenv tty
 * User information::   id logname whoami groups users who
 * System context:: date uname hostname hostid uptime
+* SELinux context::chcon runcon
 * Modified command invocation::chroot env nice nohup su timeout
 * Process control::kill
 * Delaying::   sleep
@@ -421,6 +423,10 @@ System context
 * Date input formats::   Specifying date strings.
 * Examples of date:: Examples.
 
+SELinux context
+* chcon invocation:: Change SELinux context of file
+* runcon invocation::Run a command in specified SELinux context
+
 Modified command invocation
 
 * chroot invocation::Run a command with a different root directory
@@ -12882,6 +12888,180 @@ information.
 * uptime invocation::   Print system uptime and load
 @end menu
 
[EMAIL PROTECTED] SELinux context
[EMAIL PROTECTED] SELinux context
+
[EMAIL PROTECTED] SELinux context
[EMAIL PROTECTED] SELinux, context
[EMAIL PROTECTED] commands for SELinux context
+
+This section describes commands for operations with SELinux
+contexts.
+
[EMAIL PROTECTED]
+* chcon invocation::Change SELinux context of file
+* runcon invocation::   Run a command in specified SELinux context
[EMAIL PROTECTED] menu
+
[EMAIL PROTECTED] chcon invocation
[EMAIL PROTECTED] @command{chcon}: Change SELinux context of file.
+
[EMAIL PROTECTED] chcon
[EMAIL PROTECTED] changing security context
[EMAIL PROTECTED] change SELinux context
+
+
[EMAIL PROTECTED] changes the SELinux security context of the selected files.
+Synopses

[PATCH]: cp '-a' should try to preserve SELinux context, SELinux context cp documentation adjustments

2008-10-07 Thread Ondřej Vašík
Hello,
as documented in NEWS and as written in test cp-a-selinux, cp -a should
try to preserve selinux context, if possible. The activation boolean
preserve_security_context was missing in this branch. Also cp -a is not
really equivalent to -dpR, but to -dR --preserve-all , as it tries(or at
least it should try) SELinux context. Following changes were done to
make documentation more precise and preserve=context and preserve=all
behaviour after failure SELinux context preserving is documented by that
patch as well.

Greetings,
 Ondřej Vašík

From bc163403999c973be4050fa29000122c3706ce0f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Tue, 7 Oct 2008 16:43:49 +0200
Subject: [PATCH] cp: document selinux options, preserving SELinux context for '-a' option

* coreutils.texi(cp invocation): Document SELinux related things
* cp.c (main): adjust '-a' option to preserve SELinux context if possible
---
 doc/coreutils.texi |   11 ---
 src/cp.c   |6 --
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 67da740..a7c0da3 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7227,8 +7227,9 @@ The program accepts the following options.  Also see @ref{Common options}.
 Preserve as much as possible of the structure and attributes of the
 original files in the copy (but do not attempt to preserve internal
 directory structure; i.e., @samp{ls -U} may list the entries in a copied
-directory in a different order).
-Equivalent to @option{-dpR}.
+directory in a different order). Try to preserve SELinux security context
+as well, but do not fail when this is not succesful.
+Equivalent to @option{-dR --preserve=all}.
 
 @item -b
 @itemx @[EMAIL PROTECTED]@var{method}]}
@@ -7358,9 +7359,13 @@ Preserve in the destination files
 any links between corresponding source files.
 @c Give examples illustrating how hard links are preserved.
 @c Also, show how soft links map to hard links with -L and -H.
[EMAIL PROTECTED] context
+Preserve SELinux security context of the file. @command{cp} will fail
+if the preserving of SELinux security context is not succesful.
 @itemx all
 Preserve all file attributes.
-Equivalent to specifying all of the above.
+Equivalent to specifying all of the above. Ignores failure of 
+preserving SELinux security context.
 @end table
 
 Using @option{--preserve} with no @var{attribute_list} is equivalent
diff --git a/src/cp.c b/src/cp.c
index 77d4702..f09f96f 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -174,7 +174,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
 Mandatory arguments to long options are mandatory for short options too.\n\
 ), stdout);
   fputs (_(\
-  -a, --archivesame as -dpR\n\
+  -a, --archivesame as -dR --preserve=all\n\
   --backup[=CONTROL]   make a backup of each existing destination file\n\
   -b   like --backup but does not accept an argument\n\
   --copy-contents  copy contents of special files when recursive\n\
@@ -920,13 +920,15 @@ main (int argc, char **argv)
  sparse_type_string, sparse_type);
 	  break;
 
-	case 'a':		/* Like -dpR. */
+	case 'a':		/* Like -dR --preserve=all. */
 	  x.dereference = DEREF_NEVER;
 	  x.preserve_links = true;
 	  x.preserve_ownership = true;
 	  x.preserve_mode = true;
 	  x.preserve_timestamps = true;
 	  x.require_preserve = true;
+	  if (selinux_enabled)
+	 x.preserve_security_context = true;
 	  x.recursive = true;
 	  break;
 
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH]: Invalid nonimplemented option in chcon

2008-10-06 Thread Ondřej Vašík
Hello,
as reported in RedHat bugzilla #463883, chcon option -c is described in
help, but not implemented. After short talk with Jim via IRC decision
was to remove this option and related things from chcon source code
completetely.
It is done in attached patch.

Greetings,
 Ondřej Vašík

From 723305ee365f6045f2edc1a6018cc49ec781e3fa Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Mon, 6 Oct 2008 12:42:45 +0200
Subject: [PATCH] chcon: Remove unused enums, remove not implemented '-c' option from help

* chcon.c (main): Remove option 'c' from help messages and getopt,
remove no longer used related enums
---
 src/chcon.c |   23 +--
 1 files changed, 1 insertions(+), 22 deletions(-)

diff --git a/src/chcon.c b/src/chcon.c
index c929cdf..022858a 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -35,26 +35,6 @@
   proper_name (Russell Coker), \
   proper_name (Jim Meyering)
 
-enum Change_status
-{
-  CH_NOT_APPLIED,
-  CH_SUCCEEDED,
-  CH_FAILED,
-  CH_NO_CHANGE_REQUESTED
-};
-
-enum Verbosity
-{
-  /* Print a message for each file that is processed.  */
-  V_high,
-
-  /* Print a message for each file whose attributes we change.  */
-  V_changes_only,
-
-  /* Do not be verbose.  This is the default. */
-  V_off
-};
-
 /* If nonzero, and the systems has support for it, change the context
of symbolic links rather than any files they point to.  */
 static bool affect_symlink_referent;
@@ -369,7 +349,6 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
 Change the security context of each FILE to CONTEXT.\n\
 With --reference, change the security context of each FILE to that of RFILE.\n\
 \n\
-  -c, --changes  like verbose but report only when a change is made\n\
   -h, --no-dereference   affect symbolic links instead of any referenced file\n\
 ), stdout);
   fputs (_(\
@@ -430,7 +409,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  while ((optc = getopt_long (argc, argv, HLPRchvu:r:t:l:, long_options, NULL))
+  while ((optc = getopt_long (argc, argv, HLPRhvu:r:t:l:, long_options, NULL))
 	 != -1)
 {
   switch (optc)
-- 
1.5.6.1.156.ge903b



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


[PATCH]: Basic info documentation for SELinux context related commands runcon and chcon

2008-10-06 Thread Ondřej Vašík
Hello,
as those commands were not documented in info documentation, I wrote
basic info documentation for runcon and chcon command (and related
SELinux context menu section). It is completely based on man
documentation, I would say just the first step to have them documented.
Patch is in attachement.

Greetings,
  Ondřej Vašík

From 0b46a52b8f94fcbf145e0def84174cadd06bc4d2 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Mon, 6 Oct 2008 14:18:53 +0200
Subject: [PATCH] Coreutils.texi: Document runcon and chcon in SELinux context section

* coreutils.texi: Document commands runcon and chcon,
add SELinux context section
---
 doc/coreutils.texi |  177 +++-
 1 files changed, 176 insertions(+), 1 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 67da740..48976ee 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -32,7 +32,6 @@
 @c * [: (coreutils)[ invocation.   File/string tests.
 @c * pinky: (coreutils)pinky invocation.   FIXME.
 @c * mktemp: (coreutils)mktemp invocation. FIXME.
[EMAIL PROTECTED] * chcon: (coreutils)chcon invocation.   FIXME.
 
 @dircategory Individual utilities
 @direntry
@@ -40,6 +39,7 @@
 * base64: (coreutils)base64 invocation. Base64 encode/decode data.
 * basename: (coreutils)basename invocation. Strip directory and suffix.
 * cat: (coreutils)cat invocation.   Concatenate and write files.
+* chcon: (coreutils)chcon invocation.   Change SELinux CTX of files.
 * chgrp: (coreutils)chgrp invocation.   Change file groups.
 * chmod: (coreutils)chmod invocation.   Change file permissions.
 * chown: (coreutils)chown invocation.   Change file owners/groups.
@@ -95,6 +95,7 @@
 * readlink: (coreutils)readlink invocation. Print referent of a symlink.
 * rm: (coreutils)rm invocation. Remove files.
 * rmdir: (coreutils)rmdir invocation.   Remove empty directories.
+* runcon: (coreutils)runcon invocation. Run file in specif. SELinux CTX.
 * seq: (coreutils)seq invocation.   Print numeric sequences
 * sha1sum: (coreutils)sha1sum invocation.   Print or check SHA-1 digests.
 * sha2: (coreutils)sha2 utilities.  Print or check SHA-2 digests.
@@ -194,6 +195,7 @@ Free Documentation License''.
 * Working context::pwd stty printenv tty
 * User information::   id logname whoami groups users who
 * System context:: date uname hostname hostid uptime
+* SELinux context::chcon runcon
 * Modified command invocation::chroot env nice nohup su timeout
 * Process control::kill
 * Delaying::   sleep
@@ -421,6 +423,10 @@ System context
 * Date input formats::   Specifying date strings.
 * Examples of date:: Examples.
 
+SELinux context
+* chcon invocation:: Change SELinux context of file
+* runcon invocation::Run file in specified SELinux context
+
 Modified command invocation
 
 * chroot invocation::Run a command with a different root directory
@@ -12882,6 +12888,175 @@ information.
 * uptime invocation::   Print system uptime and load
 @end menu
 
[EMAIL PROTECTED] SELinux context
[EMAIL PROTECTED] SELinux context
+
[EMAIL PROTECTED] SELinux context
[EMAIL PROTECTED] SELinux, context
[EMAIL PROTECTED] commands for SELinux context
+
+This section describes commands for operations with SELinux
+contexts.
+
[EMAIL PROTECTED]
+* chcon invocation::Change SELinux context of file
+* runcon invocation::   Run file in specified SELinux context
[EMAIL PROTECTED] menu
+
[EMAIL PROTECTED] chcon invocation
[EMAIL PROTECTED] @command{chcon}: Change SELinux context of file.
+
[EMAIL PROTECTED] chcon
[EMAIL PROTECTED] changing security context
[EMAIL PROTECTED] change SELinux context
+
+
[EMAIL PROTECTED] changes SELinux security context of the file.
+Synopses:
+
[EMAIL PROTECTED]
+chcon [EMAIL PROTECTED]@dots{} CONTEXT @[EMAIL PROTECTED]
+chcon [EMAIL PROTECTED]@dots{} [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] @[EMAIL PROTECTED]
+chcon [EMAIL PROTECTED]@dots{} --reference=RFILE @[EMAIL PROTECTED]
[EMAIL PROTECTED] smallexample
+
+Change  the  SELinux  security  context  of each FILE to CONTEXT.  With
+--reference, change the security context of each FILE to that of RFILE.
+
+The program accepts the following options.  Also see @ref{Common options}.
+
[EMAIL PROTECTED] @samp
+
[EMAIL PROTECTED] -h
[EMAIL PROTECTED] --no-dereference
[EMAIL PROTECTED] -h
[EMAIL PROTECTED] --no-dereference
[EMAIL PROTECTED] no dereference
+Affect symbolic links instead of any referenced file
+
[EMAIL PROTECTED] --reference=RFILE
[EMAIL PROTECTED] --reference
[EMAIL PROTECTED] reference file
+Use  RFILE’s  security  context rather than specifying a CONTEXT

Issue with ls -v / sort -V and strverscmp() usage

2008-09-03 Thread Ondřej Vašík
Hello,
as reported in RH bugzilla #253817
(https://bugzilla.redhat.com/show_bug.cgi?id=253817), there is an issue
with ls -v (and there will be same issue with sort -V soon). Problem is
with sorting files with extensions or dist-tags (like .tar.gz)
because .tar.gz is more than .1.tar.gz. Therefore foo-5.0.tar.gz will be
considered as later version than foo-5.0.1.tar.gz . As ls -v and sort -V
now use glibc strverscmp() and this function is not going to change
(http://sourceware.org/bugzilla/show_bug.cgi?id=3506) , I would like to
know your opinion how to solve the issue. I see several possible ways
how to solve it: 
1) keep it as it is and document those limitations
2) to use gnulib strverscmp() for ls -v and sort -V and to modify it
somehow to handle such cases correctly
3) to use/create different function for handling version sort (like
rpmvercmp in rpm/rpmlib.h recommended in glibc strverscmp() bugzilla)

Which way do you like? Or do you have different ideas?

Greetings,
 Ondrej Vasik


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Issue with ls -v / sort -V and strverscmp() usage

2008-09-03 Thread Ondřej Vašík
Bruno Haible wrote:
 Ondřej Vašík wrote:
  3) to use/create different function for handling version sort (like
  rpmvercmp in rpm/rpmlib.h recommended in glibc strverscmp() bugzilla)
 
 Does rpmvercmp have the above property?

Similar. It separates name, epoch, version, release and architecture and
compares those. Uses subsections of alphanum segments separated by
non-alphanum chars. When same segment have different types, numeric is
always considered as newer than alpha or alphanum. This solves issue
with suffix, but changes behaviour for prefix (name) - as fully numeric
project/file name will be considered as newer than alphanum
project/file name and will be listed after alphanumeric names.

Greetings,
 Ondrej Vasik


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: Fix for several getdate.y issues (amended patch #3)

2008-07-25 Thread Ondřej Vašík
Jim Meyering wrote:
 Documenting in getdate.texi will be enough, because that file is
 included by coreutils.texi.  Thanks!

Ok, here is amended version of the patch, first two (or less) digits are
considered as hours, TZ correction limit set to +/-24:00, both changes
in behaviour documented in getdate.texi.

Greetings,
 Ondrej

From cf9655b40b3850e0d848490674949997f5b9402f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 25 Jul 2008 15:29:40 +0200
Subject: [PATCH] getdate.y: add limits for TZ, handle TZ +HH format correctly

 * doc/getdate.texi: Document new behaviour and limits of time zone
 correction
 * lib/getdate.y (time_zone_hh_mm): Allow only TZ in the range
 UTC-24 to UTC+24 hours, consider first two digits of TZ as hours
 when no minutes specified. Invalid TZ will cause invalid date format
 error.
 * tests/test-getdate.c: Tests for that change

---
 ChangeLog|8 ++
 doc/getdate.texi |   10 ---
 lib/getdate.y|   34 --
 tests/test-getdate.c |   63 ++
 4 files changed, 103 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6c48308..b19680f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-25  Ondřej Vašík  [EMAIL PROTECTED]
+
+	getdate.y: Allow only timezone range specified by POSIX
+	* lib/getdate.y (time_zone_hhmm): Allow only TZ in the range
+	-24 to +24 hours, consider first two digits	as hours. Invalid TZ
+	should cause invalid format error.
+	* tests/test-getdate.c: Tests for the fix
+
 2008-07-23  Ulrich Drepper  [EMAIL PROTECTED]
 
 	mktime.c: normalize tp-tm_isdst value to -1/0/1.
diff --git a/doc/getdate.texi b/doc/getdate.texi
index eae4526..687d187 100644
--- a/doc/getdate.texi
+++ b/doc/getdate.texi
@@ -271,10 +271,12 @@ forces interpretation of the time relative to
 Coordinated Universal Time (@sc{utc}), overriding any previous
 specification for the time zone or the local time zone.  For example,
 @samp{+0530} and @samp{+05:30} both stand for the time zone 5.5 hours
-ahead of @sc{utc} (e.g., India).  The @var{minute}
-part of the time of day may not be elided when a time zone correction
-is used.  This is the best way to specify a time zone correction by
-fractional parts of an hour.
+ahead of @sc{utc} (e.g., India). Only time zone correction between -24:00  
+and +24:00 from basic UTC0 time zone is accepted. Time zones outside of this 
+range are considered as invalid. If you specify only two or less digits, they 
+are interpreted as hours. The @var{minute} part of the time of day may not 
+be elided when a time zone correction is used.  This is the best way to 
+specify a time zone correction by fractional parts of an hour.
 
 Either @samp{am}/@samp{pm} or a time zone correction may be specified,
 but not both.
diff --git a/lib/getdate.y b/lib/getdate.y
index 695fd59..9fe2181 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -205,7 +205,7 @@ typedef struct
 union YYSTYPE;
 static int yylex (union YYSTYPE *, parser_control *);
 static int yyerror (parser_control const *, char const *);
-static long int time_zone_hhmm (textint, long int);
+static long int time_zone_hhmm (parser_control *, textint, long int);
 
 /* Extract into *PC any date and time info from a string of digits
of the form e.g., MMDD, YYMMDD, HHMM, HH (and sometimes YYY,
@@ -358,7 +358,7 @@ time:
 	set_hhmmss (pc, $1.value, $3.value, 0, 0);
 	pc-meridian = MER24;
 	pc-zones_seen++;
-	pc-time_zone = time_zone_hhmm ($4, $5);
+	pc-time_zone = time_zone_hhmm (pc, $4, $5);
   }
   | tUNUMBER ':' tUNUMBER ':' unsigned_seconds o_merid
   {
@@ -370,7 +370,7 @@ time:
 	set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec);
 	pc-meridian = MER24;
 	pc-zones_seen++;
-	pc-time_zone = time_zone_hhmm ($6, $7);
+	pc-time_zone = time_zone_hhmm (pc, $6, $7);
   }
   ;
 
@@ -394,7 +394,7 @@ zone:
   { pc-time_zone = $1;
 	apply_relative_time (pc, $2, 1); }
   | tZONE tSNUMBER o_colon_minutes
-  { pc-time_zone = $1 + time_zone_hhmm ($2, $3); }
+  { pc-time_zone = $1 + time_zone_hhmm (pc, $2, $3); }
   | tDAYZONE
   { pc-time_zone = $1 + 60; }
   | tZONE tDST
@@ -795,15 +795,33 @@ static table const military_table[] =
 
 /* Convert a time zone expressed as HH:MM into an integer count of
minutes.  If MM is negative, then S is of the form HHMM and needs
-   to be picked apart; otherwise, S is of the form HH.  */
+   to be picked apart; otherwise, S is of the form HH. As specified at
+   http://www.opengroup.org/onlinepubs/95399/basedefs/xbd_chap08.html
+   allow only valid TZ range, consider first two digits as hours, if no
+   minutes specified */
 
 static long int
-time_zone_hhmm (textint s, long int mm)
+time_zone_hhmm (parser_control *pc, textint s, long int mm)
 {
+  long int returnvalue;
+
+  /* if 's' length is two or less, consider it as hours when no
+ minutes specified

Re: [PATCH]: Fix for several getdate.y issues (amended patch #3)

2008-07-21 Thread Ondřej Vašík
Hello,
Jim Meyering wrote:
 I'm a little leery of this patch, because it makes interpretation
 of UTC+dd and UTC-dd dependent on the value of dd.  For dd = 14, dd
 represents hours.  Otherwise, it represents minutes.  That would have
 to be documented, but seems odd enough that my reflex is to avoid the
 change so I don't have to document something so strange.

You are right, it has to be documented or changed. Opengroup
specification for offset in ENVVAR TZ states that first two numbers
should be considered as hours. Therefore one possible solution could be
to replace my change for dd = 14 with dd=99 (or other way to separate
two digit specification) and documenting it - it would be easier to
understand and hopefully will not break anything. Current situation
causes behaviour that commonly used UTC+5 format is misinterpreted as
UTC+0:05. 
I used the dd = 14 approach to allow TZ UTC+00:20 to be written UTC
+0020 (or UTC+20)... there are no TZ in use between UTC and UTC+/-1 now,
but there used to be several in the past. None of them was shifted by
less than 20 minutes(+0:20, -0:25, +0:30 , -0:44 were used, latest
stopped in 1972). Anyway POSIX specification for TZ ENVVAR could be good
excuse to not support fully that unlikely TZ offset - UTC-0:44 will
still work.
Where should I document current the changes? In gnulib getdate.texi
only? Or in both gnulib and coreutils documentation?

Greetings,
 Ondrej Vasik


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: Fix for several getdate.y issues (amended patch #3)

2008-07-04 Thread Ondřej Vašík
Hello,
as discussed with Jim Meyering via IRC, I'm sending changed version of
the patch #3 to the list. This one patch adds range to valid TZ and
handles correctly hours when no minutes are specified (until that patch
is UTC+14 handled incorrectly as UTC+0:14) and are in common range of
UTC-12 to UTC+14. 
Although there are few different implementations of TZ limits (Microsoft
uses range UTC-14 to UTC+14 , various sources show that only TZ between
UTC-12 and UTC+14 are in use), this patch uses range UTC-24 to UTC+24 as
recommended for TZ environmental variable in POSIX
(http://www.opengroup.org/onlinepubs/95399/basedefs/xbd_chap08.html).
After applying that patch invalid TZ will show an invalid date format
error (because of double increment of pc-zones_seen).
I added few tests to gnulib getdate test suite to check if various TZ
formats are showing the same result.

Greetings,
 Ondrej Vasik

From 1c284d1a4155136ddaee44eab7fd5d55a75962fc Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 4 Jul 2008 17:44:57 +0200
Subject: [PATCH] getdate.y: add limits for TZ, handle TZ +HH format correctly

* lib/getdate.y (time_zone_hh_mm): Allow only TZ in the range
UTC-24 to UTC+24 hours, consider first two digits of TZ as hours
when no minutes are specified and number is in the range -14
and +14 (as common TZ ranges UTC-12 to UTC+14). Invalid TZ will
cause invalid date format error.
* tests/test-getdate.c: Tests for that change
---
 ChangeLog|9 
 lib/getdate.y|   35 ++---
 tests/test-getdate.c |   51 ++
 3 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6c5f522..076d70e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-07-04  Ondřej Vašík  [EMAIL PROTECTED]
+
+	getdate.y: Allow only timezone range specified by POSIX
+	* lib/getdate.y (time_zone_hhmm): Allow only TZ in the range
+	-24 to +24 hours, consider first two digits between -14 and 14
+	as hours (as common TZ ranges UTC-12 to UTC+14). Invalid TZ
+	will cause invalid format error.
+	* tests/test-getdate.c: Tests for the fix
+
 2008-07-04  Jim Meyering  [EMAIL PROTECTED]
 
 	* users.txt: Add vc-dwim.
diff --git a/lib/getdate.y b/lib/getdate.y
index 695fd59..ace35be 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -205,7 +205,7 @@ typedef struct
 union YYSTYPE;
 static int yylex (union YYSTYPE *, parser_control *);
 static int yyerror (parser_control const *, char const *);
-static long int time_zone_hhmm (textint, long int);
+static long int time_zone_hhmm (parser_control *, textint, long int);
 
 /* Extract into *PC any date and time info from a string of digits
of the form e.g., MMDD, YYMMDD, HHMM, HH (and sometimes YYY,
@@ -358,7 +358,7 @@ time:
 	set_hhmmss (pc, $1.value, $3.value, 0, 0);
 	pc-meridian = MER24;
 	pc-zones_seen++;
-	pc-time_zone = time_zone_hhmm ($4, $5);
+	pc-time_zone = time_zone_hhmm (pc, $4, $5);
   }
   | tUNUMBER ':' tUNUMBER ':' unsigned_seconds o_merid
   {
@@ -370,7 +370,7 @@ time:
 	set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec);
 	pc-meridian = MER24;
 	pc-zones_seen++;
-	pc-time_zone = time_zone_hhmm ($6, $7);
+	pc-time_zone = time_zone_hhmm (pc, $6, $7);
   }
   ;
 
@@ -394,7 +394,7 @@ zone:
   { pc-time_zone = $1;
 	apply_relative_time (pc, $2, 1); }
   | tZONE tSNUMBER o_colon_minutes
-  { pc-time_zone = $1 + time_zone_hhmm ($2, $3); }
+  { pc-time_zone = $1 + time_zone_hhmm (pc, $2, $3); }
   | tDAYZONE
   { pc-time_zone = $1 + 60; }
   | tZONE tDST
@@ -795,15 +795,34 @@ static table const military_table[] =
 
 /* Convert a time zone expressed as HH:MM into an integer count of
minutes.  If MM is negative, then S is of the form HHMM and needs
-   to be picked apart; otherwise, S is of the form HH.  */
+   to be picked apart; otherwise, S is of the form HH. As specified at
+   http://www.opengroup.org/onlinepubs/95399/basedefs/xbd_chap08.html
+   allow only valid TZ range, otherwise increment pc-zones_seen to cause
+   invalid format error. */
 
 static long int
-time_zone_hhmm (textint s, long int mm)
+time_zone_hhmm (parser_control *pc, textint s, long int mm)
 {
+  long int returnvalue;
+
+  /* if s.value is lower than 15, add 00 minutes if minutes are
+ not specified as common time zones ranges between UTC-1200
+ and UTC+1400 */
+  if ((abs (s.value)  15)  (mm  0))
+s.value *= 100;
+
   if (mm  0)
-return (s.value / 100) * 60 + s.value % 100;
+returnvalue = (s.value / 100) * 60 + s.value % 100;
   else
-return s.value * 60 + (s.negative ? -mm : mm);
+returnvalue = s.value * 60 + (s.negative ? -mm : mm);
+
+  /* check if the return value is in real timezone range,
+ otherwise increment pc-zones_seen to cause time format
+ error, allow UTC-24:00 to UTC+24:00 */
+  if (abs (returnvalue)  1440)
+pc-zones_seen

[PATCH]: who -r empty last runlevel + missing informations about some who options in coreutils.texi

2008-07-02 Thread Ondřej Vašík
Hello,
In rhbz #453249 Gian Piero De Lolliis ([EMAIL PROTECTED]) reported missing last
runlevel in who -r. Command runlevel displayed last runlevel 'N' - which
should be displayed as last=S in who -r. Attached patch fixes that issue
(another possibility could be to not display last= at all for this
case). As this is just a small change I think it doesn't deserve
mentioning in NEWS.

Additionally I found that there are some options missing in
coreutils.texi who section. I added just the options + basic info from
help, it would be good to extend it, but this is at least first step.

Greetings,
 Ondrej Vasik

From 275644abc591d1e8652263e1ace62012f1292994 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Wed, 2 Jul 2008 13:38:15 +0200
Subject: [PATCH] *src/who.c: handle empty last runlevel in who -r  as 'S'.


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 src/who.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/who.c b/src/who.c
index 5529618..952023a 100644
--- a/src/who.c
+++ b/src/who.c
@@ -508,7 +508,7 @@ print_runlevel (const STRUCT_UTMP *utmp_ent)
 
   if (!comment)
 comment = xmalloc (strlen (_(last=)) + 2);
-  sprintf (comment, %s%c, _(last=), (last == 'N') ? 'S' : last);
+  sprintf (comment, %s%c, _(last=), (!last || last == 'N') ? 'S' : last);
 
   print_line (-1, , ' ', -1, runlevline, time_string (utmp_ent),
 	  , , comment, );
-- 
1.5.2.2


From 10db2e5e05c67eea205b3ec76a2408f46356a7fd Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Wed, 2 Jul 2008 14:11:05 +0200
Subject: [PATCH] *doc/coreutils.texi: Mention some missing options for who command


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 doc/coreutils.texi |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 155ba8d..c0ea237 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12710,6 +12710,24 @@ automatic dial-up internet access.
 @opindex --heading
 Print a line of column headings.
 
[EMAIL PROTECTED] -p
[EMAIL PROTECTED] --process
[EMAIL PROTECTED] -p
[EMAIL PROTECTED] --process
+Print active processes spawned by init.
+
[EMAIL PROTECTED] -r
[EMAIL PROTECTED] --runlevel
[EMAIL PROTECTED] -r
[EMAIL PROTECTED] --runlevel
+Print current and last runlevel. 
+
[EMAIL PROTECTED] -t
[EMAIL PROTECTED] --time
[EMAIL PROTECTED] -t
[EMAIL PROTECTED] --time
+Print last system clock change. 
+
 @item -w
 @itemx -T
 @itemx --mesg
-- 
1.5.2.2



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH]: Fix for several getdate.y issues

2008-07-01 Thread Ondřej Vašík
Ondřej Vašík wrote:
 Jim Meyering wrote:
  Would you mind separating that into a few separate change sets?
 ...
 I hope I will do the rest of patches ( 1 or 2 more
 are still necessary to cover all the issues I found).

Here is the second set of patches. 

First one (getdate_4) addresses issue with countable dayshift (like
next yesterday, last tomorrow etc. . I dropped the change of adding
tWEEK_UNIT as this is not necessary for functionality of the changes. 

Second one (getdate_5) addresses signed relative time offset issue. That
was not possible until time zone is specified(only case where it was
allowed was the hybrid section solution). Grammar before the patch
handles any signed number as timezone (as empty o_colon_minutes and
o_merid section handles anything like valid). I added grammar for signed
numbers without time offset unit (which will handle old required
behaviour of o_colon_minutes and o_merid) and added grammar for signed
relative time offset.

date_2 patch is for coreutils and mentions changes in NEWS and adds one
test (getdate_5 patch related).

Total number of shift/reduce conflicts is 32 (which is 4 lower than 36
in the first all-in-one patch - as there is no tWEEK_UNIT token type).
Increase of the shift/reduce conflicts is caused by o_colon_minutes and
o_merid change - which was required for the functionality of the
patch_5. 

Greetings,
 Ondrej Vasik

From 0f60536a86f4a8e1c657d9d31348a366d74d5e3b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Mon, 30 Jun 2008 16:48:17 +0200
Subject: [PATCH] *lib/getdate.y: prevent usage of invalid date syntax of countable ordinal dayshift e.g. 40 yesterday or next yesterday


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 lib/getdate.y |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/getdate.y b/lib/getdate.y
index f33c0a4..93e8e6f 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -292,7 +292,7 @@ extract_hhmmss (parser_control *pc, long int ho, long int mi, time_t sec, long i
 %token tAGO tDST
 
 %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT
-%token intval tDAY_UNIT
+%token intval tDAY_UNIT tDAY_SHIFT
 
 %token intval tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN
 %token intval tMONTH tORDINAL tZONE
@@ -522,6 +522,8 @@ relunit:
   { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; }
   | tDAY_UNIT
   { $$ = RELATIVE_TIME_0; $$.day = $1; }
+  | tDAY_SHIFT
+  { $$ = RELATIVE_TIME_0; $$.day = $1; }
   | tORDINAL tHOUR_UNIT
   { $$ = RELATIVE_TIME_0; $$.hour = $1; }
   | tUNUMBER tHOUR_UNIT
@@ -668,10 +670,10 @@ static table const time_units_table[] =
 /* Assorted relative-time words. */
 static table const relative_time_table[] =
 {
-  { TOMORROW,	tDAY_UNIT,	 1 },
-  { YESTERDAY,tDAY_UNIT,	-1 },
-  { TODAY,	tDAY_UNIT,	 0 },
-  { NOW,	tDAY_UNIT,	 0 },
+  { TOMORROW,	tDAY_SHIFT,	 1 },
+  { YESTERDAY,tDAY_SHIFT,	-1 },
+  { TODAY,	tDAY_SHIFT,	 0 },
+  { NOW,	tDAY_SHIFT,	 0 },
   { LAST,	tORDINAL,	-1 },
   { THIS,	tORDINAL,	 0 },
   { NEXT,	tORDINAL,	 1 },
-- 
1.5.2.2


From 4a31fd8c749229be352d2045d4aecd3a125bbad7 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Mon, 30 Jun 2008 17:32:28 +0200
Subject: [PATCH] *lib/getdate.y: Allow usage of relative signed time offset even before time zone is specified.


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 lib/getdate.y |   56 +---
 1 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/lib/getdate.y b/lib/getdate.y
index 93e8e6f..ff7850c 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -1,8 +1,8 @@
 %{
 /* Parse a string into an internal time stamp.
 
-   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-   Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Free Software Foundation, Inc.
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -278,8 +278,8 @@ extract_hhmmss (parser_control *pc, long int ho, long int mi, time_t sec, long i
 %parse-param { parser_control *pc }
 %lex-param { parser_control *pc }
 
-/* This grammar has 20 shift/reduce conflicts. */
-%expect 20
+/* This grammar has 32 shift/reduce conflicts. */
+%expect 32
 
 %union
 {
@@ -371,7 +371,43 @@ time:
 	pc-zones_seen++;
 	pc-time_zone = time_zone_hhmm (pc, $6, $7);
   }
-  ;
+  | tUNUMBER ':' tUNUMBER relunit_snumber
+  {
+  extract_hhmmss (pc, $1.value, $3.value, 0, 0);
+	pc-meridian = MER24;
+	extract_relative_time (pc, $4, 1); 
+  }
+  | tUNUMBER ':' tUNUMBER ':' unsigned_seconds relunit_snumber
+  {
+  extract_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec);
+	pc-meridian = MER24;
+	extract_relative_time (pc, $6, 1); 
+  } 
+  | tUNUMBER ':' tUNUMBER
+  {
+  extract_hhmmss (pc, $1.value, $3.value, 0, 0);
+	pc

[PATCH]: Fix for several getdate.y issues

2008-06-27 Thread Ondřej Vašík
Hello,
while playing a bit with date formats, I found several issues (still
present in GIT head). Current date on my machine is Fri Jun 27 11:58:47
CEST 2008, used in all examples.

1) Strange results of signed relative time offset
[EMAIL PROTECTED] ~]$ date -d 11:40 + 60 minutes
Fri Jun 27 12:41:00 CEST 2008
[EMAIL PROTECTED] ~]$ date -d 11:40 + 61 minutes
Fri Jun 27 12:40:00 CEST 2008
[EMAIL PROTECTED] ~]$ date -d 11:40 + 62 minutes
Fri Jun 27 12:39:00 CEST 2008

2) TZ shift ignored when relative time offset by days/months/years done
(doesn't matter if signed or unsigned)
[EMAIL PROTECTED] ~]$ date -d 11:40 UTC+0400 +24 hours
Sat Jun 28 09:40:00 CEST 2008
[EMAIL PROTECTED] ~]$ date -d 11:40 UTC+0400 +1 day
Sat Jun 28 11:40:00 CEST 2008

3) numeric TZ is not limited by usual TZ limits UTC+14 and UTC-12
(timezone used in example is UTC+500:00)
[EMAIL PROTECTED] ~]$ date -d 11:40 +5 
Fri Jul  2 07:33:04 CEST 1982

4) Date with dayshift could be quiet wrong
[EMAIL PROTECTED] ~]$ date -d 11:40 UTC+0200 yesterday 
Mon Dec 10 11:40:00 CET 2007

5) Multiplied dayshift is allowed as valid date 
[EMAIL PROTECTED] src]$ date -d 11:40 40 yesterday
Sun May 18 11:40:00 CEST 2008

All of those issues are fixed by the getdate.y patch (and additional
three test cases for date added in the second patch). Increase of
potential shift/reduce conflicts in grammar is from 20 to 36, usually
caused by some splits (tDAY_UNIT split to tDAY_UNIT, tWEEK_UNIT and
tDAY_SHIFT). Some code duplicities in parser were replaced by functions.
Input from example #3 and #5 now considered as invalid, others handled
correctly by new grammar. This grammar past coreutils tests/misc/date
without troubles. If you know about any situation where this new grammar
will output invalid values, please let me know and I will try to fix it.
TIA.

Greetings,
 Ondrej Vasik

From 1a6311778c0203b116259914b321196d53ccde67 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 27 Jun 2008 12:31:10 +0200
Subject: [PATCH] * tests/misc/date: add tests for new fixes of date format


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 tests/misc/date |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tests/misc/date b/tests/misc/date
index fb700b5..98651a3 100755
--- a/tests/misc/date
+++ b/tests/misc/date
@@ -118,6 +118,11 @@ my @Tests =
  ['rel-1day',  -d '20050101  1 day'  +%F, {OUT=2005-01-02}],
  # ...but up to coreutils-6.9, this was rejected due to the +.
  ['rel-plus1', -d '20050101 +1 day'  +%F, {OUT=2005-01-02}],
+ #...and following three were failing up to 6-12
+ ['rel-plus60m', -d '11:40 + 60 minute' +%T, {OUT=12:40:00}],
+ ['rel-plus6d', -d '20070101 12:40 +6 day' $fmt, {OUT=2007-01-07 12:40:00}],
+ ['rel-plusTZ6d', -d '20070101 12:40 UTC+4 +6 day' $fmt, {OUT=2007-01-07 08:40:00}],
+
 
  ['next-s', -d '$d1 next second' '+%Y-%m-%d %T', {OUT=$d0 $ts}],
  ['next-m', -d '$d1 next minute' '+%Y-%m-%d %T', {OUT=$d0 $tm}],
-- 
1.5.2.2


From 55d067b5172b233c63b364cad8efc171910eddee Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 27 Jun 2008 12:34:08 +0200
Subject: [PATCH] * lib/getdate.y: Several fixes for date grammar, no longer replace time zone
  after relative day/month/year offset

Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 lib/getdate.y |  242 +
 1 files changed, 140 insertions(+), 102 deletions(-)

diff --git a/lib/getdate.y b/lib/getdate.y
index 1deec51..f0773e9 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -1,8 +1,8 @@
 %{
 /* Parse a string into an internal time stamp.
 
-   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-   Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008 
+   Free Software Foundation, Inc.
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -205,7 +205,7 @@ typedef struct
 union YYSTYPE;
 static int yylex (union YYSTYPE *, parser_control *);
 static int yyerror (parser_control const *, char const *);
-static long int time_zone_hhmm (textint, long int);
+static long int time_zone_hhmm (parser_control *,textint, long int);
 
 /* Extract into *PC any date and time info from a string of digits
of the form e.g., MMDD, YYMMDD, HHMM, HH (and sometimes YYY,
@@ -246,6 +246,28 @@ digits_to_date_time (parser_control *pc, textint text_int)
 }
 }
 
+static void extract_hhmmss (parser_control *pc, long int ho, long int mi, long int sec, long int nsec)
+{
+	pc-hour = ho;
+	pc-minutes = mi;
+	pc-seconds.tv_sec = sec;
+	pc-seconds.tv_nsec = nsec;
+}
+
+/* Extract relative time multiplied by factor */
+static void
+extract_relative_time (parser_control *pc, relative_time rel, int factor)
+{
+	pc-rel.ns += factor*rel.ns;
+	pc

Re: [PATCH]: Fix for several getdate.y issues

2008-06-27 Thread Ondřej Vašík
Jim Meyering wrote:
 Would you mind separating that into a few separate change sets?

No problem, I splitted the main patch into smaller sub-patches, it is
still not complete set of changes, following 3 gnulib getdate.y patches
are fixing only issue #2 and #3. 

 - in a function definition, the function name must begin in col 1
 - new pointer parameters must be const
 - adjust type of new, time-related parameters.  at least one should be time_t

Thanks for spotting time_t for seconds and function name not in col 1.
I'm not sure about the const for pointer params, as I have to modify 
this parser_control *pc (to extract infos from arguments and store them
or to pass information about wrong date format spotted). Or you meant
something else? Could you please clarify that? TIA.

 For coreutils, please add a NEWS entry for each bug fix.

I did summary for those three gnulib patches and added one test to the
date test. Hope that it's sufficient. Test will pass only if at least
getdate.y patches #1 and #3 are applied.

 I will have time next week to give this a more thorough review.

Thanks in advance, I hope I will do the rest of patches ( 1 or 2 more
are still necessary to cover all the issues I found).

Greetings,
 Ondrej

From 4c9db16207b5c76bb85b05ee5853c525372bb80a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 27 Jun 2008 16:32:28 +0200
Subject: [PATCH] *lib/getdate.y: Do not ignore specified time zone when relative offset for days/months/years is specified.


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 lib/getdate.y |   40 
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/getdate.y b/lib/getdate.y
index 1deec51..7b55c31 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -1436,26 +1436,7 @@ get_date (struct timespec *result, char const *p, struct timespec const *now)
 	goto fail;
 	}
 
-  if (pc.zones_seen)
-	{
-	  long int delta = pc.time_zone * 60;
-	  time_t t1;
-#ifdef HAVE_TM_GMTOFF
-	  delta -= tm.tm_gmtoff;
-#else
-	  time_t t = Start;
-	  struct tm const *gmt = gmtime (t);
-	  if (! gmt)
-	goto fail;
-	  delta -= tm_diff (tm, gmt);
-#endif
-	  t1 = Start - delta;
-	  if ((Start  t1) != (delta  0))
-	goto fail;	/* time_t overflow */
-	  Start = t1;
-	}
-
-  /* Add relative date.  */
+/* Add relative date.  */
   if (pc.rel.year | pc.rel.month | pc.rel.day)
 	{
 	  int year = tm.tm_year + pc.rel.year;
@@ -1477,6 +1458,25 @@ get_date (struct timespec *result, char const *p, struct timespec const *now)
 	goto fail;
 	}
 
+  if (pc.zones_seen)
+	{
+	  long int delta = pc.time_zone * 60;
+	  time_t t1;
+#ifdef HAVE_TM_GMTOFF
+	  delta -= tm.tm_gmtoff;
+#else
+	  time_t t = Start;
+	  struct tm const *gmt = gmtime (t);
+	  if (! gmt)
+	goto fail;
+	  delta -= tm_diff (tm, gmt);
+#endif
+	  t1 = Start - delta;
+	  if ((Start  t1) != (delta  0))
+	goto fail;	/* time_t overflow */
+	  Start = t1;
+	}
+
   /* Add relative hours, minutes, and seconds.  On hosts that support
 	 leap seconds, ignore the possibility of leap seconds; e.g.,
 	 + 10 minutes adds 600 seconds, even if one of them is a
-- 
1.5.2.2


From 9eb2711cd03b3825e36cff33e7e7fccbbfc504d1 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Fri, 27 Jun 2008 17:37:40 +0200
Subject: [PATCH] *lib/getdate.y: Factorize duplicate code for relative time offset and hhmmss times.


Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 lib/getdate.y |   86 ++---
 1 files changed, 33 insertions(+), 53 deletions(-)

diff --git a/lib/getdate.y b/lib/getdate.y
index 7b55c31..e4f2598 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -246,6 +246,30 @@ digits_to_date_time (parser_control *pc, textint text_int)
 }
 }
 
+/* Extract relative time multiplied by factor into *pc */
+static void
+extract_relative_time (parser_control *pc, relative_time rel, int factor)
+{
+	pc-rel.ns += factor*rel.ns;
+	pc-rel.seconds += factor*rel.seconds;
+	pc-rel.minutes += factor*rel.minutes;
+	pc-rel.hour += factor*rel.hour;
+	pc-rel.day += factor*rel.day;
+	pc-rel.month += factor*rel.month;
+	pc-rel.year += factor*rel.year;
+	pc-rels_seen = true;
+} 
+
+/* Extract hours, minutes, seconds and nanoseconds from arguments into *pc */
+static void 
+extract_hhmmss (parser_control *pc, long int ho, long int mi, time_t sec, long int nsec)
+{
+	pc-hour = ho;
+	pc-minutes = mi;
+	pc-seconds.tv_sec = sec;
+	pc-seconds.tv_nsec = nsec;
+}
+
 %}
 
 /* We want a reentrant parser, even if the TZ manipulation and the calls to
@@ -313,7 +337,6 @@ item:
   | day
   { pc-days_seen++; }
   | rel
-  { pc-rels_seen = true; }
   | number
   | hybrid
   ;
@@ -321,42 +344,29 @@ item:
 time:
 tUNUMBER tMERIDIAN
   {
-	pc-hour = $1.value;
-	pc-minutes = 0;
-	pc-seconds.tv_sec = 0;
-	pc-seconds.tv_nsec = 0

[PATCH] id should not show selinux context when user is specified

2008-04-22 Thread Ondřej Vašík
Hello,
when using id username SELinux context of the user who executed id
command is printed. This is quiet misleading and should be avoided.
Problem reported in RH bugzilla #443485 by Ronny Buchmann
([EMAIL PROTECTED]) 

Patch changing the id behaviour to don't show scontext when
user is specified is attached.

Greetings,
 Ondrej Vasik

From b12554c8d2738385543ea7f8304a6b83ee5661b7 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= [EMAIL PROTECTED]
Date: Tue, 22 Apr 2008 15:37:13 +0200
Subject: [PATCH] id will now show selinux context only when used without specified user

Signed-off-by: Ondřej Vašík [EMAIL PROTECTED]
---
 NEWS |4 
 src/id.c |7 +--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 04893c6..ef3feda 100644
--- a/NEWS
+++ b/NEWS
@@ -75,6 +75,10 @@ GNU coreutils NEWS-*- outline -*-
   id and groups work around an AFS-related bug whereby those programs
   would print an invalid group number, when given no user-name argument.
 
+  id will now show selinux context only when used without specified
+  user. Showing SELinux context of user who executed id command could 
+  be misleading.
+
   ls --color no longer outputs unnecessary escape sequences
 
   seq gives better diagnostics for invalid formats.
diff --git a/src/id.c b/src/id.c
index a178714..621f2f9 100644
--- a/src/id.c
+++ b/src/id.c
@@ -48,6 +48,9 @@ char *program_name;
 /* If true, output user/group name instead of ID number. -n */
 static bool use_name = false;
 
+/* If true, id is used on specified user/group name */
+static bool specified_name = false;
+
 /* The real and effective IDs of the user to print. */
 static uid_t ruid, euid;
 static gid_t rgid, egid;
@@ -170,7 +173,7 @@ main (int argc, char **argv)
   usage (EXIT_FAILURE);
 }
 
-  if (argc - optind == 1  just_context)
+  if ((specified_name = (argc - optind == 1))  just_context)
 error (EXIT_FAILURE, 0,
 	   _(cannot print security context when user specified));
 
@@ -338,6 +341,6 @@ print_full_info (const char *username)
 free (groups);
   }
 #endif /* HAVE_GETGROUPS */
-  if (context != NULL)
+  if (!specified_name  context != NULL)
 printf ( context=%s, context);
 }
-- 
1.5.2.2



signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] mkdir/split: send --verbose output to stdout + [PATCH]: same for rmdir/install

2008-03-10 Thread Ondřej Vašík
Jim Meyering wrote:
 ...
 So you'll have to make the three .c files include the new .h,
 and you'll have to adjust src/Makefile.am to link the new .c
 file to each of those three programs.

 ...

 Then, create the file patch like this:
 
   git format-patch --stdout --signoff HEAD~1  patch
 
 and mail that file to the list.

Ok, hopefully fixed your objections from that mail and from the
discussion off the list, patch is in attachement.

Greetings,
 Ondrej Vasik


prog-vfprintf.patch
Description: application/mbox


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: date issues with YYYYMMDD/YYMMDD date format and relative offset

2007-11-19 Thread Ondřej Vašík
Hi Jim,

Jim Meyering wrote:
 However, there's a simple work-around: simply to drop the +, e.g.,
 
   $ date -d '20050101 1 day'
   Sun Jan  2 00:00:00 CST 2005

Yes, I know about that work-around, you could use unsigned offset/
unsigned offset ago as work-around, but the behaviour still differs
from the others for that format - and that's imho wrong.

 In any case, I couldn't accept that patch, because it would allow
 the MMDD syntax anywhere get_date currently accepts a rel
 (relative offset) non-terminal.

Sorry, that was my fault, but it had nothing to do with nonterminal
rel -I used pc-dates_seen=true; instead pc-dates_seen++; and that
allowed usage of more date inputs(made dates_seen non-terminal). Sorry
for that error, have to check my patches more carefully next time.

I improved previous patch, created hybrid section - as is more clean
to have such things out of common sections (maybe same thing from zone
section should be moved here - of course with pc-zones_seen++) and used
the same code as is in number section + relative signed offset code. 

This should solve your objection. Is the patch now acceptable?

Greetings,
 Ondrej Vasik
diff -urp coreutils-6.9.orig/lib/getdate.y coreutils-6.9/lib/getdate.y
--- coreutils-6.9.orig/lib/getdate.y	2007-02-23 19:25:21.0 +0100
+++ coreutils-6.9/lib/getdate.y	2007-11-17 09:31:07.0 +0100
@@ -268,6 +268,7 @@ item:
   | rel
   { pc-rels_seen = true; }
   | number
+  | hybrid
   ;
 
 time:
@@ -577,6 +578,52 @@ number:
 	  }
   }
   ;
+hybrid:
+   tUNUMBER relunit_snumber
+  {
+	 /* Hybrid between date and relative for MMDD/YYMMDD date format
+	   for which was MMDD +X days considered as wrong format */
+	if (pc-dates_seen  ! pc-year.digits
+	 ! pc-rels_seen  (pc-times_seen || 2  $1.digits))
+	  pc-year = $1;
+	else
+	  {
+	if (4  $1.digits)
+	  {
+		pc-dates_seen++;
+		pc-day = $1.value % 100;
+		pc-month = ($1.value / 100) % 100;
+		pc-year.value = $1.value / 1;
+		pc-year.digits = $1.digits - 4;
+	  }
+	else
+	  {
+		pc-times_seen++;
+		if ($1.digits = 2)
+		  {
+		pc-hour = $1.value;
+		pc-minutes = 0;
+		  }
+		else
+		  {
+		pc-hour = $1.value / 100;
+		pc-minutes = $1.value % 100;
+		  }
+		pc-seconds.tv_sec = 0;
+		pc-seconds.tv_nsec = 0;
+		pc-meridian = MER24;
+	  }
+	  }
+	 pc-rel.ns += $2.ns;
+	 pc-rel.seconds += $2.seconds;
+	 pc-rel.minutes += $2.minutes;
+	 pc-rel.hour += $2.hour;
+	 pc-rel.day += $2.day;
+	 pc-rel.month += $2.month;
+	 pc-rel.year += $2.year;
+	 pc-rels_seen = true; 
+  }
+		;	
 
 o_colon_minutes:
 /* empty */


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


date issues with YYYYMMDD/YYMMDD date format and relative offset

2007-11-16 Thread Ondřej Vašík
Hello,
date command has some troubles with MMDD date format.
When you try 'date -d 20050101 +1 day' (or whatever 
relative offset), you will get invalid date because 
of conflicts in translation tables. Nearly same command
date -d 20050101 UTC +1 day is working correctly with
current version of coreutils.

Solution is easy - to add hybrid date/time/relative option 
to getdate.y as I did in attached patch. Should be 
harmless for the rest of date formats. I know that
this MMDD format is not recommended in any man/info 
pages, but is still considered valid, so should be 
handled correctly. Same is corrected for time 
hhmm/hh format.
(for details you can check redhat bugzilla #377781)


Greetings,
 Ondrej Vasik 
diff -urp coreutils-6.9-orig/lib/getdate.y coreutils-6.9/lib/getdate.y
--- coreutils-6.9-orig/lib/getdate.y	2007-02-23 19:25:21.0 +0100
+++ coreutils-6.9/lib/getdate.y	2007-11-16 18:12:17.0 +0100
@@ -446,7 +446,43 @@ date:
   ;
 
 rel:
-relunit tAGO
+   tUNUMBER relunit_snumber
+  {
+	 /* Hybrid between date and relative for MMDD/YYMMDD date format
+	   for which was MMDD +X days considered as wrong format */
+	 pc-rel.ns += $2.ns;
+	 pc-rel.seconds += $2.seconds;
+	 pc-rel.minutes += $2.minutes;
+	 pc-rel.hour += $2.hour;
+	 pc-rel.day += $2.day;
+	 pc-rel.month += $2.month;
+	 pc-rel.year += $2.year;
+	 pc-rels_seen = true; 
+	 if (4  $1.digits)
+	  {
+	pc-day = $1.value % 100;
+	pc-month = ($1.value / 100) % 100;
+	pc-year.value = $1.value / 1;
+	pc-year.digits = $1.digits - 4;
+	pc-dates_seen = true;
+	  } else {
+	pc-times_seen++;
+	if ($1.digits = 2)
+	{
+	  pc-hour = $1.value;
+	  pc-minutes = 0;
+	}
+	else
+	{
+	  pc-hour = $1.value / 100;
+	  pc-minutes = $1.value % 100;
+	}
+	pc-seconds.tv_sec = 0;
+	pc-seconds.tv_nsec = 0;
+	pc-meridian = MER24;
+	  } 
+  }  
+  |  relunit tAGO
   {
 	pc-rel.ns -= $1.ns;
 	pc-rel.seconds -= $1.seconds;


signature.asc
Description: Toto je digitálně	 podepsaná část	 zprávy
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils