[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid mkdir/selinux failure when mknod is a shell built-in
From: |
Jim Meyering |
Subject: |
Re: avoid mkdir/selinux failure when mknod is a shell built-in |
Date: |
Wed, 16 Apr 2008 14:30:57 +0200 |
Eric Blake <address@hidden> wrote:
> According to Jim Meyering on 4/16/2008 2:33 AM:
> | This test would fail not only because the built-in mknod
> | doesn't support -Z, but because it doesn't know about 'p' pipes.
> |
> | tests: avoid mkdir/selinux failure when mknod is a shell built-in
> | * tests/mkdir/selinux: Skip the mknod test if it's a built-in.
>
> Couldn't you try to defeat the shell builtin by using a subshell and exec
> to force the PATH lookup? For example, on bash:
>
> $ printf --version | head -n1
> bash: printf: --: invalid option
> printf: usage: printf [-v var] format [arguments]
> $ (exec printf --version) | head -n1
> printf (GNU coreutils) 6.10
My first reaction was "great! that looks much better".
Unfortunately, the technique doesn't work with that shell:
openbsd$ ./mknod --version|head -1
mknod (GNU coreutils) 6.10.188-7cb24
openbsd$ PATH=. /bin/sh -c 'mknod --version'|head -1
/bin/sh: mknod: --: unknown option
/bin/sh: mknod: usage: mknod [-m mode] name [b | c] major minor
/bin/sh: mknod: usage: mknod [-m mode] name p
However, if m4/gl_POSIX_SHELL were to test for this, I could
clean up this test as you suggest, and simply skip it whenever
POSIX_SHELL is empty. Volunteers?
> Doesn't this also mean that you need to patch mknod.c to print
> USAGE_BUILTIN_WARNING?
Yes. Good catch!
Thanks!
mknod --help: note that this command may be a shell built-in
* src/mknod.c (usage): Print USAGE_BUILTIN_WARNING.
Suggestion from Eric Blake.
diff --git a/src/mknod.c b/src/mknod.c
index 8a1718d..445117c 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -83,6 +83,7 @@ otherwise, as decimal. TYPE may be:\n\
c, u create a character (unbuffered) special file\n\
p create a FIFO\n\
"), stdout);
+ printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
emit_bug_reporting_address ();
}
exit (status);
--
1.5.5.56.gbcf7f
- avoid mkdir/selinux failure when mknod is a shell built-in, Jim Meyering, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Eric Blake, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in,
Jim Meyering <=
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Thomas Schwinge, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Jim Meyering, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Eric Blake, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Jim Meyering, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Jim Meyering, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Ralf Wildenhues, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Eric Blake, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Ralf Wildenhues, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Eric Blake, 2008/04/16
- Re: avoid mkdir/selinux failure when mknod is a shell built-in, Matthew Woehlke, 2008/04/16