feross / SpoofMAC

:briefcase: Change your MAC address for debugging
https://feross.org/spoofmac/
3.03k stars 269 forks source link

"Run automatically at startup" problem... #18

Closed galakhov closed 9 years ago

galakhov commented 11 years ago

Hi, sorry for silly question but I can't get the script to run on system startup properly (according to steps described in readme file)...

I'm getting an error "$1: unbound variable" if I try to run the script manually.

Any ideas how to fix it?

Best regards, Dmitry.

feross commented 11 years ago

Running the script manually won't work, as it's not a normal bash script. The startup script must be placed in the StartupItems folder to work correctly.

What happens when you follow the instructions in the README file and startup your computer?

galakhov commented 11 years ago

Maybe I just haven't assigned the script to run on startup of OS X. I placed both files to "/Library/StartupItems/SpoofMAC/" directory and set "root:wheel" group and rights for them, too. The only one change to SpoofMAC script I made was this:

StartService () { ConsoleMessage "Running SpoofMAC script." spoof-mac randomize en0 spoof-mac randomize en1 }

On startup I am not getting any console message at all... I'm using OS X 10.8.2. Could I anyhow debug the script to test it? Could it help if I change the *.plist file into xml?

feross commented 11 years ago

I would try checking Console.app for any startup errors or SpoofMAC related messages. Let me know if you find anything there.

bmy commented 11 years ago

I followed the instructions to a T, and didn't touch the script itself. I get

SystemStarter: SpoofMAC (PID) did not complete successfully SystemStarter: /Library/StartupItems/SpoofMAC

Whenever my machine boots. Works fine when executed from the command line normally, but it'd be tops to have it work at startup. Thanks!

feross commented 11 years ago

Hey @bmy, sorry but I just don't have time to look into this right now. If you end up figuring this out please share the solution here so I can fix the code for other users!

longwayofdrums commented 11 years ago

Running 10.8.4, same issue: no console message, no joy. These are the errors I get:

SystemStarter[100]: SpoofMAC (103) did not complete successfully SystemStarter[100]: The following StartupItems failed to start properly: SystemStarter[100]: /Library/StartupItems/SpoofMAC SystemStarter[100]: - execution of Startup script failed

But I can also add that running the program from the command line after boot doesn't always work the first time. In the console, it reports success, but I frequently have to run it two or three times and have to wait a bit before it actually works. May be something that hasn't initialized yet or is timing out after boot? I really have no idea.

longwayofdrums commented 11 years ago

Using it more, I've realized it may have nothing to do with the startup script at all. spoof-mac just fails sometimes without spitting out an error message or seeming not to work, and I have to run it repeatedly before it eventually (seeming at random) takes effect. I've tried both randomize and using a specific address, and it doesn't seem to affect this behavior.

The best I could do is pull log entries. This first one is from when it failed:

7/28/13 12:06:04.500 PM sudo[276]: JR : TTY=ttys000 ; PWD=/Users/JR ; USER=root ; COMMAND=/usr/local/bin/spoof-mac randomize wi-fi 7/28/13 12:06:05.000 PM kernel[0]: Auth result for: 00:13:5f:fa:c4:e0 MAC AUTH succeeded 7/28/13 12:06:05.000 PM kernel[0]: Auth result for: 00:13:5f:fa:c4:ef MAC AUTH succeeded 7/28/13 12:06:05.000 PM kernel[0]: Auth result for: 00:13:5f:fa:b1:00 MAC AUTH succeeded 7/28/13 12:06:06.000 PM kernel[0]: Auth result for: 00:13:5f:fa:e0:b0 MAC AUTH succeeded 7/28/13 12:06:06.000 PM kernel[0]: Auth result for: 00:13:5f:fa:e1:60 MAC AUTH succeeded 7/28/13 12:06:08.000 PM kernel[0]: Auth result for: 00:13:5f:fa:c4:e0 MAC AUTH succeeded 7/28/13 12:06:09.000 PM kernel[0]: Auth result for: 00:13:5f:fa:c4:ef MAC AUTH succeeded 7/28/13 12:06:09.000 PM kernel[0]: Auth result for: 00:13:5f:fa:b1:00 MAC AUTH succeeded 7/28/13 12:06:09.000 PM kernel[0]: Auth result for: 00:13:5f:fa:e0:b0 MAC AUTH succeeded 7/28/13 12:06:10.000 PM kernel[0]: Auth result for: 00:13:5f:fa:e1:60 MAC AUTH succeeded

This is from when it succeeded:

7/28/13 12:06:37.613 PM sudo[292]: JR : TTY=ttys000 ; PWD=/Users/JR ; USER=root ; COMMAND=/usr/local/bin/spoof-mac randomize wi-fi 7/28/13 12:06:38.000 PM kernel[0]: Auth result for: 00:13:5f:fa:c4:e0 MAC AUTH succeeded 7/28/13 12:06:38.000 PM kernel[0]: AirPort: Link Up on en1 7/28/13 12:06:38.000 PM kernel[0]: en1: BSSID changed to 00:13:5f:fa:c4:e0 7/28/13 12:06:38.000 PM kernel[0]: en1::IO80211Interface::postMessage bssid changed 7/28/13 12:06:38.478 PM airportd[251]: _doAutoJoin: Already associated to “_”. Bailing on auto-join. 7/28/13 12:06:38.505 PM airportd[251]: _doAutoJoin: Already associated to “___”. Bailing on auto-join. 7/28/13 12:06:42.907 PM configd[17]: network changed: v4(en1+:10.10.28.85) DNS+ Proxy+ SMB 7/28/13 12:06:42.970 PM UserEventAgent[11]: CFPreferences: user home directory for user mobile at is unavailable. User domains will be volatile. 7/28/13 12:06:42.973 PM UserEventAgent[11]: Captive: en1: Probing '_' 7/28/13 12:06:43.014 PM UserEventAgent[11]: Captive: Online (not captive) 7/28/13 12:06:43.016 PM configd[17]: network changed: v4(en1!:10.10.28.85) DNS Proxy SMB

Still running 10.8.4 on an old iMac.

feross commented 11 years ago

Bizarre. My best guess is that it's a race condition where disassociating from airport fails or takes longer than usual and so setting the MAC address fails.

longwayofdrums commented 11 years ago

Well, I didn't figure it out, but maybe a little closer. That computer (not mine) was (somehow) missing a symbolic link for airport in usr/sbin (no idea how that happened). Put that back in and I can spoof manually now, but spoof-mac still has the same problem. However, if I manually dissociate first and then run spoof-mac, everything works fine, so something's still wrong with spoof-mac dissociating. I just have no idea where (and startup functionality's still not working, since I have to manually dissociate first).

Not sure if this is related to the problem other people were having, but I feel like it might be.

ikudriavtsev commented 10 years ago

While searching in /var/log/system.log I found -bash: spoof-mac: command not found. I made it work by using the whole path instead of just spoof-mac in /Library/StartupItems/SpoofMAC/SpoofMAC. Probably some more path manipulations required at the beginning of the script.

feross commented 10 years ago

@ikudriavtsev thanks for the note. if you're sure that this is the solution, send a PR and I'll accept it.

Casthardi commented 9 years ago

Not sure, if this is the right place to put my comment. However, under Mac 10.10 Yosemite the instruction in the README sudo cp local.macspoof.plist /Library/LaunchDaemons does not work, for automatic changing the MAC address at startup. The plist file needs to be in the library directory of the system directory, i.e. sudo cp local.macspoof.plist /System/Library/LaunchDaemons at least this works for me.

feross commented 9 years ago

@Casthardi Interesting. /Library/LaunchDaemons works for me. There must be something different about your setup. Is your user account an administrator?

Casthardi commented 9 years ago

Yes, my account has administrator rights. I thought it might be the order how the LaunchDaemons are executed during startup. However, I am not an expert in these launching processes. I changed en0 by the way with spoof-mac set xxxxxx en0

feross commented 9 years ago

Is en0 a wired or wireless network interface?

On Tuesday, October 21, 2014, Casthardi notifications@github.com wrote:

Yes, my account has administrator rights. I thought it might be the order how the LaunchDaemons are executed during startup. However, I am not an expert in these launching processes. I changed en0 by the way with spoof-mac set xxxxxx en0

— Reply to this email directly or view it on GitHub https://github.com/feross/SpoofMAC/issues/18#issuecomment-59890013.

Feross | blog http://feross.org/ | webtorrent http://webtorrent.io/ | studynotes http://www.apstudynotes.org/

Casthardi commented 9 years ago

It's wired.

feross commented 9 years ago

Interesting. It works with wireless on my system. Can you try it for a wireless interface and report if it works?

Casthardi commented 9 years ago

That was what I assumed, too. However, it does not work either in /Library/LaunchDaemons. If I find some time I try it on two other computers.

feross commented 9 years ago

Great! Please report your findings.

On Tuesday, October 21, 2014, Casthardi notifications@github.com wrote:

That was what I assumed, too. However, it does not work either in /Library/LaunchDaemons. If I find some time I try it on two other computers.

— Reply to this email directly or view it on GitHub https://github.com/feross/SpoofMAC/issues/18#issuecomment-59893411.

Feross | blog http://feross.org/ | webtorrent http://webtorrent.io/ | studynotes http://www.apstudynotes.org/