The return value of nameif was wrong
authorJiri Popelka <jpopelka@redhat.com>
Wed, 7 Dec 2011 17:16:09 +0000 (18:16 +0100)
committerJiri Popelka <jpopelka@redhat.com>
Thu, 5 Jan 2012 11:22:43 +0000 (12:22 +0100)
Steps to Reproduce:
/sbin/nameif eth1 00:00:10:10:11:11; echo $?

Actual Results:
interface 'eth1' not found
0

Expected Results:
interface 'eth1' not found
1

nameif.c

index 04658c5..209d492 100644 (file)
--- a/nameif.c
+++ b/nameif.c
@@ -210,6 +210,7 @@ int main(int ac, char **av)
        int linenum; 
        char *line = NULL;
        size_t linel = 0;
+       int ret = 0;
 
        for (;;) {
                int c = getopt_long(ac,av,"c:s",lopt,NULL);
@@ -288,13 +289,15 @@ int main(int ac, char **av)
        while (clist) { 
                struct change *ch = clist;
                clist = clist->next;
-               if (!ch->found)
+               if (!ch->found){
                        warning(_("interface '%s' not found"), ch->ifname); 
+                       ret = 1;
+               }
                free(ch); 
        }
 
        if (use_syslog)
                closelog();
-       return 0;
+       return ret;
 }