[PATCH] Fix solaris acl/nfs breakage
Hello all, I'm packaging coreutils for Solaris as part of the OpenCSW project. When running the test suite with an NFS mounted build directory, some tests were failing. It seems that while ACL's are supported over NFS in Solaris, this is only true with some combinations of server and client. The following patch treats EOPNOTSUPP like ENOSYS in the (standard) Solaris acl handling code. I'm not sure whether similar changes are also appropriate in the ifdef ACE_GETACL sections or not at this time. With this patch applied, the core test suite passes (61 tests skipped). Please let me know if there is anything wrong with this patch as I'm happy to correct it to meet project standards. Thanks -Ben Ben Walton (1): Fix solaris acl support breakage lib/copy-acl.c |4 ++-- lib/set-mode-acl.c |2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH] Fix solaris acl support breakage
Solaris has support for ACL's on NFS, but only in certain combinations of client and server. When ACL operations are attempted in unsupported situations, EOPNOTSUPP can be returned instead of ENOSYS. This patch allows utilities that work with ACL's to handle the difference properly. Signed-off-by: Ben Walton --- lib/copy-acl.c |4 ++-- lib/set-mode-acl.c |2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/copy-acl.c b/lib/copy-acl.c index af85a08..bfacf20 100644 --- a/lib/copy-acl.c +++ b/lib/copy-acl.c @@ -294,7 +294,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (count < 0) { - if (errno == ENOSYS || errno == ENOTSUP) + if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) { count = 0; entries = NULL; @@ -358,7 +358,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (ret < 0 && saved_errno == 0) { saved_errno = errno; - if (errno == ENOSYS && !acl_nontrivial (count, entries)) + if ((errno == ENOSYS || errno == EOPNOTSUPP) && !acl_nontrivial (count, entries)) saved_errno = 0; } else diff --git a/lib/set-mode-acl.c b/lib/set-mode-acl.c index ddac4df..fdc74f2 100644 --- a/lib/set-mode-acl.c +++ b/lib/set-mode-acl.c @@ -387,7 +387,7 @@ qset_acl (char const *name, int desc, mode_t mode) ret = acl (name, SETACL, sizeof (entries) / sizeof (aclent_t), entries); if (ret < 0) { - if (errno == ENOSYS) + if (errno == ENOSYS || errno == EOPNOTSUPP) return chmod_or_fchmod (name, desc, mode); return -1; } -- 1.6.5.1
Re: permissions of files in dist tarball
Ralf Wildenhues wrote: > Hello Alan, Jim, > * Jim Meyering wrote on Sun, Nov 22, 2009 at 04:32:57PM CET: >> Alan Curry wrote: >> > So was the drwxrwxrwx in the tarball put there to teach a lesson to those >> > who trust a tarball to have sane permissions? Or is it a bug? >> >> On one hand, you can also think of it as a LART for >> anyone who builds from source as root ;-) >> >> I think the motivation was to avoid imposing restrictions. With relaxed >> permissions, the umask of the unpacker completely determines the permissions. >> If the distribution-tarball-creator were to choose stricter permissions, >> say prohibiting group/other write access, that would make it harder for >> people who use 002 and want all directories to be group-writable. >> >> That said, I'd have no objection to applying "chmod 755" >> (rather than a+rwx) to the directories that go into the tarball. >> >> FYI, those permissions were set via the Automake-generated "make dist" >> rule, so every automake-using package has created distribution tarballs >> that way for at least 10 years. > > Automake is following the GNU Coding Standards recommendation here, > which lists another reason ((standards.info)Releases): > > Make sure that the directory into which the distribution unpacks (as > well as any subdirectories) are all world-writable (octal mode 777). > This is so that old versions of `tar' which preserve the ownership and > permissions of the files from the tar archive will be able to extract > all the files even if the user is unprivileged. > > Make sure that all the files in the distribution are world-readable. Thanks, Ralf. Considering that that text is at least 10 years old, I think we can say with confidence that the reason for it (that then-old version of tar) is no longer relevant. I would like to update that part of the GNU Coding Standards. Can anyone think of a reason *not* to revise the GCS to allow or even recommend using more safety-conscious permissions?
quoted-printable [--decode]: it's time
OK, now that there is a base64(1) command, I could have sworn I also saw a quoted-printable command too [or else I wouldn't have deleted mine so fast :-(]. OK, I restored mine $ cat bin/qp-decode #!/bin/sh -e #jidanni *** replacement for mime-codecs package *** case $0 in *qp-encode)perl -MMIME::QuotedPrint -wne 'print encode_qp($_)';; *qp-decode)perl -MMIME::QuotedPrint -wne 'print decode_qp($_)';; *base64-encode)perl -MMIME::Base64 -wne 'print encode_base64($_)';; *base64-decode)perl -MMIME::Base64 -wne 'print decode_base64($_)';; *)exit 88;; esac And as $ apt-file search quoted-printable|wc -l 8 aren't coreutils, ("qp" finds even more), I hereby sure wish coreutils had one.
Re: quoted-printable [--decode]: it's time
jida...@jidanni.org wrote: > OK, now that there is a base64(1) command, I could have sworn I also saw > a quoted-printable command too [or else I wouldn't have deleted mine so > fast :-(]. > OK, I restored mine > $ cat bin/qp-decode > #!/bin/sh -e > #jidanni *** replacement for mime-codecs package *** > case $0 in > *qp-encode)perl -MMIME::QuotedPrint -wne 'print encode_qp($_)';; > *qp-decode)perl -MMIME::QuotedPrint -wne 'print decode_qp($_)';; > *base64-encode)perl -MMIME::Base64 -wne 'print encode_base64($_)';; > *base64-decode)perl -MMIME::Base64 -wne 'print decode_base64($_)';; > *)exit 88;; > esac > > And as > $ apt-file search quoted-printable|wc -l > 8 > aren't coreutils, ("qp" finds even more), I hereby sure wish coreutils > had one. GNU recode does that: $ printf '\0\1'|recode ../QP =00=01= $ printf '\0\1'|recode ../QP | recode /QP| od -tx1 000 00 01 002
Re: quoted-printable [--decode]: it's time
> "JM" == Jim Meyering writes: JM> GNU recode does that: JM> $ printf '\0\1'|recode ../QP Ah ha, then checkmate, $ recode -l|grep -i base64 /Base64 64 b64 I.e., you must either 1. Make a separate quoted-printable(1) command too, just to be fair. 2. Leave a note on the base64(1) man page saying that if one is looking for quoted-printable(1) try recode instead... however this isn't a good place to leave such a note... hmmm OK, whatever. I'll try to remember recode.
[PATCH] split: --chunks option
Hi all, This is mostly a step towards multithreaded sort the unix way, but as Padraig mentioned, has its other uses. Parsing and I/O are not my strong suits, so I have a couple of questions: Are there more appropriate functions than open and pread to use here? I usually see wrapper functions called in place of actual functions like fopen, fread, etc, and it feels rather inappropriate for me to use open and pread here. And are there any suggestions for parsing the --chunk option in a better way? I feel having two separate options specifying both required values is redundant, so I decided to separate the values by a comma, as Jim had in an example he linked me. The way I wrote it, it feels like a hacked workaround, but I'm not sure how else to get around that comma. Also, any opinions on how the lines should be output? As of now I just have it as stdout, since that's how I see sort would use it. And of course, anything else I missed/could've done better? Thanks a lot guys. >From 875147fd73abfb4d798f0beb0c84a5ed54bab28c Mon Sep 17 00:00:00 2001 From: Chen Guo Date: Thu, 26 Nov 2009 05:12:32 +0100 Subject: [PATCH] Split: add --chunk=N,TOT option to extract Nth of TOT chunks. --- src/split.c | 145 --- 1 files changed, 139 insertions(+), 6 deletions(-) diff --git a/src/split.c b/src/split.c index d1a0e0d..e8446ad 100644 --- a/src/split.c +++ b/src/split.c @@ -82,6 +82,7 @@ enum static struct option const longopts[] = { {"bytes", required_argument, NULL, 'b'}, + {"chunk", required_argument, NULL, 'c'}, {"lines", required_argument, NULL, 'l'}, {"line-bytes", required_argument, NULL, 'C'}, {"suffix-length", required_argument, NULL, 'a'}, @@ -116,6 +117,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fprintf (stdout, _("\ -a, --suffix-length=N use suffixes of length N (default %d)\n\ -b, --bytes=SIZEput SIZE bytes per output file\n\ + -c, --chunk=N,CHUNKSgenerate Nth of CHUNKS pieces\n\ -C, --line-bytes=SIZE put at most SIZE bytes of lines per output file\n\ -d, --numeric-suffixes use numeric suffixes instead of alphabetic\n\ -l, --lines=NUMBER put NUMBER lines per output file\n\ @@ -362,6 +364,99 @@ line_bytes_split (size_t n_bytes) free (buf); } +/* If file is seekable, extract nth of total chunks, starting from first line + entirely in the nth chunk to the last line whose first byte is in the nth + chunk. + FIXME: Support non-seekable files as such: extract lines whose line number L + is such that L % total + 1 = n. + */ + +static void +chunk_split (uintmax_t n, uintmax_t total, char* buf, int fildes, off_t file_size, + size_t bufsize) +{ + ssize_t n_read; + bool new_flag = true; + bool end_of_chunk = false; + bool skip = true; + char *bp = buf, *bp_out = buf, *eob; + off_t start; + off_t end; + + /* For n != 1, start reading 1 byte before nth chunk of file. This is to + detect if the first byte of chunk is the first byte of a line. */ + if (n == 1) +{ + start = 0; + skip = false; +} + else +start = (n - 1) * (file_size / total) - 1; + end = (n == total)? file_size - 1: n * file_size / total - 1; + + /* bp: point from which to read into buffer + bp_out: point from which to write out + eob: point where write out ends */ + while (1) +{ + n_read = pread (fildes, bp, bufsize, start); + if (n_read < 0) +error (EXIT_FAILURE, errno, "%s", infile); + if (n_read == 0) +end_of_chunk = true; + start += n_read; + eob = bp + n_read; + + /* Unless n == 1, skip past the first newline character + encountered. */ + if (skip) +{ + bp_out = memchr (bp, '\n', n_read); + if (!bp_out) +{ + if (start < end) +{ + off_t offset = eob - buf; + bufsize *= 2; + buf = x2nrealloc (buf, &bufsize, sizeof *buf); + bp = buf + offset; +} + else +break; +} + else +{ + bp_out++; + skip == false; +} +} + + if (start >= end) +{ + char *base; + if (eob - start + end > bp_out) +base = eob - start + end; + else +base = bp_out; + char *line = memchr (base, '\n', eob - base); + if (line) +{ + eob = line + 1; + *eob = '\0'; + end_of_chunk == true; +} +} + // cwrite (new_flag, bp_out, eob - bp_out); + if (write (STDOUT_FILENO, bp_out, eob - bp_out) != eob - bp_out) +error (EXIT_FAILURE, errno, "output error"); + if (end_of_chunk) +break; + new_flag = false; + bp = buf; + bp_out =