Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to list iptables rules (-S) when is_numeric = true (-n is an invalid argument with -S) #12

Open
WatakiWatako opened this issue Feb 16, 2022 · 0 comments

Comments

@WatakiWatako
Copy link

Hey,

Since version 0.5.0, the "list" function returns an empty list.
This appears to be because the "-n" argument is invalid when used with -S.

For example:

$ iptables -t filter -S INPUT -n
iptables v1.6.1: Illegal option `-n' with this command

Try `iptables -h' or 'iptables --help' for more information.

true => self.get_list(&["-t", table, "-S", chain, "-n"]), from the following code should not contain "-n" in the argument list. The save arguments do not appear to include hostnames in any case.

/// Lists rules in the table/chain.
    pub fn list(&self, table: &str, chain: &str) -> Result<Vec<String>, Box<dyn Error>> {
        match self.is_numeric {
            false => self.get_list(&["-t", table, "-S", chain]),
            true => self.get_list(&["-t", table, "-S", chain, "-n"]),
        }
    }

Suggested solution:

/// Lists rules in the table/chain.
    pub fn list(&self, table: &str, chain: &str) -> Result<Vec<String>, Box<dyn Error>> {
        self.get_list(&["-t", table, "-S", chain])
    }

The exists_old_version and list_table functions also appear to have the same issue.

Thank you for this excellent crate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant