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

Add command ip support for linux platform #58

Merged
merged 3 commits into from
Dec 27, 2015
Merged

Conversation

lublud
Copy link
Contributor

@lublud lublud commented Dec 27, 2015

Being a arch linux user, ip has been chosen over ifconfig deprecated.

I thus changed a bit the code so I can use it with ip.

Tested only on arch linux.

@lublud lublud changed the title Add command ip for linux platform Add command ip support for linux platform Dec 27, 2015
@@ -63,7 +144,8 @@ def find_interfaces(self, targets=None):
# - the adapter name/device associated with this, if any,
# - the MAC address, if any

output = subprocess.check_output(["ifconfig"], stderr=subprocess.STDOUT, universal_newlines=True)
#output = subprocess.check_output(["ifconfig"], stderr=subprocess.STDOUT, universal_newlines=True)
output = subprocess.check_output(["ip addr"], stderr=subprocess.STDOUT, universal_newlines=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this line stay unchanged?

@feross
Copy link
Owner

feross commented Dec 27, 2015

Please address my inline comment, then I'm happy to merge this.

@lublud
Copy link
Contributor Author

lublud commented Dec 27, 2015

Yes indeed, my bad, shouldn't change.. I fix that.

feross added a commit that referenced this pull request Dec 27, 2015
Add command ip support for linux platform
@feross feross merged commit c60a660 into feross:master Dec 27, 2015
@feross
Copy link
Owner

feross commented Dec 27, 2015

Released as 2.1.0.

@lublud Please install and make sure it works for you.

@lublud
Copy link
Contributor Author

lublud commented Dec 28, 2015

Working fine for me, thanks!

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2016

It looks like there are more uses of ifconfig on lines 147 and 129 of this file that it would be good to find workarounds for, if possible. On OpenSUSE 42.1, ifconfig is at /sbin/ifconfig which is not on the default path of a non-root user:

tkelman@linux:~> spoof-mac --version
2.1.0
tkelman@linux:~> spoof-mac list
Traceback (most recent call last):
  File "/usr/bin/spoof-mac", line 138, in <module>
    sys.exit(main(arguments, root_or_admin))
  File "/usr/bin/spoof-mac", line 76, in main
    list_interfaces(args, spoofer)
  File "/usr/bin/spoof-mac", line 56, in list_interfaces
    for port, device, address, current_address in spoofer.find_interfaces(targets=targets):
  File "/usr/lib/python2.7/site-packages/spoofmac/interface.py", line 147, in find_interfaces
    output = subprocess.check_output(["ifconfig"], stderr=subprocess.STDOUT, universal_newlines=True)
  File "/usr/lib64/python2.7/subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

@feross
Copy link
Owner

feross commented Jan 3, 2016

@tkelman PRs welcome!

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2016

Not sure what the best solution would be - locally changing ifconfig to /sbin/ifconfig works on my system, but would that be appropriate on other distros?

@feross
Copy link
Owner

feross commented Jan 3, 2016

What about using /sbin/ifconfig when it exists, otherwise use the current command name?

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2016

I like that idea. I guess it would also likely be needed on lines 193, 196, 451, and 472 if I had hit those.

edit: 451 and 472 are for osx, and there's an easier fix using /bin/ip

@feross
Copy link
Owner

feross commented Jan 3, 2016

Probably best to check once and set a variable with the command to use,
then use that throughout.

On Sun, Jan 3, 2016 at 4:16 AM Tony Kelman notifications@github.com wrote:

I like that idea. I guess it would also likely be needed on lines 193,
196, 451, and 472 if I had hit those.


Reply to this email directly or view it on GitHub
#58 (comment).

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

Successfully merging this pull request may close these issues.

3 participants