Skip to main content
broken link fixed, cf. https://meta.stackoverflow.com/a/406565/4751173
Source Link

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpagesmanpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commandsexit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do thesethese have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU BashBash; more generallymore generally; random weirdnessweirdness; recent question with reference to codes being application specific + historical /usr/include/sysexits.h etc.

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do these have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU Bash; more generally; random weirdness; recent question with reference to codes being application specific + historical /usr/include/sysexits.h etc.

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do these have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU Bash; more generally; random weirdness; recent question with reference to codes being application specific + historical /usr/include/sysexits.h etc.

replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do these have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU Bash; more generally; random weirdness; recent questionquestion with reference to codes being application specific + historical /usr/include/sysexits.h etc.

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do these have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU Bash; more generally; random weirdness; recent question with reference to codes being application specific + historical /usr/include/sysexits.h etc.

I simply forgot to use sudo:

usr@arch ~[0] $ iptables -L
iptables v1.4.21: can't initialize iptables table `filter': Permission
denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
usr@arch ~[3] $ <---

My bash PS1 prompt echoes the last command exit status ($?). The iptables manpages doesn't refer to a return code of 3:

Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2, and other errors cause an exit code of 1.

The SUSv3/POSIX discusses exit status for commands.1 A command such as mount - which has 7 different exit statuses for error conditions - executed without privileges returns 1; something that's documented in its manpages: incorrect invocation or permissions.


Q. So why does iptables and mount differ in that respect - is it purely application specific? Why is it that doing an strace on the former outputs things such as: socket(PF_INET, SOCK_RAW, IPPROTO_RAW) = -1 EPERM (Operation not permitted) - shouldn't it be EACCES instead? Why is it that tracing unprivileged mount calls does not reveal similar errors and do these have an impact on the exit status; or is -1 a failure whatever the reason? Where does that 3 come from?


1. Also: GNU Bash; more generally; random weirdness; recent question with reference to codes being application specific + historical /usr/include/sysexits.h etc.

Notice removed Reward existing answer by user44370
Bounty Ended with Gilles 'SO- stop being evil''s answer chosen by CommunityBot
Tweeted twitter.com/#!/StackUnix/status/532045053649100802
Notice added Reward existing answer by user44370
Bounty Started worth 50 reputation by CommunityBot
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Source Link
user44370
user44370
Loading